new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Drizzle ORM · all subjects

drizzle-kit/config

129 notes in this subject, read out of this brain and free to use. This is page 2 of 3.

extended drizzle-kit configuration example for MSSQL

import { defineConfig } from 'drizzle-kit'; export default defineConfig({ out: './drizzle', dialect: 'mssql', schema: './src/schema.ts', dbCredentials: { url: 'mssql://user:password@host:3306/dbname', }, schemaFilter: 'dbo', tablesFilter: '*', introspect: { casing: 'camel', }, migrations: { table: '__drizzle_migrations__', schema: 'drizzle', }, breakpoints: true, verbose: true, });

introspect casing camel example

When introspect.casing is set to 'camel', column names from the database are converted to camelCase in the generated schema. For example, database columns 'first-name', 'LastName', and 'phone_number' become TypeScript properties firstName, lastName, and phoneNumber in the schema.

introspect casing preserve example

When introspect.casing is set to 'preserve', column names from the database are preserved exactly as they are in the generated schema. For example, database columns 'first-name', 'LastName', and 'phone_number' remain with those exact names (using string keys for non-identifier characters) in the TypeScript schema.

tablesFilter in drizzle-kit config for multi-project schema

When using multi-project schema with mssqlTableCreator, add tablesFilter: ['project1_*'] to the drizzle-kit config to ensure migrations only reference tables with the specified prefix.

Multiple Drizzle Kit configs for different database stages

You can provide different Drizzle Kit config files via CLI parameter for different database stages or databases. Example: drizzle-kit push --config=drizzle-dev.config and drizzle-kit push --config=drizzle-prod.config allow you to use different configurations for development and production databases on the same project.

Simple Drizzle Kit config for MSSQL

A minimal drizzle.config.ts for MSSQL requires two properties: dialect set to 'mssql' and schema set to the path to your schema file. Example: import { defineConfig } from 'drizzle-kit'; export default defineConfig({ dialect: 'mssql', schema: './src/schema.ts', });

Extended Drizzle Kit config for MSSQL

An extended drizzle.config.ts for MSSQL can include: out (output directory for migrations), dialect ('mssql'), schema (path to schema file), dbCredentials with url property, schemaFilter (filter schemas by name), tablesFilter (filter tables by pattern), introspect with casing option ('camel'), migrations object with table and schema properties, and boolean flags for breakpoints and verbose output.

Drizzle Kit configuration file

Create drizzle.config.ts at the project root. Use defineConfig() from 'drizzle-kit'. The config must specify dialect (e.g., 'postgresql'), schema path (e.g., './src/schema.ts'), and out directory (e.g., './drizzle').

driver config option for SingleStore

Drizzle Kit automatically picks an available SingleStore driver from the current project based on dialect: 'singlestore'. SingleStore uses MySQL-compatible connection parameters, so a separate driver option is typically not needed. Type: none (auto-detected). Commands: migrate, push, pull.

dbCredentials config option

Database connection credentials can be provided as either a connection URL string or individual connection parameters. Type: union of driver-specific connection options. Default: none (required for migrate, push, pull commands). For SingleStore with URL: dbCredentials: { url: 'mysql://user:password@host:3306/db' }. For SingleStore with params: dbCredentials: { host, port (3306), user, password, database, ssl (optional, can be string or SslOptions from mysql2) }.

introspect.casing config option

The introspect.casing option controls how column names are converted when using 'drizzle-kit pull'. Type: 'preserve' | 'camel'. Default: 'camel'. Commands: pull. Set to 'camel' to convert database column names to camelCase in the generated schema (e.g., 'first_name' becomes 'firstName'). Set to 'preserve' to keep the original column name casing.

tablesFilter config option

The tablesFilter option uses glob-based patterns to specify which tables are managed by 'drizzle-kit push' and 'drizzle-kit pull'. By default, all tables are managed. Type: string or string[]. Default: none (all tables). Commands: generate, push, pull. Example: tablesFilter: ['users', 'posts', 'project1_*'].

strict config option

The strict option prompts for confirmation before executing SQL statements when running 'drizzle-kit push'. Type: boolean. Default: false. Commands: push.

verbose config option

The verbose option controls whether all SQL statements are printed during command execution. Type: boolean. Default: true. Commands: generate, pull. Set to false to suppress SQL statement output.

Migration folder structure with drizzle-kit

The migration folder (specified by the 'out' option) contains subdirectories for each migration with generated names like '20242409125510_premium_mister_fear', each containing .sql migration files. The folder also contains schema files like user.ts, post.ts, and comment.ts.

