이 버전에서 많은 변경사항이 도입되었으며, 일부 기능이 동작하지 않을 수 있습니다. 문제가 발생하면
1.0.0-beta.1또는0.44.7버전으로 다운그레이드할 수 있으며, GitHub나 Discord에 이슈를 제보해 주세요!
1.0.0-beta.1릴리스 노트도 함께 확인하세요: https://github.com/drizzle-team/drizzle-orm/blob/beta/changelogs/drizzle-orm/1.0.0-beta.1.md
RQBv1에서 RQBv2로의 마이그레이션 가이드를 확인하세요: https://orm.drizzle.team/docs/relations-v1-v2
새로운 RQBv2 스키마 문서를 확인하세요: https://orm.drizzle.team/docs/relations-v2
새로운 RQBv2 쿼리 문서를 확인하세요: https://orm.drizzle.team/docs/rqb-v2
새로운 기능
MSSQL dialect
Drizzle이 이제 drizzle-orm, drizzle-kit, drizzle-seed 패키지에서 MSSQL을 지원합니다. 대부분의 컬럼, 쿼리 빌더 기능, 마이그레이션 전략 등을 지원합니다.
아직 지원되지 않는 기능은 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이 이제 drizzle-orm, drizzle-kit, drizzle-seed 패키지에서 CockroachDB를 지원합니다. 대부분의 컬럼, 쿼리 빌더 기능, 마이그레이션 전략 등을 지원합니다.
아직 지원되지 않는 기능은 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');관계형 쿼리 파트
관계 설정을 여러 부분으로 분리해야 하는 경우 defineRelationsPart 헬퍼를 사용할 수 있습니다.
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,
}),
}
}));그런 다음 db 인스턴스에 제공할 수 있습니다.
const db = drizzle(process.env.DB_URL, { relations: { ...relations, ...part } })폴더 v3 마이그레이션
관련 논의: https://github.com/drizzle-team/drizzle-orm/discussions/2832
마이그레이션 폴더 구조를 다음과 같이 업데이트했습니다:
- journal.json 제거
- SQL 파일과 스냅샷을 별도의 마이그레이션 폴더로 그룹화
drizzle-kit drop명령어 제거
이러한 변경사항은 journal 파일과의 잠재적인 Git 충돌을 제거하고 충돌된 마이그레이션을 삭제하거나 수정하는 프로세스를 단순화합니다.
향후 베타 릴리스에서는 팀 마이그레이션 충돌을 안내하고, 가능한 충돌을 감지하며, 해결 방법을 제안하는 교환법칙 검사 기능을 도입할 예정입니다.
교환법칙 논의: https://github.com/drizzle-team/drizzle-orm/discussions/5005
이전 폴더를 새로운 형식으로 마이그레이션하려면 다음을 실행해야 합니다.
drizzle-kit up전체 drizzle-kit 재작성
주요 kit 및 마이그레이션 이슈를 해결하기 위한 아키텍처 재작성입니다. 더 빠른 반복 개발, 테스트 커버리지 개선, 전반적인 안정성 향상을 위한 가치 있고 필요한 업데이트를 완료했습니다.
완료된 작업 요약:
- 데이터베이스 스냅샷에서 데이터베이스 DDL 스냅샷으로 마이그레이션
- diff 감지 및 적용을 위한 전체 아키텍처 재작업
- 기본값, 표현식, 타입 감지에 대한 상당한 개선 추가
- 데이터베이스 호출 및 쿼리 복잡도를 최소화하여 스키마 introspection 시간을 10초에서 1초 미만으로 단축
- push를 위한 쿼리 힌트 및 explain 지원 추가
- 테스트 커버리지 확대 - 각 테스트 케이스가 이제 최대 6가지 다른 시나리오를 실행 (예: push+push, pull+generate 등)
drizzle-kit pull --init 추가
이 플래그는 데이터베이스에 drizzle 마이그레이션 테이블을 생성하고 첫 번째 pull된 마이그레이션을 적용된 것으로 표시하므로, 거기서부터 계속 반복할 수 있습니다.
schemaFilter 동작 업데이트
drizzle-kit은 코드에 정의된 모든 스키마를 관리하기 시작합니다. 필터링하려면 schemaFilter를 사용할 수 있습니다.
이전에는 schemaFilter에 명시적으로 더 많은 스키마를 추가하지 않는 한 public 스키마만 관리되었습니다.
이제 glob 패턴도 지원하므로 원하는 방식으로 스키마를 필터링할 수 있습니다.
.enableRLS() 지원 중단
이전에는 RLS가 활성화된 PostgreSQL 테이블을 표시하려면 다음과 같이 해야 했습니다:
// 이전 구문
pgTable('name', {}).enableRLS()이 옵션을 다른 위치로 이동했습니다:
pgTable.withRLS('users', {});컬럼에 직접 별칭 지정
이제 간단한 방법으로 컬럼에 as 별칭을 추가할 수 있습니다:
const query = db
.select({ age: users.age.as('ageOfUser'), id: users.id.as('userId') })
.from(users)
.orderBy(asc(users.id.as('userId')));MySQL 새 컬럼 타입
몇 가지 MySQL 컬럼 타입을 추가했습니다:
- 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
추가 업데이트 및 수정사항
- node-postgres 트랜잭션에서 pg-native Pool 감지 수정
- select 필드에서 서브쿼리 허용
- 오타 수정: algorythm => algorithm
$onUpdate가SQL값을 처리하지 않는 문제 수정 (#2388 해결, L-Mario564가 #2911에서 테스트 구현)date,timestamp타입에 대한bun-sql:postgresql드라이버 응답에서pg매퍼가Date인스턴스를 처리하지 않는 문제 수정 (#4493 해결)
버그 수정
이 목록은 완전하지 않으며, 일부 이슈만 처리할 시간이 있었습니다. 이 목록은 향후 몇 주 동안 업데이트될 예정입니다.
-
[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]: Drizzle not pulling foreign key names using introspect command in ts + mysql
-
[BUG]: Invalid SQL query generated for MySQL when using “with” feature
-
[BUG]: with Relation in findMany Returns Flattened Array Instead of Key-Value Object
-
[BUG]: drizzle-orm@beta query object is empty in NuxtHub project
-
[BUG]: Big int precision loss when data fetched with json_agg
-
[BUG]: Incorrect column types when using
withfor table created with helper function -
[BUG]: Identifier is too long (should not exceed 63 characters)
-
[BUG]: Drizzle type inferrence doesn’t work properly with many tables
-
[BUG]: drizzle-kit generate when dropping table attempts to delete already deleted constraint
-
[BUG]: Incomplete inferred result type in query API when using optional columns
-
SQLite columns are not marked as unique, instead a unique index has been created
-
[BUG]:Error Typescript for query where in relation (version “drizzle-orm”: “^0.38.3”)
-
[BUG]: findFirst not return undefined or null when not data is found.
-
[BUG]: Type error when performing filter select according to docs
-
[BUG]: Incorrect Non-Nullable Type Inference for One-to-One Related Entities
-
[BUG]: Custom types not working when insert with onConflictDoUpdate in Sqlite
-
[BUG]: Drizzle-kit no longer supporting the special characters in enum values (MySQL)
-
[BUG]:push creates duplicate statements for unique column index
-
[BUG]: TypeError: Cannot read properties of undefined (reading ‘columns’)
-
push:mysql fails to drop a serial column and replace with another column type
-
Drizzle Studio giving error due to
CURRENT_TIMESTAMPin schema -
[BUG]: Mysql new .unique().notNull(),
add constraintis put beforeadd column, throwing error. -
There are three cases where drizzle-kit’s introspect:mysql does not work.
-
[BUG]:
findMany/findFirstincorrectly substituting table names in sql operator -
[BUG]: Incorrect bigint value retrieval using findMany with relations (postgresql)
-
[BUG]: Pressing
escapewhile in thepushconfirmation dialog runs the push -
[BUG]: arrayContains, arrayContained, arrayOverlaps aren’t there in queries find callbacks
-
[BUG]: UUID Error on push, but no issue via generate / migrate
-
[BUG]: default value in migration generates invalid sql.ts file
-
[BUG]: drizzle-kit triggers a _ZodError when uniqueIndex is used together with sql lower
-
[BUG]: drizzle-kit introspect TypeError: Cannot read properties of null (reading ‘camelCase’)
-
[BUG]: Types aren’t correctly inferred for nested
with: { where }clauses -
[BUG]: drizzle-kit introspection does not import “bigint” type when introspecting a MySql database.
-
[BUG]: migrations do not work - table already exists - ER_TABLE_EXISTS_ERROR - mysql
-
[BUG]: Do statement double dollar sign not escaping cases where you want a ”$” as a value
-
[BUG]: PG Numeric inferred as string, but is numeric at runtime
-
[BUG]: Unique key reconciliation with upstream schema is inconsistent
-
[BUG]: Aggregated results from many-to-one relations doesn’t return timestamp using postgres DB
-
[BUG]: Issues with nested conditions & placeholders in SQLite query
-
[BUG]: Geometry config type doesn’t appear to affect the output sql
-
[BUG]: relation query API default alias is different than regular alias
-
[BUG]: Typing issue when using tables with the same name across different schemas
-
[BUG]: Timestamp formatted differently if fetched as relation rather than directly
-
[BUG]: Adding new column and unique key on the new column generates invalid migration file
-
[BUG]: Query API does not include schema name when including child relations
-
[BUG]: Planetscale got packets out of order for ‘serial’ type on push
-
[BUG]: on cascade delete issue with multiple foreign keys and migrations
-
[BUG]: Schema name is not prepended to the table name when aliased const.
-
[BUG]:
Do not know how to serialize a BigInterrors when using BigInt indefault(0n)directive -
[BUG]: sql“ interpolates the wrong table name when used in extras
-
[FEATURE]: infer possible undefined columns value if is a boolean (not specifically true or false)
-
[BUG]: ER_WRONG_AUTO_KEY - Drizzle Kit not detecting primary keys
-
[BUG]: Unable to use orderBy clause on multiple relations when placed adjacently in a query (MySQL)
-
[BUG]: wrong typeHint when using relations (one and automatic limit: 1)
-
[BUG]:
columnspartial select gives bad type with dynamic conditions -
[BUG]:
mapWithisn’t working onextraswhen doing relational queries withfindFirstorfindMany -
[BUG]:
findFirstandfindManyisn’t correctly setting the table name when using sql directive -
[FEATURE]: Add back filtering by nested relations in relational queries
-
[BUG]: where clause on relational query overwrites the table name
-
[BUG]: error: column “role” cannot be cast automatically to type user_role
-
[BUG]: Relations inferring incorrect table with non-default Postgres schema
-
[BUG]: Relational queries break customTypes with underlying DECIMAL dataTypes
-
[BUG]: Relational query on sqlite/d1 with order-by has issues
-
Allow referencing deeply nested properties in relational queries
-
[BUG]: planetscale - now() and current_timestamp() doesn’t work when FSP is specified for timestamp
-
[BUG]: MySQL alter table fails where tablename is reserved word