Releases: drizzle-team/drizzle-orm
v1.0.0-rc.1
v1.0.0-rc.1
casing API(see below) and removes RQB v1 ._query for postgres
JIT mappers
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!
Effect v4
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);New Casing API
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.tableNew Netlify Database Driver
Note: The Netlify Database driver is developed and maintained by the Netlify team.
Installation:
npm install @netlify/databaseUsage 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');Bug fixes and improvements:
- Codec system for
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) - Optimized query mappers for
postgres - Opt-in JIT-generated mappers for all dialects
- Optimized RQBv2 mappers for all dialects
⚠️ BREAKING CHANGE: Removed RQBv1 (db._query) frompostgres- Moved pg array utils (
makePgArray,parsePgArray) fromdrizzle-orm/pg-core/utils[/array]todrizzle-orm/pg-core/array - Simplified
postgressessions & prepared queries - Fixed
neon-httpbyteadata corruption - Fixed
bun-sql/postgrestimestamp timezone truncation,json[b]data double stringification ⚠️ BREAKING CHANGE: Reworked casing API - moved casing control fromdbinstance totable\view\schemaviaimport { snakeCase, camelCase } from "drizzle-orm/dialect-core", fixed #5112 #5282 #4181 #4209- Switched from Effect V3 to Effect V4 beta for
effect-schema,effect-postgres(fixes #5414)
v1.0.0-rc.2
Updates
- Disabled default codec type selectors for custom columns (fixes #5711)
- Сallback type overload for codec selector in custom pg columns (
codec: (config) => config?.withTimeZone ? 'timestamptz' : 'timestamp') - Extended list of postgis types for codecs (improvement for #5711)
- Updated codecs:
geometry->geometry(point),geometry:tuple->geometry(point):tuple - Switched PG transactions from class properties back to class methods (fixes #5709)
- Updated
AWS Data Apicodecs, removed query typings, improved input param mapping - Removed prepared query
typingsfield from all builders - Added
columnargument toCastParam,CastArrayParamcodecs
Migration updates in SQLite
- Added migration conflict detection for SQLite. When migration history has multiple open branches,
drizzle-kit generatenow 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- If the conflict is expected and you want to continue anyway, pass
--ignore-conflictsto skip the conflict check for that command.
npx drizzle-kit generate --ignore-conflicts
npx drizzle-kit check --ignore-conflicts- Added proper SQLite migration tree merging. New snapshots now collect all open leaf snapshot IDs and write them as parents, instead of keeping only one latest parent. This means a new migration generated after branching can merge all open leaves and use the combined SQLite state for the next snapshot diff.
{
"prevIds": ["first-open-leaf-id", "second-open-leaf-id"]
}- Fixed
DrizzleQueryErrorandTransactionRollbackErrorconstructors to properly set the error name for better instanceof checks - Fixed error handling in aws-data-api to properly show database error messages
v1.0.0-beta.22
Bug fixed
-
drizzle-kit generate fails to generate correct migrations.js file on Windows
-
[BUG]: MSSQL real() column returns imprecise float64 values -- missing mapFromDriverValue
-
[BUG]: [Drizzle-kit][Pg] Altering a UNIQUE constraint: generated SQL ignores the new changes
-
[BUG]: Non-commutative migration false positive: create_index commutativity check ignores table name
-
Commutativity checks were updated for PostgreSQL and MySQL. Before,
create_indexstatements could be reported as non-commutative even when they targeted different tables, and--ignore-conflictscould still collapse multi-parent history down to a single parent. Now index/table/schema footprints are resolved more accurately, unrelated index branches are accepted, and--ignore-conflictspreserves all open leaf parents for the next migration -
fix: mark mssql and @types/mssql as optional peer dependencies
1.0.0-beta.21
More fixes for the drizzle-kit migration process and commutativity checks
- Adding a value to a PostgreSQL enum will no longer be treated as commutative
- Enum values added in different leaves will now be merged properly
1.0.0-beta.20
- Fixed
sql.identifier(),sql.as()escaping issues. Previously all the values passed to this functions were not properly escaped
causing a possible SQL Injection (CWE-89) vulnerability
Thanks to @EthanKim88, @0x90sh and @wgoodall01 for reaching out to us with a reproduction and suggested fix
0.45.2
- Fixed
sql.identifier(),sql.as()escaping issues. Previously all the values passed to this functions were not properly escaped
causing a possible SQL Injection (CWE-89) vulnerability
Thanks to @EthanKim88, @0x90sh and @wgoodall01 for reaching out to us with a reproduction and suggested fix
v1.0.0-beta.19
New Features
sqlcommenter support for PostgreSQL and MySQL
You can now add custom tags to the query. These tags will be appended to the end of each query, helping the database add metadata/tags to it. This will be especially useful with PlanetScale’s new Database Traffic Control feature
// raw string support
db.select().from().comment("key='val'");
db.select().from().comment("my_first_tag");
// developer friendly dedicated to tags
db.select().from().comment({ key: 'val' });Example:
db.select().from(comments).comment({ priority: 'high', category: "analytics" });select "id", "name" from "comments" /*priority='high',category='analytics'*/The only limitation is that you can't use comments with a prepared statement:
// can't be used
const p = db.select().from().prepare();
// ❌
p.comment({ key: 'val' }).execute();Bug fixes
- Fixed error message for the defineRelations function
- [BUG]: drizzle-kit push attempts to drop policies in excluded schemas (e.g. cron) despite schemaFilter: ["public"]
- [BUG]: error attempting to drizzle-kit migrate table with char array field generated using drizzle-kit generate
- [BUG]: Ignore Vim *.swp files in drizzle-kit generate
- [BUG]: drizzle-kit pull outputs access method name instead of operator class for ivfflat indexes
- [BUG]: drizzle-kit pull generates not enough data provided to build the relation
- drizzle-kit push fails with Turso/libSQL on table recreation: "cannot commit - no transaction is active"
- [BUG]: Cannot read properties of undefined (reading 'requestLayout') when running drizzle-kit introspect (MySQL)
- [BUG (beta)]: RDS Data API pulling schema error
- [BUG]: drizzle-kit commutative migrations takes only last leaf migration into account
Updates
-
Updated
migrate()function for mysql dialect to correctly manage multiple databases -
The behavior for reading schema files has been updated. From now only files with the following extensions will be processed:
.js.mjs.cjs.jsx.ts.mts.cts.tsx. All other file types will be ignored
v1.0.0-beta.18
New driver support for kit and studio
You can now use the node:sqlite driver to run migrations and browse Drizzle Studio. If node:sqlite is available at runtime, we will automatically detect it and use it.
Fixes
- resolved tsconfig path aliases in drizzle-kit loader using get-tsconfig + jiti alias mapping
- added fixtures and tests covering wildcard and non-wildcard path aliases
- ensured schema load succeeds for alias imports
- Updated to
hanji@0.0.8- native bunstringWidth,stripANSIsupport, errors for non-TTY environments - [BUG]: drizzle-kit@1.0.0-beta.13 regression in module resolution
- [BUG]: drizzle-kit does not support node:sqlite
drizzle-kit@0.31.10
- Updated to
hanji@0.0.8- native bunstringWidth,stripANSIsupport, errors for non-TTY environments - We've migrated away from
esbuild-registertotsxloader, it will now allow to usedrizzle-kitseamlessly with bothESMandCJSmodules - We've also added native
BunandDenolaunch support, which will not triggertsxloader and utilise nativebunanddenoimports capabilities and faster startup times
v1.0.0-beta.17
New SQLite driver node-sqlite
Usage example:
import { drizzle } from 'drizzle-orm/node-sqlite';
const db = drizzle("sqlite.db");
const result = db.select().from(...);If you need to provide your existing driver:
import { drizzle } from 'drizzle-orm/node-sqlite';
import { DatabaseSync } from 'node:sqlite';
const sqlite = new DatabaseSync('sqlite.db');
const db = drizzle({ client: sqlite });
const result = db.select().from(...);Fixes
We added a few checks to the migration upgrade logic introduced in beta.16. Now, when your migrations table is upgraded, we double-check that all entities in the table have been updated. If any are missing, we prompt you to pull all migrations into your environment so that we can properly update the drizzle_migrations table