drizzle-kit 0.17.0-6323eb6 → 0.17.0-8c0281d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +18619 -18387
- package/package.json +5 -3
- package/readme.md +88 -14
- package/utils.js +83 -35
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drizzle-kit",
|
|
3
|
-
"version": "0.17.0-
|
|
3
|
+
"version": "0.17.0-8c0281d",
|
|
4
4
|
"repository": "https://github.com/drizzle-team/drizzle-kit-mirror",
|
|
5
5
|
"author": "Drizzle Team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,11 +9,13 @@
|
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"migrate:old": "drizzle-kit generate:pg --out ./dev/migrations-pg --schema ./dev/migrations-pg/schema.ts",
|
|
12
|
+
"push": "node -r esbuild-register ./src/cli/index.ts push:mysql",
|
|
12
13
|
"migrate:old:mysql": "drizzle-kit generate:mysql --out ./dev/migrations-mysql --schema ./dev/migrations-mysql/schema.ts",
|
|
13
|
-
"start:pg": "node -r esbuild-register ./src/cli/index.ts generate:pg --out ./dev/
|
|
14
|
+
"start:pg": "node -r esbuild-register ./src/cli/index.ts generate:pg --out ./dev/migrations-pg --schema ./dev/migrations-pg/schema.ts",
|
|
15
|
+
"start:sqlite": "node -r esbuild-register ./src/cli/index.ts generate:sqlite --out ./dev/migrations-sqlite --schema ./dev/migrations-sqlite/schema.ts",
|
|
14
16
|
"start:mysql": "node -r esbuild-register ./src/cli/index.ts generate:mysql --out ./dev/introspect-mysql --schema ./dev/introspect-mysql/schema.ts",
|
|
15
17
|
"check:pg": "node -r esbuild-register ./src/cli/index.ts check --out ./dev/migrations --dialect pg",
|
|
16
|
-
"introspect:mysql": "node -r esbuild-register ./src/cli/index.ts introspect:mysql
|
|
18
|
+
"introspect:mysql": "node -r esbuild-register ./src/cli/index.ts introspect:mysql",
|
|
17
19
|
"introspect:pg": "node -r esbuild-register ./src/cli/index.ts introspect:pg --out ./dev/introspect-pg --connectionString=postgresql://postgres@localhost:5432/introspect",
|
|
18
20
|
"up:pg": "node -r esbuild-register ./src/cli/index.ts up:pg --out ./dev/migrations-pg",
|
|
19
21
|
"up:mysql": "node -r esbuild-register ./src/cli/index.ts up:mysql --out ./dev/migrations-mysql",
|
package/readme.md
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
## Drizzle Kit
|
|
2
|
+
|
|
2
3
|
DrizzleKit - is a CLI migrator tool for DrizzleORM. It is probably one and only tool that lets you completely automatically generate SQL migrations and covers ~95% of the common cases like delitions and renames by prompting user input.\
|
|
3
|
-
https://github.com/drizzle-team/drizzle-kit-mirror - is a mirror repository for issues.
|
|
4
|
+
<https://github.com/drizzle-team/drizzle-kit-mirror> - is a mirror repository for issues.
|
|
4
5
|
|
|
5
6
|
### How it works
|
|
7
|
+
|
|
6
8
|
`drizzle-kit` will traverse `schema folder` or `schema file`, generate schema snapshot and compare it to the previous version(if there's one).\
|
|
7
9
|
Based on the difference it will generate all needed SQL migrations and if there're any `automatically unresolvable` cases like `renames` it will prompt user for input.
|
|
8
10
|
|
|
9
11
|
For schema file:
|
|
12
|
+
|
|
10
13
|
```typescript
|
|
11
14
|
// ./src/db/schema.ts
|
|
12
15
|
|
|
@@ -26,17 +29,19 @@ export const authOtp = pgTable("auth_otp", {
|
|
|
26
29
|
userId: integer("user_id").references(() => users.id),
|
|
27
30
|
});
|
|
28
31
|
```
|
|
32
|
+
|
|
29
33
|
It will generate:
|
|
34
|
+
|
|
30
35
|
```SQL
|
|
31
36
|
CREATE TABLE IF NOT EXISTS auth_otp (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
"id" SERIAL PRIMARY KEY,
|
|
38
|
+
"phone" character varying(256),
|
|
39
|
+
"user_id" INT
|
|
35
40
|
);
|
|
36
41
|
|
|
37
42
|
CREATE TABLE IF NOT EXISTS users (
|
|
38
|
-
|
|
39
|
-
|
|
43
|
+
"id" SERIAL PRIMARY KEY,
|
|
44
|
+
"full_name" character varying(256)
|
|
40
45
|
);
|
|
41
46
|
|
|
42
47
|
DO $$ BEGIN
|
|
@@ -49,26 +54,69 @@ CREATE INDEX IF NOT EXISTS users_full_name_index ON users (full_name);
|
|
|
49
54
|
```
|
|
50
55
|
|
|
51
56
|
### Installation & configuration
|
|
57
|
+
|
|
52
58
|
```shell
|
|
53
|
-
|
|
59
|
+
npm install -D drizzle-kit
|
|
54
60
|
```
|
|
55
61
|
|
|
56
62
|
Running with CLI options
|
|
63
|
+
|
|
57
64
|
```shell
|
|
58
|
-
|
|
65
|
+
npm exec drizzle-kit generate:pg --out migrations-folder --schema src/db/schema.ts
|
|
59
66
|
```
|
|
60
67
|
|
|
61
68
|
Or put your file to `drizzle.config.json` configuration file:
|
|
69
|
+
|
|
62
70
|
```json
|
|
63
71
|
{
|
|
64
72
|
"out": "./migrations-folder",
|
|
65
73
|
"schema": "./src/db"
|
|
66
74
|
}
|
|
67
75
|
```
|
|
76
|
+
|
|
68
77
|
---
|
|
78
|
+
|
|
79
|
+
## Upgrading to 0.17.0
|
|
80
|
+
|
|
81
|
+
Before running any new migrations `drizzle-kit` will ask you to upgrade in a first place
|
|
82
|
+
|
|
83
|
+
Migration file structure < 0.17.0
|
|
84
|
+
|
|
85
|
+
```plaintext
|
|
86
|
+
📦 <project root>
|
|
87
|
+
└ 📂 migrations
|
|
88
|
+
└ 📂 20221207174503
|
|
89
|
+
├ 📜 migration.sql
|
|
90
|
+
├ 📜 snapshot.json
|
|
91
|
+
└ 📂 20230101104503
|
|
92
|
+
├ 📜 migration.sql
|
|
93
|
+
├ 📜 snapshot.json
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Migration file structure >= 0.17.0
|
|
97
|
+
|
|
98
|
+
```plaintext
|
|
99
|
+
📦 <project root>
|
|
100
|
+
└ 📂 migrations
|
|
101
|
+
└ 📂 meta
|
|
102
|
+
├ 📜 _journal.json
|
|
103
|
+
├ 📜 0000_snapshot.json
|
|
104
|
+
├ 📜 0001_snapshot.json
|
|
105
|
+
└ 📜 0000_icy_stranger.sql
|
|
106
|
+
└ 📜 0001_strange_avengers.sql
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
To easily migrate from previous folder structure to new you need to run `up` command in drizzle kit. It's a great helper to upgrade your migrations to new format on each drizzle kit major update
|
|
110
|
+
|
|
111
|
+

|
|
112
|
+
---
|
|
113
|
+
|
|
69
114
|
## List of commands
|
|
70
115
|
|
|
71
116
|
### Generate SQL migrations based on current .ts schema\
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
72
120
|
**`$ drizzle-kit generate:pg`** \
|
|
73
121
|
**`$ drizzle-kit generate:mysql`** \
|
|
74
122
|
**`$ drizzle-kit generate:sqlite`** \
|
|
@@ -76,6 +124,7 @@ Or put your file to `drizzle.config.json` configuration file:
|
|
|
76
124
|
`--config` [optional defalut=drizzle.config.json] config file path\
|
|
77
125
|
`--schema` path to typescript schema file or folder with multiple schema files\
|
|
78
126
|
`--out` [optional default=drizzle/] migrations folder
|
|
127
|
+
|
|
79
128
|
```shell
|
|
80
129
|
$ drizzle-kit generate:pg
|
|
81
130
|
## runs generate command with drizzle.config.json
|
|
@@ -91,40 +140,65 @@ $ drizzle-kit generate:pg --schema=./src/schema.ts --out=./migrations/
|
|
|
91
140
|
```
|
|
92
141
|
|
|
93
142
|
### Introspect existing database and generate typescript schema
|
|
94
|
-
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
**`$ drizzle-kit introspect:pg`** \
|
|
147
|
+
**`$ drizzle-kit introspect:mysql`**
|
|
148
|
+
|
|
95
149
|
```shell
|
|
96
150
|
drizzle-kit introspect:pg --out=migrations/ --connectionString=postgresql://user:pass@host:port/db_name
|
|
97
151
|
|
|
98
152
|
drizzle-kit introspect:pg --out=migrations/ --host=0.0.0.0 --port=5432 --user=postgres --password=pass --database=db_name --ssl
|
|
99
153
|
```
|
|
100
154
|
|
|
155
|
+

|
|
156
|
+
|
|
101
157
|
### Update stale snapshots
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
102
161
|
**`$ drizzle-kit up:pg`** \
|
|
103
162
|
**`$ drizzle-kit up:mysql`**\
|
|
104
163
|
**`$ drizzle-kit up:sqlite`**
|
|
105
164
|
|
|
106
165
|
`--out` [optional] migrations folder\
|
|
107
166
|
`--config` [optional defalut=drizzle.config.json] config file path
|
|
167
|
+
|
|
108
168
|
```shell
|
|
109
169
|
## migrations folder is taken from drizzle.config.json
|
|
110
|
-
drizzle-kit up:
|
|
170
|
+
drizzle-kit up:mysql
|
|
111
171
|
|
|
112
|
-
drizzle-kit up:
|
|
172
|
+
drizzle-kit up:mysql --out=migrations/
|
|
113
173
|
```
|
|
114
174
|
|
|
175
|
+

|
|
176
|
+
|
|
177
|
+
### Drop migration
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
**`$ drizzle-kit drop`** \
|
|
182
|
+
|
|
183
|
+
`--out` [optional] migrations folder\
|
|
184
|
+
`--config` [optional defalut=drizzle.config.json] config file path
|
|
185
|
+
|
|
186
|
+

|
|
187
|
+
|
|
115
188
|
### Migrations collisions check
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
116
192
|
**`$ drizzle-kit check:pg`**\
|
|
117
193
|
**`$ drizzle-kit check:mysql`**\
|
|
118
194
|
**`$ drizzle-kit check:sqlite`**
|
|
119
195
|
|
|
120
196
|
`--out` [optional] migration folder\
|
|
121
197
|
`--config` [optional defalut=drizzle.config.json] config file path
|
|
198
|
+
|
|
122
199
|
```shell
|
|
123
200
|
## migrations folder is taken from drizzle.config.json
|
|
124
201
|
drizzle-kit check:pg
|
|
125
202
|
|
|
126
203
|
drizzle-kit check:pg --out=migrations/
|
|
127
204
|
```
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
package/utils.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -10358,6 +10357,13 @@ var compositePK = objectType({
|
|
|
10358
10357
|
name: stringType(),
|
|
10359
10358
|
columns: stringType().array()
|
|
10360
10359
|
}).strict();
|
|
10360
|
+
var tableV4 = objectType({
|
|
10361
|
+
name: stringType(),
|
|
10362
|
+
schema: stringType().optional(),
|
|
10363
|
+
columns: recordType(stringType(), column),
|
|
10364
|
+
indexes: recordType(stringType(), index),
|
|
10365
|
+
foreignKeys: recordType(stringType(), fk)
|
|
10366
|
+
}).strict();
|
|
10361
10367
|
var table = objectType({
|
|
10362
10368
|
name: stringType(),
|
|
10363
10369
|
schema: stringType().optional(),
|
|
@@ -10379,7 +10385,7 @@ var schemaInternalV3 = objectType({
|
|
|
10379
10385
|
var schemaInternalV4 = objectType({
|
|
10380
10386
|
version: literalType("4"),
|
|
10381
10387
|
dialect,
|
|
10382
|
-
tables: recordType(stringType(),
|
|
10388
|
+
tables: recordType(stringType(), tableV4),
|
|
10383
10389
|
schemas: recordType(stringType(), stringType())
|
|
10384
10390
|
}).strict();
|
|
10385
10391
|
var schemaInternal = objectType({
|
|
@@ -10396,6 +10402,13 @@ var schemaInternal = objectType({
|
|
|
10396
10402
|
var schemaV3 = schemaInternalV3.merge(schemaHash);
|
|
10397
10403
|
var schemaV4 = schemaInternalV4.merge(schemaHash);
|
|
10398
10404
|
var schema = schemaInternal.merge(schemaHash);
|
|
10405
|
+
var tableSquashedV4 = objectType({
|
|
10406
|
+
name: stringType(),
|
|
10407
|
+
schema: stringType().optional(),
|
|
10408
|
+
columns: recordType(stringType(), column),
|
|
10409
|
+
indexes: recordType(stringType(), stringType()),
|
|
10410
|
+
foreignKeys: recordType(stringType(), stringType())
|
|
10411
|
+
}).strict();
|
|
10399
10412
|
var tableSquashed = objectType({
|
|
10400
10413
|
name: stringType(),
|
|
10401
10414
|
schema: stringType().optional(),
|
|
@@ -10410,6 +10423,12 @@ var schemaSquashed = objectType({
|
|
|
10410
10423
|
tables: recordType(stringType(), tableSquashed),
|
|
10411
10424
|
schemas: recordType(stringType(), stringType())
|
|
10412
10425
|
}).strict();
|
|
10426
|
+
var schemaSquashedV4 = objectType({
|
|
10427
|
+
version: literalType("4"),
|
|
10428
|
+
dialect,
|
|
10429
|
+
tables: recordType(stringType(), tableSquashedV4),
|
|
10430
|
+
schemas: recordType(stringType(), stringType())
|
|
10431
|
+
}).strict();
|
|
10413
10432
|
var MySqlSquasher = {
|
|
10414
10433
|
squashIdx: (idx) => {
|
|
10415
10434
|
var _a, _b, _c;
|
|
@@ -10566,6 +10585,13 @@ var compositePK2 = objectType({
|
|
|
10566
10585
|
name: stringType(),
|
|
10567
10586
|
columns: stringType().array()
|
|
10568
10587
|
}).strict();
|
|
10588
|
+
var tableV42 = objectType({
|
|
10589
|
+
name: stringType(),
|
|
10590
|
+
schema: stringType(),
|
|
10591
|
+
columns: recordType(stringType(), column2),
|
|
10592
|
+
indexes: recordType(stringType(), index2),
|
|
10593
|
+
foreignKeys: recordType(stringType(), fk2)
|
|
10594
|
+
}).strict();
|
|
10569
10595
|
var table2 = objectType({
|
|
10570
10596
|
name: stringType(),
|
|
10571
10597
|
schema: stringType(),
|
|
@@ -10587,7 +10613,7 @@ var pgSchemaInternalV3 = objectType({
|
|
|
10587
10613
|
var pgSchemaInternalV4 = objectType({
|
|
10588
10614
|
version: literalType("4"),
|
|
10589
10615
|
dialect: literalType("pg"),
|
|
10590
|
-
tables: recordType(stringType(),
|
|
10616
|
+
tables: recordType(stringType(), tableV42),
|
|
10591
10617
|
enums: recordType(stringType(), enumSchema),
|
|
10592
10618
|
schemas: recordType(stringType(), stringType())
|
|
10593
10619
|
}).strict();
|
|
@@ -10611,6 +10637,20 @@ var tableSquashed2 = objectType({
|
|
|
10611
10637
|
foreignKeys: recordType(stringType(), stringType()),
|
|
10612
10638
|
compositePrimaryKeys: recordType(stringType(), stringType())
|
|
10613
10639
|
}).strict();
|
|
10640
|
+
var tableSquashedV42 = objectType({
|
|
10641
|
+
name: stringType(),
|
|
10642
|
+
schema: stringType(),
|
|
10643
|
+
columns: recordType(stringType(), column2),
|
|
10644
|
+
indexes: recordType(stringType(), stringType()),
|
|
10645
|
+
foreignKeys: recordType(stringType(), stringType())
|
|
10646
|
+
}).strict();
|
|
10647
|
+
var pgSchemaSquashedV4 = objectType({
|
|
10648
|
+
version: literalType("4"),
|
|
10649
|
+
dialect: enumType(["pg"]),
|
|
10650
|
+
tables: recordType(stringType(), tableSquashedV42),
|
|
10651
|
+
enums: recordType(stringType(), enumSchema),
|
|
10652
|
+
schemas: recordType(stringType(), stringType())
|
|
10653
|
+
}).strict();
|
|
10614
10654
|
var pgSchemaSquashed = objectType({
|
|
10615
10655
|
version: literalType("5"),
|
|
10616
10656
|
dialect: enumType(["pg"]),
|
|
@@ -11191,7 +11231,9 @@ var MySqlCreateTableConvertor = class extends Convertor {
|
|
|
11191
11231
|
`;
|
|
11192
11232
|
if (typeof compositePKs !== "undefined" && compositePKs.length > 0) {
|
|
11193
11233
|
const compositePK4 = MySqlSquasher.unsquashPK(compositePKs[0]);
|
|
11194
|
-
statement += `ALTER TABLE ${tName} ADD PRIMARY KEY(\`${compositePK4.columns.join(
|
|
11234
|
+
statement += `ALTER TABLE ${tName} ADD PRIMARY KEY(\`${compositePK4.columns.join(
|
|
11235
|
+
"`,`"
|
|
11236
|
+
)}\`);`;
|
|
11195
11237
|
statement += `
|
|
11196
11238
|
`;
|
|
11197
11239
|
}
|
|
@@ -11285,7 +11327,7 @@ var DropTableConvertor = class extends Convertor {
|
|
|
11285
11327
|
}
|
|
11286
11328
|
convert(statement) {
|
|
11287
11329
|
const { tableName } = statement;
|
|
11288
|
-
return `DROP TABLE
|
|
11330
|
+
return `DROP TABLE \`${tableName}\`;`;
|
|
11289
11331
|
}
|
|
11290
11332
|
};
|
|
11291
11333
|
var PgRenameTableConvertor = class extends Convertor {
|
|
@@ -11393,12 +11435,13 @@ var MySqlAlterTableAddColumnConvertor = class extends Convertor {
|
|
|
11393
11435
|
}
|
|
11394
11436
|
convert(statement) {
|
|
11395
11437
|
const { tableName, column: column4 } = statement;
|
|
11396
|
-
const { name, type, notNull, primaryKey, autoincrement } = column4;
|
|
11397
|
-
const defaultStatement = `${column4.default !== void 0 ? `DEFAULT ${column4.default}` : ""}`;
|
|
11398
|
-
const notNullStatement = `${notNull ? "NOT NULL" : ""}`;
|
|
11399
|
-
const primaryKeyStatement = `${primaryKey ? "PRIMARY KEY" : ""}`;
|
|
11400
|
-
const autoincrementStatement = `${autoincrement ? "AUTO_INCREMENT" : ""}`;
|
|
11401
|
-
|
|
11438
|
+
const { name, type, notNull, primaryKey, autoincrement, onUpdate } = column4;
|
|
11439
|
+
const defaultStatement = `${column4.default !== void 0 ? ` DEFAULT ${column4.default}` : ""}`;
|
|
11440
|
+
const notNullStatement = `${notNull ? " NOT NULL" : ""}`;
|
|
11441
|
+
const primaryKeyStatement = `${primaryKey ? " PRIMARY KEY" : ""}`;
|
|
11442
|
+
const autoincrementStatement = `${autoincrement ? " AUTO_INCREMENT" : ""}`;
|
|
11443
|
+
const onUpdateStatement = `${onUpdate ? " ON UPDATE CURRENT_TIMESTAMP" : ""}`;
|
|
11444
|
+
return `ALTER TABLE ${tableName} ADD \`${name}\` ${type}${primaryKeyStatement}${autoincrementStatement}${defaultStatement}${notNullStatement}${onUpdateStatement};`;
|
|
11402
11445
|
}
|
|
11403
11446
|
};
|
|
11404
11447
|
var SQLiteAlterTableAddColumnConvertor = class extends Convertor {
|
|
@@ -11473,27 +11516,9 @@ var PgAlterTableAlterColumnDropDefaultConvertor = class extends Convertor {
|
|
|
11473
11516
|
return `ALTER TABLE ${tableName} ALTER COLUMN "${columnName}" DROP DEFAULT;`;
|
|
11474
11517
|
}
|
|
11475
11518
|
};
|
|
11476
|
-
var MySqlAlterTableAlterColumnSetDefaultConvertor = class extends Convertor {
|
|
11477
|
-
can(statement, dialect3) {
|
|
11478
|
-
return statement.type === "alter_table_alter_column_set_default" && dialect3 === "mysql";
|
|
11479
|
-
}
|
|
11480
|
-
convert(statement) {
|
|
11481
|
-
const { tableName, columnName } = statement;
|
|
11482
|
-
return `ALTER TABLE ${tableName} ALTER COLUMN \`${columnName}\` SET DEFAULT ${statement.newDefaultValue};`;
|
|
11483
|
-
}
|
|
11484
|
-
};
|
|
11485
|
-
var MySqlAlterTableAlterColumnDropDefaultConvertor = class extends Convertor {
|
|
11486
|
-
can(statement, dialect3) {
|
|
11487
|
-
return statement.type === "alter_table_alter_column_drop_default" && dialect3 === "mysql";
|
|
11488
|
-
}
|
|
11489
|
-
convert(statement) {
|
|
11490
|
-
const { tableName, columnName } = statement;
|
|
11491
|
-
return `ALTER TABLE ${tableName} ALTER COLUMN \`${columnName}\` DROP DEFAULT;`;
|
|
11492
|
-
}
|
|
11493
|
-
};
|
|
11494
11519
|
var MySqlModifyColumn = class extends Convertor {
|
|
11495
11520
|
can(statement, dialect3) {
|
|
11496
|
-
return (statement.type === "alter_table_alter_column_set_type" || statement.type === "alter_table_alter_column_set_notnull" || statement.type === "alter_table_alter_column_drop_notnull" || statement.type === "alter_table_alter_column_drop_on_update" || statement.type === "alter_table_alter_column_set_on_update" || statement.type === "alter_table_alter_column_set_autoincrement" || statement.type === "alter_table_alter_column_drop_autoincrement") && dialect3 === "mysql";
|
|
11521
|
+
return (statement.type === "alter_table_alter_column_set_type" || statement.type === "alter_table_alter_column_set_notnull" || statement.type === "alter_table_alter_column_drop_notnull" || statement.type === "alter_table_alter_column_drop_on_update" || statement.type === "alter_table_alter_column_set_on_update" || statement.type === "alter_table_alter_column_set_autoincrement" || statement.type === "alter_table_alter_column_drop_autoincrement" || statement.type === "alter_table_alter_column_set_default" || statement.type === "alter_table_alter_column_drop_default") && dialect3 === "mysql";
|
|
11497
11522
|
}
|
|
11498
11523
|
convert(statement) {
|
|
11499
11524
|
const { tableName, columnName } = statement;
|
|
@@ -11538,6 +11563,18 @@ var MySqlModifyColumn = class extends Convertor {
|
|
|
11538
11563
|
columnType = ` ${statement.newDataType}`;
|
|
11539
11564
|
columnDefault = statement.columnDefault ? ` DEFAULT ${statement.columnDefault}` : "";
|
|
11540
11565
|
columnAutoincrement = "";
|
|
11566
|
+
} else if (statement.type === "alter_table_alter_column_set_default") {
|
|
11567
|
+
columnNotNull = statement.columnNotNull ? ` NOT NULL` : "";
|
|
11568
|
+
columnOnUpdate = columnOnUpdate = statement.columnOnUpdate ? ` ON UPDATE CURRENT_TIMESTAMP` : "";
|
|
11569
|
+
columnType = ` ${statement.newDataType}`;
|
|
11570
|
+
columnDefault = ` DEFAULT ${statement.newDefaultValue}`;
|
|
11571
|
+
columnAutoincrement = statement.columnAutoIncrement ? " AUTO_INCREMENT" : "";
|
|
11572
|
+
} else if (statement.type === "alter_table_alter_column_drop_default") {
|
|
11573
|
+
columnNotNull = statement.columnNotNull ? ` NOT NULL` : "";
|
|
11574
|
+
columnOnUpdate = columnOnUpdate = statement.columnOnUpdate ? ` ON UPDATE CURRENT_TIMESTAMP` : "";
|
|
11575
|
+
columnType = ` ${statement.newDataType}`;
|
|
11576
|
+
columnDefault = "";
|
|
11577
|
+
columnAutoincrement = statement.columnAutoIncrement ? " AUTO_INCREMENT" : "";
|
|
11541
11578
|
} else {
|
|
11542
11579
|
columnType = ` ${statement.newDataType}`;
|
|
11543
11580
|
columnNotNull = statement.columnNotNull ? ` NOT NULL` : "";
|
|
@@ -12102,8 +12139,6 @@ convertors.push(new PgAlterTableAlterColumnDropNotNullConvertor());
|
|
|
12102
12139
|
convertors.push(new PgAlterTableAlterColumnSetDefaultConvertor());
|
|
12103
12140
|
convertors.push(new PgAlterTableAlterColumnDropDefaultConvertor());
|
|
12104
12141
|
convertors.push(new MySqlModifyColumn());
|
|
12105
|
-
convertors.push(new MySqlAlterTableAlterColumnSetDefaultConvertor());
|
|
12106
|
-
convertors.push(new MySqlAlterTableAlterColumnDropDefaultConvertor());
|
|
12107
12142
|
convertors.push(new PgCreateForeignKeyConvertor());
|
|
12108
12143
|
convertors.push(new MySqlCreateForeignKeyConvertor());
|
|
12109
12144
|
convertors.push(new PgAlterForeignKeyConvertor());
|
|
@@ -12376,7 +12411,11 @@ var _prepareAlterColumns = (tableName, schema3, columns, json2) => {
|
|
|
12376
12411
|
tableName,
|
|
12377
12412
|
columnName,
|
|
12378
12413
|
newDefaultValue: column4.default.value,
|
|
12379
|
-
schema: schema3
|
|
12414
|
+
schema: schema3,
|
|
12415
|
+
columnOnUpdate,
|
|
12416
|
+
columnNotNull,
|
|
12417
|
+
columnAutoIncrement,
|
|
12418
|
+
newDataType: columnType
|
|
12380
12419
|
});
|
|
12381
12420
|
}
|
|
12382
12421
|
if (((_c = column4.default) == null ? void 0 : _c.type) === "changed") {
|
|
@@ -12385,7 +12424,11 @@ var _prepareAlterColumns = (tableName, schema3, columns, json2) => {
|
|
|
12385
12424
|
tableName,
|
|
12386
12425
|
columnName,
|
|
12387
12426
|
newDefaultValue: column4.default.new,
|
|
12388
|
-
schema: schema3
|
|
12427
|
+
schema: schema3,
|
|
12428
|
+
columnOnUpdate,
|
|
12429
|
+
columnNotNull,
|
|
12430
|
+
columnAutoIncrement,
|
|
12431
|
+
newDataType: columnType
|
|
12389
12432
|
});
|
|
12390
12433
|
}
|
|
12391
12434
|
if (((_d = column4.default) == null ? void 0 : _d.type) === "deleted") {
|
|
@@ -12393,7 +12436,12 @@ var _prepareAlterColumns = (tableName, schema3, columns, json2) => {
|
|
|
12393
12436
|
type: "alter_table_alter_column_drop_default",
|
|
12394
12437
|
tableName,
|
|
12395
12438
|
columnName,
|
|
12396
|
-
schema: schema3
|
|
12439
|
+
schema: schema3,
|
|
12440
|
+
columnDefault,
|
|
12441
|
+
columnOnUpdate,
|
|
12442
|
+
columnNotNull,
|
|
12443
|
+
columnAutoIncrement,
|
|
12444
|
+
newDataType: columnType
|
|
12397
12445
|
});
|
|
12398
12446
|
}
|
|
12399
12447
|
if (((_e = column4.notNull) == null ? void 0 : _e.type) === "added") {
|