Drizzle ORM Migration Error— push vs migrate Fix [2026]
Also covers: drizzle.config.ts · No config found · out-of-sync journal · programmatic migrate · reset migrations
⚡ Common Migration Errors
No config file found. Please create a drizzle.config.ts
// OR:
Cannot find module './drizzle/meta/_journal.json'
// OR:
Error: Migrations are out of sync. Run 'drizzle-kit generate' first.✅ Quick dev fix
npx drizzle-kit push # syncs schema to DB — dev onlypush vs generate+migrate — Which to Use
Drizzle has two migration workflows. push is for development — it directly syncs your schema to the database instantly, no files created. generate + migrate is for production — it creates versioned SQL files you review, commit, and apply in CI/CD.
Fix drizzle.config.ts Setup
Foundation — correct config fileimport { defineConfig } from "drizzle-kit"
export default defineConfig({
schema: "./db/schema.ts", // path to your schema file(s)
out: "./drizzle", // where migration files are stored
dialect: "postgresql", // or "mysql" | "sqlite"
dbCredentials: {
url: process.env.DATABASE_URL!, // connection string
},
verbose: true, // show SQL being applied
strict: true, // prompt before destructive changes
})DATABASE_URL=postgresql://username:password@localhost:5432/mydb
# For Neon / Supabase:
DATABASE_URL=postgresql://user:pass@host.neon.tech/dbname?sslmode=requireFix 'No Config File Found' Error
drizzle-kit can't find drizzle.config.ts# Default — looks for drizzle.config.ts at project root
npx drizzle-kit push
# If your config is elsewhere — specify path
npx drizzle-kit push --config ./config/drizzle.config.ts
# Verify drizzle-kit is installed
npx drizzle-kit --version
# If missing:
npm install --save-dev drizzle-kitFix Out-of-Sync Migration Journal
Journal and SQL files don't match# Option A — use push during development (skip migration files entirely)
npx drizzle-kit push
# Option B — regenerate from scratch (DEV ONLY — destructive in production)
# 1. Delete the drizzle/ folder
rm -rf drizzle/
# 2. Regenerate all migrations from current schema
npx drizzle-kit generate
# 3. Apply to database
npx drizzle-kit migrate
# Option C — mark a migration as applied without running it
# Edit drizzle/meta/_journal.json and add the migration entry manually
# Only do this if you've manually applied the SQL alreadyNever delete and regenerate migration files in a shared team environment or production system. The migration history exists for a reason — all team members' databases need to stay in sync.
Run Migrations Programmatically at Startup
Auto-migrate in production / CIimport { drizzle } from "drizzle-orm/node-postgres"
import { migrate } from "drizzle-orm/node-postgres/migrator"
import { Pool } from "pg"
async function runMigrations() {
const pool = new Pool({ connectionString: process.env.DATABASE_URL! })
const db = drizzle(pool)
console.log("Running migrations...")
await migrate(db, { migrationsFolder: "./drizzle" })
console.log("Migrations complete")
await pool.end()
}
runMigrations().catch((err) => {
console.error("Migration failed:", err)
process.exit(1)
}){
"scripts": {
"db:generate": "drizzle-kit generate",
"db:migrate": "tsx db/migrate.ts",
"db:push": "drizzle-kit push",
"db:studio": "drizzle-kit studio"
}
}Reset and Recreate Migrations (Dev Only)
Fresh start — local development only# 1. Drop all tables (DANGER — destroys all data)
npx drizzle-kit drop # interactive drop
# OR connect to DB and run: DROP SCHEMA public CASCADE; CREATE SCHEMA public;
# 2. Delete migration files
rm -rf drizzle/
# 3. Regenerate from current schema
npx drizzle-kit generate
# 4. Apply migrations
npx drizzle-kit migrate
# 5. (Optional) Seed test data
tsx db/seed.tsDrizzle Studio is a visual database browser — run npx drizzle-kit studio to explore your tables, run queries, and debug schema issues in a browser UI.
Prevention
- Use push for development, generate+migrate for production — never mix the two for the same database
- Always commit the drizzle/ folder to git — it is part of your codebase, not a build artifact
- Run migrations as part of your CI/CD pipeline before deploying new code
- Add db:generate, db:migrate, db:push scripts to package.json for consistency
- Never manually edit migration SQL files after they've been applied
- Use drizzle-kit studio to visually verify schema changes before applying them
Frequently Asked Questions
What is the difference between drizzle-kit push and migrate?+−
Why does drizzle-kit push say 'No config file found'?+−
Why are my migrations out of sync?+−
How do I run Drizzle migrations automatically in production?+−
Should I commit migration files to git?+−
Can I use drizzle-kit push in production?+−
Need Expert Help?
We Manage Drizzle ORM Migrations in Production
Softplix engineers set up Drizzle with safe CI/CD migration pipelines, schema versioning, and zero-downtime deploys. Let us help.
Talk to an Engineer