NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
npm
npm, #3545 most downloaded on npm
Drizzle Kit is a CLI migrator tool for Drizzle ORM. It is probably the one and only tool that lets you completely automatically generate SQL migrations and covers ~95% of the common cases like deletions and renames by prompting user input. <https://github
Latest stable
0.31.11
Last release 1 months ago
21 Oct 2026
Ships fairly regularly
a new release about every 2 weeks
Most releases are documented
notes for 39 of the last 60 stable releases
Nothing withdrawn
no release was ever pulled
5 years old
507 releases · first in 2021
Drag across the ruler to compare, or tap a release to open it.
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
…name field to protected and marked getSQL as @deprecated to prevent field from bleeding into relational filters' autocomplete
postgres-js transparent parsers set by drizzle() constructors breaking driver's own serializers for timestamptz, timestamp, date, time, json, jsonb types (fixes #3171, #4426, #5789) paramsInErrors
:exclamation: Any existing workarounds with manual JSON.stringify(jsonValue) in raw sql or raw driver calls must be removed to prevent double stringification of JSON params; For array-type JSON params in sql use sql.param(jsonArrayValue) to avoid it being parsed as value list instead of param.undefined value passed to fields in relational queries' where - now throws an error upon encountering undefined in filters, added EmptyFilter symbol (import { EmptyFilter } from 'drizzle-orm/relations') that can be used as an explicit replacement of undefined where possibly absent filter is desired by design rather than possible bug (fixes #5636) db.query.users.findMany({ where: { isActive: params.isActive ?? EmptyFilter } })
{}, or containing only empty conditions) are now skipped like any other empty filter instead of generating exists (...) check of relation's presence - use true to filter by relation's presence, false - by its absence // Previously: `where exists (select * from "posts" ...)`, now: no filter
db.query.users.findMany({ where: { posts: {} } })
// Users with at least one post
db.query.users.findMany({ where: { posts: true } })
postgres codecs: now generic codecs contain only in-json codecs (mirroring mysql), contents of drivers' codecs remain unchangedpg bytea in-json codecs from encode(..., 'base64') casts to decoding to_json's native hex outputSQL field data during nullificationsqlite ignoring .$defaultFn(...) on insert when .default(...) is presentbun-sql/mysql, mysql2, singlestore column mapping from connection config, removed forced bigint params on their respective configs, replaced with more stable cast codecscockroach column builders to mirror pg - now both have same .array('[][]...') syntaxView exports from drizzle-orm/sql/sql to drizzle-orm/viewgetTableUniqueName no longer prefixes aliased views or tables with their schemagetTableUniqueName no longer sets public. prefix for entities without schemaView class: switched to Table-like object config for type template, typed schema propertywithReplicas (indirectly fixes #4185):
db.$replicawithCastCodecs = false switch to getSQL(), withCastCodecs = true switch to toSQL() of non-relational query builders - now db.select(...).from(...).getSQL() emits query without cast codecs by defaultsqlite-proxy:
rowMode: 'array' | 'object' switch for 'all' | 'get' execute methods{ rows: Result[] } callback result wrapping - now expected direct return of expected datacallback, batchCallback with SqliteProxyExecutors object - must provide run, all, get handlers & optional batch handlervalues execute method due to it being duplicate of array-mode allTRunResult type inferrence based on return type of run executor, updated SqliteRemoteDatabase template with TRunResult argumentrowMode: 'array' | 'object' to batch, batch is expected to mirror executors' return types per queryget (data | undefined in runtime, data[] in types) (fixes #5461, #3394)sqlite db.get(sql) return type lacking | undefined for queries without returned rowsparams from DrizzleQueryError by default, added paramsInErrors option to drizzle constructor to enable query params in DrizzleQueryError (fixes #5939)const db = drizzle({
connection: 'postgres://...',
paramsInErrors: true
})
mysql, postgres, cockroach, mssql set RQBv2 to new query build strategy to fix slow query plans (fixes #5245)strategy switch: db.query.findMany({ strategy: 'basic' })
When used, may break direct references to relations in raw SQL syntax where, orderBy:// posts with the most comments first
db.query.posts.findMany({
with: { author: true, comments: true },
orderBy: (t, { sql }) => sql`json_array_length("comments"."r") desc, ${t.id}`, // "comments" becomes unreachable due to query nesting
limit: 2,
});
// posts of verified authors
db.query.posts.findMany({
with: { author: true },
where: { RAW: (t, { sql }) => sql`("author"."r"->>'verified')::boolean` }, // "author" becomes unreachable due to query nesting
});
StringChunk, commonStringChunks exports from drizzle-orm/sql/sql to drizzle-orm/sql/common-chunks (still exported from drizzle-orm/sql)collectTo: SQLChunk[] array to push chunks to and returns chunk arrays instead of SQLsql directly are rendered as value lists - wrap them in new SQL(chunks) to use them as query parts
relationsFilterToSQL(...).sql: SQL | undefined -> SQLChunk[] | undefined, added collectTo parameterrelationsOrderToSQL(...): SQL | undefined -> SQLChunk[] | undefined, added collectTo parameterrelationsOrderEntriesToSQL(...): replaced parts: SQL[] parameter with collectTo: SQLChunk[], start?: number; RelationsOrderSource's from, filters are now SQLChunk[], SQLChunk[][]relationExtrasToSQL(...).sql: SQL | undefined -> SQLChunk[] | undefined, added collectTo parameterrelationToSQL(...): { filter?: SQL; joinCondition?: SQL } -> { filter: SQLChunk[]; joinCondition?: SQLChunk[] }, added filterTo, joinConditionTo parametersgetTableAsAliasSQL(...): SQL -> SQLChunk[], added collectTo parameterall strategy (global: true), opt out per query via withCache: falseDBQueryConfigWithComment type with DBQueryConfigRoot - config of root relational query containing all root-only options (strategy, comment, withCache); dialects' relational query builders accept it with options they don't support omittedeq filter (fixes #5298)$onUpdateFn being executed without need (fixes #5780)$onUpdateFn potentially overriding explicit nullszod schema generator returning unknown-templated coerced types (fixes #5659)mysql2 constructor setting param in potentially undefined mistyped config (fixes #5972)sql fields in selection when non-current table's column is referenced (fixes #5734)orderBy, extras, RAW of relational queries_ field in RelationsHelperStaticisReversed to isFilterReversed in Relationobjects, arrays db.execute modes (db.all, db.get in sqlite) (bypasses #4464)geometry, geography & box array types data getting reduced to one item due to wrong delimiter used during pgArray construction\parsingmakePgArray, parsePgArray utilitiesdb.insert (workaround for #5001, #5309)
db.insert(users, 'name', 'email').values([{ name: 'First', email: 'first@example.com' }, { name: 'Second', email: 'second@example.com' }])pg dialectpg transaction config related errors on empty but present config (fixes #1772)pg driverstursodatabase library versionstursodatabase driversmysql transaction options being joined on wrong separatorisolationLevel in bun-sql/mysql transactionseffect-sqlite, effect-mysql due to lack of support in driverslibsql, tidb driversop-sqlite transaction being handled as synchronousop-sqlite query executors (fixes #5936)op-sqlite to v17 (fixes #5928)expo-sqlite not finalizing prepared statementsexpo-sqlite/async for async querying (fixes #5240)sha256 hash function as a fallback for cache query hashing in environments without globalThis.crypto availablenot-null behavior on not yet joined column groups in selection (fixes #4232)bytea not being included in pg table creation callback format column listSQL.usedTables calculation from constructor to getterObject.prototype properties like constructor (fixes #6076)neon-http migrator to automatically rollback failed migrationseffect to 4.0.0 (fixes #6162, #6403, #6412)typebox to 1.2.0 (fixes #5981)mssql, cockroach, singlestore sessions to new formatlateral (apply), cross joins, insert ... select, db.$count to mssqlmssqlblob columns on React Native drivers: writes no longer require Buffer, op-sqlite and expo-sqlite reads normalized to Uint8Array. Use blob(...).$type<UInt8Array>() to override column's typepg, mysqlorder by in set operation queriesMSSQL, MySQL, SingleStore serial types returning different types based on column's valuesqlite generating View,Subquery queries with cast on numeric columnssqlite, cockroach, mssql, singlestoremssql, cockroach to RQBv2limit 1 from relational where, coalesce for json arrays in sqlite in RQBv2schema from DrizzleConfigmysql2 not using codecs from config over driver's default when providedmakeCockroachArray, parseCockroachArray utilities, mirroring their pg counterpartscockroach geometry arrays being unwritable due to wrong delimitercockroach array parser dropping backslashes from string valuescockroach int4[] being parsed to string[]mapper caching for queries reused without .prepare().$dynamic() query builder being unusable with .from, .*Join (fixes #4069)Placeholder value field described as declare protected: TValue instead of declared protected value: TValue; Set name field to protected and marked getSQL as @deprecated to prevent field from bleeding into relational filters' autocompleteSubquery.getSQL() (fixes #2174)Subquery type fields in Viewsalias function returning materialized views typed as regular viewsisAlias: boolean type config property to View, Table to identify if it was aliasedisTableAlias, getTableSchema utils, supported View in getTableName utilSubquery as relational entity in RQBv2:
Subquery must have flat selection, same as ViewSubquery will be invoked only once in WITH section on root level of relational query, every reference will use it's aliasSubquery instances with same aliasmysql, mssql, singlestore iteratorsmysql2 iterators leaving connection un-drained & deadlocked on errorsmysql2 iterators hanging when connection is dropped mid-streamExtraConfigColumn.getSQL() recursing into stack overflow (fixes #6050)sqlite dropping | undefined from .get() return type of db.update(table).set(...).returning()sqlite dropping | undefined from .get() return type of db.insert(table).values(...).returning() with .onConflictDoNothing() or .onConflictSet({ where: ... }) present, db.insert(table).select(...).returning() (fixes #6107)undefined = null, bigint = mimic string, different data view type collisions in hashQuery (fixes #5842)tableCreator-prefixed tablessqlgetCacheKey(table) util returning the name query cache tracks a table by (schema.name, or name for tables without schema; aliases resolve to their original tables)orderBy of set operations dropping table qualifiers in passed sql objects (e.g. desc(column))DSQL adapters for postgres-js (@aws/aurora-dsql-postgresjs-connector) - drizzle-orm/postgres-js/dsql, node-postgres (@aws/aurora-dsql-node-postgres-connector) - drizzle-orm/node-postgres/dsqldb.execute types (fixes #661):
db.execute(sql) - returns union every possible response type by driverdb.execute<never>(sql) - returns rowless response type (i.e. insert without returning)db.execute<ReturnedObject> - driver response with rows typed as ReturnedObject[]db.execute<IReturnedObject>(sql) type template rejecting interfaceseffect drivers' raw db.execute, db.run (fixes #6382)typescript@6 and above (fixes #5644, #6383)mysql date column being affected by server's timezone (fixes #1442)effect-mysql, bun-sql/mysql drivers losing time fractionSQLiteBigInt attempting to use Buffer in encoder without Buffer present in environment (fixes #2043)durable-sqlite db.get(sql) throwing on queries returning zero or more than one row instead of returning undefined or the first rownode-postgres transaction crashing process if connection is dropped mid-transaction (fixes #6437)node-postgres transaction leaking the pool client on BEGIN error (fixes #6341)rollback error replacing the original error that triggered it// Select users sorted by last post
db.query.users.findMany({ orderBy: { posts: { createdAt: 'desc(max)' } } })
// Select users sorted by post count
db.query.users.findMany({ orderBy: { posts: 'asc(count)' } })
// Select admin posts first, sort rest by creation date
db.query.posts.findMany({ orderBy: { author: { isAdmin: 'desc' }, createdAt: 'desc' } })
withCache switch:
true - cache queryfalse - never cache queryundefined - cache only with all cache strategydb.query.users.findMany({ with: { posts: true }, withCache: true })
instanceof not working reliably for drizzle classes in monorepos with multiple library instancesaws-data-api/pg:
Unknown type error - now sent as pg array literalsUnknown type error - now sent as JSON with JSON type hintArrayValue objectschar(n) params being truncated to a single character by ::char castinet values gaining full-width netmask (/32, /128) in resultstime({ withTimezone: true }) values losing their offset: params were cast to ::time, results were converted to UTC by Data APIpg time({ withTimezone: true }) columns using time codecs instead of timetz onesdefineConfig allowing fields from every config variant simultaneouslypull command - migration.sql is no longer has comments when running pull --initdrizzle-orm not being listed as peer dependencyFixed broken View types when using Subquery in selection
View types when using Subquery in selectionSQL fieldsSQL field when .mapWith(column) is set (fixes #5724)Subquery fields' columns' codecs not being applied to subqueryrc.3 db.select in bun-sql/pg driver (fixes #5779)db.$count builder to include .sync() executor for sync driverssqlite, removed RQBv1 TSchema, TFullSchema arguments from sqlite entities' genericssqlite query errors not being wrapped in DrizzleQueryError (db.batch() excluded due to api incompatibility)CockroachArrayBuilder constructor caused by referencing internal field's typemapResult method from PreparedQuery interface, removed mapResult, mapBatchResult from pg and sqlite raw queriesbun-sqlite run result typesqlite RQBv2 to array modesqlitesqlite sessions: replaced per-driver PreparedQuery instances with executors passed via sessions, similar to current postgresql and mysql implementations, moved useJitMappers flag handling to dialectstring overload on .comment(sqlCommenterComment) in query builders@tursodatabase/database, @tursodatabase/database-wasm@tursodatabase/database-wasm at drizzle-orm/tursodatbase/wasm-migratorasync, effect versions (sync remains subtype of async)SQLiteSyncDialect, SQLiteAsyncDialect, moved generic SQLite async\sync migrators to sqlite-core/async/session as migrateSync, migrateAsyncsqlite cache using same cache entry for different execute methodsEffectDrizzlePgConfig to drizzle-orm/pg-core/effect/utilscache field in EffectCacheShape optionalmysql into async, effect versionsmysqlmysql float rounding to either 6 digits or doublemysql cropping .000 from timestamp(3)dialect.buildSelection to orderSelectedFields;PG, MySQL] Improved codec system in set operators:
[QUERY 1] UNION [QUERY 2] to SELECT ... FROM ([QUERY 1] UNION [QUERY 2]) "drizzle_union" so cast codecs would apply after union's type mutationeffect package versions to 4.0.0-beta.83sql.param passing Placeholder as expected input value to encoder function instead of Placeholder's value typeBuffer reference in drizzle-orm/effect-schema that caused error in environments without Buffersqlite blob column runtime-type default mode mismatch (fixes #1064)sql operator - preserved nullability, inferred initial data type to mapWithcallback argument, added .nullable() method to modify output type with | null (fixes #571): // Before:
sql<Type | null>`...`.mapWith((v: any) => String(v)) // Output type: string
// After:
sql<Type | null>`...`.mapWith((v: Type) => String(v)) // Output type: string | null
// `.nullable()` method:
sql`...`.mapWith((v: unknown) => new Type(v)).nullable() // Output type: Type | null
generatedByDefaultAsIdentity columns not being filtered from inserts in runtime in postgres dialectdb.insert(table).select(...): removed column order match requirement, allowed skipping selection for columns with defaults or nullability (fixes #3608)Updated @tursodatabase/database, @tursodatabase/database-wasm to v0.6.0, updated session internals for asynchronous prepare on driver side
Added @tursodatabase/serverless driver support
Added @tursodatabase/sync driver support
Added @effect/sql-pglite driver support
Added @effect/sql-sqlite-node driver support
Added @effect/sql-sqlite-bun driver support
Added @effect/sql-sqlite-do driver support
Added @effect/sql-sqlite-wasm driver support
Added @effect/sql-libsql driver support
Added @effect/sql-d1 driver support
Added @effect/sql-mysql2 driver support
Fixed @effect/sql-pg driver returning object response instead of raw response on db.execute
pg-proxy: added dialect config to optional dialect creator callback
Fixed postgres pull from failing for non-admin roles (fixes #5568)
--output text|json mode to generate, push, pull, up, export, and check. In json mode each command emits a typed JSON envelope (status, errors, payloads) for programmatic and agent consumption (see OUTPUT_MODES.md, JSON_CONTRACT.md)drizzle-kit/cli subpath exposing generate(), push(), pull(), up(), exportSql(), and check() with typed options and results matching the CLI JSON contract (see SDK.md)--output json, or --output text with a non-TTY stdin) no longer renders interactive prompts. Instead, unresolved renames and destructive changes (confirm_data_loss) are surfaced as a missing_hints envelope (or a missing-decisions report under text) and resolved by supplying a structured hints array up front via --hints / --hints-file (see HINTS.md)drizzle-kit mcp, a Model Context Protocol server over stdio that exposes the migration lifecycle (generate, push, check, export, up, pull) as MCP tools for any MCP-capable AI agent (see MCP.md)drizzle-kit skills, which installs Drizzle Kit's bundled Agent Skills into your project for AI coding assistants. Ships 8 skills: drizzle, drizzle-generate, drizzle-hints, drizzle-migrations, drizzle-output-modes, drizzle-pull, drizzle-push, and drizzle-responses-and-errors (see drizzle-kit/skills folder)Porting all the changes that were made in PostgreSQL to other dialects. This release is about MySQL:
Porting all the changes that were made in PostgreSQL to other dialects. This release is about MySQL:
mysql dialect (._query)lastInsertId, affectedRows from dedicated response fieldsNext releases will include:
Disabled default codec type selectors for custom columns (fixes #5711)
codec: (config) => config?.withTimeZone ? 'timestamptz' : 'timestamp')geometry -> geometry(point), geometry:tuple -> geometry(point):tupleAWS Data Api codecs, removed query typings, improved input param mappingtypings field from all builderscolumn argument to CastParam,CastArrayParam codecsdrizzle-kit generate now checks whether those branches can be merged safely before creating the next migration. This helps catch cases where two migrations were created from the same parent and then changed the same SQLite object in incompatible ways, for example two branches changing the same table, index, or view.npx drizzle-kit generate
--ignore-conflicts to skip the conflict check for that command.npx drizzle-kit generate --ignore-conflicts
npx drizzle-kit check --ignore-conflicts
{
"prevIds": ["first-open-leaf-id", "second-open-leaf-id"]
}
DrizzleQueryError and TransactionRollbackError constructors to properly set the error name for better instanceof checks⚠️ This release introduced a breaking change into our casing API(see below) and removes RQB v1 ._query for postgres
⚠️ This release introduced a breaking change into our casing API(see below) and removes RQB v1 ._query for postgres
Drizzle ORM now has an opt-in API for JIT(just in time compilated) mappers which make most expensive part of the db request pipeline(row mapping) as fast as humanly possible.
const db = drizzle({ ..., jit: true })
const query = db.select().from(users).prepare();
// ^ here drizzle generates a jit mapper which will then be reused during each invocation
server.get('users', (c) => {
const users = await query.execute(); // as fast as using raw driver
return c.json(users)
})
We've reworked internals of Drizzle ORM with the new system of codecs. Those are now in charge of normalising responses and requests for diffrent drivers across pg dialect. They helped us not only properly fix a set of data mapping issues but also massively improve performance by not doing unnecessary work.
We've seen a 25%-30% reduction in latency, while +800rps(14500->15300) in our benchmarks
Give it a go and let us know if everything works just fine!
drizzle-orm@1.0.0-rc.1 comes with native support for Effect v4 via:
import { PgClient } from '@effect/sql-pg';
import * as PgDrizzle from 'drizzle-orm/effect-postgres';
import * as Effect from 'effect/Effect';
import * as Redacted from 'effect/Redacted';
import { relations } from '../relations';
const connectionStr = Redacted.make(process.env['PG_CONNECTION_STRING']!);
const PgClientLive = PgClient.layer({
url: connectionStr,
});
const DB = PgDrizzle.make({ relations }).pipe(Effect.provide(PgDrizzle.DefaultServices));
const program = Effect.gen(function*() {
const db = yield* DB;
const users = yield* db.select().from(usersTable);
}).pipe(Effect.provide(PgClientLive));
await Effect.runPromise(program);
⚠️ BREAKING CHANGE
In rc.1 we've finally reworked our legacy casing API of const db = drizzle({..., casing: "camel" }) which turned out to not be a proper solution, it required duplication in drizzle-orm instantiation and drizzle-kit config and introduced and set of endless bugs all around query builder chain. All of the above is now fixed with new API:
import * as d from "drizzle-orm/pg-core";
const users = d.snakeCase.table("users", {
id: d.serial().primaryKey(),
email: d.text().unique(),
fullName: d.text(), // full_name in db
createdAt: d.timestamp().defaultNow(), // created_at in db
})
// --- for namespaces/schemas you can use
const schema2 = d.camelCase.schema("schema2");
const usersInSchema2 = schema2.table("users", ...);
const ordersInSchema2 = schema2.table("orders", ...);
// ^ all entities in schema2 will be snake_cased
// --- all available entities
import { snakeCase, camelCase } from "drizzle-orm/pg-core";
snakeCase.view
snakeCase.materializedView
snakeCase.schema
snakeCase.table
camelCase.view
camelCase.materializedView
camelCase.schema
camelCase.table
Note: The Netlify Database driver is developed and maintained by the Netlify team.
Installation:
npm install @netlify/database
Usage example:
import { drizzle } from 'drizzle-orm/netlify-db';
const db = drizzle();
const result = await db.execute('select 1');
import { drizzle } from 'drizzle-orm/netlify-db';
const db = drizzle(process.env.DATABASE_URL);
const result = await db.execute('select 1');
import { drizzle } from 'drizzle-orm/netlify-db';
// Explicit client — consumer controls the driver
const db = drizzle({ client: netlifyDbClient });
const result = await db.execute('select 1');
postgres - resolves issues created by differences of data types returned by different drivers or different contexts of query (regular select, JSON object, postgres array). Currently only handles supported by drizzle constructors column types. (fixes #3018, #5090, #5287)postgresdb._query) from postgresmakePgArray, parsePgArray) from drizzle-orm/pg-core/utils[/array] to drizzle-orm/pg-core/arraypostgres sessions & prepared queriesneon-http bytea data corruptionbun-sql/postgres timestamp timezone truncation, json[b] data double stringificationdb instance to table \ view \ schema via import { snakeCase, camelCase } from "drizzle-orm/dialect-core", fixed #5112 #5282 #4181 #4209effect-schema, effect-postgres (fixes #5414)Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
One column per quarter.