Skip to content

Commit 4abf5d8

Browse files
j15zclaude
andcommitted
fix(db): build the 0255 output-name index CONCURRENTLY
workspace_files is an existing (hot) table, so the plain CREATE UNIQUE INDEX that drizzle-kit generated would hold ACCESS EXCLUSIVE for the whole build. Rewritten to the runner convention: COMMIT breakpoint, lock_timeout 0, CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS, restore lock_timeout (mirrors migration 0250). A pre-existing duplicate pair fails the build into an INVALID index that migrate.ts WARNs about — dedupe, drop, re-run. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 573a425 commit 4abf5d8

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1-
CREATE UNIQUE INDEX "workspace_files_chat_output_display_name_unique" ON "workspace_files" USING btree ("chat_id","display_name") WHERE "workspace_files"."context" = 'output' AND "workspace_files"."chat_id" IS NOT NULL;
1+
-- workspace_files is an existing table: build the new partial unique index CONCURRENTLY
2+
-- so the build never write-locks the relation (runner convention — plain CREATE INDEX
3+
-- takes ACCESS EXCLUSIVE). A pre-existing duplicate (chat_id, display_name) output pair
4+
-- (an artifact of the pre-index allocation race) fails the build and leaves an INVALID
5+
-- index that migrate.ts surfaces with a WARN — dedupe the rows, drop the invalid index,
6+
-- and re-run.
7+
COMMIT;--> statement-breakpoint
8+
SET lock_timeout = 0;--> statement-breakpoint
9+
CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS "workspace_files_chat_output_display_name_unique" ON "workspace_files" USING btree ("chat_id","display_name") WHERE "workspace_files"."context" = 'output' AND "workspace_files"."chat_id" IS NOT NULL;--> statement-breakpoint
10+
SET lock_timeout = '5s';

0 commit comments

Comments
 (0)