From e8f4262804828b4731fe5382ffd6686c08d9bd71 Mon Sep 17 00:00:00 2001 From: Ashwin Kumar Sivakumar Date: Mon, 17 Aug 2026 18:37:08 +0530 Subject: [PATCH] fix(db): drop untracked invoices_payment_id_check trigger before 050000 recreates it Prod has this trigger from an out-of-band creation that was never recorded in _sqlx_migrations, so migration 20260814050000 failed with 'trigger already exists' and stopped the whole migrate run partway through. Co-Authored-By: Claude Sonnet 5 --- ...drop_stale_invoices_payment_id_check_trigger.down.sql | 2 ++ ...0_drop_stale_invoices_payment_id_check_trigger.up.sql | 9 +++++++++ 2 files changed, 11 insertions(+) create mode 100644 crates/db/migrations/20260814045000_drop_stale_invoices_payment_id_check_trigger.down.sql create mode 100644 crates/db/migrations/20260814045000_drop_stale_invoices_payment_id_check_trigger.up.sql diff --git a/crates/db/migrations/20260814045000_drop_stale_invoices_payment_id_check_trigger.down.sql b/crates/db/migrations/20260814045000_drop_stale_invoices_payment_id_check_trigger.down.sql new file mode 100644 index 0000000..181a154 --- /dev/null +++ b/crates/db/migrations/20260814045000_drop_stale_invoices_payment_id_check_trigger.down.sql @@ -0,0 +1,2 @@ +-- No-op: 20260814050000's up migration recreates the trigger, and its own +-- down migration is responsible for dropping it again. diff --git a/crates/db/migrations/20260814045000_drop_stale_invoices_payment_id_check_trigger.up.sql b/crates/db/migrations/20260814045000_drop_stale_invoices_payment_id_check_trigger.up.sql new file mode 100644 index 0000000..35336ae --- /dev/null +++ b/crates/db/migrations/20260814045000_drop_stale_invoices_payment_id_check_trigger.up.sql @@ -0,0 +1,9 @@ +-- Prod has an `invoices_payment_id_check` trigger that was created outside +-- of sqlx's migration tracking (never recorded in _sqlx_migrations), which +-- made 20260814050000_invoices_payment_id_polymorphic_check.up.sql fail +-- with "trigger already exists" and stop the whole migrate run partway +-- through, blocking every migration after it. Drop the untracked trigger +-- here (a version strictly before 050000) so 050000 can recreate it +-- cleanly and the run proceeds. + +DROP TRIGGER IF EXISTS invoices_payment_id_check ON invoices;