---
title: "Configuration and Validations"
description: "Configuration and Validations provides the schema definitions, parsing routines, and validation rules that govern drizzle.config.ts loading and command-line options across supported database engine..."
last_updated: "2026-10-12T08:14:00.734142+00:00"
canonical_url: "https://www.doc0.dev/docs/e1b68fed-3c4e-4c95-b2ba-ebf050f78025/technical/migration-toolkit/configuration-and-validations"
---

<details>
<summary>Relevant source files</summary>

The following files were used as context for generating this wiki page:

- [drizzle-kit/src/cli/commands/utils.ts](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/commands/utils.ts)
- [drizzle-kit/src/index.ts](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/index.ts)
- [drizzle-kit/src/snapshotsDiffer.ts](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/snapshotsDiffer.ts)
- [drizzle-kit/src/api.ts](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/api.ts)
- [drizzle-kit/src/serializer/studio.ts](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/serializer/studio.ts)
- [drizzle-kit/src/cli/connections.ts](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/connections.ts)
- [drizzle-orm/src/utils.ts](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-orm/src/utils.ts)
- [drizzle-orm/src/gel-core/dialect.ts](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-orm/src/gel-core/dialect.ts)
- [drizzle-kit/src/cli/validations/common.ts](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/common.ts)
- [drizzle-kit/src/cli/validations/sqlite.ts](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/sqlite.ts)
- [drizzle-kit/src/cli/validations/studio.ts](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/studio.ts)
- [drizzle-kit/src/cli/validations/gel.ts](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/gel.ts)
- [drizzle-kit/src/cli/validations/postgres.ts](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/postgres.ts)
- [drizzle-kit/src/serializer/index.ts](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/serializer/index.ts)
- [drizzle-kit/src/utils.ts](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/utils.ts)
- [drizzle-kit/src/serializer/pgImports.ts](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/serializer/pgImports.ts)
- [drizzle-orm/src/mysql2/driver.ts](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-orm/src/mysql2/driver.ts)
- [drizzle-kit/src/cli/validations/cli.ts](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/cli.ts)
- [drizzle-kit/src/cli/validations/libsql.ts](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/libsql.ts)
- [drizzle-kit/src/schemaValidator.ts](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/schemaValidator.ts)
- [drizzle-kit/src/cli/validations/mysql.ts](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/mysql.ts)
- [drizzle-orm/src/better-sqlite3/driver.ts](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-orm/src/better-sqlite3/driver.ts)
- [drizzle-kit/src/cli/validations/singlestore.ts](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/singlestore.ts)
- [drizzle-orm/src/relations.ts](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-orm/src/relations.ts)
- [eslint-plugin-drizzle/src/configs/all.ts](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/eslint-plugin-drizzle/src/configs/all.ts)
- [eslint-plugin-drizzle/src/utils/options.ts](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/eslint-plugin-drizzle/src/utils/options.ts)
- [drizzle-kit/src/cli/validations/outputs.ts](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/outputs.ts)
- [drizzle-seed/tsconfig.json](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-seed/tsconfig.json)
- [drizzle-valibot/tsconfig.json](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-valibot/tsconfig.json)
- [drizzle-orm/tsup.config.ts](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-orm/tsup.config.ts)
</details>

## Overview

Configuration and Validations provides the schema definitions, parsing routines, and validation rules that govern `drizzle.config.ts` loading and command-line options across supported database engines. It leverages Zod schemas to validate configuration properties such as dialects, schema paths, migration output directories, and database credentials for PostgreSQL, MySQL, SQLite, LibSQL, SingleStore, and Gel. By validating user inputs early, the subsystem detects missing or ambiguous parameters, resolves file globs, and reports diagnostic issues via chalk-styled terminal outputs.

