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 1 of 3.

entities.roles provider option for Supabase

To exclude roles defined by Supabase and let Drizzle Kit skip them automatically, set entities.roles: { provider: 'supabase' }

entities.roles combining provider and exclude options

You can combine provider option with exclude option to handle both provider-specific roles and additional custom roles to exclude: entities: { roles: { provider: 'supabase', exclude: ['new_supabase_role'] } }

entities.roles enable role management

To enable role management in Drizzle Kit, set entities.roles to true in drizzle.config.ts: entities: { roles: true }

dialect option in drizzle-kit config

The dialect option specifies the database type. Type is string. Default is none (required). Supported commands: generate, push, pull, studio, migrate, up, export.

entities.roles exclude specific roles

To exclude specific roles from Drizzle Kit management, use entities.roles: { exclude: ['admin'] } where the exclude array lists role names to skip.

migrations folder structure and SQL files

The migrations folder specified by the out parameter contains subdirectories with timestamp-prefixed names (e.g., 20242409125510_premium_mister_fear) that hold .sql migration files generated by drizzle-kit.

entities.roles provider option for Neon

To exclude roles defined by Neon and let Drizzle Kit skip them automatically, set entities.roles: { provider: 'neon' }

defineConfig basic CockroachDB example

A minimal drizzle.config.ts for CockroachDB with defineConfig includes three required properties: dialect set to "cockroach", schema pointing to the schema file path (e.g. "./src/schema.ts"), and out specifying the migrations output directory (e.g. "./drizzle").

entities.roles include specific roles

To explicitly include specific roles for Drizzle Kit management, use entities.roles: { include: ['admin'] } where the include array lists role names to manage.

schema option glob pattern support

The schema option in drizzle-kit config supports glob patterns, allowing paths like "./src/schema/*" to include all schema files in a directory.

introspect casing camel option behavior

When introspect.casing is set to "camel", column names in the generated schema are converted to camelCase. For example, a database column named "first_name" becomes firstName in the TypeScript schema definition.

introspect casing preserve option behavior

When introspect.casing is set to "preserve", column names in the generated schema match exactly as they exist in the database. For example, a database column named "first_name" remains "first_name" in the TypeScript schema definition.

CockroachDB dbCredentials connection parameters format

For CockroachDB, dbCredentials can use individual parameters: dbCredentials: { host: "host", port: 26257, user: "user", password: "password", database: "dbname", ssl: true }. The ssl parameter can be a boolean or one of: "require", "allow", "prefer", "verify-full", or options from node:tls.

CockroachDB dbCredentials connection string format

For CockroachDB, dbCredentials can use a connection string: dbCredentials: { url: "postgres://user:password@host:port/db" }

Drizzle Kit minimal config

A minimal drizzle.config.ts configuration requires: dialect set to 'cockroach' and schema path set to the location of your schema file (e.g., './src/schema.ts').

Drizzle Kit extended config properties

Extended drizzle.config.ts configuration can include: out (output directory for migrations), entities (with exclude/include/provider options), dbCredentials (url for database connection), schemaFilter, tablesFilter, introspect (with casing option), migrations (table name and schema), breakpoints, and verbose.

drizzle.config.ts configuration for schema location

In drizzle.config.ts, use the schema property to point Drizzle-Kit to your schema. For a single file: export default defineConfig({ dialect: 'cockroach', schema: './src/db/schema.ts' }). For a schema folder: export default defineConfig({ dialect: 'cockroach', schema: './src/db/schema' }). Drizzle-Kit uses this path during migration generation.

dbCredentials config option for Cloudflare D1

For Cloudflare D1, use dialect "sqlite" with driver "d1-http" and dbCredentials containing: accountId (string), databaseId (string), token (string). No default. Used by commands: push, pull, migrate, studio.

dbCredentials config option for Turso

For Turso, dbCredentials accepts url ("libsql://acme.turso.io" for remote, ":memory:" or "file:sqlite.db" for local) and authToken (string). No default. Used by commands: push, pull, migrate, studio.

dbCredentials config option for PostgreSQL

For PostgreSQL, dbCredentials accepts either a url string in format "postgres://user:password@host:port/db" or individual connection parameters: host (string), port (number, 5432), user (string), password (string), database (string), ssl (boolean | "require" | "allow" | "prefer" | "verify-full" | options from node:tls). No default. Used by commands: push, pull, migrate, studio.

driver config option

The driver option lets you explicitly pick database driver exceptions. Some vendor-specific databases require different connection parameters than what Drizzle Kit automatically detects. Type: varies by database. No default value. Used by commands: push, migrate, pull, studio.

dialect config option

The dialect option specifies the database dialect being used. It is required and has no default value. It is used by commands: generate, push, pull, studio, migrate, up, export.

