PR #173 fixed cad_buildings_pkey but missed 5 other indexes. Same root cause: PG does NOT auto-rename indexes on table rename → all 6 backing indexes remain on cad_buildings_old_apr26 with original names. Add 5 more `ALTER INDEX IF EXISTS ... RENAME TO ..._old_apr26_*` statements for: geom_gist, quarter_idx, objdoc_idx, complex_idx, purpose_idx. Migration 92 still NOT in _schema_migrations (4× rollback now). Next deploy will re-apply cleanly. Co-authored-by: lekss361 <claudestars@proton.me>
This commit is contained in:
parent
7b2d1782e9
commit
37e4f854c5
1 changed files with 11 additions and 6 deletions
|
|
@ -503,13 +503,18 @@ 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.
|
||||
-- First, retire ALL legacy index names that are still attached to
|
||||
-- cad_buildings_old_apr26 — PG does NOT auto-rename indexes on
|
||||
-- table rename, so pre-K.1 backup left all 6 names occupied.
|
||||
-- Without these renames, the _new → unsuffixed renames below collide
|
||||
-- → '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_geom_gist RENAME TO cad_buildings_old_apr26_geom_gist;
|
||||
ALTER INDEX IF EXISTS cad_buildings_quarter_idx RENAME TO cad_buildings_old_apr26_quarter_idx;
|
||||
ALTER INDEX IF EXISTS cad_buildings_objdoc_idx RENAME TO cad_buildings_old_apr26_objdoc_idx;
|
||||
ALTER INDEX IF EXISTS cad_buildings_complex_idx RENAME TO cad_buildings_old_apr26_complex_idx;
|
||||
ALTER INDEX IF EXISTS cad_buildings_purpose_idx RENAME TO cad_buildings_old_apr26_purpose_idx;
|
||||
-- Now rename _new → unsuffixed names safely
|
||||
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
|
||||
-- automatically in PG 16. No separate RENAME CONSTRAINT needed.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue