Skip to content

Commit 86a8714

Browse files
committedAug 8, 2024
Add release notes
1 parent d486e9b commit 86a8714

File tree

5 files changed

+133
-61
lines changed

5 files changed

+133
-61
lines changed
 

‎changelogs/drizzle-kit/0.24.0.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## Breaking changes (for SQLite users)
2+
3+
#### Fixed [Composite primary key order is not consistent](https://github.com/drizzle-team/drizzle-kit-mirror/issues/342) by removing `sort` in SQLite and to be consistant with the same logic in PostgreSQL and MySQL
4+
5+
The issue that may arise for SQLite users with any driver using composite primary keys is that the order in the database may differ from the Drizzle schema.
6+
7+
- If you are using `push`, you **MAY** be prompted to update your table with a new order of columns in the composite primary key. You will need to either change it manually in the database or push the changes, but this may lead to data loss, etc.
8+
9+
- If you are using `generate`, you **MAY** also be prompted to update your table with a new order of columns in the composite primary key. You can either keep that migration or skip it by emptying the SQL migration file.
10+
11+
If nothing works for you and you are blocked, please reach out to me @AndriiSherman. I will try to help you!
12+
13+
14+
## Bug fixes
15+
16+
- [[BUG] When using double type columns, import is not inserted](https://github.com/drizzle-team/drizzle-kit-mirror/issues/403) - thanks @Karibash
17+
- [[BUG] A number value is specified as the default for a column of type char](https://github.com/drizzle-team/drizzle-kit-mirror/issues/404) - thanks @Karibash
18+
- [[BUG]: Array default in migrations are wrong](https://github.com/drizzle-team/drizzle-orm/issues/2621) - thanks @L-Mario564
19+
- [[FEATURE]: Simpler default array fields](https://github.com/drizzle-team/drizzle-orm/issues/2709) - thanks @L-Mario564
20+
- [[BUG]: drizzle-kit generate succeeds but generates invalid SQL for default([]) - Postgres](https://github.com/drizzle-team/drizzle-orm/issues/2432) - thanks @L-Mario564
21+
- [[BUG]: Incorrect type for array column default value](https://github.com/drizzle-team/drizzle-orm/issues/2334) - thanks @L-Mario564
22+
- [[BUG]: error: column is of type integer[] but default expression is of type integer](https://github.com/drizzle-team/drizzle-orm/issues/2224) - thanks @L-Mario564
23+
- [[BUG]: Default value in array generating wrong migration file](https://github.com/drizzle-team/drizzle-orm/issues/1003) - thanks @L-Mario564
24+
- [[BUG]: enum as array, not possible?](https://github.com/drizzle-team/drizzle-orm/issues/1564) - thanks @L-Mario564

‎changelogs/drizzle-orm/0.33.0.md

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
## Breaking changes (for some of postgres.js users)
2+
3+
#### Bugs fixed for this breaking change
4+
5+
- [Open
6+
[BUG]: jsonb always inserted as a json string when using postgres-js](https://github.com/drizzle-team/drizzle-orm/issues/724)
7+
- [[BUG]: jsonb type on postgres implement incorrectly](https://github.com/drizzle-team/drizzle-orm/issues/1511)
8+
9+
If you were using `postgres-js` with `jsonb` fields, you might have seen stringified objects in your database, while drizzle insert and select operations were working as expected.
10+
11+
You need to convert those fields from strings to actual JSON objects. To do this, you can use the following query to update your database:
12+
13+
**if you are using jsonb:**
14+
```sql
15+
update table_name
16+
set jsonb_column = (jsonb_column #>> '{}')::jsonb;
17+
```
18+
19+
**if you are using json:**
20+
```sql
21+
update table_name
22+
set json_column = (json_column #>> '{}')::json;
23+
```
24+
25+
We've tested it in several cases, and it worked well, but only if all stringified objects are arrays or objects. If you have primitives like strings, numbers, booleans, etc., you can use this query to update all the fields
26+
27+
**if you are using jsonb:**
28+
```sql
29+
UPDATE table_name
30+
SET jsonb_column = CASE
31+
-- Convert to JSONB if it is a valid JSON object or array
32+
WHEN jsonb_column #>> '{}' LIKE '{%' OR jsonb_column #>> '{}' LIKE '[%' THEN
33+
(jsonb_column #>> '{}')::jsonb
34+
ELSE
35+
jsonb_column
36+
END
37+
WHERE
38+
jsonb_column IS NOT NULL;
39+
```
40+
41+
**if you are using json:**
42+
```sql
43+
UPDATE table_name
44+
SET json_column = CASE
45+
-- Convert to JSON if it is a valid JSON object or array
46+
WHEN json_column #>> '{}' LIKE '{%' OR json_column #>> '{}' LIKE '[%' THEN
47+
(json_column #>> '{}')::json
48+
ELSE
49+
json_column
50+
END
51+
WHERE json_column IS NOT NULL;
52+
```
53+
54+
If nothing works for you and you are blocked, please reach out to me @AndriiSherman. I will try to help you!
55+
56+
## Bug Fixes
57+
58+
- [[BUG]: boolean mode not working with prepared statements (bettersqlite)](https://github.com/drizzle-team/drizzle-orm/issues/2568) - thanks @veloii
59+
- [[BUG]: isTable helper function is not working](https://github.com/drizzle-team/drizzle-orm/issues/2672) - thanks @hajek-raven
60+
- [[BUG]: Documentation is outdated on inArray and notInArray Methods](https://github.com/drizzle-team/drizzle-orm/issues/2690) - thanks @RemiPeruto

‎drizzle-kit/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "drizzle-kit",
3-
"version": "0.23.2",
3+
"version": "0.24.0",
44
"homepage": "https://orm.drizzle.team",
55
"keywords": [
66
"drizzle",

‎drizzle-kit/src/serializer/sqliteSerializer.ts

+47-59
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ export const generateSqliteSnapshot = (
6565
as: is(generated.as, SQL)
6666
? `(${dialect.sqlToQuery(generated.as as SQL, 'indexes').sql})`
6767
: typeof generated.as === 'function'
68-
? `(${dialect.sqlToQuery(generated.as() as SQL, 'indexes').sql})`
69-
: `(${generated.as as any})`,
68+
? `(${dialect.sqlToQuery(generated.as() as SQL, 'indexes').sql})`
69+
: `(${generated.as as any})`,
7070
type: generated.mode ?? 'virtual',
7171
}
7272
: undefined,
@@ -79,9 +79,9 @@ export const generateSqliteSnapshot = (
7979
columnToSet.default = typeof column.default === 'string'
8080
? `'${column.default}'`
8181
: typeof column.default === 'object'
82-
|| Array.isArray(column.default)
83-
? `'${JSON.stringify(column.default)}'`
84-
: column.default;
82+
|| Array.isArray(column.default)
83+
? `'${JSON.stringify(column.default)}'`
84+
: column.default;
8585
}
8686
}
8787
columnsObject[column.name] = columnToSet;
@@ -90,24 +90,19 @@ export const generateSqliteSnapshot = (
9090
const existingUnique = indexesObject[column.uniqueName!];
9191
if (typeof existingUnique !== 'undefined') {
9292
console.log(
93-
`\n${
94-
withStyle.errorWarning(`We\'ve found duplicated unique constraint names in ${
95-
chalk.underline.blue(
96-
tableName,
97-
)
93+
`\n${withStyle.errorWarning(`We\'ve found duplicated unique constraint names in ${chalk.underline.blue(
94+
tableName,
95+
)
9896
} table.
99-
The unique constraint ${
100-
chalk.underline.blue(
101-
column.uniqueName,
102-
)
103-
} on the ${
104-
chalk.underline.blue(
105-
column.name,
106-
)
107-
} column is confilcting with a unique constraint name already defined for ${
108-
chalk.underline.blue(
109-
existingUnique.columns.join(','),
110-
)
97+
The unique constraint ${chalk.underline.blue(
98+
column.uniqueName,
99+
)
100+
} on the ${chalk.underline.blue(
101+
column.name,
102+
)
103+
} column is confilcting with a unique constraint name already defined for ${chalk.underline.blue(
104+
existingUnique.columns.join(','),
105+
)
111106
} columns\n`)
112107
}`,
113108
);
@@ -202,26 +197,21 @@ export const generateSqliteSnapshot = (
202197
const existingUnique = indexesObject[name];
203198
if (typeof existingUnique !== 'undefined') {
204199
console.log(
205-
`\n${
206-
withStyle.errorWarning(
207-
`We\'ve found duplicated unique constraint names in ${
208-
chalk.underline.blue(
209-
tableName,
210-
)
211-
} table. \nThe unique constraint ${
212-
chalk.underline.blue(
213-
name,
214-
)
215-
} on the ${
216-
chalk.underline.blue(
217-
columnNames.join(','),
218-
)
219-
} columns is confilcting with a unique constraint name already defined for ${
220-
chalk.underline.blue(
221-
existingUnique.columns.join(','),
222-
)
223-
} columns\n`,
200+
`\n${withStyle.errorWarning(
201+
`We\'ve found duplicated unique constraint names in ${chalk.underline.blue(
202+
tableName,
203+
)
204+
} table. \nThe unique constraint ${chalk.underline.blue(
205+
name,
206+
)
207+
} on the ${chalk.underline.blue(
208+
columnNames.join(','),
224209
)
210+
} columns is confilcting with a unique constraint name already defined for ${chalk.underline.blue(
211+
existingUnique.columns.join(','),
212+
)
213+
} columns\n`,
214+
)
225215
}`,
226216
);
227217
process.exit(1);
@@ -237,7 +227,7 @@ export const generateSqliteSnapshot = (
237227
primaryKeys.forEach((it) => {
238228
if (it.columns.length > 1) {
239229
primaryKeysObject[it.getName()] = {
240-
columns: it.columns.map((it) => it.name).sort(),
230+
columns: it.columns.map((it) => it.name),
241231
name: it.getName(),
242232
};
243233
} else {
@@ -464,26 +454,26 @@ export const fromDatabase = async (
464454
default: columnDefault === null
465455
? undefined
466456
: /^-?[\d.]+(?:e-?\d+)?$/.test(columnDefault)
467-
? Number(columnDefault)
468-
: ['CURRENT_TIME', 'CURRENT_DATE', 'CURRENT_TIMESTAMP'].includes(
457+
? Number(columnDefault)
458+
: ['CURRENT_TIME', 'CURRENT_DATE', 'CURRENT_TIMESTAMP'].includes(
469459
columnDefault,
470460
)
471-
? `(${columnDefault})`
472-
: columnDefault === 'false'
473-
? false
474-
: columnDefault === 'true'
475-
? true
476-
: columnDefault.startsWith("'") && columnDefault.endsWith("'")
477-
? columnDefault
478-
// ? columnDefault.substring(1, columnDefault.length - 1)
479-
: `(${columnDefault})`,
461+
? `(${columnDefault})`
462+
: columnDefault === 'false'
463+
? false
464+
: columnDefault === 'true'
465+
? true
466+
: columnDefault.startsWith("'") && columnDefault.endsWith("'")
467+
? columnDefault
468+
// ? columnDefault.substring(1, columnDefault.length - 1)
469+
: `(${columnDefault})`,
480470
autoincrement: isAutoincrement,
481471
name: columnName,
482472
type: mapSqlToSqliteType(columnType),
483473
primaryKey: false,
484474
notNull: isNotNull,
485475
generated: tableToGeneratedColumnsInfo[tableName]
486-
&& tableToGeneratedColumnsInfo[tableName][columnName]
476+
&& tableToGeneratedColumnsInfo[tableName][columnName]
487477
? {
488478
type: tableToGeneratedColumnsInfo[tableName][columnName].type,
489479
as: tableToGeneratedColumnsInfo[tableName][columnName].expression,
@@ -509,7 +499,6 @@ export const fromDatabase = async (
509499

510500
for (const [key, value] of Object.entries(tableToPk)) {
511501
if (value.length > 1) {
512-
value.sort();
513502
result[key].compositePrimaryKeys = {
514503
[`${key}_${value.join('_')}_pk`]: {
515504
columns: value,
@@ -580,10 +569,9 @@ export const fromDatabase = async (
580569
const columnsTo = fkByTableName[`${tableName}_${id}`].columnsTo;
581570
fkByTableName[
582571
`${tableName}_${id}`
583-
].name = `${tableName}_${
584-
columnsFrom.join(
585-
'_',
586-
)
572+
].name = `${tableName}_${columnsFrom.join(
573+
'_',
574+
)
587575
}_${refTableName}_${columnsTo.join('_')}_fk`;
588576
}
589577

‎drizzle-orm/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "drizzle-orm",
3-
"version": "0.32.2",
3+
"version": "0.33.0",
44
"description": "Drizzle ORM package for SQL databases",
55
"type": "module",
66
"scripts": {

0 commit comments

Comments
 (0)
Please sign in to comment.