#10722·tldraw

Migration transaction-block guard misses END; and END WORK;

Author: drievCreated Sep 10, 2026Updated Sep 17, 2026
Labelsdotcom

️: migrate.ts transaction-block guard misses END; and END WORK; (COMMIT synonyms); strip dollar-quoted bodies, comments and strings before matching and add bare END; fold into migrationFile.ts from #10576. Found by Codex review on #10591.


The migration runner refuses a migration file that contains its own transaction statements, because the runner opens one transaction for every pending migration and a stray COMMIT; mid-file ends it early, which makes --dry-run apply everything after it for real. The guard added in #10591 covers BEGIN, START TRANSACTION, COMMIT, ROLLBACK and END TRANSACTION, but Postgres also accepts END; and END WORK; as synonyms for COMMIT, and those pass. Bare END; cannot simply be added, since every plpgsql function body ends with one; the guard needs to ignore dollar-quoted bodies, comments and string literals before matching, and then treat a top-level END; as a transaction statement. #10576 introduces a per-file migration parser, and this check should live there rather than beside it.

Open questions

  1. Should this wait for #10576 to merge and land as part of the fold-in, or ship on its own first? Awaiting answer.

Confidence: 85%, ready to get started.