mirror of
https://github.com/multica-ai/multica.git
synced 2026-07-16 22:59:04 +02:00
The 162_resource_labels down migration recreated issue_label_workspace_name_lower_idx with a plain CREATE UNIQUE INDEX, which takes a blocking lock on the existing issue_label table during a rollback to v0.3.43 and violates the online-migration rule that every CREATE INDEX must be CONCURRENTLY. CREATE INDEX CONCURRENTLY cannot run in a transaction or a multi-command migration, so the rebuild is split out of 162.down: - 171.down now rebuilds the legacy index as a single CREATE UNIQUE INDEX CONCURRENTLY (the natural inverse of 171.up, which drops it). - 174 (new, no-op up) deletes the agent/skill label rows in its down so they are gone before 171.down rebuilds the workspace-wide unique index. Down migrations apply high->low, so 174.down -> 171.down -> 162.down runs in the required order. - 162.down keeps only the transaction-safe structural teardown. Validated on an isolated Postgres: full up->down->up chain with a colliding issue/agent label pair; the concurrent rebuild succeeds after the rows are deleted, restores the valid pre-162 unique index, and a negative control (rebuild before the delete) fails on the exact collision. Co-authored-by: J <j@multica.ai> Co-authored-by: multica-agent <github@multica.ai>
22 lines
1.1 KiB
SQL
22 lines
1.1 KiB
SQL
-- Revert issue_label to its pre-162 issue-only shape and drop the resource
|
|
-- label junction tables. The two rollback steps that each need their own
|
|
-- transaction live in earlier down migrations, because a single migration
|
|
-- file cannot mix DML/DDL with CREATE INDEX CONCURRENTLY:
|
|
-- * 174.down removes the agent/skill rows, and
|
|
-- * 171.down rebuilds the legacy workspace-wide unique name index
|
|
-- CONCURRENTLY.
|
|
-- Both run before this file (down migrations apply high->low), so the
|
|
-- non-issue rows are already gone by the time we drop resource_type here.
|
|
DROP TABLE IF EXISTS skill_to_label;
|
|
DROP TABLE IF EXISTS agent_to_label;
|
|
|
|
-- Defensive: a short-lived pre-release deploy may have applied the original
|
|
-- 162 that created these indexes inline. On the normal down chain 167/168
|
|
-- already dropped them CONCURRENTLY, so these are no-ops.
|
|
DROP INDEX IF EXISTS issue_label_workspace_type_idx;
|
|
DROP INDEX IF EXISTS issue_label_workspace_type_name_lower_idx;
|
|
|
|
ALTER TABLE issue_label
|
|
DROP COLUMN IF EXISTS description,
|
|
DROP COLUMN IF EXISTS resource_type;
|