Migration validation
Before merging migration changes, detect conflicting or colliding generated migrations.
Drizzle ORM · Command
Checks generated SQL migration history for consistency, including race conditions or collisions. It requires a dialect and supports configuration through drizzle.config.ts or CLI flags.
The command examines generated SQL migration history for consistency and detects conflicts or race conditions between migrations. It requires a database dialect, supplied in drizzle.config.ts or with --dialect; configuration can also be selected with --config.
npx drizzle-kit check [--dialect=<dialect>] [--out=<migrations-folder>] [--config=<config-file>] [--ignore-conflicts]| Name | Type | Description |
|---|---|---|
--dialect | string | Database dialect; supported values include postgresql, mysql, sqlite, turso, singlestore, mssql, and cockroach. |
--out | string | Path to the migrations folder; defaults to ./drizzle. |
--config | string | Path to the Drizzle configuration file; defaults to drizzle.config.ts. |
--ignore-conflicts | boolean | Bypasses commutativity-conflict checks. |
Reports whether the generated SQL migration history is consistent; the page does not specify a formal return value.
npx drizzle-kit check --dialect=postgresql --out=./drizzleChecks the migration history for consistency using the PostgreSQL dialect and the default-style migrations directory.
Before merging migration changes, detect conflicting or colliding generated migrations.
Run the same check with environment-specific Drizzle configuration files.
Validate migrations stored outside the default ./drizzle directory.
It validates the consistency of generated SQL migration history and checks for race conditions or collisions among generated migrations. The command needs a dialect, configured in drizzle.config.ts or passed on the command line.
Follow-up: How would you run it against a nondefault migration directory? Pass both the dialect and the directory, for example npx drizzle-kit check --dialect=postgresql --out=./migrations-folder.
The command accepts a dialect either through drizzle.config.ts or through the --dialect CLI option. Supported dialects include PostgreSQL, MySQL, SQLite, Turso, SingleStore, MSSQL, and CockroachDB.
Follow-up: How can separate environments use different settings? Supply the relevant file with --config, such as --config=drizzle-prod.config.ts.
The default migrations directory is ./drizzle, and the default configuration file is drizzle.config.ts. You can override the directory with --out and the configuration path with --config.
Follow-up: What if commutativity conflicts are expected? Run the command with --ignore-conflicts to bypass those checks.
drizzle-kit generatedrizzle-kit migratedrizzle.config.tsDrizzle Kit