fix(migrations): re-issue the invoice payee migrations skipping migration-reset source companies (#2260)
* fix(migrations): re-issue the invoice payee migrations skipping migration-reset source companies #2233 merged, but its first migration (20260903150000) failed on prod at the backfill's INSERT into invoice_payee_defaults: ERROR: Archived migration reset source records are immutable (P0001) The insert fires the SECURITY DEFINER mirror into company_settings, and one of the companies with a legacy payment map is a migration-reset source, whose rows are immutable by trigger. The migration rolled back as a whole, prod has neither table nor column, and every migration merged after it is queued behind the failure. Same fix as #2249 used for the country backfill: both entry branches of the backfill now skip companies present in company_migration_resets, and both files are re-issued under fresh versions (20260904010000 and 20260904011000) so Supabase applies them in order after everything that landed today. The failed versions never applied on prod, so no orphan; staging applied them by hand and its schema_migrations rows must be renamed to match (see DECISIONS.md). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(migrations): make the re-issued payee migrations rerunnable pg-upgrade builds from main, where the first issue (20260903150000) already ran, then applies the re-issued file on top: the composite UNIQUE constraint already existed. Every statement in both files is now guarded (constraint DO blocks, CREATE TABLE/INDEX IF NOT EXISTS, DROP POLICY / DROP TRIGGER IF EXISTS before each CREATE), so staging and the preview branches that applied the first issue take the re-issue cleanly too, and prod, which never applied it, is unaffected. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
91e2c66afc
commit
9ab823a43c
+2
-2
@@ -644,7 +644,7 @@ export interface BankAccount {
|
||||
export type CashAccountSource = 'enable_banking' | 'manual' | 'sie_import'
|
||||
|
||||
/**
|
||||
* What a customer pays to. Lives on cash_accounts (migration 20260903150000)
|
||||
* What a customer pays to. Lives on cash_accounts (migration 20260904010000)
|
||||
* and is the single source for the payee printed on customer invoices; the
|
||||
* per-currency map on company_settings is a trigger-maintained mirror of the
|
||||
* default account per currency.
|
||||
@@ -1363,7 +1363,7 @@ export interface Invoice {
|
||||
stripe_payment_link_id?: string | null
|
||||
// Per-invoice opt-out for automatic payment link creation on send.
|
||||
payment_link_auto?: boolean
|
||||
// Per-invoice payee (migration 20260903193000): the bank account this
|
||||
// Per-invoice payee (migration 20260904011000): the bank account this
|
||||
// invoice asks the customer to pay to (null = the per-currency default),
|
||||
// and its payee fields frozen when chosen and refreshed at issue. Issued
|
||||
// invoices print from payment_details; the resolver falls back to the
|
||||
|
||||
Reference in New Issue
Block a user