Releases: drizzle-team/drizzle-orm
0.45.0
- Fixed pg-native Pool detection in node-postgres transactions
- Allowed subqueries in select fields
- Updated typo algorythm => algorithm
- Fixed
$onUpdatenot handlingSQLvalues (fixes #2388, tests implemented by L-Mario564 in #2911) - Fixed
pgmappers not handlingDateinstances inbun-sql:postgresqldriver responses fordate,timestamptypes (fixes #4493)
[email protected]
Bug fixes
- Fixed
algorythm=>algorithmtypo. - Fixed external dependencies in build configuration.
1.0.0-beta.2
We've introduced a lot of changes in this version, and something will definitely break. If anything goes wrong, you can either downgrade to version
1.0.0-beta.1or0.44.7, and please report any issues on GitHub or our Discord!
Don't forget to check
1.0.0-beta.1release notes as well: https://github.com/drizzle-team/drizzle-orm/blob/beta/changelogs/drizzle-orm/1.0.0-beta.1.md
Check the migration guide for RQBv1 to RQBv2 migration steps: https://orm.drizzle.team/docs/relations-v1-v2
Check new RQBv2 schema docs: https://orm.drizzle.team/docs/relations-v2
Check new RQBv2 query docs: https://orm.drizzle.team/docs/rqb-v2
New Features
MSSQL dialect
Drizzle now supports MSSQL in drizzle-orm, drizzle-kit and drizzle-seed packages. It support most of the columns, query builder capabilities, migration strategies, etc.
The only feature that is not yet supported is RQBv2
// Make sure to install the 'mssql' package
import { drizzle } from 'drizzle-orm/node-mssql';
const db = drizzle(process.env.DATABASE_URL);
const result = await db.execute('select 1');// Make sure to install the 'pg' package
import { drizzle } from 'drizzle-orm/node-mssql';
// You can specify any property from the mssql connection options
const db = drizzle({
connection: {
connectionString: process.env.DATABASE_URL,
ssl: true
}
});
const result = await db.execute('select 1');CockroachDB dialect
Drizzle now supports MSSQL in drizzle-orm, drizzle-kit and drizzle-seed packages. It support most of the columns, query builder capabilities, migration strategies, etc.
The only feature that is not yet supported is RQBv2
// Make sure to install the 'pg' package
import { drizzle } from 'drizzle-orm/cockroach';
const db = drizzle(process.env.DATABASE_URL);
const result = await db.execute('select 1');// Make sure to install the 'pg' package
import { drizzle } from 'drizzle-orm/cockroach';
// You can specify any property from the node-postgres connection options
const db = drizzle({
connection: {
connectionString: process.env.DATABASE_URL,
ssl: true
}
});
const result = await db.execute('select 1');Relational Query Parts
In a case you need to separate relations config into several parts you can use defineRelationsPart helpers
import { defineRelations, defineRelationsPart } from 'drizzle-orm';
import * as schema from "./schema";
export const relations = defineRelations(schema, (r) => ({
users: {
invitee: r.one.users({
from: r.users.invitedBy,
to: r.users.id,
}),
posts: r.many.posts(),
}
}));
export const part = defineRelationsPart(schema, (r) => ({
posts: {
author: r.one.users({
from: r.posts.authorId,
to: r.users.id,
}),
}
}));and then you can provide it to the db instance
const db = drizzle(process.env.DB_URL, { relations: { ...relations, ...part } })Folders v3 migrations
Linked discussion: #2832
We've updated the migrations folder structure by:
- removing journal.json
- grouping SQL files and snapshots into separate migration folders
- removing the
drizzle-kit dropcommand
These changes eliminate potential Git conflicts with the journal file and simplify the process of dropping or fixing conflicted migrations
In upcoming beta releases, we'll introduce commutativity checks to help guide you through team migration conflicts, detect possible collisions, and suggest ways to resolve them
Commutativity discussion: #5005
To migrate previous folders to a new format you would need to run
drizzle-kit up
Full drizzle-kit rewrite
Architecture rewrite to close major kit and migration issues. We’ve completed a set of valuable and necessary updates to help us iterate faster, improve test coverage, and enhance overall stability.
Summary of work completed:
- Migrated from database snapshots to database DDL snapshots
- Reworked the entire architecture for detecting and applying diffs
- Added significant improvements for defaults, expressions, and types detection
- Reduced schema introspection time from 10 seconds to under 1 second by minimizing database calls and query complexity
- Added query hints and explain support for push
- Expanded test coverage - each test case now runs up to 6 different scenarios (e.g., push+push, pull+generate, etc.)
Added drizzle-kit pull --init
This flag will create a drizzle migration table in the database and will mark first pulled migration as applied, so you can contrinue iterating from there
schemaFilter behavior update
drizzle-kit will start managing all the schemas defined in your code. If you want to filter them, you can use schemaFilter
Previously, only the public schema was managed unless you explicitly added more schemas to schemaFilter.
It now also supports glob patterns, allowing you to filter schemas in any way you like
.enableRLS() deprecation
Previously to mark PostgreSQL table with RLS enabled you would need to:
// OLD syntax
pgTable('name', {}).enableRLS()We moved this option to a different place
pgTable.withRLS('users', {});Alias directly on columns
You can now add as alias to the column in a simple way:
const query = db
.select({ age: users.age.as('ageOfUser'), id: users.id.as('userId') })
.from(users)
.orderBy(asc(users.id.as('userId')));
MySQL new column types
We've added a few more MySQL column types:
- blob: https://orm.drizzle.team/docs/column-types/mysql#blob
- tinyblob: https://orm.drizzle.team/docs/column-types/mysql#tinyblob
- mediumblob: https://orm.drizzle.team/docs/column-types/mysql#mediumblob
- longblob: https://orm.drizzle.team/docs/column-types/mysql#longblob
More Updates and Fixes
- Fixed pg-native Pool detection in node-postgres transactions
- Allowed subqueries in select fields
- Updated typo algorythm => algorithm
- Fixed
$onUpdatenot handlingSQLvalues (fixes #2388, tests implemented by L-Mario564 in #2911) - Fixed
pgmappers not handlingDateinstances inbun-sql:postgresqldriver responses fordate,timestamptypes (fixes #4493)
Bugs fixed
This list is not full, we just had a time to get through some of the issues. This list will be updated through the next few weeks
-
[BUG]: Drizzle-kit pulls postgres functions as Typescript methods
-
[BUG]: When setting the casing to snake_case, the constraint name for unique fields isn't converted
-
[BUG]:
drizzle-kit pushappendDROP SCHEMAat the end for other schema name -
[BUG]: MySQL enum defaults with value '0' are ignored during introspection
-
[BUG]: bunx drizzle-kit push Freezes at “Reading config file” in Version ^0.31.4
-
[BUG]: Introspect generated files don't show columns in Views as arrays
-
[BUG]:
drizzle-kit introspectempty''mysqlEnum nad default introspect error -
[BUG]: CHECK constraints with operator functions generate invalid SQL with parameterized values
-
[BUG]: tinyint, bigint doesn't include when run drizzle-kit pull
-
[BUG]:drizzle-kit pull missing one ' letter column with default empty text
-
[BUG]: Unable to create composite foreign key: order of SQL statements [Postgres]
-
[BUG]: drizzle-kit MySQL Serializer doesn't see PKs and CHECK constraints
-
[BUG]: unique key names for multiple columns doesn't respect casing configuration
-
[BUG]:
drizzle-kit generategenerates out of order/ incorrect migrations -
[[BUG]:
with:colum...
[email protected]
[email protected]
0.44.7
- fix durable sqlite transaction return value #3746 - thanks @joaocstro
0.44.6
[email protected]
- Add casing support to studio configuration and related functions
0.44.5
- Fixed invalid usage of
.one()indurable-sqlitesession - Fixed spread operator related crash in sqlite
blobcolumns - Better browser support for sqlite
blobcolumns - Improved sqlite
blobmapping
0.44.4
- Fix wrong DrizzleQueryError export. thanks @nathankleyn