From b88f47a67b37d20affe7e6fb9ad21fc22df7bc9c Mon Sep 17 00:00:00 2001 From: Alex Luong Date: Tue, 11 Aug 2026 02:01:51 +0700 Subject: [PATCH] migrator: rename stale deliveries_* pkey indexes to attempts_* Co-Authored-By: Claude Opus 5 (1M context) --- .../000010_rename_attempts_pkey.down.sql | 6 ++++++ .../000010_rename_attempts_pkey.up.sql | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 internal/migrator/migrations/postgres/000010_rename_attempts_pkey.down.sql create mode 100644 internal/migrator/migrations/postgres/000010_rename_attempts_pkey.up.sql 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;