fix(customers): re-issue the country backfill skipping migration-reset source companies (#2249)

* fix(customers): re-issue the country backfill skipping migration-reset source companies

Migration 20260903170000 (PR #2241) failed on prod at its first UPDATE:
"Archived migration reset source records are immutable" (SQLSTATE P0001).
Rows of a company listed in company_migration_resets are frozen by
trigger, and the backfill touched them, so the whole file rolled back and
prod has neither normalize_country_code() nor country_raw.

The same SQL ships again as 20260903173000 with every UPDATE excluding
those companies (their legacy text keeps being read through
normalizeCountryCode() at runtime). The old file is removed rather than
edited: prod never recorded it, staging was re-tracked under the new
version by hand. References in code, tests and DECISIONS.md follow.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D5EmmndLyDCmY5NHYAvYkE

* docs(decisions): cite the shipped backfill version 20260903173000

The country-ISO entry still named 20260903170000, the version that never
landed on prod; only the follow-up entry keeps that number, as history.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D5EmmndLyDCmY5NHYAvYkE

* docs(decisions): drop the duplicate country-ISO entry the merge carried in

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D5EmmndLyDCmY5NHYAvYkE

* docs(decisions): keep a single country-ISO entry

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D5EmmndLyDCmY5NHYAvYkE

* docs(decisions): rebuild the tail from main so the merge leaves no duplicated entries

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:
Mattsson
2026-09-03 19:39:56 +02:00
committed by GitHub
co-authored by Claude Fable 5.1
parent a48508e5b0
commit 3159920d7c
5 changed files with 22 additions and 13 deletions
+2 -2
View File
@@ -1,5 +1,5 @@
/**
* pg-real test for migration 20260903170000: customers.country and
* pg-real test for migration 20260903173000: customers.country and
* suppliers.country are ISO 3166-1 alpha-2 (#2025, #2028).
*
* The backfill ran once when the migration was applied, so what can be
@@ -51,7 +51,7 @@ describe('normalize_country_code()', () => {
})
})
describe('country columns after migration 20260903170000', () => {
describe('country columns after migration 20260903173000', () => {
it('keeps the pre-backfill text in country_raw on both tables', async () => {
const { rows } = await getPool().query<{ table_name: string; column_name: string }>(
`select table_name, column_name