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

Drizzle ORM · Command

drizzle-kit pull

drizzle-kit pull introspects an existing database and generates a Drizzle schema.ts file in the configured output directory. It supports database-first migrations and can mark the result as the initial migration with --init.

How it works

Run this command to introspect an existing database, generate a Drizzle schema file, and place the generated output in the configured directory. Use --init when the pulled schema should become the baseline for later migration diffs.

Syntax

npx drizzle-kit pull [options]

Parameters

NameTypeDescription
dialectrequired optionDatabase dialect, such as postgresql, mysql, sqlite, turso, singlestore, mssql, or cockroach.
urlconnection optionDatabase connection string; alternatively provide user, password, host, port, and database.
outoptionDirectory for generated output; defaults to ./drizzle.
--initflagMarks the pulled schema as an applied initial migration.
tablesFilteroptionFilters the tables included during introspection.

Returns

A generated schema.ts file and migration-related output in the configured out directory; with --init, the pulled schema is recorded as the applied baseline.

Key points

  • Use pull for a database-first workflow: it converts the existing database structure into a Drizzle schema file.
  • The command reads the database definition language from the connected database.
  • Generated schema output is written to the configured out directory.
  • Connection settings may come from drizzle.config.ts or directly from command-line flags.
  • For MySQL, every table is included unless the table selection is configured.

Common mistakes

  • The dialect and a database connection must be supplied, either through drizzle.config.ts or command-line options.
  • Use --init only when the current database structure should be treated as the starting migration baseline.

Example: Pull an existing PostgreSQL schema

npx drizzle-kit pull --dialect=postgresql --url=postgresql://user:password@host:port/dbname
npx drizzle-kit pull --init

Introspects the PostgreSQL database and then marks the pulled schema as the initial applied migration.

When to use it

Adopt an existing database

An existing database is the source of truth and the application needs a typed Drizzle schema.

Create an initial migration baseline

A team wants future migration diffs to start from the current production schema.

Automate schema pulls

A CI/CD job needs to run introspection with an explicit database configuration.

Interview questions

QWhat does drizzle-kit pull do?

It introspects the existing database schema and generates a schema.ts Drizzle schema file. The generated file is saved in the configured out directory.

Follow-up: How do you establish that introspected structure as the migration baseline? Use the --init flag, which marks the pulled schema as an applied migration.

QWhat inputs does pull require?

The command requires a dialect plus either a database URL or separate connection parameters. These values can be configured in drizzle.config.ts or passed as CLI options.

Follow-up: What is a practical reason to pass configuration through CLI options? Separate configuration files or CLI arguments can be useful in CI/CD workflows.

QWhere does pull write its generated output?

By default, pull introspects the database schema and writes the generated Drizzle output to the out directory, whose default is ./drizzle. The output directory can be configured.

Follow-up: How can the set of introspected tables be restricted? Configure tablesFilter in the Drizzle Kit configuration.

  • drizzle-kit generate
  • drizzle-kit migrate
  • drizzle-kit push
  • drizzle.config.ts
  • tablesFilter

Source: Drizzle ORM - `pull`. Checked 2026-10-16.