From 2d2ca80e3b0692ffc044d9b877739e22cc746a62 Mon Sep 17 00:00:00 2001 From: jochen Date: Sun, 13 Sep 2026 01:41:23 +0200 Subject: [PATCH] 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. --- modules/mesh-catalog/store.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/mesh-catalog/store.ts b/modules/mesh-catalog/store.ts index b929204..0e6aa58 100644 --- a/modules/mesh-catalog/store.ts +++ b/modules/mesh-catalog/store.ts @@ -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 {