Skip to main content
Drizzle Kit provides a comprehensive CLI for managing database migrations and schema operations. All commands support both CLI flags and configuration file options.

Installation

Available Commands

generate

Generate SQL migration files from your Drizzle schema.
string
required
Database dialect: postgresql, mysql, sqlite, turso, or singlestore
string
Path to schema file or folder. Can be a glob pattern.
string
default:"drizzle"
Output folder for migration files
string
Custom migration file name
boolean
default:false
Generate an empty migration file for custom SQL
boolean
default:true
Enable SQL statement breakpoints in generated migrations. Required for databases that don’t support multiple DDL statements in one transaction (MySQL, SQLite, SingleStore).
string
default:"index"
Migration file prefix formatOptions: index, timestamp, supabase, unix, none
string
Path to config file (default: drizzle.config.ts)
string
Column name casing for serialization: camelCase or snake_case
The generate command does not execute migrations - it only creates migration files. Use the migrate command to apply migrations to your database.

migrate

Apply pending migrations to your database.
string
Path to config file containing database credentials and migration settings
The migrate command requires database credentials to be configured in your drizzle.config.ts file. It reads migration files from the out directory and applies them in order.
How it works:
  1. Reads migration files from the configured output directory (default: drizzle)
  2. Checks the migrations table to see which migrations have been applied
  3. Applies pending migrations in sequential order
  4. Records applied migrations in the migrations table
Configuration example:

push

Push schema changes directly to the database without generating migration files.
string
required
Database dialect: postgresql, mysql, sqlite, turso, or singlestore
string
required
Path to schema file or folder
boolean
default:false
Print all SQL statements that will be executed
boolean
default:false
Always ask for confirmation before applying changes
boolean
default:false
Auto-approve all data loss statements without confirmation
Use with caution! This flag will automatically approve statements that may truncate tables or delete data.
string
Path to config file
Database Credentials (CLI flags):
string
Database connection URL
string
Database host
string
Database port
string
Database user
string
Database password
string
Database name
string
SSL mode for PostgreSQL: require, allow, prefer, or verify-full
string
Authentication token (for Turso)
Filtering Options:
string
Filter tables with glob patterns
string
PostgreSQL schema name filters
The push command is ideal for prototyping and development. For production, use generate and migrate to maintain a history of schema changes.

pull (introspect)

Introspect an existing database and generate Drizzle schema.
string
required
Database dialect: postgresql, mysql, sqlite, turso, singlestore, or gel
string
default:"drizzle"
Output folder for generated schema files
string
Path to config file
string
default:"camel"
Casing format for generated schema: camel or preserve
  • camel: Converts snake_case to camelCase
  • preserve: Keeps original database casing
boolean
default:true
Generate migration files with breakpoints
Database credentials and filtering options are the same as the push command. Example:
This generates:
  • schema.ts: Complete Drizzle schema based on your database
  • relations.ts: Inferred relations between tables

studio

Launch Drizzle Studio - a visual database browser.
number
default:4983
Custom port for Drizzle Studio
string
default:"0.0.0.0"
Custom host for Drizzle Studio
boolean
default:false
Print all SQL statements executed by Studio
string
Path to config file containing database credentials
Features:
  • Browse and edit database records
  • Run queries
  • View table schemas and relationships
  • Real-time data updates
Access Studio at https://local.drizzle.studio

drop

Remove a migration file and update the migration journal.
string
default:"drizzle"
Migrations folder
string
Path to config file
This command only removes the migration file locally. It does not revert applied migrations from the database.

check

Validate migration files and ensure consistency.
string
required
Database dialect
string
default:"drizzle"
Migrations folder
string
Path to config file
Validates:
  • Migration file syntax
  • Migration journal consistency
  • Schema snapshot integrity

up

Upgrade migration files to the latest Drizzle Kit format.
string
required
Database dialect
string
default:"drizzle"
Migrations folder
string
Path to config file
This command upgrades migration metadata format when updating Drizzle Kit versions. It preserves your migration SQL while updating internal metadata.

export

Generate SQL diff between current schema and empty state.
string
required
Database dialect
string
required
Path to schema file or folder
boolean
default:true
Generate output as SQL
string
Path to config file
Generates a complete SQL file representing your entire schema without using migrations.

Global Options

All commands support:
  • --config: Specify custom config file path
  • Using environment variables through config file
  • Both CLI flags and config file (flags take precedence)

Exit Codes

  • 0: Success
  • 1: Error occurred

Examples

Complete workflow

Quick prototyping

Working with existing database