dbCredentials for PostgreSQL URL connection
The dbCredentials option accepts a url property with format "postgres://user:password@host:port/db" for URL-based PostgreSQL connections. Type is string. This is used by commands: push, pull, migrate, and studio.
dbCredentials for PostgreSQL connection parameters
The dbCredentials option accepts individual connection parameters as an alternative to URL: host (string), port (number, default 5432), user (string), password (string), database (string), and ssl (boolean or string). The ssl property can be boolean, "require", "allow", "prefer", "verify-full", or options from node:tls. Used by commands: push, pull, migrate, and studio.
migrations configuration option
The migrations option is an object with two properties: table (string) and schema (string). It specifies where drizzle-kit records successfully applied migrations. Default is { table: "__drizzle_migrations", schema: "drizzle" }. Used by commands: migrate, push, and pull.
introspect configuration option
The introspect option configures drizzle-kit pull command behavior. It accepts { casing: "preserve" | "camel" } to control in-code column key casing. Default value is { casing: "camel" }. Used only by the pull command.
introspect camel casing example
When introspect.casing is set to "camel", database columns like "first-name" and "phone_number" are converted to camelCase keys in the generated TypeScript schema: firstName and phoneNumber respectively. Column names in the database remain unchanged.
introspect preserve casing example
When introspect.casing is set to "preserve", database column names are kept exactly as they are in the TypeScript schema keys. Column "first-name" becomes key "first-name", and "phone_number" becomes key "phone_number".
tablesFilter configuration option
The tablesFilter option uses glob-based patterns to specify which tables drizzle-kit push and pull will manage. Accepts string or string[] such as ["users", "posts"] or "user*". No default value. Used by commands: push and pull.
schemaFilter configuration option
The schemaFilter option uses glob-based patterns to specify which schemas drizzle-kit push and pull will manage. Accepts string[] such as ["public", "auth"] or ["tenant_*"]. No default value. Used by commands: push and pull.
extensionsFilters configuration option
The extensionsFilters option accepts an array of extension names like ["postgis"] that should be ignored by drizzle-kit push and pull. Extensions like PostGIS create their own tables that should not be managed by Drizzle. Default value is []. Used by commands: push and pull.
entities.roles configuration option
The entities.roles option controls role management in Drizzle Kit. Type is boolean or { provider: "neon" | "supabase", include: string[], exclude: string[] }. Default value is false (roles not managed). Used by commands: push and pull. When true, all roles are managed. Set to false to skip role management.
entities.roles exclude option
The entities.roles.exclude property accepts an array of role names to exclude from Drizzle Kit management. For example, { roles: { exclude: ['admin'] } } prevents the 'admin' role from being managed.
entities.roles include option
The entities.roles.include property accepts an array of role names to explicitly include for Drizzle Kit management. For example, { roles: { include: ['admin'] } } enables management of the 'admin' role.
entities.roles provider option for Neon
Set entities.roles.provider to "neon" to automatically exclude roles defined by Neon cloud platform from Drizzle Kit management. Example: { roles: { provider: 'neon' } }.
entities.roles provider option for Supabase
Set entities.roles.provider to "supabase" to automatically exclude roles defined by Supabase from Drizzle Kit management. Example: { roles: { provider: 'supabase' } }.
entities.roles combined provider and exclude
The entities.roles option supports combining provider and exclude options. For example, { roles: { provider: 'supabase', exclude: ['new_supabase_role'] } } excludes both Supabase-defined roles and the specified new role from management.
verbose configuration option
The verbose option is a boolean that prints all SQL statements during drizzle-kit push command. Default value is false. Used only by the pull command.
breakpoints configuration option
The breakpoints option is a boolean that controls whether Drizzle Kit embeds "--> statement-breakpoint" into generated SQL migration files. This is necessary for databases that do not support multiple DDL statements in one transaction. Default value is true. Used by commands: generate and pull.
schema glob pattern with wildcard
The schema option supports glob patterns. For example, schema: "./src/schema/*" will match all files in the schema directory. This allows organizing schema definitions across multiple files.
node-postgres and postgres.js native support
Drizzle has native support for PostgreSQL connections with the node-postgres and postgres.js drivers.
pg-native boosts node-postgres speed
With node-postgres, you can install pg-native to boost the speed of both node-postgres and Drizzle by approximately 10%.
node-postgres per-query type parsers
node-postgres supports providing type parsers on a per-query basis without globally patching things.
postgres.js prepared statements default behavior
postgres.js uses prepared statements by default, which you may need to opt out of. This could be a potential issue in AWS environments.
node-postgres with existing Pool
To use an existing node-postgres Pool: import { drizzle } from 'drizzle-orm/node-postgres' and import { Pool } from 'pg', then pass it as const db = drizzle({ client: pool });
Install postgres.js with Drizzle
To use postgres.js, install drizzle-orm@rc and postgres as production dependencies, and drizzle-kit@rc as a dev dependency.
Initialize postgres.js with connection string
Import drizzle from 'drizzle-orm/postgres-js' and initialize with process.env.DATABASE_URL: const db = drizzle(process.env.DATABASE_URL);
postgres.js with configuration options
Import drizzle from 'drizzle-orm/postgres-js' and pass a connection object with postgres.js properties: const db = drizzle({ connection: { url: process.env.DATABASE_URL, ssl: true } });
postgres.js with existing client
To use an existing postgres.js client: import { drizzle } from 'drizzle-orm/postgres-js' and import postgres from 'postgres', then pass it as const db = drizzle({ client: queryClient });
Relational Queries v2: drizzle() configuration no longer requires mode
In v2, the drizzle() initialization no longer requires a 'mode' parameter for MySQL dialects. The configuration now only requires the relations option: drizzle(process.env.DATABASE_URL, { relations }).
Migrating from v1 to v2: update drizzle() configuration
When migrating, change the drizzle() call from: drizzle(url, { schema }) to: drizzle(url, { relations }). The relations option should be imported from your relations file that was created or migrated in Step 2.
Relational Queries v2: generic argument changes for internal types
The drizzle database instance, session, migrator, and transaction classes were updated with TRelations generic argument instead of TSchema. For example: NodePgDatabase<TRelations extends AnyRelations> instead of NodePgDatabase<TSchema extends Record<string, unknown>>.
Relational Queries v2: DrizzleConfig interface changes
The DrizzleConfig interface now takes TRelationConfigs extends AnyRelations as a generic and includes a relations?: TRelationConfigs field. The schema field was removed. It also added cache?: Cache and jit?: boolean fields.
PlanetScale Postgres connection methods
Drizzle can connect to PlanetScale Postgres using the standard node-postgres driver or the @neondatabase/serverless driver for serverless environments.
node-postgres installation for PlanetScale
Install drizzle-orm@rc, pg, and dev dependencies drizzle-kit@rc and @types/pg.
node-postgres connection with config object
Import drizzle from 'drizzle-orm/node-postgres', initialize with drizzle({ connection: { connectionString: process.env.DATABASE_URL, ssl: true } }), and execute queries with db.execute().
node-postgres connection with existing Pool client
Import drizzle from 'drizzle-orm/node-postgres' and Pool from 'pg'. Create a Pool with connectionString, then initialize drizzle with drizzle({ client: pool }).
Neon serverless driver installation for PlanetScale
Install drizzle-orm@rc and @neondatabase/serverless, with dev dependencies drizzle-kit@rc.
Neon serverless driver HTTP mode for PlanetScale
Import neon and neonConfig from '@neondatabase/serverless', import drizzle from 'drizzle-orm/neon-http'. Set neonConfig.fetchEndpoint = (host) => `https://${host}/sql` to configure for PlanetScale. Initialize with const sql = neon(process.env.DATABASE_URL!) and drizzle({ client: sql }).
Neon serverless driver WebSocket mode for PlanetScale
Import Pool and neonConfig from '@neondatabase/serverless', import drizzle from 'drizzle-orm/neon-serverless'. Set neonConfig.pipelineConnect = false and neonConfig.wsProxy = (host, port) => `${host}/v2?address=${host}:${port}`. Initialize with const pool = new Pool({ connectionString: process.env.DATABASE_URL }) and drizzle({ client: pool }).
Neon serverless driver WebSocket mode with ws package
For Node.js environments using WebSocket mode, install the 'ws' package. Import ws from 'ws', Pool and neonConfig from '@neondatabase/serverless', and drizzle from 'drizzle-orm/neon-serverless'. Set neonConfig.webSocketConstructor = ws, neonConfig.pipelineConnect = false, and neonConfig.wsProxy = (host, port) => `${host}/v2?address=${host}:${port}`.
PlanetScale Postgres connection URL format
The connection URL format is postgresql://{username}:{pa••••••d}@{host}:{port}/postgres?sslmode=verify-full.
PlanetScale Postgres connection ports
PlanetScale Postgres supports port 5432 for direct connection to PostgreSQL with total connections limited by the cluster's max_connections setting, and port 6432 for connection via PgBouncer for connection pooling, recommended when you have many simultaneous connections.
Neon serverless driver modes
The Neon serverless driver supports two modes: HTTP mode which is faster for single queries and non-interactive transactions, and WebSocket mode which is required for interactive transactions or session-based features.