Extended drizzle.config.ts example for SingleStore

import { defineConfig } from 'drizzle-kit'; export default defineConfig({ out: './drizzle', dialect: 'singlestore', schema: './src/schema.ts', dbCredentials: { url: 'mysql://user:password@host:3306/dbname', }, introspect: { casing: 'camel', }, migrations: { prefix: 'timestamp', table: '__drizzle_migrations__', }, breakpoints: true, strict: true, verbose: true, });

Drizzle Kit config file location and structure

The drizzle-kit configuration file is named drizzle.config.ts or drizzle.config.js and is placed in the project root directory. It uses the defineConfig function exported from 'drizzle-kit'.

Basic drizzle.config.ts for SingleStore

A minimal SingleStore configuration requires three properties: dialect set to 'singlestore', schema pointing to the schema file path (e.g., './src/schema.ts'), and out pointing to the migrations folder (defaults to './drizzle').

dialect config option

The dialect option specifies which database you are using. Type: string. Default: none (required). Commands: generate, migrate, push, pull, check, up. For SingleStore, use dialect: 'singlestore'. Other supported dialects include: mysql, sqlite, postgresql, turso, and mssql.

schema config option

The schema option specifies glob-based paths to drizzle schema file(s) or folder(s). Type: string or string[]. Default: none (required). Commands: generate, push. Example: './src/schema.ts' or './src/schema/*'.

tablesFilter in drizzle-kit config for multi-project schemas

In drizzle.config.ts, use the tablesFilter option to filter tables by pattern: tablesFilter: ['project1_*']. Multiple filters can be applied with OR logic: tablesFilter: ['project1_*', 'project2_*'].

Drizzle Kit configuration file required parameters

Drizzle Kit is configured through drizzle.config.ts configuration file or via CLI params. At minimum, you must provide the SQL dialect and schema path for Drizzle Kit to know how to generate migrations.

Simple Drizzle Kit config example

A minimal drizzle.config.ts configuration requires importing defineConfig from drizzle-kit and exporting a config object with dialect and schema properties: dialect: "singlestore" and schema: "./src/schema.ts".

Extended Drizzle Kit configuration options

Extended drizzle.config.ts configuration can include: out (output directory for migrations, e.g., "./drizzle"), dialect (database type, e.g., "singlestore"), schema (path to schema file, e.g., "./src/schema.ts"), driver (database driver, e.g., "pglite"), dbCredentials (database connection details), extensionsFilters (array of extensions to filter, e.g., ["postgis"]), schemaFilter (schema to filter, e.g., "public"), tablesFilter (tables filter pattern, e.g., "*"), introspect object with casing property (e.g., { casing: "camel" }), migrations object with prefix, table, and schema properties (e.g., { prefix: "timestamp", table: "__drizzle_migrations__", schema: "public" }), breakpoints (boolean), strict (boolean), and verbose (boolean).

Drizzle Kit config path via CLI parameter

You can provide Drizzle Kit config path via CLI parameter using --config flag, which is useful when you have multiple database stages, multiple databases, or different databases in the same project. Example: drizzle-kit push --config=drizzle-dev.drizzle.config or drizzle-kit push --config=drizzle-prod.drizzle.config.

Drizzle config file structure for Neon

Create a drizzle.config.ts file in the project root with the following structure: import { config } from 'dotenv'; import { defineConfig } from "drizzle-kit"; config({ path: '.env' }); export default defineConfig({ schema: "./src/db/schema.ts", out: "./migrations", dialect: "postgresql", dbCredentials: { url: process.env.DATABASE_URL! } });

Drizzle config for Encore projects

Create a drizzle.config.ts file using defineConfig from drizzle-kit. Set out to "migrations", schema to "schema.ts", and dialect to "postgresql".

Drizzle config setup for Neon Postgres

Create a drizzle.config.ts file with defineConfig(). Set dialect to 'postgresql', schema path to './src/schema.ts', out path to './migrations', and dbCredentials with url set to process.env.DATABASE_URL.

Setup Drizzle config file for Netlify Edge Functions

Create a drizzle.config.ts file in the root of your project with the following content: import 'dotenv/config'; import type { Config } from "drizzle-kit"; export default { schema: './netlify/edge-functions/common/schema.ts', out: './drizzle', dialect: 'postgresql', dbCredentials: { url: process.env.DATABASE_URL!, }, } satisfies Config; Remove the dotenv/config import if using Node.js v20.6.0 or later.

Drizzle config file for Netlify Edge Functions with Supabase

