migration-until-applied makes migrations APPLY in dev — but that passes even when committed migrations have silently fallen behind the schema source of truth. This loop targets the opposite, sharper failure: DRIFT. Each pass regenerates migrations from the current schema and checks whether the generator emitted anything new or left the tree dirty — a non-empty result is exactly the condition a CI drift check rejects. It commits the generated migration (or reconciles a hand-edit), then regenerates again to confirm a no-op. ORM-agnostic: works with Drizzle (db:generate), Prisma (migrate diff), or any generate-then-diff toolchain.
Loop
- Goal
- the committed migration set exactly describes the current schema — a fresh regenerate produces no new files and leaves the working tree clean
- Exit when
- db:generate exits 0 and git status --porcelain prints nothing (no new or modified migration files)
Check between iterations