-- Scheduled jobs (owner review 2, R10): one row per schedule, the timers a host used to run out of sight included as -- system schedules (system_key set, seeded by the host at start, never here). next_run is claimed by compare-and-set, -- so one process fires each run. Jobs remember the schedule that queued them. Mirrors sqlite/0007_schedules.sql. CREATE TABLE schedules ( id uuid NOT NULL PRIMARY KEY, system_key text COLLATE "C" UNIQUE, name text NOT NULL, action text NOT NULL, target text NOT NULL DEFAULT 'current', parameters_json jsonb, recurrence text NOT NULL, catch_up boolean NOT NULL DEFAULT TRUE, priority integer NOT NULL DEFAULT 0, enabled boolean NOT NULL DEFAULT TRUE, next_run timestamptz, last_run timestamptz, last_job_id uuid, last_outcome text, created_by uuid, created timestamptz NOT NULL, updated timestamptz NOT NULL ); CREATE INDEX ix_schedules_due ON schedules (enabled, next_run); ALTER TABLE jobs ADD COLUMN schedule_id uuid; CREATE INDEX ix_jobs_schedule ON jobs (schedule_id, created);