Skip to content

Commit 77fd96b

Browse files
Preloop AgentBnjoroge1
authored andcommitted
fix(control): baseline migration matches the current v5/v4 schema
main moved the control schema in place (Postgres v5 / SQLite v4, #365): `check_run_updates` gained the outbox `version`/`lease_owner` columns and dropped its foreign key to `jobs`. The frozen baseline was copied from the pre-#365 tree, so a database created by the current runtime no longer matched it: `preloop store migrate --adopt-baseline` refused every released store, and the fresh-vs-upgraded parity checks drifted from `schema.sql`. The baseline is now the shape the pre-migration runtime actually creates, which is what adoption and the upgrade fixtures compare against. Header names the commit it was frozen from.
1 parent 63c6f5e commit 77fd96b

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

‎migrations/postgres/V2026100501__control_schema_baseline.sql‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
-- Control schema v1 baseline (PostgreSQL).
22
--
33
-- Frozen copy of `crates/preloop-runner-server/src/control/pg/schema.sql`
4-
-- as of base commit 05126635 (the schema the pre-migration runtime created).
4+
-- as of base commit 992e3b81 — the schema the pre-migration runtime creates
5+
-- (Postgres v5: `check_run_updates` carries the outbox `version`/`lease_owner`
6+
-- columns and no foreign key, per #365).
57
-- Migration files are immutable: refinery stores a checksum per version and
68
-- refuses a changed file (abort_divergent), so never edit an applied
79
-- migration — add a new V<version>__<name>.sql instead. An executable parity
@@ -671,12 +673,13 @@ CREATE TABLE check_run_updates (
671673
job_id text NOT NULL,
672674
installation_id bigint NOT NULL,
673675
check_run_id bigint,
676+
version bigint NOT NULL DEFAULT 0,
674677
payload jsonb NOT NULL,
675678
not_before timestamptz NOT NULL DEFAULT now(),
676679
attempts integer NOT NULL DEFAULT 0,
677680
leased_until timestamptz,
678-
PRIMARY KEY (run_id, job_id),
679-
FOREIGN KEY (run_id, job_id) REFERENCES jobs(run_id, job_id) ON DELETE CASCADE
681+
lease_owner text,
682+
PRIMARY KEY (run_id, job_id)
680683
);
681684
CREATE INDEX check_run_updates_queue ON check_run_updates(installation_id, not_before);
682685

‎migrations/sqlite/V2026100501__control_schema_baseline.sql‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
-- Control schema v1 baseline (SQLite).
22
--
33
-- Frozen copy of `crates/preloop-runner-server/src/control/lite/schema.sql`
4-
-- as of base commit 05126635 (the schema the pre-migration runtime created).
4+
-- as of base commit 992e3b81 — the schema the pre-migration runtime creates
5+
-- (SQLite v4: `check_run_updates` carries the outbox `version`/`lease_owner`
6+
-- columns and no foreign key, per #365).
57
-- Migration files are immutable: refinery stores a checksum per version and
68
-- refuses a changed file (abort_divergent), so never edit an applied
79
-- migration — add a new V<version>__<name>.sql instead. An executable parity
@@ -572,12 +574,13 @@ CREATE TABLE check_run_updates (
572574
job_id TEXT NOT NULL,
573575
installation_id INTEGER NOT NULL,
574576
check_run_id INTEGER,
577+
version INTEGER NOT NULL DEFAULT 0,
575578
payload TEXT NOT NULL,
576579
not_before INTEGER NOT NULL DEFAULT (CAST(unixepoch('subsec') * 1000000 AS INTEGER)),
577580
attempts INTEGER NOT NULL DEFAULT 0,
578581
leased_until INTEGER,
579-
PRIMARY KEY (run_id, job_id),
580-
FOREIGN KEY (run_id, job_id) REFERENCES jobs(run_id, job_id) ON DELETE CASCADE
582+
lease_owner TEXT,
583+
PRIMARY KEY (run_id, job_id)
581584
);
582585
CREATE INDEX check_run_updates_queue ON check_run_updates(installation_id, not_before);
583586

0 commit comments

Comments
 (0)