mirror of
https://gh-proxy.org/https://github.com/klinsmaya/multica.git
synced 2026-11-09 01:46:46 +08:00
Migrations 316, 317, 326, 328, 330 and 331 build indexes with CREATE INDEX
CONCURRENTLY but shipped without an invalid-index cleanup hook. An interrupted
build leaves an INVALID index of the same name behind; on retry the IF NOT
EXISTS ones are recorded as applied while the index stays unusable (316's
uniqueness is then never enforced), and the bare CREATE ones fail on "already
exists" - 328 backs a primary key, so 329 cannot attach it and the migrator
stops there.
Registration was opt-in per batch, which is why this recurred.
concurrentIndexCleanups is now total: every up migration that builds an index
concurrently is registered, matching the invariant concurrentDownIndexCleanups
already held for rollbacks, and TestEveryConcurrentUpBuildHasCleanup fails the
build when a new migration arrives without its entry. Historical entries only
ever run on a database where those migrations are still pending - a fresh
self-hosted install, which is exactly where an interrupted build would otherwise
leave a permanently unusable index.
328/330/331 also gain IF NOT EXISTS, so the other retry window (build committed,
version never recorded) is a no-op instead of a wedged release.
Verified against a live Postgres: the new share-link test drives an interrupted
build through the real 327-331 files and the real hook map, and fails without
either half of the fix ("index is not valid" when the hook is missing, "relation
already exists" without IF NOT EXISTS).
Co-authored-by: Bohan-J <[email protected]>
Co-authored-by: multica-agent <[email protected]>
8 lines
383 B
SQL
8 lines
383 B
SQL
-- Lookup index for joins/previews by invite code.
|
|
--
|
|
-- IF NOT EXISTS keeps a retry idempotent when the build committed but the
|
|
-- version was never recorded; an interrupted build's INVALID leftover is
|
|
-- dropped first by this migration's cleanup hook in cmd/migrate.
|
|
CREATE UNIQUE INDEX CONCURRENTLY IF NOT EXISTS workspace_share_link_code_uidx
|
|
ON workspace_share_link (code);
|