← Registry
Loop Official

Schema Migration Drift to Zero

After every schema edit, regenerate migrations and prove there is no drift — loop until a fresh generate produces no new files and leaves the working tree clean.

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

npm run db:generate && git status --porcelain
$

Kickoff prompt

Start the "Schema Migration Drift to Zero" loop. Goal: the committed migration set exactly describes the current schema — a fresh regenerate produces no new files and leaves the working tree clean Max iterations: 6 Between iterations run: npm run db:generate && git status --porcelain Exit when: db:generate exits 0 and git status --porcelain prints nothing (no new or modified migration files) Step 1: Run the migration generator against the current schema, and if it emits or modifies any migration file, review and commit that file (or reconcile the hand-edit) before regenerating to confirm the next run is a no-op.