Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Drizzle Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-drizzle-knowledge-patch)
---
name: drizzle-knowledge-patch
description: Drizzle ORM
version: "1.0.0-beta.19"
license: MIT
metadata:
author: Nevaberry
---
# Drizzle ORM Knowledge Patch
Load this skill when updating Drizzle APIs, configuring query behavior and
database drivers, automating Drizzle Kit, or generating Zod schemas.
Use the references for the version-specific behavior of each API and integration.
| Reference | Topics |
| --- | --- |
| [Queries and Runtime](references/queries-and-runtime.md) | Identifier escaping, entity casing, relational queries, codecs, typed SQL, prepared queries, Effect, and database drivers |
| [Migrations and Drizzle Kit](references/migrations-and-kit.md) | Runtime loading, output modes, SDK, hints, MCP, skills, migration branches, introspection, and schema discovery |
| [Schema Validation](references/schema-validation.md) | Built-in Zod integration, views and enums, refinements, replacements, coercion, generated constraints, and JSON validation |
## Security fix and API migrations
### Identifier and alias escaping
Upgrade to Drizzle ORM 0.45.2 for the fix to a potential SQL injection
vulnerability in names passed to `sql.identifier()` and SQL expression aliases
set with `.as()`.
### Entity-level casing
In `1.0.0-rc.1`, replace instance-level `casing` with `snakeCase` or `camelCase`
constructors for tables, views, materialized views, and schemas. A schema created
this way also supplies casing-aware constructors for its entities.
```ts
import { snakeCase, text } from 'drizzle-orm/pg-core';
export const users = snakeCase.table('users', { fullName: text() });
// The database column is full_name.
```
### Relational queries and PostgreSQL imports
Move relational query v1 callers from `db._query` to Relational Queries v2 via
`db.query`. The v1 API is removed for PostgreSQL in `1.0.0-rc.1`, MySQL in
`1.0.0-rc.3`, and SQLite in `1.0.0-rc.4`. Remove SQLite's v1 `TSchema` and
`TFullSchema` generic arguments.
In `1.0.0-rc.1`, import `makePgArray` and `parsePgArray` from
`drizzle-orm/pg-core/array`. The previous entry points were
`drizzle-orm/pg-core/utils` and `drizzle-orm/pg-core/utils/array`.
### SQLite, prepared, and raw query removals
In `1.0.0-rc.4`, `SQLiteSyncDialect` and `SQLiteAsyncDialect` are removed.
Import the generic migrators `migrateSync` and `migrateAsync` from
`drizzle-orm/sqlite-core/async/session`.
Prepared query builders drop `typings` in `1.0.0-rc.2`. In `1.0.0-rc.4`,
`PreparedQuery` drops `mapResult`, and PostgreSQL and SQLite raw queries drop
`mapResult` and `mapBatchResult`.
### Effect dependencies and response shape
`effect-schema` and `effect-postgres` switch from Effect v3 to the v4 beta in
`1.0.0-rc.1`; `1.0.0-rc.4` requires `effect@4.0.0-beta.83`.
In rc.4, import `EffectDrizzlePgConfig` from
`drizzle-orm/pg-core/effect/utils`, and expect the raw driver response from
`db.execute()` with `@effect/sql-pg`.
### Built-in Zod integration
Starting with `drizzle-orm@1.0.0-beta.15`, install `zod` alongside the ORM and
import schema generators from `drizzle-orm/zod`. The deprecated `drizzle-zod`
package still works; future updates go to the built-in integration.
## Query mapping and execution
### Custom codecs and set operations
In `1.0.0-rc.2`, select a PostgreSQL custom column codec explicitly with `codec`,
which accepts callbacks such as
`codec: (config) => config?.withTimeZone ? 'timestamptz' : 'timestamp'`.
Update point codec names from `geometry` and `geometry:tuple` to
`geometry(point)` and `geometry(point):tuple`.
In `1.0.0-rc.4`, a PostgreSQL or MySQL set operation uses the codec for the
database's resulting type when both input columns have codecs. Otherwise, the
result inherits the left column's codec behavior, including the absence of a
codec. Database coercion can still lose information.
### Typed SQL nullability
In `1.0.0-rc.4`, `mapWith()` on `sql<T>` infers the mapper input from `T` and
carries through `null` in the expression's result type. Use `.nullable()` to
add `null` to an expression's result type explicitly.
```ts
import { sql } from 'drizzle-orm';
const value = sql<number | null>`nullif(1, 1)`.mapWith((n) => String(n));
// n has type number and the mapped expression has type string | null.
```
### JIT mappers and query tags
Starting in `1.0.0-rc.1`, pass `jit: true` in the `drizzle()` config to generate
row mappers. A prepared query reuses its mapper on subsequent executions.
PostgreSQL and MySQL query builders can append SQL comments with
`.comment({ priority: 'high' })` or `.comment("priority='high'")` before execution.
Apply comments on the builder: prepared statements lack `.comment()`.
Query tags start in `1.0.0-beta.19`; the builder's string overload was restored
in `1.0.0-rc.4`.
### Inserts, iterators, and SQLite execution
In `1.0.0-rc.4`, selections passed to `db.insert(table).select(...)` can use a
different column order from the target table and omit nullable columns or
columns with defaults.
In `1.0.0-rc.3`, MySQL iterator queries fall back to regular queries when a
driver lacks streaming support.
In `1.0.0-rc.4`, synchronous SQLite drivers can execute counts with
`db.$count(users).sync()`. SQLite query failures are wrapped in
`DrizzleQueryError`, with `db.batch()` as an exception.
## Drizzle Kit automation
### Structured output and missing decisions
In `1.0.0-rc.4`, `generate`, `push`, `pull`, `up`, `export`, and `check` accept
`--output text` or `--output json`. For example:
```bash
npx drizzle-kit generate --output json
```
JSON output emits a typed envelope with status, errors, and payloads.
`drizzle-kit/cli` exposes matching typed `generate()`, `push()`, `pull()`, `up()`,
`exportSql()`, and `check()` functions.
JSON output and text output with non-TTY stdin both suppress interactive prompts.
Supply a structured hints array through `--hints` or `--hints-file` to resolve
rename and `confirm_data_loss` decisions. Unresolved decisions appear as
`missing_hints` in JSON or as a missing-decisions report in text.
### Kit tools and migration branches
In `1.0.0-rc.4`, `npx drizzle-kit mcp` starts a stdio server with tools for
`generate`, `push`, `check`, `export`, `up`, and `pull`.
`npx drizzle-kit skills` installs bundled project skills, including guidance for
hints, output modes, and migration responses and errors.
SQLite migration generation checks open branches for conflicts in `1.0.0-rc.2`
and records all open leaf IDs in the next snapshot's `prevIds`.
`npx drizzle-kit generate --ignore-conflicts` or
`npx drizzle-kit check --ignore-conflicts` bypasses the check for that invocation.
See [Migrations and Drizzle Kit](references/migrations-and-kit.md) for
PostgreSQL and MySQL branch behavior, enum merges, runtime loading, and discovery.
## Driver integrations
For the `1.0.0-rc.1` adapter at `drizzle-orm/netlify-db`, install
`@netlify/database`. Its `drizzle()` factory accepts no arguments, a database URL,
or `{ client: netlifyDbClient }` to reuse an existing client.
Drizzle ORM 0.45.3 adds the Netlify DB adapter with `@netlify/db`.
Calling `drizzle()` without arguments reads `NETLIFY_DB_URL` and
`NETLIFY_DB_DRIVER`.
See [Queries and Runtime](references/queries-and-runtime.md) for the additional
Effect SQL drivers, serverless, sync, and WASM drivers, proxy configuration,
and SQL Server peer dependencies.
## Validation behavior
`createSelectSchema()` accepts PostgreSQL views and standalone enums. A view
produces an object schema for its selected fields; an enum produces a schema
for its values.
In a schema generator's second argument, a field callback runs before Drizzle
applies column nullability and optionality. Passing a Zod schema directly takes
over the whole field: declare any required `.nullable()` or `.optional()` on it.
`createSchemaFactory({ zodInstance: z })` binds its generators to an extended
Zod instance. Use `coerce: true` for all supported coercions or a per-type map
such as `{ date: true }` to generate `z.coerce.date()` for date-valued columns.
Generated JSON validators check only the top-level value as a JSON primitive,
record, or array and accept arbitrary nested values. Supply a field refinement
or replacement schema to enforce the nested shape.
See [Schema Validation](references/schema-validation.md) for the generated
bit-string, character-length, numeric-bound, and year constraints.