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;