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

npm install -D drizzle-kit

Available Commands

generate

Generate SQL migration files from your Drizzle schema.
drizzle-kit generate
--dialect
string
required
Database dialect: postgresql, mysql, sqlite, turso, or singlestore
--schema
string
Path to schema file or folder. Can be a glob pattern.
drizzle-kit generate --schema=./src/schema.ts
drizzle-kit generate --schema=./src/schema/*
--out
string
default:"drizzle"
Output folder for migration files
--name
string
Custom migration file name
drizzle-kit generate --name=add_users_table
--custom
boolean
default:false
Generate an empty migration file for custom SQL
drizzle-kit generate --custom
--breakpoints
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).
--prefix
string
default:"index"
Migration file prefix formatOptions: index, timestamp, supabase, unix, none
# Results in: 0001_migration.sql
drizzle-kit generate --prefix=index

# Results in: 20240304120000_migration.sql  
drizzle-kit generate --prefix=timestamp
--config
string
Path to config file (default: drizzle.config.ts)
--casing
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.
drizzle-kit migrate
--config
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:
import { defineConfig } from 'drizzle-kit';

export default defineConfig({
  dialect: 'postgresql',
  schema: './src/schema.ts',
  out: './drizzle',
  dbCredentials: {
    url: process.env.DATABASE_URL,
  },
  migrations: {
    table: 'migrations',
    schema: 'public',
  },
});

push

Push schema changes directly to the database without generating migration files.
drizzle-kit push
--dialect
string
required
Database dialect: postgresql, mysql, sqlite, turso, or singlestore
--schema
string
required
Path to schema file or folder
--verbose
boolean
default:false
Print all SQL statements that will be executed
--strict
boolean
default:false
Always ask for confirmation before applying changes
--force
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.
--config
string
Path to config file
Database Credentials (CLI flags):
--url
string
Database connection URL
drizzle-kit push --url=postgresql://user:pass@host:5432/db
--host
string
Database host
--port
string
Database port
--user
string
Database user
--password
string
Database password
--database
string
Database name
--ssl
string
SSL mode for PostgreSQL: require, allow, prefer, or verify-full
--auth-token
string
Authentication token (for Turso)
Filtering Options:
--tablesFilter
string
Filter tables with glob patterns
drizzle-kit push --tablesFilter=users_*,posts_*
--schemaFilters
string
PostgreSQL schema name filters
drizzle-kit push --schemaFilters=public,custom
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.
drizzle-kit pull
drizzle-kit introspect  # Alias
--dialect
string
required
Database dialect: postgresql, mysql, sqlite, turso, singlestore, or gel
--out
string
default:"drizzle"
Output folder for generated schema files
--config
string
Path to config file
--introspect-casing
string
default:"camel"
Casing format for generated schema: camel or preserve
  • camel: Converts snake_case to camelCase
  • preserve: Keeps original database casing
--breakpoints
boolean
default:true
Generate migration files with breakpoints
Database credentials and filtering options are the same as the push command. Example:
drizzle-kit pull --dialect=postgresql --url=$DATABASE_URL --out=./src/db/schema
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.
drizzle-kit studio
--port
number
default:4983
Custom port for Drizzle Studio
drizzle-kit studio --port=3000
--host
string
default:"0.0.0.0"
Custom host for Drizzle Studio
drizzle-kit studio --host=localhost
--verbose
boolean
default:false
Print all SQL statements executed by Studio
--config
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.
drizzle-kit drop
--out
string
default:"drizzle"
Migrations folder
--config
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.
drizzle-kit check
--dialect
string
required
Database dialect
--out
string
default:"drizzle"
Migrations folder
--config
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.
drizzle-kit up
--dialect
string
required
Database dialect
--out
string
default:"drizzle"
Migrations folder
--config
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.
drizzle-kit export
--dialect
string
required
Database dialect
--schema
string
required
Path to schema file or folder
--sql
boolean
default:true
Generate output as SQL
--config
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

# 1. Generate migration from schema changes
drizzle-kit generate

# 2. Review generated SQL in drizzle/ folder
cat drizzle/0001_*.sql

# 3. Apply migration to database
drizzle-kit migrate

# 4. Open Studio to verify changes
drizzle-kit studio

Quick prototyping

# Push changes directly without migration files
drizzle-kit push --verbose

Working with existing database

# Pull schema from database
drizzle-kit pull --out=./src/schema

# Generate initial migration
drizzle-kit generate --name=init

Build docs developers (and LLMs) love