drizzle-kit 0.22.0-3b0ba5f → 0.22.0-ed86dfa
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/bin.cjs +17549 -10966
- package/index.d.mts +9 -1
- package/index.d.ts +9 -1
- package/package.json +2 -1
- package/payload.js +168 -84
- package/payload.mjs +153 -69
- package/utils-studio.js +591 -12
- package/utils-studio.mjs +591 -12
- package/utils.js +0 -1
- package/utils.mjs +0 -1
package/payload.mjs
CHANGED
|
@@ -8530,7 +8530,7 @@ var init_utils4 = __esm({
|
|
|
8530
8530
|
|
|
8531
8531
|
// src/cli/views.ts
|
|
8532
8532
|
import { Prompt, render, SelectState, TaskView } from "hanji";
|
|
8533
|
-
var error, isRenamePromptItem, ResolveColumnSelect, tableKey, ResolveSelect, ResolveSchemasSelect;
|
|
8533
|
+
var error, isRenamePromptItem, ResolveColumnSelect, tableKey, ResolveSelect, ResolveSchemasSelect, Spinner, ProgressView;
|
|
8534
8534
|
var init_views = __esm({
|
|
8535
8535
|
"src/cli/views.ts"() {
|
|
8536
8536
|
"use strict";
|
|
@@ -8682,6 +8682,42 @@ Is ${source_default.bold.blue(
|
|
|
8682
8682
|
return this.state.items[this.state.selectedIdx];
|
|
8683
8683
|
}
|
|
8684
8684
|
};
|
|
8685
|
+
Spinner = class {
|
|
8686
|
+
constructor(frames) {
|
|
8687
|
+
this.frames = frames;
|
|
8688
|
+
this.offset = 0;
|
|
8689
|
+
this.tick = () => {
|
|
8690
|
+
this.iterator();
|
|
8691
|
+
};
|
|
8692
|
+
this.value = () => {
|
|
8693
|
+
return this.frames[this.offset];
|
|
8694
|
+
};
|
|
8695
|
+
this.iterator = () => {
|
|
8696
|
+
this.offset += 1;
|
|
8697
|
+
this.offset %= frames.length - 1;
|
|
8698
|
+
};
|
|
8699
|
+
}
|
|
8700
|
+
};
|
|
8701
|
+
ProgressView = class extends TaskView {
|
|
8702
|
+
constructor(progressText, successText) {
|
|
8703
|
+
super();
|
|
8704
|
+
this.progressText = progressText;
|
|
8705
|
+
this.successText = successText;
|
|
8706
|
+
this.spinner = new Spinner("\u28F7\u28EF\u28DF\u287F\u28BF\u28FB\u28FD\u28FE".split(""));
|
|
8707
|
+
this.timeout = setInterval(() => {
|
|
8708
|
+
this.spinner.tick();
|
|
8709
|
+
this.requestLayout();
|
|
8710
|
+
}, 128);
|
|
8711
|
+
this.on("detach", () => clearInterval(this.timeout));
|
|
8712
|
+
}
|
|
8713
|
+
render(status) {
|
|
8714
|
+
if (status === "pending") {
|
|
8715
|
+
const spin = this.spinner.value();
|
|
8716
|
+
return `[${spin}] ${this.progressText}`;
|
|
8717
|
+
}
|
|
8718
|
+
return `[${source_default.green("\u2713")}] ${this.successText}`;
|
|
8719
|
+
}
|
|
8720
|
+
};
|
|
8685
8721
|
}
|
|
8686
8722
|
});
|
|
8687
8723
|
|
|
@@ -8802,6 +8838,12 @@ var init_sqlite = __esm({
|
|
|
8802
8838
|
url: string6(),
|
|
8803
8839
|
authToken: string6()
|
|
8804
8840
|
}),
|
|
8841
|
+
object6({
|
|
8842
|
+
driver: literal5("d1-http"),
|
|
8843
|
+
accountId: string6(),
|
|
8844
|
+
databaseId: string6(),
|
|
8845
|
+
token: string6()
|
|
8846
|
+
}),
|
|
8805
8847
|
object6({
|
|
8806
8848
|
url: string6()
|
|
8807
8849
|
})
|
|
@@ -8851,6 +8893,7 @@ var init_common2 = __esm({
|
|
|
8851
8893
|
literal6("turso"),
|
|
8852
8894
|
literal6("libsql"),
|
|
8853
8895
|
literal6("d1"),
|
|
8896
|
+
literal6("d1-http"),
|
|
8854
8897
|
literal6("expo")
|
|
8855
8898
|
]);
|
|
8856
8899
|
postgresDriver = literal6("aws-data-api");
|
|
@@ -9837,6 +9880,7 @@ ${withStyle.errorWarning(
|
|
|
9837
9880
|
"time without time zone": "::time without time zone",
|
|
9838
9881
|
// "timestamp with time zone": "::timestamp with time zone",
|
|
9839
9882
|
"timestamp without time zone": "::timestamp without time zone",
|
|
9883
|
+
"timestamp(": "::timestamp without time zone",
|
|
9840
9884
|
// date: "::date",
|
|
9841
9885
|
// interval: "::interval",
|
|
9842
9886
|
// character: "::bpchar",
|
|
@@ -9849,15 +9893,15 @@ ${withStyle.errorWarning(
|
|
|
9849
9893
|
"character(": "::bpchar"
|
|
9850
9894
|
};
|
|
9851
9895
|
defaultForColumn = (column4) => {
|
|
9896
|
+
if (column4.column_default === null) {
|
|
9897
|
+
return void 0;
|
|
9898
|
+
}
|
|
9852
9899
|
if (column4.data_type === "serial" || column4.data_type === "smallserial" || column4.data_type === "bigserial") {
|
|
9853
9900
|
return void 0;
|
|
9854
9901
|
}
|
|
9855
9902
|
const hasDifferentDefaultCast = Object.keys(columnToDefault).find(
|
|
9856
9903
|
(it) => column4.data_type.startsWith(it)
|
|
9857
9904
|
);
|
|
9858
|
-
if (column4.column_default === null) {
|
|
9859
|
-
return void 0;
|
|
9860
|
-
}
|
|
9861
9905
|
const columnDefaultAsString = column4.column_default.toString();
|
|
9862
9906
|
if (columnDefaultAsString.endsWith(
|
|
9863
9907
|
hasDifferentDefaultCast ? columnToDefault[hasDifferentDefaultCast] : column4.data_type
|
|
@@ -11339,8 +11383,7 @@ var init_jsonDiffer = __esm({
|
|
|
11339
11383
|
};
|
|
11340
11384
|
findAlternationsInTable = (table4) => {
|
|
11341
11385
|
const columns = table4.columns ?? {};
|
|
11342
|
-
const
|
|
11343
|
-
const altered = Object.keys(columns).filter((it) => !(it.includes("__deleted") || it.includes("__added") || isSemanticallyEqual(it))).map((it) => {
|
|
11386
|
+
const altered = Object.keys(columns).filter((it) => !(it.includes("__deleted") || it.includes("__added"))).map((it) => {
|
|
11344
11387
|
return { name: it, ...columns[it] };
|
|
11345
11388
|
});
|
|
11346
11389
|
const deletedIndexes = Object.fromEntries(
|
|
@@ -11442,6 +11485,9 @@ var init_jsonDiffer = __esm({
|
|
|
11442
11485
|
return it;
|
|
11443
11486
|
}).map((it) => {
|
|
11444
11487
|
if ("type" in it) {
|
|
11488
|
+
if (it.type.__old.replace(" (", "(") === it.type.__new.replace(" (", "(")) {
|
|
11489
|
+
return void 0;
|
|
11490
|
+
}
|
|
11445
11491
|
return {
|
|
11446
11492
|
...it,
|
|
11447
11493
|
type: { type: "changed", old: it.type.__old, new: it.type.__new }
|
|
@@ -11604,7 +11650,7 @@ var init_jsonDiffer = __esm({
|
|
|
11604
11650
|
};
|
|
11605
11651
|
}
|
|
11606
11652
|
return it;
|
|
11607
|
-
});
|
|
11653
|
+
}).filter(Boolean);
|
|
11608
11654
|
return result[0];
|
|
11609
11655
|
};
|
|
11610
11656
|
}
|
|
@@ -12488,7 +12534,7 @@ var init_jsonStatements = __esm({
|
|
|
12488
12534
|
tableName,
|
|
12489
12535
|
data: it,
|
|
12490
12536
|
schema: schema4,
|
|
12491
|
-
constraintName: json2.tables[`${schema4}.${tableName}`].compositePrimaryKeys[unsquashed.name].name
|
|
12537
|
+
constraintName: json2.tables[`${schema4 || "public"}.${tableName}`].compositePrimaryKeys[unsquashed.name].name
|
|
12492
12538
|
};
|
|
12493
12539
|
});
|
|
12494
12540
|
};
|
|
@@ -12511,8 +12557,8 @@ var init_jsonStatements = __esm({
|
|
|
12511
12557
|
old: it.__old,
|
|
12512
12558
|
new: it.__new,
|
|
12513
12559
|
schema: schema4,
|
|
12514
|
-
oldConstraintName: json1.tables[`${schema4}.${tableName}`].compositePrimaryKeys[PgSquasher.unsquashPK(it.__old).name].name,
|
|
12515
|
-
newConstraintName: json2.tables[`${schema4}.${tableName}`].compositePrimaryKeys[PgSquasher.unsquashPK(it.__new).name].name
|
|
12560
|
+
oldConstraintName: json1.tables[`${schema4 || "public"}.${tableName}`].compositePrimaryKeys[PgSquasher.unsquashPK(it.__old).name].name,
|
|
12561
|
+
newConstraintName: json2.tables[`${schema4 || "public"}.${tableName}`].compositePrimaryKeys[PgSquasher.unsquashPK(it.__new).name].name
|
|
12516
12562
|
};
|
|
12517
12563
|
});
|
|
12518
12564
|
};
|
|
@@ -12793,7 +12839,7 @@ var init_snapshotsDiffer = __esm({
|
|
|
12793
12839
|
for (let ren of renamedTables) {
|
|
12794
12840
|
if (table4.name === ren.from.name && table4.schema === ren.from.schema) {
|
|
12795
12841
|
return {
|
|
12796
|
-
key: `${ren.to.schema}.${ren.to.name}`,
|
|
12842
|
+
key: `${ren.to.schema || "public"}.${ren.to.name}`,
|
|
12797
12843
|
name: ren.to.name,
|
|
12798
12844
|
schema: ren.to.schema
|
|
12799
12845
|
};
|
|
@@ -14165,8 +14211,7 @@ var init_sqlgenerator = __esm({
|
|
|
14165
14211
|
convert(st) {
|
|
14166
14212
|
const { tableName, columns, schema: schema4, compositePKs, uniqueConstraints } = st;
|
|
14167
14213
|
let statement = "";
|
|
14168
|
-
|
|
14169
|
-
statement += `CREATE TABLE ${tName} (
|
|
14214
|
+
statement += `CREATE TABLE \`${tableName}\` (
|
|
14170
14215
|
`;
|
|
14171
14216
|
for (let i = 0; i < columns.length; i++) {
|
|
14172
14217
|
const column4 = columns[i];
|
|
@@ -14286,8 +14331,7 @@ var init_sqlgenerator = __esm({
|
|
|
14286
14331
|
}
|
|
14287
14332
|
convert(statement) {
|
|
14288
14333
|
const unsquashed = MySqlSquasher.unsquashUnique(statement.data);
|
|
14289
|
-
|
|
14290
|
-
return `ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT \`${unsquashed.name}\` UNIQUE(\`${unsquashed.columns.join("`,`")}\`);`;
|
|
14334
|
+
return `ALTER TABLE \`${statement.tableName}\` ADD CONSTRAINT \`${unsquashed.name}\` UNIQUE(\`${unsquashed.columns.join("`,`")}\`);`;
|
|
14291
14335
|
}
|
|
14292
14336
|
};
|
|
14293
14337
|
MySQLAlterTableDropUniqueConstraintConvertor = class extends Convertor {
|
|
@@ -14296,8 +14340,7 @@ var init_sqlgenerator = __esm({
|
|
|
14296
14340
|
}
|
|
14297
14341
|
convert(statement) {
|
|
14298
14342
|
const unsquashed = MySqlSquasher.unsquashUnique(statement.data);
|
|
14299
|
-
|
|
14300
|
-
return `ALTER TABLE ${tableNameWithSchema} DROP INDEX \`${unsquashed.name}\`;`;
|
|
14343
|
+
return `ALTER TABLE \`${statement.tableName}\` DROP INDEX \`${unsquashed.name}\`;`;
|
|
14301
14344
|
}
|
|
14302
14345
|
};
|
|
14303
14346
|
SQLiteAlterTableAddUniqueConstraintConvertor = class extends Convertor {
|
|
@@ -14412,10 +14455,8 @@ var init_sqlgenerator = __esm({
|
|
|
14412
14455
|
return statement.type === "rename_table" && dialect7 === "mysql";
|
|
14413
14456
|
}
|
|
14414
14457
|
convert(statement) {
|
|
14415
|
-
const { tableNameFrom, tableNameTo
|
|
14416
|
-
|
|
14417
|
-
const to = fromSchema ? `\`${fromSchema}\`.\`${tableNameTo}\`` : `\`${tableNameTo}\``;
|
|
14418
|
-
return `RENAME TABLE ${from} TO ${to};`;
|
|
14458
|
+
const { tableNameFrom, tableNameTo } = statement;
|
|
14459
|
+
return `RENAME TABLE \`${tableNameFrom}\` TO \`${tableNameTo}\`;`;
|
|
14419
14460
|
}
|
|
14420
14461
|
};
|
|
14421
14462
|
PgAlterTableRenameColumnConvertor = class extends Convertor {
|
|
@@ -15223,9 +15264,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
|
15223
15264
|
return statement.type === "drop_index" && dialect7 === "mysql";
|
|
15224
15265
|
}
|
|
15225
15266
|
convert(statement) {
|
|
15226
|
-
const tableName = typeof statement.schema === "undefined" ? `\`${statement.tableName}\`` : `\`${statement.schema}\`.\`${statement.tableName}\``;
|
|
15227
15267
|
const { name: name2 } = MySqlSquasher.unsquashIdx(statement.data);
|
|
15228
|
-
return `DROP INDEX \`${name2}\` ON
|
|
15268
|
+
return `DROP INDEX \`${name2}\` ON \`${statement.tableName}\`;`;
|
|
15229
15269
|
}
|
|
15230
15270
|
};
|
|
15231
15271
|
convertors = [];
|
|
@@ -18880,12 +18920,24 @@ The unique constraint ${source_default.underline.blue(
|
|
|
18880
18920
|
`SELECT
|
|
18881
18921
|
m.name as "tableName", p.name as "columnName", p.type as "columnType", p."notnull" as "notNull", p.dflt_value as "defaultValue", p.pk as pk
|
|
18882
18922
|
FROM sqlite_master AS m JOIN pragma_table_info(m.name) AS p
|
|
18883
|
-
WHERE m.type = 'table'
|
|
18923
|
+
WHERE m.type = 'table'
|
|
18924
|
+
and m.tbl_name != 'sqlite_sequence'
|
|
18925
|
+
and m.tbl_name != 'sqlite_stat1'
|
|
18926
|
+
and m.tbl_name != '_litestream_seq'
|
|
18927
|
+
and m.tbl_name != '_litestream_lock'
|
|
18928
|
+
and m.tbl_name != 'libsql_wasm_func_table'
|
|
18929
|
+
and m.tbl_name != '__drizzle_migrations'
|
|
18930
|
+
and m.tbl_name != '_cf_KV';
|
|
18884
18931
|
`
|
|
18885
18932
|
);
|
|
18886
18933
|
const tablesWithSeq = [];
|
|
18887
18934
|
const seq = await db.query(
|
|
18888
|
-
`SELECT * FROM sqlite_master WHERE name != 'sqlite_sequence'
|
|
18935
|
+
`SELECT * FROM sqlite_master WHERE name != 'sqlite_sequence'
|
|
18936
|
+
and name != 'sqlite_stat1'
|
|
18937
|
+
and name != '_litestream_seq'
|
|
18938
|
+
and name != '_litestream_lock'
|
|
18939
|
+
and tbl_name != '_cf_KV'
|
|
18940
|
+
and sql GLOB '*[ *' || CHAR(9) || CHAR(10) || CHAR(13) || ']AUTOINCREMENT[^'']*';`
|
|
18889
18941
|
);
|
|
18890
18942
|
for (const s of seq) {
|
|
18891
18943
|
tablesWithSeq.push(s.name);
|
|
@@ -18970,7 +19022,8 @@ The unique constraint ${source_default.underline.blue(
|
|
|
18970
19022
|
try {
|
|
18971
19023
|
const fks = await db.query(
|
|
18972
19024
|
`SELECT m.name as "tableFrom", f.id as "id", f."table" as "tableTo", f."from", f."to", f."on_update" as "onUpdate", f."on_delete" as "onDelete", f.seq as "seq"
|
|
18973
|
-
FROM sqlite_master m, pragma_foreign_key_list(m.name) as f
|
|
19025
|
+
FROM sqlite_master m, pragma_foreign_key_list(m.name) as f
|
|
19026
|
+
where m.tbl_name != '_cf_KV';`
|
|
18974
19027
|
);
|
|
18975
19028
|
const fkByTableName = {};
|
|
18976
19029
|
for (const fkRow of fks) {
|
|
@@ -19029,7 +19082,9 @@ FROM sqlite_master AS m,
|
|
|
19029
19082
|
pragma_index_list(m.name) AS il,
|
|
19030
19083
|
pragma_index_info(il.name) AS ii
|
|
19031
19084
|
WHERE
|
|
19032
|
-
m.type = 'table'
|
|
19085
|
+
m.type = 'table'
|
|
19086
|
+
and il.name NOT LIKE 'sqlite_autoindex_%'
|
|
19087
|
+
and m.tbl_name != '_cf_KV';`
|
|
19033
19088
|
);
|
|
19034
19089
|
for (const idxRow of idxs) {
|
|
19035
19090
|
const tableName = idxRow.tableName;
|
|
@@ -23938,6 +23993,7 @@ var mysqlIntrospect_exports = {};
|
|
|
23938
23993
|
__export(mysqlIntrospect_exports, {
|
|
23939
23994
|
mysqlPushIntrospect: () => mysqlPushIntrospect
|
|
23940
23995
|
});
|
|
23996
|
+
import { renderWithTask as renderWithTask3 } from "hanji";
|
|
23941
23997
|
var mysqlPushIntrospect;
|
|
23942
23998
|
var init_mysqlIntrospect = __esm({
|
|
23943
23999
|
"src/cli/commands/mysqlIntrospect.ts"() {
|
|
@@ -23945,6 +24001,7 @@ var init_mysqlIntrospect = __esm({
|
|
|
23945
24001
|
init_mysqlSerializer();
|
|
23946
24002
|
init_global();
|
|
23947
24003
|
init_mjs();
|
|
24004
|
+
init_views();
|
|
23948
24005
|
mysqlPushIntrospect = async (db, databaseName, filters) => {
|
|
23949
24006
|
const matchers = filters.map((it) => {
|
|
23950
24007
|
return new Minimatch(it);
|
|
@@ -23959,7 +24016,14 @@ var init_mysqlIntrospect = __esm({
|
|
|
23959
24016
|
}
|
|
23960
24017
|
return false;
|
|
23961
24018
|
};
|
|
23962
|
-
const
|
|
24019
|
+
const progress = new ProgressView(
|
|
24020
|
+
"Pulling schema from database...",
|
|
24021
|
+
"Pulling schema from database..."
|
|
24022
|
+
);
|
|
24023
|
+
const res = await renderWithTask3(
|
|
24024
|
+
progress,
|
|
24025
|
+
fromDatabase3(db, databaseName, filter2)
|
|
24026
|
+
);
|
|
23963
24027
|
const schema4 = { id: originUUID, prevId: "", ...res };
|
|
23964
24028
|
const { internal, ...schemaWithoutInternals } = schema4;
|
|
23965
24029
|
return { schema: schemaWithoutInternals };
|
|
@@ -23980,6 +24044,8 @@ import { randomUUID } from "crypto";
|
|
|
23980
24044
|
init_pgSerializer();
|
|
23981
24045
|
init_global();
|
|
23982
24046
|
init_mjs();
|
|
24047
|
+
init_views();
|
|
24048
|
+
import { renderWithTask } from "hanji";
|
|
23983
24049
|
var pgPushIntrospect = async (db, filters, schemaFilters) => {
|
|
23984
24050
|
const matchers = filters.map((it) => {
|
|
23985
24051
|
return new Minimatch(it);
|
|
@@ -23994,7 +24060,14 @@ var pgPushIntrospect = async (db, filters, schemaFilters) => {
|
|
|
23994
24060
|
}
|
|
23995
24061
|
return false;
|
|
23996
24062
|
};
|
|
23997
|
-
const
|
|
24063
|
+
const progress = new ProgressView(
|
|
24064
|
+
"Pulling schema from database...",
|
|
24065
|
+
"Pulling schema from database..."
|
|
24066
|
+
);
|
|
24067
|
+
const res = await renderWithTask(
|
|
24068
|
+
progress,
|
|
24069
|
+
fromDatabase(db, filter2, schemaFilters)
|
|
24070
|
+
);
|
|
23998
24071
|
const schema4 = { id: originUUID, prevId: "", ...res };
|
|
23999
24072
|
const { internal, ...schemaWithoutInternals } = schema4;
|
|
24000
24073
|
return { schema: schemaWithoutInternals };
|
|
@@ -24412,7 +24485,7 @@ Array.prototype.random = function() {
|
|
|
24412
24485
|
|
|
24413
24486
|
// src/cli/commands/sqliteIntrospect.ts
|
|
24414
24487
|
init_mjs();
|
|
24415
|
-
import { renderWithTask } from "hanji";
|
|
24488
|
+
import { renderWithTask as renderWithTask2 } from "hanji";
|
|
24416
24489
|
var sqlitePushIntrospect = async (db, filters) => {
|
|
24417
24490
|
const matchers = filters.map((it) => {
|
|
24418
24491
|
return new Minimatch(it);
|
|
@@ -24427,7 +24500,14 @@ var sqlitePushIntrospect = async (db, filters) => {
|
|
|
24427
24500
|
}
|
|
24428
24501
|
return false;
|
|
24429
24502
|
};
|
|
24430
|
-
const
|
|
24503
|
+
const progress = new ProgressView(
|
|
24504
|
+
"Pulling schema from database...",
|
|
24505
|
+
"Pulling schema from database..."
|
|
24506
|
+
);
|
|
24507
|
+
const res = await renderWithTask2(
|
|
24508
|
+
progress,
|
|
24509
|
+
fromDatabase2(db, filter2)
|
|
24510
|
+
);
|
|
24431
24511
|
const schema4 = { id: originUUID, prevId: "", ...res };
|
|
24432
24512
|
return { schema: schema4 };
|
|
24433
24513
|
};
|
|
@@ -24544,7 +24624,7 @@ var logSuggestionsAndReturn = async (connection, statements, json1, json2, meta)
|
|
|
24544
24624
|
).find(
|
|
24545
24625
|
(c) => SQLiteSquasher.unsquashIdx(c).columns.includes(statement.columnName)
|
|
24546
24626
|
);
|
|
24547
|
-
const columnIsPk =
|
|
24627
|
+
const columnIsPk = json2.tables[newTableName].columns[statement.columnName].primaryKey;
|
|
24548
24628
|
const columnIsPartOfFk = Object.values(
|
|
24549
24629
|
json1.tables[newTableName].foreignKeys
|
|
24550
24630
|
).find(
|
|
@@ -24628,48 +24708,52 @@ var logSuggestionsAndReturn = async (connection, statements, json1, json2, meta)
|
|
|
24628
24708
|
}
|
|
24629
24709
|
}
|
|
24630
24710
|
} else if (statement.type === "alter_table_alter_column_set_type" || statement.type === "alter_table_alter_column_set_default" || statement.type === "alter_table_alter_column_drop_default" || statement.type === "alter_table_alter_column_set_notnull" || statement.type === "alter_table_alter_column_drop_notnull" || statement.type === "alter_table_alter_column_drop_autoincrement" || statement.type === "alter_table_alter_column_set_autoincrement" || statement.type === "alter_table_alter_column_drop_pk" || statement.type === "alter_table_alter_column_set_pk") {
|
|
24631
|
-
|
|
24632
|
-
|
|
24633
|
-
|
|
24634
|
-
|
|
24635
|
-
|
|
24636
|
-
const count2 = Number(res[0].count);
|
|
24637
|
-
if (count2 > 0) {
|
|
24638
|
-
infoToPrint.push(
|
|
24639
|
-
`\xB7 You're about to add not-null constraint to ${source_default.underline(
|
|
24640
|
-
statement.columnName
|
|
24641
|
-
)} column without default value, which contains ${count2} items`
|
|
24711
|
+
if (!(statement.type === "alter_table_alter_column_set_notnull" && statement.columnPk)) {
|
|
24712
|
+
const newTableName = getOldTableName(statement.tableName, meta);
|
|
24713
|
+
if (statement.type === "alter_table_alter_column_set_notnull" && typeof statement.columnDefault === "undefined") {
|
|
24714
|
+
const res = await connection.query(
|
|
24715
|
+
`select count(*) as count from \`${newTableName}\``
|
|
24642
24716
|
);
|
|
24643
|
-
|
|
24644
|
-
|
|
24645
|
-
|
|
24646
|
-
|
|
24647
|
-
|
|
24648
|
-
|
|
24649
|
-
|
|
24650
|
-
|
|
24651
|
-
|
|
24652
|
-
|
|
24717
|
+
const count2 = Number(res[0].count);
|
|
24718
|
+
if (count2 > 0) {
|
|
24719
|
+
infoToPrint.push(
|
|
24720
|
+
`\xB7 You're about to add not-null constraint to ${source_default.underline(
|
|
24721
|
+
statement.columnName
|
|
24722
|
+
)} column without default value, which contains ${count2} items`
|
|
24723
|
+
);
|
|
24724
|
+
tablesToTruncate.push(newTableName);
|
|
24725
|
+
shouldAskForApprove = true;
|
|
24726
|
+
}
|
|
24653
24727
|
tablesContext[newTableName] = _moveDataStatements(
|
|
24654
24728
|
statement.tableName,
|
|
24655
|
-
json2
|
|
24729
|
+
json2,
|
|
24730
|
+
true
|
|
24656
24731
|
);
|
|
24732
|
+
} else {
|
|
24733
|
+
if (typeof tablesContext[newTableName] === "undefined") {
|
|
24734
|
+
tablesContext[newTableName] = _moveDataStatements(
|
|
24735
|
+
statement.tableName,
|
|
24736
|
+
json2
|
|
24737
|
+
);
|
|
24738
|
+
}
|
|
24657
24739
|
}
|
|
24658
|
-
|
|
24659
|
-
|
|
24660
|
-
|
|
24661
|
-
|
|
24662
|
-
|
|
24663
|
-
|
|
24664
|
-
|
|
24665
|
-
|
|
24666
|
-
|
|
24667
|
-
|
|
24668
|
-
|
|
24669
|
-
|
|
24670
|
-
|
|
24671
|
-
|
|
24672
|
-
tablesContext[table4]
|
|
24740
|
+
const tablesReferncingCurrent = [];
|
|
24741
|
+
for (const table4 of Object.values(json1.tables)) {
|
|
24742
|
+
const tablesRefs = Object.values(json1.tables[table4.name].foreignKeys).filter(
|
|
24743
|
+
(t) => SQLiteSquasher.unsquashFK(t).tableTo === newTableName
|
|
24744
|
+
).map((t) => {
|
|
24745
|
+
return getNewTableName(
|
|
24746
|
+
SQLiteSquasher.unsquashFK(t).tableFrom,
|
|
24747
|
+
meta
|
|
24748
|
+
);
|
|
24749
|
+
});
|
|
24750
|
+
tablesReferncingCurrent.push(...tablesRefs);
|
|
24751
|
+
}
|
|
24752
|
+
const uniqueTableRefs = [...new Set(tablesReferncingCurrent)];
|
|
24753
|
+
for (const table4 of uniqueTableRefs) {
|
|
24754
|
+
if (typeof tablesContext[table4] === "undefined") {
|
|
24755
|
+
tablesContext[table4] = [..._moveDataStatements(table4, json2)];
|
|
24756
|
+
}
|
|
24673
24757
|
}
|
|
24674
24758
|
}
|
|
24675
24759
|
} else if (statement.type === "create_reference" || statement.type === "delete_reference" || statement.type === "alter_reference") {
|