entities roles Neon provider example

export default defineConfig({ dialect: "postgresql", entities: { roles: { provider: 'neon' } } });

entities roles combined provider and exclude example

export default defineConfig({ dialect: "postgresql", entities: { roles: { provider: 'supabase', exclude: ['new_supabase_role'] } } });

dbCredentials config option for SQLite

For SQLite, dbCredentials accepts a url string: ":memory:" for in-memory database, "sqlite.db" for file-based, or "file:sqlite.db" (file: prefix required by libsql). No default. Used by commands: push, pull, migrate, studio.

migrations folder default location

The out parameter defines the folder for migrations. It defaults to 'drizzle' if not specified. The migrations folder contains subdirectories with timestamped names (e.g., 20242409125510_premium_mister_fear) that hold .sql migration files generated by drizzle-kit.

entities roles include example

export default defineConfig({ dialect: "postgresql", entities: { roles: { include: ['admin'] } } });

entities config option for roles

The entities.roles option configures role management in Drizzle Kit. Type: boolean | { provider: "neon" | "supabase", include: string[], exclude: string[] }. Default: false. Used by commands: push, pull, generate. When enabled, allows including/excluding specific roles and specifying provider modes for Neon and Supabase.

dbCredentials config option for AWS Data API

For AWS Data API, use dialect "postgresql" with driver "aws-data-api" and dbCredentials containing: database (string), resourceArn (string), secretArn (string). No default. Used by commands: push, pull, migrate, studio.

dbCredentials config option for PGLite

For PGLite, use dialect "postgresql" with driver "pglite" and dbCredentials containing url (string pointing to database folder path, e.g., "./database/"). No default. Used by commands: push, pull, migrate, studio.

extensionsFilters config option

The extensionsFilters option declares list of installed database extensions (e.g., "postgis") that drizzle-kit should ignore their tables during push or pull operations. Type: string array. Default: []. Used by commands: push, pull.

D1 Drizzle config file setup

The drizzle.config.ts file for D1 must include: dialect set to 'sqlite', driver set to 'd1-http', out pointing to the migrations directory (typically './drizzle'), schema pointing to the schema file (typically './src/db/schema.ts'), and dbCredentials containing accountId, databaseId, and token from Cloudflare environment variables.

Drizzle config for Cloudflare Durable Objects SQLite

To set up Drizzle for Cloudflare Durable Objects, create a drizzle.config.ts file with dialect set to 'sqlite' and driver set to 'durable-sqlite'. Example: export default defineConfig({ out: './drizzle', schema: './src/db/schema.ts', dialect: 'sqlite', driver: 'durable-sqlite' });

wrangler.toml configuration for Durable Objects with Drizzle

The wrangler.toml file for Cloudflare Durable Objects with Drizzle requires: a name field, main entry point, compatibility_date (e.g., '2024-11-12'), and compatibility_flags including 'nodejs_compat'. Include [[durable_objects.bindings]] section with a name (e.g., 'MY_DURABLE_OBJECT') and class_name. Include [[migrations]] section with a tag (e.g., 'v1') and new_sqlite_classes array listing the Durable Object classes. Include [[rules]] section with type 'Text' and globs pattern '**/*.sql' with fallthrough true to allow importing migration files.

Drizzle config file for Durable Objects with durable-sqlite driver

Create drizzle.config.ts with: dialect set to 'sqlite', driver set to 'durable-sqlite', schema pointing to schema file (e.g., './src/db/schema.ts'), and out pointing to migrations folder (e.g., './drizzle'). Import and use defineConfig from 'drizzle-kit'.

Gel dialect in Drizzle config

To configure Drizzle ORM for Gel database, create a drizzle.config.ts file with dialect set to 'gel'. Example: export default defineConfig({ dialect: 'gel' });

Drizzle config file dialect for Neon is postgresql

When setting up the Drizzle config file for use with Neon, specify the dialect as 'postgresql'.

Drizzle config for Gel dialect

The drizzle.config.ts file for Gel uses dialect: 'gel'. Example: import { defineConfig } from 'drizzle-kit'; export default defineConfig({ dialect: 'gel' });

Drizzle config dialect for Node:SQLite

When setting up the Drizzle config file for Node:SQLite, use 'sqlite' as the dialect value.

Nile drizzle.config setup dialect

When setting up the Drizzle config file for Nile, use 'postgresql' as the dialect and reference the NILEDB_URL environment variable.

PGlite config dialect setting

When setting up the Drizzle config file for PGlite, use 'postgresql' as the dialect.

Drizzle config for PostgreSQL

Create a Drizzle config file with the dialect set to 'postgresql' and reference the DATABASE_URL environment variable for the connection URL.

