| 1 | -- Every run of a scheduled job: when it ran, how it went, and what it found. |
| 2 | -- One run per job and slot, the time it was due: a replica that wrongly |
| 3 | -- thinks it leads still can't run the same slot twice. |
| 4 | CREATE TABLE job_runs ( |
| 5 | id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY, |
| 6 | job text NOT NULL, |
| 7 | slot timestamptz NOT NULL, |
| 8 | status text NOT NULL DEFAULT 'running' |
| 9 | CHECK (status IN ('running', 'succeeded', 'failed')), |
| 10 | summary jsonb, |
| 11 | started_at timestamptz NOT NULL DEFAULT now(), |
| 12 | finished_at timestamptz, |
| 13 | UNIQUE (job, slot) |
| 14 | ); |