fix(db): retire legacy cad_buildings_pkey — fix migration 92 hotfix (#168) #173

Merged
lekss361 merged 1 commit from fix/cadastre-schema-pkey-rename into main 2026-05-15 10:59:53 +00:00

View file

@ -503,6 +503,12 @@ BEGIN
WHERE table_schema = 'public' AND table_name = 'cad_buildings'
) THEN
ALTER TABLE cad_buildings_new RENAME TO cad_buildings;
-- First, retire the legacy PK index name that's still attached to
-- cad_buildings_old_apr26 (PG does NOT auto-rename PK indexes on
-- table rename — pre-K.1 backup left cad_buildings_pkey behind).
-- Without this rename, the next line collides with the existing
-- index name → 'relation already exists' → tx rollback.
ALTER INDEX IF EXISTS cad_buildings_pkey RENAME TO cad_buildings_old_apr26_pkey;
-- Rename indexes to drop the _new suffix
ALTER INDEX IF EXISTS cad_buildings_new_pkey RENAME TO cad_buildings_pkey;
-- Note: ALTER INDEX RENAME on a PK index also renames the constraint