Skip to content
Latchkey

Drizzle drift: generated migration differs from schema in CI

A common CI guard runs drizzle-kit generate and fails if it produces new files. When the committed migrations do not reflect the current schema.ts, generate emits a new migration and the working tree is no longer clean, failing the check.

What this error means

A CI step that runs drizzle-kit generate followed by a git diff check fails because a new migration file was created, meaning the schema and committed migrations are out of sync.

drizzle-kit output
[✓] Your SQL migration file ➜ drizzle/0007_curved_silver_surfer.sql

Error: migrations directory is not up to date with schema (uncommitted changes)

Common causes

Schema changed but migrations were not regenerated

Someone edited schema.ts without running drizzle-kit generate, so the committed SQL no longer matches the schema and CI regenerates it.

A generated migration was not committed

The migration was generated locally but left out of the commit, so CI produces it again and the diff is dirty.

How to fix it

Regenerate and commit the migration

  1. Run drizzle-kit generate locally.
  2. Commit every file it creates under the migrations directory.
  3. Push so the committed migrations match the schema and the CI check passes.
Terminal
npx drizzle-kit generate
git add drizzle/ && git commit -m "chore: regenerate drizzle migration"

Keep the drift check as a CI gate

Run generate then fail if anything changed, so out-of-date migrations are caught in review.

Terminal
npx drizzle-kit generate
git diff --exit-code drizzle/

How to prevent it

  • Run drizzle-kit generate after every schema change.
  • Commit generated migrations together with the schema change.
  • Add a generate-then-diff gate so drift fails CI early.

Frequently asked questions

What causes "drizzle-kit generate drift"?
Someone edited schema.ts without running drizzle-kit generate, so the committed SQL no longer matches the schema and CI regenerates it.
How do I fix drizzle-kit generate drift?
Regenerate and commit the migration

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card