Drizzle Kit configuration file

This guide assumes familiarity with:

Drizzle Kit lets you declare configuration options in TypeScript or JavaScript configuration files.

📦 <project root>
 ├ ...
 ├ 📂 drizzle
 ├ 📂 src
 ├ 📜 drizzle.config.ts
 └ 📜 package.json
drizzle.config.ts
drizzle.config.js
import { defineConfig } from "drizzle-kit";

export default defineConfig({
  dialect: "sqlite",
  schema: "./src/schema.ts",
  out: "./drizzle",
});

Example of an extended config file

import { defineConfig } from "drizzle-kit";

export default defineConfig({
  out: "./drizzle",
  dialect: "sqlite",
  schema: "./src/schema.ts",

  driver: "d1-http",
  dbCredentials: {
    url: "./sqlite.db",
  },

  tablesFilter: "*",

  introspect: {
    casing: "camel",
  },

  migrations: {
    table: "__drizzle_migrations__",
  },

  breakpoints: true,
  verbose: true,
});
Expand

Multiple configuration files

You can have multiple config files in the project, it’s very useful when you have multiple database stages or multiple databases or different databases on the same project:

npm
yarn
pnpm
bun
npx drizzle-kit generate --config=drizzle-dev.config.ts
npx drizzle-kit generate --config=drizzle-prod.config.ts
📦 <project root>
 ├ 📂 drizzle
 ├ 📂 src
 ├ 📜 .env
 ├ 📜 drizzle-dev.config.ts
 ├ 📜 drizzle-prod.config.ts
 ├ 📜 package.json
 └ 📜 tsconfig.json

Migrations folder

out param lets you define folder for your migrations, it’s optional and drizzle by default.
It’s very useful since you can have many separate schemas for different databases in the same project and have different migration folders for them.

Migration folder contains folders with .sql migration files which is used by drizzle-kit

📦 <project root>
 ├ ...
 ├ 📂 drizzle
 │ ├ 📂 20242409125510_premium_mister_fear
 │ ├ 📜 user.ts 
 │ ├ 📜 post.ts 
 │ └ 📜 comment.ts 
 ├ 📂 src
 ├ 📜 drizzle.config.ts
 └ 📜 package.json
import { defineConfig } from "drizzle-kit";

export default defineConfig({
  dialect: "sqlite",
  schema: "./src/schema/*",
  out: "./drizzle",
});

---

dialect

Dialect of the database you’re using

typepostgresql mysql sqlite turso singlestore mssql cockroach
default
commandsgenerate, push, pull, studio, migrate, up, export
import { defineConfig } from "drizzle-kit";

export default defineConfig({
  dialect: "sqlite", 
});

schema

glob based path to drizzle schema file(s) or folder(s) contaning schema files.

typestring string[]
default
commandsgenerate, push, export, studio
Example 1
Example 2
Example 3
Example 4
📦 <project root>
 ├ ...
 ├ 📂 drizzle
 ├ 📂 src
 │ ├ ...
 │ ├ 📜 index.ts
 │ └ 📜 schema.ts 
 ├ 📜 drizzle.config.ts
 └ 📜 package.json
import { defineConfig } from "drizzle-kit";

export default defineConfig({
  schema: "./src/schema.ts",
});

out

Defines output folder of your SQL migration files, json snapshots of your schema and schema.ts from drizzle-kit pull command.

typestring string[]
defaultdrizzle
commandsgenerate, pull, migrate, check, up
import { defineConfig } from "drizzle-kit";

export default defineConfig({
  out: "./drizzle", 
});

driver

Drizzle Kit automatically picks an available SQLite driver from your current project based on dialect: "sqlite". Use driver for SQLite driver exceptions, such as Cloudflare D1 HTTP.

typed1-http
default
commandspush, migrate, pull, studio
import { defineConfig } from "drizzle-kit";

export default defineConfig({
  dialect: "sqlite",
  driver: "d1-http",
  dbCredentials: {
    accountId: "accountId",
    databaseId: "databaseId",
    token: "token",
  },
});

---

dbCredentials

Database connection credentials in a form of url, user:password@host:port/db params or exceptions drivers(aws-data-api d1-http pglite ) specific connection options.

typepostgresql mysql sqlite turso singlestore mssql cockroach
default
commandspush, pull, migrate, studio
SQLite
Turso
Cloudflare D1
import { defineConfig } from 'drizzle-kit'

export default defineConfig({
  dialect: "sqlite",
  dbCredentials: {
    url: ":memory:", // in-memory database
    // or
    url: "sqlite.db", 
    // or
    url: "file:sqlite.db" // file: prefix is required by libsql
  }
});

migrations

When running drizzle-kit migrate - drizzle will records about successfully applied migrations in your database in log table named __drizzle_migrations.

migrations config options lets you change the migrations log table name.

type{ table: string }
default{ table: "__drizzle_migrations" }
commandsmigrate, push, pull
export default defineConfig({
  dialect: "sqlite",
  schema: "./src/schema.ts",
  migrations: {
    table: 'my-migrations-table', // `__drizzle_migrations` by default
  },
});

introspect

Configuration for drizzle-kit pull command.

casing is responsible for in-code column keys casing

type{ casing: "preserve" | "camel" }
default{ casing: "camel" }
commandspull
camel
preserve
import * as p from "drizzle-orm/sqlite-core"

export const users = p.sqliteTable("users", {
  id: p.integer().primaryKey({ autoIncrement: true }),
  firstName: p.text("first-name"),
  lastName: p.text("LastName"),
  email: p.text("email"),
  phoneNumber: p.text("phone_number"),
});
PRAGMA table_info(users);
 column_name   | data_type        
---------------+------------------------
 id            | integer
 first-name    | text
 LastName      | text
 email         | text
 phone_number  | text

---

tablesFilter

If you want to run multiple projects with one database - check out our guide.

drizzle-kit push and drizzle-kit pull will manage all tables by default. You can configure the list of tables via tablesFilter.

tablesFilter option lets you specify glob based table names filter, e.g. ["users", "user_info"] or "user*"

typestring string[]
default
commandspush pull
import { defineConfig } from "drizzle-kit";

export default defineConfig({
  dialect: "sqlite",
  tablesFilter: ["users", "posts", "project1_*"],
});

---

verbose

Print all SQL statements during drizzle-kit push command.

typeboolean
defaultfalse
commandspull
export default defineConfig({
  dialect: "sqlite",
  verbose: false,
});

breakpoints

Drizzle Kit will automatically embed --> statement-breakpoint into generated SQL migration files, that’s necessary for databases that do not support multiple DDL alternation statements in one transaction(MySQL and SQLite).

breakpoints option flag lets you switch it on and off

typeboolean
defaulttrue
commandsgenerate pull
export default defineConfig({
  dialect: "sqlite",
  breakpoints: false,
});