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
@@ -254,7 +254,7 @@ export const PUT = withRouteContext(
|
||||
}
|
||||
|
||||
// Payment instructions live on cash_accounts since migration
|
||||
// 20260903150000; the bank columns below are a mirror of the default
|
||||
// 20260904010000; the bank columns below are a mirror of the default
|
||||
// payee account per currency. Write the change through to the account
|
||||
// FIRST: if that fails nothing has been written and the caller gets an
|
||||
// error, instead of a settings row that the next mirror would undo.
|
||||
|
||||
@@ -287,7 +287,7 @@ export const PATCH = withApiV1<{ params: Promise<{ companyId: string }> }>(
|
||||
// are `undefined` here and are dropped by supabase-js JSON serialization,
|
||||
// so only supplied fields are written; explicit null still clears.
|
||||
// The bank columns mirror the default SEK payee account (migration
|
||||
// 20260903150000): write the change through to it FIRST so a failure
|
||||
// 20260904010000): write the change through to it FIRST so a failure
|
||||
// leaves nothing half-written, and the PDF prints what this call set.
|
||||
try {
|
||||
await propagateLegacyPayeeWrite(ctx.supabase, ctx.companyId!, changes)
|
||||
|
||||
Reference in New Issue
Block a user