Supabase drizzle config dialect

When setting up the Drizzle config file for Supabase, use 'postgresql' as the dialect specification.

TiDB Drizzle config dialect

When setting up the Drizzle config file for TiDB, use 'mysql' as the dialect since TiDB is MySQL-compatible.

TiDB setup step 3 drizzle config

The third step is to setup the Drizzle config file with mysql dialect and DATABASE_URL environment variable.

Turso database environment configuration

Configure Drizzle ORM for Turso by setting up a drizzle.config.ts file with dialect set to 'sqlite' and referencing an environment variable for the database file name.

Turso Database drizzle.config.ts dialect

When setting up drizzle.config.ts for Turso Database, use 'sqlite' as the dialect.

drizzle.config.ts structure for Turso

import 'dotenv/config'; import { defineConfig } from 'drizzle-kit'; export default defineConfig({ out: './drizzle', schema: './src/db/schema.ts', dialect: 'turso', dbCredentials: { url: process.env.TURSO_DATABASE_URL, authToken: process.env.TURSO_AUTH_TOKEN, }, });

OP-SQLite Drizzle config for Expo

For OP-SQLite with Expo, create a drizzle.config.ts file with: dialect set to 'sqlite', driver set to 'expo', schema pointing to './db/schema.ts', and out pointing to './drizzle' for migrations.

Drizzle config for Xata PostgreSQL

When setting up Drizzle config file for Xata, use 'postgresql' as the dialect and 'DATABASE_URL' as the environment variable reference.

Example drizzle.config.ts for Cloudflare D1 HTTP

```ts import { defineConfig } from 'drizzle-kit'; export default defineConfig({ schema: './src/schema.ts', out: './migrations', dialect: 'sqlite', driver: 'd1-http', dbCredentials: { accountId: process.env.CLOUDFLARE_ACCOUNT_ID!, databaseId: process.env.CLOUDFLARE_DATABASE_ID!, token: process.env.CLOUDFLARE_D1_TOKEN!, }, }); ``` This example shows the complete configuration for using Drizzle Kit with Cloudflare D1 via HTTP API.

D1 HTTP driver configuration in drizzle.config.ts

To configure Drizzle Kit with Cloudflare D1 HTTP API, set dialect to 'sqlite' and driver to 'd1-http'. The dbCredentials object must include three properties: accountId (from Cloudflare Workers & Pages Overview), databaseId (from the D1 database page), and token (created in My profile > API Tokens with D1 edit permissions). All three credentials should be passed as environment variables for security.

Getting Cloudflare D1 credentials for Drizzle Kit

accountId can be found in the Cloudflare dashboard under Workers & Pages > Overview in the right sidebar. databaseId is found by opening the D1 database and copying the Database ID field. token should be created in My profile > API Tokens with D1 edit permissions.

Drizzle config for Gel auth schema

In drizzle.config.ts, configure Drizzle Kit for Gel auth by setting dialect to 'gel' and including schemaFilter: ['ext::auth', 'public'] to enable the auth schema for drizzle-kit.

dialect configuration option

The dialect option specifies which database you are using. For MSSQL, set dialect to 'mssql'. This is a required configuration option used by commands: generate, push, pull, studio, migrate, up, export.

schemaFilter configuration option

The schemaFilter option uses glob-based patterns to filter which schemas drizzle-kit push and drizzle-kit pull will manage. It accepts type string[], for example ['dbo', 'auth'] or glob pattern 'tenant_*'. Default is unspecified (all schemas). Used by commands: push, pull.

verbose configuration option

The verbose option is a boolean that enables printing all SQL statements during drizzle-kit push command. Default value is false. Used by command: pull.

dbCredentials configuration option for MSSQL

The dbCredentials option contains database connection credentials. For MSSQL, it can be specified as either a connection string using 'url' property (e.g., 'mssql://user:password@host:3306/db'), or as connection parameters with properties: database (string), password (string), port (number), server (string), user (string), and options object containing encrypt (boolean) and trustServerCertificate (boolean). This option is used by commands: push, pull, migrate, studio.

migrations configuration option

The migrations option configures the migrations log table name and schema used by drizzle-kit migrate. It is an object with two properties: table (string, default '__drizzle_migrations') and schema (string, default 'drizzle'). Used by commands: migrate, push, pull.

migrations folder structure in drizzle-kit

The migrations folder (specified by the 'out' parameter) contains subdirectories with migration names (e.g., 20242409125510_premium_mister_fear) that hold .sql migration files used by drizzle-kit. The out parameter is optional and defaults to 'drizzle'. Having multiple migration folders is useful when you have separate schemas for different databases in the same project.

Give your agent this brain