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.
[✓] 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
- Run
drizzle-kit generatelocally. - Commit every file it creates under the migrations directory.
- Push so the committed migrations match the schema and the CI check passes.
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.
npx drizzle-kit generate
git diff --exit-code drizzle/How to prevent it
- Run
drizzle-kit generateafter every schema change. - Commit generated migrations together with the schema change.
- Add a generate-then-diff gate so drift fails CI early.