diff --git a/internal/migrator/migrations/postgres/000010_rename_attempts_pkey.down.sql b/internal/migrator/migrations/postgres/000010_rename_attempts_pkey.down.sql new file mode 100644 index 000000000..8662cc4f4 --- /dev/null +++ b/internal/migrator/migrations/postgres/000010_rename_attempts_pkey.down.sql @@ -0,0 +1,6 @@ +BEGIN; + +ALTER INDEX IF EXISTS attempts_pkey RENAME TO deliveries_pkey; +ALTER INDEX IF EXISTS attempts_default_pkey RENAME TO deliveries_default_pkey; + +COMMIT; diff --git a/internal/migrator/migrations/postgres/000010_rename_attempts_pkey.up.sql b/internal/migrator/migrations/postgres/000010_rename_attempts_pkey.up.sql new file mode 100644 index 000000000..20c53e796 --- /dev/null +++ b/internal/migrator/migrations/postgres/000010_rename_attempts_pkey.up.sql @@ -0,0 +1,18 @@ +BEGIN; + +-- ============================================================================= +-- Migration: Rename the stale deliveries_* primary key indexes to attempts_* +-- +-- 000005 renamed the deliveries tables to attempts, but Postgres does not +-- rename dependent indexes and constraints on a table rename, so the primary +-- key of attempts (and of its default partition) still carries the old name. +-- +-- Indexes renamed: +-- deliveries_pkey -> attempts_pkey +-- deliveries_default_pkey -> attempts_default_pkey +-- ============================================================================= + +ALTER INDEX IF EXISTS deliveries_pkey RENAME TO attempts_pkey; +ALTER INDEX IF EXISTS deliveries_default_pkey RENAME TO attempts_default_pkey; + +COMMIT;