Sources: [drizzle-kit/src/cli/commands/utils.ts:310-326](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/commands/utils.ts#L310-L326), [drizzle-kit/src/index.ts:23-349](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/index.ts#L23-L349), [drizzle-kit/src/cli/validations/common.ts:30-116](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/common.ts#L30-L116), [drizzle-kit/src/cli/validations/outputs.ts:4-91](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/outputs.ts#L4-L91)

## Configuration File Discovery and Resolution

### Config Loading and CLI Override Flag Integration

Configuration preparation routines retrieve settings either directly from command-line arguments or by loading configuration files based on the specified source origin. When `from` is set to `'config'`, the system invokes `drizzleConfigFromFile` with an optional configuration path string to load file-based settings, then passes the result through `flattenDatabaseCredentials` to merge nested `dbCredentials` properties directly into the root configuration object. 

CLI-provided flags take precedence or supplement configuration file properties during execution setup. For example, `preparePushConfig` explicitly evaluates options by setting `raw.verbose ||= options.verbose` if provided via the CLI for debugging, and `raw.strict ||= options.strict` exclusively from command-line flags. 

```typescript
	const raw = flattenDatabaseCredentials(
		from === 'config'
			? await drizzleConfigFromFile(options.config as string | undefined)
			: options,
	);

	raw.verbose ||= options.verbose; // if provided in cli to debug
	raw.strict ||= options.strict; // if provided in cli only
```
Sources: [drizzle-kit/src/cli/commands/utils.ts:310-318](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/commands/utils.ts#L310-L318)

> [!NOTE]
> Database credentials inside configuration files are defined under the `dbCredentials` property, which `flattenDatabaseCredentials` flattens alongside the rest of the configuration object to align with validation schemas.

Sources: [drizzle-kit/src/cli/commands/utils.ts:251-260](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/commands/utils.ts#L251-L260)

### Credential Flattening and Pull Config Transformation

The utility module provides specific transformation helpers to normalize configuration shapes depending on whether an inspection pull or schema push is requested. The `flattenPull` helper extracts `dbCredentials` and `introspect` properties from the config object, merging connection properties into the root and extracting `casing: introspect?.casing` for schema generation.

```typescript
const flattenPull = (config: any) => {
	if ('dbCredentials' in config) {
		const { dbCredentials, introspect, ...rest } = config;
		return {
			...rest,
			...dbCredentials,
			casing: introspect?.casing,
		};
	}
	return config;
};
```
Sources: [drizzle-kit/src/cli/commands/utils.ts:262-272](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/commands/utils.ts#L262-L272)

## Dialect Schema Validation with Zod

### Public Configuration Types and Top-Level Dialect Schemas

The configuration subsystem relies on Zod definitions to establish strict TypeScript types and runtime validation rules for public settings. The central dialect enum schema defines all supported database engines, compiling them into a union type utilized across CLI and file-based configurations.

```typescript
export const dialects = ['postgresql', 'mysql', 'sqlite', 'turso', 'singlestore', 'gel'] as const;
export const dialect = enumType(dialects);

export type Dialect = (typeof dialects)[number];
const _: Dialect = '' as TypeOf<typeof dialect>;
```
Sources: [drizzle-kit/src/schemaValidator.ts:7-11](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/schemaValidator.ts#L7-L11)

The supported dialects and core driver options are formally structured via validation literals and enums across the validation modules.

| Constant / Property | Type / Literals | Meaning / Purpose |
| :--- | :--- | :--- |
| `dialects` | `['postgresql', 'mysql', 'sqlite', 'turso', 'singlestore', 'gel']` | Supported database engines across Drizzle Kit commands. |
| `sqliteDriversLiterals` | `['d1-http', 'expo', 'durable-sqlite']` | Specific client drivers available for SQLite configurations. |
| `postgresqlDriversLiterals` | `['aws-data-api', 'pglite']` | Specific client drivers available for PostgreSQL configurations. |
| `prefixes` | `['index', 'timestamp', 'supabase', 'unix', 'none']` | Migration naming prefix formats. |
| `casingTypes` | `['snake_case', 'camelCase']` | Identifier casing strategies. |

Sources: [drizzle-kit/src/cli/validations/common.ts:64-91](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/common.ts#L64-L91), [drizzle-kit/src/schemaValidator.ts:7-8](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/schemaValidator.ts#L7-L8)

> [!NOTE]
> The `defineConfig` helper function acts as a typed identity wrapper for `Config` definitions in configuration files, ensuring users get proper IDE autocompletion without runtime transformation overhead.

Sources: [drizzle-kit/src/index.ts:347-349](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/index.ts#L347-L349)

### Core Zod Validation Structures

Common validation schemas establish baseline expectations for common properties such as migration settings, output directories, breakpoints, and table filters. The `configCommonSchema` validates general options using `.passthrough()` to allow engine-specific connection properties within `dbCredentials` or root structures.

```typescript
export const configCommonSchema = object({
	dialect: dialect,
	schema: union([string(), string().array()]).optional(),
	out: string().optional(),
	breakpoints: boolean().optional().default(true),
	verbose: boolean().optional().default(false),
	driver: driver.optional(),
	tablesFilter: union([string(), string().array()]).optional(),
	schemaFilter: union([string(), string().array()]).default(['public']),
	migrations: configMigrations,
	dbCredentials: any().optional(),
	casing: casingType.optional(),
	sql: boolean().default(true),
}).passthrough();
```
Sources: [drizzle-kit/src/cli/validations/common.ts:103-116](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/common.ts#L103-L116)

Specialized parameter schemas handle specific commands like introspection, generation, and schema pushing. For example, `pushParams` and `pullParams` require a `dialect`, accept table and schema filters with a default `public` schema array, and support extended entities such as roles configuration.

```typescript
export const pushParams = object({
	dialect: dialect,
	casing: casingType.optional(),
	schema: union([string(), string().array()]),
	tablesFilter: union([string(), string().array()]).optional(),
	schemaFilter: union([string(), string().array()])
		.optional()
		.default(['public']),
	extensionsFilters: literal('postgis').array().optional(),
	verbose: boolean().optional(),
	strict: boolean().optional(),
	entities: object({
		roles: boolean().or(object({
			provider: string().optional(),
			include: string().array().optional(),
			exclude: string().array().optional(),
		})).optional().default(false),
	}).optional(),
}).passthrough();
```
Sources: [drizzle-kit/src/cli/validations/cli.ts:18-36](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/cli.ts#L18-L36)

> [!WARNING]
> The `schemaFilter` property defaults to `['public']` across common and push validation schemas; omitting it explicitly scopes introspection and schema push targets to the PostgreSQL public schema.

Sources: [drizzle-kit/src/cli/validations/common.ts:111-111](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/common.ts#L111-L111), [drizzle-kit/src/cli/validations/cli.ts:23-25](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/cli.ts#L23-L25)

## Relational Engine Connection Specifications

### PostgreSQL, MySQL, and SingleStore Connection Rules

Connection specifications for PostgreSQL, MySQL, and SingleStore rely on Zod union schemas that validate discrete parameter combinations. PostgreSQL credentials support standard host-port tuples, connection strings via `url`, AWS Data API configurations utilizing `driver: 'aws-data-api'` alongside `database`, `secretArn`, and `resourceArn`, and PGLite instances using `driver: 'pglite'` with a `url`. 

| Credential Variant | Required Parameters | Optional Parameters | Driver Literal / Notes |
| :--- | :--- | :--- | :--- |
| PostgreSQL Host-Port | `host`, `database` | `port`, `user`, `password`, `ssl` | Standard TCP connection |
| PostgreSQL URL | `url` | None | Connection URI string |
| PostgreSQL AWS Data API | `database`, `secretArn`, `resourceArn` | None | `driver: 'aws-data-api'` |
| PostgreSQL PGLite | `url` | None | `driver: 'pglite'` |
| MySQL / SingleStore Host-Port | `host`, `database` | `port`, `user`, `password`, `ssl` | TCP socket or pool connection |
| MySQL / SingleStore URL | `url` | None | Connection URI string |

Sources: [drizzle-kit/src/cli/validations/postgres.ts:5-42](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/postgres.ts#L5-L42), [drizzle-kit/src/cli/validations/mysql.ts:6-30](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/mysql.ts#L6-L30), [drizzle-kit/src/cli/validations/singlestore.ts:6-30](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/singlestore.ts#L6-L30)

> [!WARNING]
> When configuring MySQL or SingleStore with explicit host parameters, the `database` property is mandatory alongside `host`, whereas URL-based connections require only the `url` string.

Sources: [drizzle-kit/src/cli/validations/mysql.ts:6-30](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/mysql.ts#L6-L30), [drizzle-kit/src/cli/validations/singlestore.ts:6-30](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/singlestore.ts#L6-L30)

### SSL and TLS Parameter Structures

Both MySQL and SingleStore share identical validation schemas for SSL configurations, accepting either a connection string or a detailed object containing certificate files and verification controls. PostgreSQL permits boolean values, specific string literals, or passthrough configuration objects for its `ssl` property.

```typescript
ssl: union([
	string(),
	object({
		pfx: string().optional(),
		key: string().optional(),
		passphrase: string().optional(),
		cert: string().optional(),
		ca: union([string(), string().array()]).optional(),
		crl: union([string(), string().array()]).optional(),
		ciphers: string().optional(),
		rejectUnauthorized: boolean().optional(),
	}),
]).optional(),
```
Sources: [drizzle-kit/src/cli/validations/mysql.ts:13-25](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/mysql.ts#L13-L25)

The MySQL and SingleStore SSL option object supports specific cryptographic properties for secure socket establishment:

| SSL Property | Expected Type | Description |
| :--- | :--- | :--- |
| `pfx` | `string` (optional) | Private key, certificate, and CA certificates in PFX or PKCS12 format. |
| `key` | `string` (optional) | Private key for the connection in PEM format. |
| `passphrase` | `string` (optional) | Shared passphrase for private key or pfx. |
| `cert` | `string` (optional) | Cert chain to use in PEM format. |
| `ca` | `string \| string[]` (optional) | Trusted certificate authorities. |
| `crl` | `string \| string[]` (optional) | Certificate revocation lists. |
| `ciphers` | `string` (optional) | Cipher suites to use or exclude. |
| `rejectUnauthorized` | `boolean` (optional) | Controls server certificate verification against list of supplied CAs. |

Sources: [drizzle-kit/src/cli/validations/mysql.ts:15-24](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/mysql.ts#L15-L24), [drizzle-kit/src/cli/validations/singlestore.ts:15-24](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/singlestore.ts#L15-L24)

> [!NOTE]
> PostgreSQL SSL validation accepts literal string values including `'require'`, `'allow'`, `'prefer'`, and `'verify-full'`, alongside standard booleans and passthrough objects.

Sources: [drizzle-kit/src/cli/validations/postgres.ts:13-20](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/postgres.ts#L13-L20)

## Embedded SQLite and LibSQL Validation

### SQLite Schema Variants and Connection Credentials

The SQLite validation module evaluates credentials across multiple driver variants using Zod union schemas. The supported configurations include Turso connections requiring a URL and optional auth token, Cloudflare D1 HTTP instances requiring an account ID, database ID, and token, and standard local SQLite database files where the driver is undefined and a file path `url` is specified.

| SQLite Credential Variant | Required Parameters | Optional Parameters | Driver Literal / Notes |
| :--- | :--- | :--- | :--- |
| Turso Cloud | `url` | `authToken` | `driver: 'turso'` |
| Cloudflare D1 HTTP | `accountId`, `databaseId`, `token` | None | `driver: 'd1-http'` |
| Local File SQLite | `url` | None | `driver: undefined` |

Sources: [drizzle-kit/src/cli/validations/sqlite.ts:6-25](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/sqlite.ts#L6-L25)

LibSQL credentials share a dedicated validation object requiring a `url` string with an optional `authToken` string.

```typescript
export const libSQLCredentials = object({
	url: string().min(1),
	authToken: string().min(1).optional(),
});
```
Sources: [drizzle-kit/src/cli/validations/libsql.ts:6-9](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/libsql.ts#L6-L9)

> [!WARNING]
> When defining local SQLite paths via the undefined driver variant, Zod transforms the object by explicitly deleting the `driver` property before passing the parsed configuration through.

Sources: [drizzle-kit/src/cli/validations/sqlite.ts:18-24](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/sqlite.ts#L18-L24)

### Better-SQLite3 Client Construction and Configuration

The Better-SQLite3 driver initializes synchronization sessions by accepting database instances, file path strings, or comprehensive configuration options through its `drizzle` entry point. The configuration accepts client objects or connection configuration blocks containing source definitions and native Better-SQLite3 options.

| Parameter Type | Accepted Values | Behavior |
| :--- | :--- | :--- |
| `client` | `Database` instance | Directly uses the provided Better-SQLite3 database instance. |
| `connection` | `string`, `Buffer`, or object with `source` and options | Instantiates a new `Client` with the given file source and options. |
| `undefined` / string | `undefined` or file path string | Creates a new in-memory or file-backed `Client` instance. |

Sources: [drizzle-orm/src/better-sqlite3/driver.ts:15-22](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-orm/src/better-sqlite3/driver.ts#L15-L22), [drizzle-orm/src/better-sqlite3/driver.ts:68-123](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-orm/src/better-sqlite3/driver.ts#L68-L123)

> [!NOTE]
> The `drizzle.mock()` method constructs a synchronous Better-SQLite3 database instance using an empty dummy client where `$client` is explicitly marked as unavailable.

Sources: [drizzle-orm/src/better-sqlite3/driver.ts:125-133](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-orm/src/better-sqlite3/driver.ts#L125-L133)

## Schema Globs and Filter Normalization

### Resolving Schema Globs and File Preparation

During configuration preparation via `preparePushConfig`, the configuration object is parsed using `pushParams.safeParse(raw)`, retrieving raw schema definitions that may be specified as a single string path or an array of path globs. These schema glob patterns are passed directly to `prepareFilenames` to locate matching typescript or javascript files across the file system. If no schema files are found matching the pattern, an informational message is rendered to the terminal using `render` with a blue info icon, and execution terminates cleanly without performing database changes.

Sources: [drizzle-kit/src/cli/commands/utils.ts:330-334](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/commands/utils.ts#L330-L334)

> [!CAUTION]
Grep-like pattern matching or glob expansion via `prepareFilenames` must locate at least one file; an empty file array causes the process to exit immediately with status code `0`, preventing subsequent database synchronization steps from executing.

Sources: [drizzle-kit/src/cli/commands/utils.ts:331-334](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/commands/utils.ts#L331-L334)

### Table and Schema Filter Normalization

Configured table filters and database schema filters undergo type normalization before being applied to introspection or push operations. The configuration values retrieved from `config.tablesFilter` and `config.schemaFilter` can be provided either as a single string or as an array of strings. Normalization handles these input types uniformly by wrapping scalar strings in an array or defaulting to an empty array when undefined.

| Configuration Key | Normalization Logic | Default Value | Target Array Result |
| :--- | :--- | :--- | :--- |
| `tablesFilter` | `typeof tablesFilterConfig === 'string' ? [tablesFilterConfig] : tablesFilterConfig` | `[]` | `string[]` |
| `schemaFilter` | `typeof schemasFilterConfig === 'string' ? [schemasFilterConfig] : schemasFilterConfig` | `[]` | `string[]` |

Sources: [drizzle-kit/src/cli/commands/utils.ts:336-349](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/commands/utils.ts#L336-L349)

> [!NOTE]
Additional table filters derived from registered dialect extensions are dynamically appended to the normalized `tablesFilter` array using `tablesFilter.push(...getTablesFilterByExtensions(config))`.

Sources: [drizzle-kit/src/cli/commands/utils.ts:351-351](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/commands/utils.ts#L351-L351)

### PostgreSQL Import Processing and Entity Categorization

When handling PostgreSQL schema imports, `prepareFromPgImports` iterates over resolved import paths inside a safe module registration context, requiring each file and categorizing its exported Drizzle entities. The `prepareFromExports` function inspects the exported dictionary values using typeguards to separate tables, enums, schemas, sequences, views, materialized views, roles, policies, and relations into distinct typed arrays.

| Entity Category | Detection Guard / Type Identifier | Result Array Type |
| :--- | :--- | :--- |
| Tables | `is(t, PgTable)` | `AnyPgTable[]` |
| Enums | `isPgEnum(t)` | `PgEnum<any>[]` |
| Schemas | `is(t, PgSchema)` | `PgSchema[]` |
| Sequences | `isPgSequence(t)` | `PgSequence[]` |
| Views | `isPgView(t)` | `PgView[]` |
| Materialized Views | `isPgMaterializedView(t)` | `PgMaterializedView[]` |
| Roles | `is(t, PgRole)` | `PgRole[]` |
| Policies | `is(t, PgPolicy)` | `PgPolicy[]` |
| Relations | `is(t, Relations)` | `Relations[]` |

Sources: [drizzle-kit/src/serializer/pgImports.ts:16-67](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/serializer/pgImports.ts#L16-L67), [drizzle-kit/src/serializer/pgImports.ts:70-109](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/serializer/pgImports.ts#L70-L109)

## Validation Diagnostics and Terminal Reporting

### Terminal Output Styling and Error Formatting

Drizzle Kit uses `chalk` combined with custom style helpers (`withStyle`) to render validation diagnostics, warnings, and error messages to the terminal. The `withStyle` utility provides standardized visual badges such as inverted background tags for invalid inputs, warnings, and suggestions. Parameter formatting uses `wrapParam` to display configuration checkmarks or crosses alongside masked secrets and sanitized database connection URLs.

| Style Function | Visual Output Format | Purpose |
| :--- | :--- | :--- |
| `withStyle.error` | `Invalid input` (white text on red background) + error message | Formatting critical configuration validation failures |
| `withStyle.warning` | `Warning` (white text on gray background) + warning text | Displaying non-fatal configuration warnings |
| `withStyle.errorWarning` | `Warning` (white text on red background) + warning text | Highlighting severe warnings |
| `withStyle.fullWarning` | `Warning` (black text on yellow bold background) + message | Highlighting prominent warnings |
| `withStyle.suggestion` | `Suggestion` (white text on gray background) + advice | Providing actionable recommendations |
| `withStyle.info` | Grey text | Rendering informational diagnostics |

Sources: [drizzle-kit/src/cli/validations/outputs.ts:4-11](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/outputs.ts#L4-L11)

> [!NOTE]
The `wrapParam` utility automatically detects string parameters, masking password components in database connection URLs using a regex replacement (`param.replace(/(?<=:\/\/[^:\n]*:)([^@]*)/, '****')`) while displaying `'*****'` for explicit secrets and green checkmarks or red crosses based on presence.

Sources: [drizzle-kit/src/cli/validations/common.ts:170-188](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/common.ts#L170-L188)

### Output Definitions and Dialect Diagnostics

The `outputs` dictionary catalogs all structured error messages for Drizzle Studio, general CLI commands, and database dialects including PostgreSQL, MySQL, SQLite, and SingleStore. When required configuration parameters or connection credentials are omitted, these functions generate descriptive messages referencing documentation URLs.

```typescript
export const outputs = {
	studio: {
		drivers: (param: string) =>
			withStyle.error(
				`"${param}" is not a valid driver. Available drivers: "pg", "mysql2", "better-sqlite", "libsql", "turso". You can read more about drizzle.config: https://orm.drizzle.team/kit-docs/config-reference`,
			),
		noCredentials: () =>
			withStyle.error(
				`Please specify a 'dbCredentials' param in config. It will help drizzle to know how to query you database. You can read more about drizzle.config: https://orm.drizzle.team/kit-docs/config-reference`,
			),
		noDriver: () =>
			withStyle.error(
				`Please specify a 'driver' param in config. It will help drizzle to know how to query you database. You can read more about drizzle.config: https://orm.drizzle.team/kit-docs/config-reference`,
			),
		noDialect: () =>
			withStyle.error(
				`Please specify 'dialect' param in config, either of 'postgresql', 'mysql', 'sqlite', turso or singlestore`,
			),
	},
```
Sources: [drizzle-kit/src/cli/validations/outputs.ts:13-31](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/outputs.ts#L13-L31)

> [!WARNING]
Using ambiguous parameters—such as supplying both `--config` and explicit conflicting CLI options for commands like `generate`, `introspect`, or `push`—triggers `outputs.common.ambiguousParams(command)` and terminates execution with `process.exit(1)`.

Sources: [drizzle-kit/src/cli/validations/common.ts:30-62](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/common.ts#L30-L62), [drizzle-kit/src/cli/validations/outputs.ts:32-38](https://github.com/blade47/drizzle-orm/blob/48e5406027103a9fca6eb66417187c4a8b5c6aa3/drizzle-kit/src/cli/validations/outputs.ts#L32-L38)

## Related

- [CLI Command Architecture](https://www.doc0.dev/docs/e1b68fed-3c4e-4c95-b2ba-ebf050f78025/technical/migration-toolkit/cli-command-architecture)


## Sitemap

See the full [sitemap](https://www.doc0.dev/docs/e1b68fed-3c4e-4c95-b2ba-ebf050f78025/llms.txt) for all pages in this wiki.
