List of commands
Generate migrations
drizzle-kit generate lets you generate migrations based on you Drizzle schema.
| param | required | description | 
|---|---|---|
| dialect | yes | Database dialect you are using. Can be postgresql,mysqlorsqlite | 
| schema | yes | path to typescript schema file or folder with multiple schema files | 
| out | no | migrations folder, default= ./drizzle | 
| config | no | config file path, default= drizzle.config.ts | 
| custom | no | generate empty SQL for custom migration | 
| name | no | generate migration with custom name | 
| breakpoints | no | SQL statements breakpoints, default= true | 
$ drizzle-kit generate// drizzle.config.ts
import { defineConfig } from "drizzle-kit";
export default defineConfig({
  dialect: "postgresql", // "mysql" | "sqlite"
  schema: "./src/schema.ts",
  out: "./drizzle",
});If you want to use custom name for your migration
$ drizzle-kit generate --name init_dbIf you want to use custom named config file
$ drizzle-kit generate --config=custom.config.tsIf you want to have all params as CLI options
$ drizzle-kit generate --schema=./src/schema.ts --out=./drizzleGenerate an empty SQL migration file for custom migration.
$ drizzle-kit generate --customApply migrations
drizzle-kit migrate lets you apply migrations stored in you migrations folder and outputed by drizzle-kit generate
| param | required | description | 
|---|---|---|
| config | no | config file path, default= drizzle.config.ts | 
$ drizzle-kit migrate// drizzle.config.ts
import { defineConfig } from "drizzle-kit";
export default defineConfig({
  dialect: "postgresql", // "mysql" | "sqlite"
  out: "./drizzle",
  migrations: {
    table: 'migrations_custom', // default `__drizzle_migrations`,
    schema: 'public', // used in PostgreSQL only and default to `drizzle`
  }
});If you want to use custom named config file
$ drizzle-kit migrate --config=custom.config.tsIntrospect / Pull
drizzle-kit introspect command lets you pull DDL from existing database and generate schema.ts file in matter of seconds.
Either url or user:password@host:port/db params are mandatory.
| param | required | description | 
|---|---|---|
| dialect | yes | Database dialect you are using. Can be postgresql,mysqlorsqlite | 
| driver | no | driver to use for querying ( aws-data-api,d1-http,turso,expo) | 
| out | no | migrations folder, default= ./drizzle | 
| url | no | database connection string | 
| user | no | database user | 
| password | no | database password | 
| host | no | host | 
| port | no | port | 
| database | no | database name | 
| config | no | config file path, default= drizzle.config.ts | 
| introspect-casing | no | strategy for JS keys creation in columns, tables, etc. ( preserve,camel) | 
| schemaFilter | no | Schema name filter. Default: ["public"] | 
| extensionsFilters | no | Database extensions internal database filters | 
$ drizzle-kit introspectimport { defineConfig } from "drizzle-kit";
export default defineConfig({
  schema: "./src/schema/*",
  out: "./drizzle",
  dialect: 'postgresql',
  dbCredentials: {
    url: "postgresql://postgres:password@host:port/db",
  }
});import { defineConfig } from "drizzle-kit";
export default defineConfig({
  schema: "./src/schema/*",
  out: "./drizzle",
  dialect: 'postgresql',
  dbCredentials: {
    user: "postgres",
    password: "password",
    host: "127.0.0.1",
    port: 5432,
    database: "db",
  }
});If you want to use custom named config file
$ drizzle-kit introspect --config=custom.config.tsIf you want to have all params as CLI options
$ drizzle-kit introspect --out=migrations/ --connectionString=postgresql://user:pass@host:port/db_name
$ drizzle-kit introspect --out=migrations/ --host=0.0.0.0 --port=5432 --user=postgres --password=pass --database=db_name --ssl
Prototype / Push
drizzle-kit push lets you push your schema changes directly to the
database and omit managing SQL migration files.
This has proven to be very useful for rapid local development(prototyping) and when working with remote databases like Planetscale, Neon, Turso and others.
Extended article on Turso and drizzle-kit push — read here.
Either url or user:password@host:port/db params are required.
| param | required | description | 
|---|---|---|
| dialect | yes | Database dialect you are using. Can be postgresql,mysqlorsqlite | 
| schema | yes | path to typescript schema file or folder with multiple schema files | 
| driver | no | driver to use for querying ( aws-data-api,d1-http,turso,expo) | 
| tablesFilter | no | table name filter | 
| schemaFilter | no | Schema name filter. Default: ["public"] | 
| extensionsFilters | no | Database extensions internal database filters | 
| url | no | database connection string | 
| user | no | database user | 
| password | no | database password | 
| host | no | host | 
| port | no | port | 
| database | no | database name | 
| config | no | config file path, default= drizzle.config.ts | 
| verbose | no | print all queries that will be executed | 
| strict | no | always ask for an approve before pushing the schema | 
| force | no | auto-accept all data-loss statements | 
$ drizzle-kit pushIf you want to use custom named config file
$ drizzle-kit push --config=custom.config.tsIf you want to have all params as CLI options
$ drizzle-kit push --schema=src/schema.ts --url=postgresql://user:pass@host:port/db_name
$ drizzle-kit push --schema=src/schema.ts --host=0.0.0.0 --port=5432 --user=postgres --password=pass --database=db_name --sslDrop migration
drizzle-kit drop lets you delete previously generated migrations from migrations folder
Please don’t delete any files in migrations folder manually, it might break drizzle-kit
| param | required | description | 
|---|---|---|
| out | no | migrations folder, default= ./drizzle | 
| config | no | config file path, default= drizzle.config.ts | 
$ drizzle-kit dropIf you want to use custom named config file
$ drizzle-kit drop --config=custom.config.tsIf you want to have all params as CLI options
$ drizzle-kit drop --out=drizzle
Maintain stale metadata
We’re rapidly evolving Drizzle Kit APIs and from time to time there’s a need to upgrade underlying metadata structure.
drizzle-kit up is a utility command to keep all metadata up to date.
| param | required | description | 
|---|---|---|
| dialect | yes | Database dialect you are using. Can be postgresql,mysqlorsqlite | 
| out | no | migrations folder, default= ./drizzle | 
| config | no | config file path, default= drizzle.config.ts | 
$ drizzle-kit upIf you want to use custom named config file
$ drizzle-kit up --config=custom.config.tsIf you want to have all params as CLI options
$ drizzle-kit up --out=drizzle
Check
drizzle-kit check is a very powerful tool for you to check consistency of your migrations.
That’s extremely useful when you have multiple people on the project, altering database schema on different branches.
Drizzle Kit will check for all collisions and inconsistencies.
| param | required | description | 
|---|---|---|
| dialect | yes | Database dialect you are using. Can be postgresql,mysqlorsqlite | 
| out | no | migrations folder, default= ./drizzle | 
| config | no | config file path, default= drizzle.config.ts | 
$ drizzle-kit checkIf you want to use custom named config file
$ drizzle-kit check --config=custom.config.tsIf you want to have all params as CLI options
$ drizzle-kit check --out=drizzleDrizzle Studio
drizzle-kit studio lets you launch Drizzle Studio database browser locally from you config file.
| param | required | description | 
|---|---|---|
| port | no | custom port | 
| host | no | custom host for studio server | 
| verbose | no | log all sql statements | 
drizzle-kit studio
drizzle-kit studio --port 3000 --host 0.0.0.0 --verbose