Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Drizzle ORM · Command

drizzle-kit migrate

drizzle-kit migrate applies SQL migrations generated by drizzle-kit generate. It checks migration history, runs only pending migrations, and records successful applications.

How it works

The command reads SQL files from the migrations folder, checks the database migration history, selects migrations that have not run yet, executes them, and records successful applications. Configure the dialect and database credentials in drizzle.config.ts or pass them as command-line options.

Syntax

npx drizzle-kit migrate [options]

Parameters

NameTypeDescription
dialectCLI option / configurationDatabase dialect, such as postgresql, mysql, sqlite, or cockroach.
urlCLI option / configurationDatabase connection credentials, commonly supplied as a URL.
configCLI optionPath to an alternative Drizzle Kit configuration file.

Returns

Applies pending SQL migrations and records successfully applied migrations in the database.

Key points

  • Use this command to apply SQL migration files previously produced by drizzle-kit generate.
  • The command scans the configured migrations folder and reads its SQL migration files.
  • Only migrations not already represented in the database history are selected for execution.
  • Execution and migration-history recording happen as part of the same command workflow.
  • Connection settings can be centralized in drizzle.config.ts or passed directly on the command line.

Common mistakes

  • The dialect and database credentials must be supplied either in the configuration file or through CLI options.
  • Successful migration records are stored in the database, so the migration log table and schema should be accounted for when managing the database.

Example: Apply production migrations

npx drizzle-kit migrate --config=drizzle-prod.config.ts

Runs pending SQL migrations using the specified Drizzle Kit configuration.

When to use it

Apply generated migrations

Code-first schema workflow

Run migrations with a selected config

Environment-specific deployment

Execute pending migrations in CI/CD

Automated database setup

Interview questions

QHow does drizzle-kit migrate determine what to run?

It reads the migration SQL files, retrieves the migration history, identifies unapplied migrations, executes them, and logs the results. This makes repeated runs apply only migrations that are still pending.

Follow-up: What must be configured before running it? The command needs both a database dialect and connection credentials, supplied in drizzle.config.ts or as CLI options.

QWhat role does migrate play after schema changes?

The command applies SQL migrations generated by drizzle-kit generate. It is intended for the code-first migration workflow, where the Drizzle schema is used to produce migration files before they are applied.

Follow-up: How could generated migrations be applied instead? They can also be run with drizzle-orm's migrate(), external migration tooling, or directly against the database.

QWhere is migration history recorded?

A successful run persists migration records in the database. The default log table is named __drizzle_migrations in the drizzle schema.

Follow-up: What operational concern follows from this? The database must preserve that log because it is used to distinguish already-applied migrations from pending ones.

  • drizzle-kit generate
  • drizzle-kit push
  • drizzle-kit pull
  • drizzle-kit export
  • drizzle-orm migrate()

Source: Drizzle Kit Migrate. Checked 2026-10-16.