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 ,mysql or sqlite |
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 |
If you want to use custom name for your migration
If you want to use custom named config file
If you want to have all params as CLI options
Generate an empty SQL migration file for custom migration.
Apply 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 |
If you want to use custom named config file
Introspect / 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 ,mysql or sqlite |
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 |
If you want to use custom named config file
If you want to have all params as CLI options
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 ,mysql or sqlite |
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 |
If you want to use custom named config file
If you want to have all params as CLI options
Drop 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 |
If you want to use custom named config file
If you want to have all params as CLI options
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 ,mysql or sqlite |
out | no | migrations folder, default=./drizzle |
config | no | config file path, default=drizzle.config.ts |
If you want to use custom named config file
If you want to have all params as CLI options
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 ,mysql or sqlite |
out | no | migrations folder, default=./drizzle |
config | no | config file path, default=drizzle.config.ts |
If you want to use custom named config file
If you want to have all params as CLI options
Drizzle 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 |