Create drizzle.config.ts in the root of your project. Set schema to the path of your schema file, out to the migrations folder, dialect to 'postgresql', and dbCredentials.url to the DATABASE_URL environment variable.

Drizzle config file for Supabase Edge Functions

Create a drizzle.config.ts file in the project root with schema path pointing to src/schema.ts, output directory set to supabase/migrations, and dialect set to postgresql. This config is used by Drizzle Kit to generate migrations.

Example drizzle.config.ts for Supabase

import { defineConfig } from "drizzle-kit"; export default defineConfig({ schema: "./src/schema.ts", out: "./supabase/migrations", dialect: "postgresql", });

Drizzle config file for Supabase

Create drizzle.config.ts in project root. Import config from dotenv and defineConfig from drizzle-kit. Call config() with path to .env file. Export defineConfig with: schema set to './src/db/schema.ts', out set to './supabase/migrations', dialect set to 'postgresql', dbCredentials object containing url set to process.env.DATABASE_URL.

Turso drizzle-kit config file

Set up a `drizzle.config.ts` file with `dialect: 'turso'`, specify the schema file path, migrations output directory, and database credentials including `url` and `authToken` from environment variables.

Drizzle config for Vercel Postgres

Create a drizzle.config.ts file in the root of your project with the following configuration: import { config } from 'dotenv'; import { defineConfig } from 'drizzle-kit'; config({ path: '.env.local' }); export default defineConfig({ schema: './src/db/schema.ts', out: './migrations', dialect: 'postgresql', dbCredentials: { url: process.env.POSTGRES_URL! } });

drizzle.config.ts configuration file structure

The drizzle config file must contain schema (path to schema file), out (migrations directory), dialect (database type like "postgresql"), and dbCredentials with url (the DATABASE_URL environment variable). Example: export default defineConfig({ schema: "./src/schema.ts", out: "./migrations", dialect: "postgresql", dbCredentials: { url: process.env.DATABASE_URL! } });

drizzle.config.ts dialect parameter is mandatory

The dialect parameter in drizzle.config.ts is now mandatory in version 0.21.0. The allowed values are 'postgresql', 'mysql', or 'sqlite'. This parameter specifies which database dialect you are connecting to.

drizzle.config.ts driver parameter is optional

The driver parameter in drizzle.config.ts is now optional and should only be included if you are using special drivers: 'aws-data-api', 'turso', 'd1-http' (currently work in progress), or 'expo'. For standard database connections, the driver parameter can be removed.

drizzle.config.ts url parameter replaces connectionString and uri

In drizzle.config.ts, the unified parameter 'url' now replaces the previously separate 'connectionString' and 'uri' parameters in dbCredentials. If you were using connectionString or uri, update them to use url instead.

drizzle.config.ts migrations parameter for custom table and schema

A new migrations parameter has been added to drizzle.config.ts to specify custom table and schema for the migrate command. The migrations object contains two properties: 'table' (the custom table where drizzle will store migrations) and 'schema' (the custom schema where drizzle will store migrations, PostgreSQL only).

PostgreSQL driver fallback order in drizzle-kit 0.21.0

For PostgreSQL dialect without an explicit driver specified, drizzle-kit checks drivers in this order: 'pg', then 'postgres', then '@vercel/postgres', then '@neondatabase/serverless'. If none are found, an error is thrown.

MySQL driver fallback order in drizzle-kit 0.21.0

For MySQL dialect without an explicit driver specified, drizzle-kit checks drivers in this order: 'mysql2', then '@planetscale/database'. If neither is found, an error is thrown.

SQLite driver fallback order in drizzle-kit 0.21.0

For SQLite dialect without an explicit driver specified, drizzle-kit checks drivers in this order: '@libsql/client', then 'better-sqlite3'. If neither is found, an error is thrown.

Example drizzle.config.ts 0.21.0 configuration

Example configuration for drizzle.config.ts in version 0.21.0: ```ts import { defineConfig } from "drizzle-kit" export default defineConfig({ dialect: "sqlite", // "postgresql" | "mysql" driver: "turso", // optional and used only if `aws-data-api`, `turso`, `d1-http`(WIP) or `expo` are used dbCredentials: { url: "" }, migrations: { table: "migrations", schema: "public" } }) ```

Configure drizzle.config.ts schema path for single file

In drizzle.config.ts, specify the path to a single schema file: export default defineConfig({ dialect: 'singlestore', schema: './src/db/schema.ts' }). The schema file can be named anything (e.g., schema.ts, models.ts).

