Report

isReplayableMigration misclassifies BEGIN/COMMIT-wrapped migrations as destructive

643ce64f-b03c-4fcd-b0b5-3fe03db54d3f

In packages/db/scripts/migrate.mjs, the isReplayableMigration() classifier walks each statement of a SQL migration and accepts CREATE/ALTER/COMMENT/INSERT-ON-CONFLICT/DO blocks. It has no clause for transaction-control statements. When a migration is wrapped in BEGIN; ... COMMIT; (a common Postgres idiom), the very first token after splitting on ; is BEGIN — which falls through every branch and returns false. The whole migration is then classified as non-replayable, and baseline()'s drift-detection branch throws "Schema drift: N non-replayable migration(s) have missing targets" at line ~498. This blocks the Vercel preview build whenever a wave includes BEGIN/COMMIT-wrapped migrations alongside missing-target ones.