fix(migrations): re-issue the 12xx label backfill inside an explicit transaction block (#2422)
* fix(migrations): re-issue the 12xx label backfill inside an explicit transaction block 20260908113353 (PR #2419) used a bare LOCK TABLE. The CI replay (psql -f per file) and the Supabase branch runner execute migration statements in autocommit, so Postgres refused it ("LOCK TABLE can only be used in transaction blocks"): pg-real, pg-upgrade and tool-pg went red on main and prod's migration queue stopped at that version, which also blocks 20260908130127 (PR #2420). Prod never recorded 113353, so the file is replaced rather than edited: same statements wrapped in BEGIN/COMMIT (precedent 20260513140000), new version 20260908120449. Applied and pg-tested on staging. Refs #2413 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NXSuVejFCvRDyNXF1otEPd * docs(decisions): migrations wrap transaction-only statements in BEGIN/COMMIT Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NXSuVejFCvRDyNXF1otEPd --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
e85eac317c
commit
5987523a25
+9
-2
@@ -26,11 +26,16 @@
|
||||
-- corrects the label the picker handed out before anything was booked on it.
|
||||
-- No row is deleted; bookings key on account_number, never on the label.
|
||||
--
|
||||
-- The migration runs in one transaction (Supabase CLI wraps it). The SHARE
|
||||
-- lock below makes the "no journal lines" check and the rename atomic against
|
||||
-- Explicit transaction block: the CI replay (psql -f per file) and the
|
||||
-- Supabase branch runner both execute statements in autocommit, where a bare
|
||||
-- LOCK TABLE is refused ("can only be used in transaction blocks"); that is
|
||||
-- how 20260908113353 failed on main and blocked the prod queue. The SHARE
|
||||
-- lock makes the "no journal lines" check and the rename atomic against
|
||||
-- concurrent postings: inserts on journal_entry_lines wait the few
|
||||
-- milliseconds this takes, reads are unaffected.
|
||||
|
||||
BEGIN;
|
||||
|
||||
LOCK TABLE public.journal_entry_lines IN SHARE MODE;
|
||||
|
||||
UPDATE public.chart_of_accounts a
|
||||
@@ -95,3 +100,5 @@ UPDATE public.chart_of_accounts a
|
||||
WHERE e.company_id = a.company_id
|
||||
AND l.account_number = a.account_number
|
||||
);
|
||||
|
||||
COMMIT;
|
||||
Reference in New Issue
Block a user