Index the edge after the column that carries it exists

On a store with the old shape the table is not re-created, so an index declared
beside it is built on a column the migration has not added yet.
This commit is contained in:
2026-09-13 01:41:23 +02:00
parent f15c814145
commit 2d2ca80e3b
+5 -2
View File
@@ -93,8 +93,6 @@ CREATE TABLE IF NOT EXISTS built_against (
against_reference text NOT NULL,
PRIMARY KEY (module, commit_sha, against_reference)
);
CREATE INDEX IF NOT EXISTS built_against_target ON built_against (against_reference);
`;
// The graph first keyed its edges on a module and a commit, which the builder does not know and
@@ -107,6 +105,11 @@ DELETE FROM built_against WHERE against_reference IS NULL;
ALTER TABLE built_against DROP COLUMN IF EXISTS against_module;
ALTER TABLE built_against DROP COLUMN IF EXISTS against_commit;
ALTER TABLE built_against ALTER COLUMN against_reference SET NOT NULL;
-- After the column exists, and not in the schema above: on a store that still has the old shape,
-- the table is not created, so an index named in the same breath would be built on a column that
-- is not there yet.
CREATE INDEX IF NOT EXISTS built_against_target ON built_against (against_reference);
`;
export class Graph {