Configure drizzle.config.ts schema path for multiple files

In drizzle.config.ts, specify a folder path to recursively find all schema files: export default defineConfig({ dialect: 'singlestore', schema: './src/db/schema' }). Drizzle will read all files in the folder and subdirectories to find drizzle tables.

Drizzle config file for Nile Database

Create a drizzle.config.ts file at the root of the project with: out: './drizzle' (migration folder), schema: './src/db/schema.ts' (schema file location), dialect: 'postgresql', and dbCredentials with url: process.env.NILEDB_URL.

Turso Drizzle config

For Turso, create drizzle.config.ts with: schema pointing to ./src/db/schema.ts, dialect set to 'turso', and dbCredentials containing url set to process.env.TURSO_CONNECTION_URL and authToken set to process.env.TURSO_AUTH_TOKEN. The connection URL format is: libsql://[db-name].turso.io

PlanetScale Drizzle config

For PlanetScale, create drizzle.config.ts with: schema pointing to ./src/db/schema.ts, dialect set to 'mysql', and dbCredentials.url set to process.env.MYSQL_URL. The connection string format is: mysql://[user]:[pa••••••d]@[host].[region].psdb.cloud/[db-name]?ssl={'rejectUnauthorized':[ssl-rejectUnauthorized]}

Neon serverless Drizzle config

For Neon serverless, create drizzle.config.ts with: schema pointing to ./src/db/schema.ts, dialect set to 'postgresql', and dbCredentials.url set to process.env.POSTGRES_URL. The connection string format is: postgres://[user]:[pa••••••d]@[host]-[region].aws.neon.tech:5432/[db-name]?sslmode=[ssl-mode]

Drizzle config for Xata PostgreSQL

Create a drizzle.config.ts file with dialect set to 'postgresql', schema path pointing to your schema file, out path for migrations directory, and dbCredentials containing the DATABASE_URL from your Xata database. Example: import { config } from 'dotenv'; import { defineConfig } from 'drizzle-kit'; config({ path: '.env' }); export default defineConfig({ schema: './src/db/schema.ts', out: './migrations', dialect: 'postgresql', dbCredentials: { url: process.env.DATABASE_URL! } });

Expo SQLite drizzle.config.ts configuration

Create drizzle.config.ts in the project root folder with schema pointing to the schema file, out pointing to the output directory (typically './drizzle'), dialect set to 'sqlite', and driver set to 'expo'.

drizzle-kit extensionsFilters configuration

Drizzle Kit v0.22.0 adds a new `extensionsFilters` parameter in drizzle.config to skip internal tables created by database extensions. Currently supports the 'postgis' option which skips the geography_columns, geometry_columns, and spatial_ref_sys tables. Usage: defineConfig({ dialect: 'postgresql', extensionsFilters: ['postgis'] }). This prevents extension-created tables from being included in push or introspect diff operations.

drizzle-kit config prefix example for Supabase

Example configuration for Supabase migrations format: import { defineConfig } from 'drizzle-kit'; export default defineConfig({ dialect: 'postgresql', migrations: { prefix: 'supabase' } });

schemaFilter behavior update in drizzle-kit

In Drizzle v1.0.0-beta.2, drizzle-kit now manages all schemas defined in your code by default. To filter schemas, use the `schemaFilter` option. The `schemaFilter` option now supports glob patterns, allowing you to filter schemas in any way you like. Previously, only the public schema was managed unless explicitly added to `schemaFilter`.

dbCredentials config property for drizzle-kit

The dbCredentials property contains database connection credentials. Type: object (dialect-specific). Default: required (no default). Commands: push, pull, migrate, studio. Can be specified as either a connection string URL (e.g., 'mysql://user:password@host:port/db') or individual connection parameters (host, port, user, password, database, ssl).

MySQL dbCredentials connection string format

For MySQL, the dbCredentials can use a URL property with the format: 'mysql://user:password@host:port/db'.

MySQL dbCredentials connection parameters

For MySQL, the dbCredentials can specify individual connection parameters: host (string), port (number, default 3306), user (string), password (string), database (string), and ssl (string or SslOptions from mysql2).

drizzle.config.ts file location and structure

The drizzle.config.ts or drizzle.config.js file should be placed in the project root directory alongside package.json. It is used to declare configuration options for Drizzle Kit in TypeScript or JavaScript.

defineConfig function for drizzle-kit config

Use the defineConfig function exported from 'drizzle-kit' to create a Drizzle Kit configuration object. The function is called with an object containing configuration properties.

Give your agent this brain