drizzle-kit 0.24.2-12ef143 → 0.24.2-1321cf9
Sign up to get free protection for your applications and to get access to all the features.
- package/api.js +1235 -658
- package/api.mjs +1235 -658
- package/bin.cjs +50506 -47233
- package/index.d.mts +3 -4
- package/index.d.ts +3 -4
- package/package.json +2 -2
- package/utils.js +11 -0
- package/utils.mjs +10 -0
package/api.mjs
CHANGED
@@ -8366,6 +8366,13 @@ var init_sqliteSchema = __esm({
|
|
8366
8366
|
function isPgArrayType(sqlType) {
|
8367
8367
|
return sqlType.match(/.*\[\d*\].*|.*\[\].*/g) !== null;
|
8368
8368
|
}
|
8369
|
+
function findAddedAndRemoved(columnNames1, columnNames2) {
|
8370
|
+
const set1 = new Set(columnNames1);
|
8371
|
+
const set2 = new Set(columnNames2);
|
8372
|
+
const addedColumns = columnNames2.filter((it) => !set1.has(it));
|
8373
|
+
const removedColumns = columnNames1.filter((it) => !set2.has(it));
|
8374
|
+
return { addedColumns, removedColumns };
|
8375
|
+
}
|
8369
8376
|
var copy, prepareMigrationMeta, schemaRenameKey, tableRenameKey, columnRenameKey;
|
8370
8377
|
var init_utils = __esm({
|
8371
8378
|
"src/utils.ts"() {
|
@@ -11475,7 +11482,20 @@ var init_jsonDiffer = __esm({
|
|
11475
11482
|
});
|
11476
11483
|
|
11477
11484
|
// src/sqlgenerator.ts
|
11478
|
-
|
11485
|
+
function fromJson(statements, dialect7, action, json2) {
|
11486
|
+
const result = statements.flatMap((statement) => {
|
11487
|
+
const filtered = convertors.filter((it) => {
|
11488
|
+
return it.can(statement, dialect7);
|
11489
|
+
});
|
11490
|
+
const convertor = filtered.length === 1 ? filtered[0] : void 0;
|
11491
|
+
if (!convertor) {
|
11492
|
+
return "";
|
11493
|
+
}
|
11494
|
+
return convertor.convert(statement, json2, action);
|
11495
|
+
}).filter((it) => it !== "");
|
11496
|
+
return result;
|
11497
|
+
}
|
11498
|
+
var pgNativeTypes, isPgNativeType, Convertor, PgCreateTableConvertor, MySqlCreateTableConvertor, SQLiteCreateTableConvertor, PgAlterTableAlterColumnSetGenerated, PgAlterTableAlterColumnDropGenerated, PgAlterTableAlterColumnAlterGenerated, PgAlterTableAddUniqueConstraintConvertor, PgAlterTableDropUniqueConstraintConvertor, MySQLAlterTableAddUniqueConstraintConvertor, MySQLAlterTableDropUniqueConstraintConvertor, CreatePgSequenceConvertor, DropPgSequenceConvertor, RenamePgSequenceConvertor, MovePgSequenceConvertor, AlterPgSequenceConvertor, CreateTypeEnumConvertor, AlterTypeAddValueConvertor, PgDropTableConvertor, MySQLDropTableConvertor, SQLiteDropTableConvertor, PgRenameTableConvertor, SqliteRenameTableConvertor, MySqlRenameTableConvertor, PgAlterTableRenameColumnConvertor, MySqlAlterTableRenameColumnConvertor, SQLiteAlterTableRenameColumnConvertor, PgAlterTableDropColumnConvertor, MySqlAlterTableDropColumnConvertor, SQLiteAlterTableDropColumnConvertor, PgAlterTableAddColumnConvertor, MySqlAlterTableAddColumnConvertor, SQLiteAlterTableAddColumnConvertor, PgAlterTableAlterColumnSetTypeConvertor, PgAlterTableAlterColumnSetDefaultConvertor, PgAlterTableAlterColumnDropDefaultConvertor, PgAlterTableAlterColumnDropGeneratedConvertor, PgAlterTableAlterColumnSetExpressionConvertor, PgAlterTableAlterColumnAlterrGeneratedConvertor, SqliteAlterTableAlterColumnDropGeneratedConvertor, SqliteAlterTableAlterColumnSetExpressionConvertor, SqliteAlterTableAlterColumnAlterGeneratedConvertor, MySqlAlterTableAlterColumnAlterrGeneratedConvertor, MySqlAlterTableAddPk, MySqlAlterTableDropPk, LibSQLModifyColumn, MySqlModifyColumn, PgAlterTableCreateCompositePrimaryKeyConvertor, PgAlterTableDeleteCompositePrimaryKeyConvertor, PgAlterTableAlterCompositePrimaryKeyConvertor, MySqlAlterTableCreateCompositePrimaryKeyConvertor, MySqlAlterTableDeleteCompositePrimaryKeyConvertor, MySqlAlterTableAlterCompositePrimaryKeyConvertor, PgAlterTableAlterColumnSetPrimaryKeyConvertor, PgAlterTableAlterColumnDropPrimaryKeyConvertor, PgAlterTableAlterColumnSetNotNullConvertor, PgAlterTableAlterColumnDropNotNullConvertor, PgCreateForeignKeyConvertor, LibSQLCreateForeignKeyConvertor, MySqlCreateForeignKeyConvertor, PgAlterForeignKeyConvertor, PgDeleteForeignKeyConvertor, MySqlDeleteForeignKeyConvertor, CreatePgIndexConvertor, CreateMySqlIndexConvertor, CreateSqliteIndexConvertor, PgDropIndexConvertor, PgCreateSchemaConvertor, PgRenameSchemaConvertor, PgDropSchemaConvertor, PgAlterTableSetSchemaConvertor, PgAlterTableSetNewSchemaConvertor, PgAlterTableRemoveFromSchemaConvertor, SqliteDropIndexConvertor, MySqlDropIndexConvertor, SQLiteRecreateTableConvertor, LibSQLRecreateTableConvertor, convertors;
|
11479
11499
|
var init_sqlgenerator = __esm({
|
11480
11500
|
"src/sqlgenerator.ts"() {
|
11481
11501
|
"use strict";
|
@@ -11627,7 +11647,7 @@ var init_sqlgenerator = __esm({
|
|
11627
11647
|
};
|
11628
11648
|
SQLiteCreateTableConvertor = class extends Convertor {
|
11629
11649
|
can(statement, dialect7) {
|
11630
|
-
return statement.type === "sqlite_create_table" && dialect7 === "sqlite";
|
11650
|
+
return statement.type === "sqlite_create_table" && (dialect7 === "sqlite" || dialect7 === "turso");
|
11631
11651
|
}
|
11632
11652
|
convert(st) {
|
11633
11653
|
const {
|
@@ -11797,32 +11817,6 @@ var init_sqlgenerator = __esm({
|
|
11797
11817
|
return `ALTER TABLE \`${statement.tableName}\` DROP INDEX \`${unsquashed.name}\`;`;
|
11798
11818
|
}
|
11799
11819
|
};
|
11800
|
-
SQLiteAlterTableAddUniqueConstraintConvertor = class extends Convertor {
|
11801
|
-
can(statement, dialect7) {
|
11802
|
-
return statement.type === "create_unique_constraint" && dialect7 === "sqlite";
|
11803
|
-
}
|
11804
|
-
convert(statement) {
|
11805
|
-
return `/*
|
11806
|
-
SQLite does not support "Adding unique constraint to an existing table" out of the box, we do not generate automatic migration for that, so it has to be done manually
|
11807
|
-
Please refer to: https://www.techonthenet.com/sqlite/unique.php
|
11808
|
-
|
11809
|
-
Due to that we don't generate migration automatically and it has to be done manually
|
11810
|
-
*/`;
|
11811
|
-
}
|
11812
|
-
};
|
11813
|
-
SQLiteAlterTableDropUniqueConstraintConvertor = class extends Convertor {
|
11814
|
-
can(statement, dialect7) {
|
11815
|
-
return statement.type === "delete_unique_constraint" && dialect7 === "sqlite";
|
11816
|
-
}
|
11817
|
-
convert(statement) {
|
11818
|
-
return `/*
|
11819
|
-
SQLite does not support "Dropping unique constraint from an existing table" out of the box, we do not generate automatic migration for that, so it has to be done manually
|
11820
|
-
Please refer to: https://www.techonthenet.com/sqlite/unique.php
|
11821
|
-
|
11822
|
-
Due to that we don't generate migration automatically and it has to be done manually
|
11823
|
-
*/`;
|
11824
|
-
}
|
11825
|
-
};
|
11826
11820
|
CreatePgSequenceConvertor = class extends Convertor {
|
11827
11821
|
can(statement, dialect7) {
|
11828
11822
|
return statement.type === "create_sequence" && dialect7 === "postgresql";
|
@@ -11930,7 +11924,7 @@ var init_sqlgenerator = __esm({
|
|
11930
11924
|
};
|
11931
11925
|
SQLiteDropTableConvertor = class extends Convertor {
|
11932
11926
|
can(statement, dialect7) {
|
11933
|
-
return statement.type === "drop_table" && dialect7 === "sqlite";
|
11927
|
+
return statement.type === "drop_table" && (dialect7 === "sqlite" || dialect7 === "turso");
|
11934
11928
|
}
|
11935
11929
|
convert(statement) {
|
11936
11930
|
const { tableName } = statement;
|
@@ -11950,7 +11944,7 @@ var init_sqlgenerator = __esm({
|
|
11950
11944
|
};
|
11951
11945
|
SqliteRenameTableConvertor = class extends Convertor {
|
11952
11946
|
can(statement, dialect7) {
|
11953
|
-
return statement.type === "rename_table" && dialect7 === "sqlite";
|
11947
|
+
return statement.type === "rename_table" && (dialect7 === "sqlite" || dialect7 === "turso");
|
11954
11948
|
}
|
11955
11949
|
convert(statement) {
|
11956
11950
|
const { tableNameFrom, tableNameTo } = statement;
|
@@ -11987,11 +11981,11 @@ var init_sqlgenerator = __esm({
|
|
11987
11981
|
};
|
11988
11982
|
SQLiteAlterTableRenameColumnConvertor = class extends Convertor {
|
11989
11983
|
can(statement, dialect7) {
|
11990
|
-
return statement.type === "alter_table_rename_column" && dialect7 === "sqlite";
|
11984
|
+
return statement.type === "alter_table_rename_column" && (dialect7 === "sqlite" || dialect7 === "turso");
|
11991
11985
|
}
|
11992
11986
|
convert(statement) {
|
11993
11987
|
const { tableName, oldColumnName, newColumnName } = statement;
|
11994
|
-
return `ALTER TABLE \`${tableName}\` RENAME COLUMN
|
11988
|
+
return `ALTER TABLE \`${tableName}\` RENAME COLUMN "${oldColumnName}" TO "${newColumnName}";`;
|
11995
11989
|
}
|
11996
11990
|
};
|
11997
11991
|
PgAlterTableDropColumnConvertor = class extends Convertor {
|
@@ -12015,7 +12009,7 @@ var init_sqlgenerator = __esm({
|
|
12015
12009
|
};
|
12016
12010
|
SQLiteAlterTableDropColumnConvertor = class extends Convertor {
|
12017
12011
|
can(statement, dialect7) {
|
12018
|
-
return statement.type === "alter_table_drop_column" && dialect7 === "sqlite";
|
12012
|
+
return statement.type === "alter_table_drop_column" && (dialect7 === "sqlite" || dialect7 === "turso");
|
12019
12013
|
}
|
12020
12014
|
convert(statement) {
|
12021
12015
|
const { tableName, columnName } = statement;
|
@@ -12068,7 +12062,7 @@ var init_sqlgenerator = __esm({
|
|
12068
12062
|
};
|
12069
12063
|
SQLiteAlterTableAddColumnConvertor = class extends Convertor {
|
12070
12064
|
can(statement, dialect7) {
|
12071
|
-
return statement.type === "sqlite_alter_table_add_column" && dialect7 === "sqlite";
|
12065
|
+
return statement.type === "sqlite_alter_table_add_column" && (dialect7 === "sqlite" || dialect7 === "turso");
|
12072
12066
|
}
|
12073
12067
|
convert(statement) {
|
12074
12068
|
const { tableName, column: column4, referenceData } = statement;
|
@@ -12092,21 +12086,6 @@ var init_sqlgenerator = __esm({
|
|
12092
12086
|
return `ALTER TABLE ${tableNameWithSchema} ALTER COLUMN "${columnName}" SET DATA TYPE ${newDataType};`;
|
12093
12087
|
}
|
12094
12088
|
};
|
12095
|
-
SQLiteAlterTableAlterColumnSetTypeConvertor = class extends Convertor {
|
12096
|
-
can(statement, dialect7) {
|
12097
|
-
return statement.type === "alter_table_alter_column_set_type" && dialect7 === "sqlite";
|
12098
|
-
}
|
12099
|
-
convert(statement) {
|
12100
|
-
return `/*
|
12101
|
-
SQLite does not support "Changing existing column type" out of the box, we do not generate automatic migration for that, so it has to be done manually
|
12102
|
-
Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
|
12103
|
-
https://www.sqlite.org/lang_altertable.html
|
12104
|
-
https://stackoverflow.com/questions/2083543/modify-a-columns-type-in-sqlite3
|
12105
|
-
|
12106
|
-
Due to that we don't generate migration automatically and it has to be done manually
|
12107
|
-
*/`;
|
12108
|
-
}
|
12109
|
-
};
|
12110
12089
|
PgAlterTableAlterColumnSetDefaultConvertor = class extends Convertor {
|
12111
12090
|
can(statement, dialect7) {
|
12112
12091
|
return statement.type === "alter_table_alter_column_set_default" && dialect7 === "postgresql";
|
@@ -12117,21 +12096,6 @@ var init_sqlgenerator = __esm({
|
|
12117
12096
|
return `ALTER TABLE ${tableNameWithSchema} ALTER COLUMN "${columnName}" SET DEFAULT ${statement.newDefaultValue};`;
|
12118
12097
|
}
|
12119
12098
|
};
|
12120
|
-
SqliteAlterTableAlterColumnSetDefaultConvertor = class extends Convertor {
|
12121
|
-
can(statement, dialect7) {
|
12122
|
-
return statement.type === "alter_table_alter_column_set_default" && dialect7 === "sqlite";
|
12123
|
-
}
|
12124
|
-
convert(statement) {
|
12125
|
-
return `/*
|
12126
|
-
SQLite does not support "Set default to column" out of the box, we do not generate automatic migration for that, so it has to be done manually
|
12127
|
-
Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
|
12128
|
-
https://www.sqlite.org/lang_altertable.html
|
12129
|
-
https://stackoverflow.com/questions/2083543/modify-a-columns-type-in-sqlite3
|
12130
|
-
|
12131
|
-
Due to that we don't generate migration automatically and it has to be done manually
|
12132
|
-
*/`;
|
12133
|
-
}
|
12134
|
-
};
|
12135
12099
|
PgAlterTableAlterColumnDropDefaultConvertor = class extends Convertor {
|
12136
12100
|
can(statement, dialect7) {
|
12137
12101
|
return statement.type === "alter_table_alter_column_drop_default" && dialect7 === "postgresql";
|
@@ -12230,7 +12194,7 @@ var init_sqlgenerator = __esm({
|
|
12230
12194
|
};
|
12231
12195
|
SqliteAlterTableAlterColumnDropGeneratedConvertor = class extends Convertor {
|
12232
12196
|
can(statement, dialect7) {
|
12233
|
-
return statement.type === "alter_table_alter_column_drop_generated" && dialect7 === "sqlite";
|
12197
|
+
return statement.type === "alter_table_alter_column_drop_generated" && (dialect7 === "sqlite" || dialect7 === "turso");
|
12234
12198
|
}
|
12235
12199
|
convert(statement) {
|
12236
12200
|
const {
|
@@ -12271,7 +12235,7 @@ var init_sqlgenerator = __esm({
|
|
12271
12235
|
};
|
12272
12236
|
SqliteAlterTableAlterColumnSetExpressionConvertor = class extends Convertor {
|
12273
12237
|
can(statement, dialect7) {
|
12274
|
-
return statement.type === "alter_table_alter_column_set_generated" && dialect7 === "sqlite";
|
12238
|
+
return statement.type === "alter_table_alter_column_set_generated" && (dialect7 === "sqlite" || dialect7 === "turso");
|
12275
12239
|
}
|
12276
12240
|
convert(statement) {
|
12277
12241
|
const {
|
@@ -12312,7 +12276,7 @@ var init_sqlgenerator = __esm({
|
|
12312
12276
|
};
|
12313
12277
|
SqliteAlterTableAlterColumnAlterGeneratedConvertor = class extends Convertor {
|
12314
12278
|
can(statement, dialect7) {
|
12315
|
-
return statement.type === "alter_table_alter_column_alter_generated" && dialect7 === "sqlite";
|
12279
|
+
return statement.type === "alter_table_alter_column_alter_generated" && (dialect7 === "sqlite" || dialect7 === "turso");
|
12316
12280
|
}
|
12317
12281
|
convert(statement) {
|
12318
12282
|
const {
|
@@ -12405,6 +12369,67 @@ var init_sqlgenerator = __esm({
|
|
12405
12369
|
return `ALTER TABLE \`${statement.tableName}\` DROP PRIMARY KEY`;
|
12406
12370
|
}
|
12407
12371
|
};
|
12372
|
+
LibSQLModifyColumn = class extends Convertor {
|
12373
|
+
can(statement, dialect7) {
|
12374
|
+
return (statement.type === "alter_table_alter_column_set_type" || statement.type === "alter_table_alter_column_drop_notnull" || statement.type === "alter_table_alter_column_set_notnull" || statement.type === "alter_table_alter_column_set_default" || statement.type === "alter_table_alter_column_drop_default") && dialect7 === "turso";
|
12375
|
+
}
|
12376
|
+
convert(statement, json2) {
|
12377
|
+
const { tableName, columnName } = statement;
|
12378
|
+
let columnType = ``;
|
12379
|
+
let columnDefault = "";
|
12380
|
+
let columnNotNull = "";
|
12381
|
+
const sqlStatements = [];
|
12382
|
+
const indexes = [];
|
12383
|
+
for (const table4 of Object.values(json2.tables)) {
|
12384
|
+
for (const index4 of Object.values(table4.indexes)) {
|
12385
|
+
const unsquashed = SQLiteSquasher.unsquashIdx(index4);
|
12386
|
+
sqlStatements.push(`DROP INDEX IF EXISTS "${unsquashed.name}";`);
|
12387
|
+
indexes.push({ ...unsquashed, tableName: table4.name });
|
12388
|
+
}
|
12389
|
+
}
|
12390
|
+
switch (statement.type) {
|
12391
|
+
case "alter_table_alter_column_set_type":
|
12392
|
+
columnType = ` ${statement.newDataType}`;
|
12393
|
+
columnDefault = statement.columnDefault ? ` DEFAULT ${statement.columnDefault}` : "";
|
12394
|
+
columnNotNull = statement.columnNotNull ? ` NOT NULL` : "";
|
12395
|
+
break;
|
12396
|
+
case "alter_table_alter_column_drop_notnull":
|
12397
|
+
columnType = ` ${statement.newDataType}`;
|
12398
|
+
columnDefault = statement.columnDefault ? ` DEFAULT ${statement.columnDefault}` : "";
|
12399
|
+
columnNotNull = "";
|
12400
|
+
break;
|
12401
|
+
case "alter_table_alter_column_set_notnull":
|
12402
|
+
columnType = ` ${statement.newDataType}`;
|
12403
|
+
columnDefault = statement.columnDefault ? ` DEFAULT ${statement.columnDefault}` : "";
|
12404
|
+
columnNotNull = ` NOT NULL`;
|
12405
|
+
break;
|
12406
|
+
case "alter_table_alter_column_set_default":
|
12407
|
+
columnType = ` ${statement.newDataType}`;
|
12408
|
+
columnDefault = ` DEFAULT ${statement.newDefaultValue}`;
|
12409
|
+
columnNotNull = statement.columnNotNull ? ` NOT NULL` : "";
|
12410
|
+
break;
|
12411
|
+
case "alter_table_alter_column_drop_default":
|
12412
|
+
columnType = ` ${statement.newDataType}`;
|
12413
|
+
columnDefault = "";
|
12414
|
+
columnNotNull = statement.columnNotNull ? ` NOT NULL` : "";
|
12415
|
+
break;
|
12416
|
+
}
|
12417
|
+
columnDefault = columnDefault instanceof Date ? columnDefault.toISOString() : columnDefault;
|
12418
|
+
sqlStatements.push(
|
12419
|
+
`ALTER TABLE \`${tableName}\` ALTER COLUMN "${columnName}" TO "${columnName}"${columnType}${columnNotNull}${columnDefault};`
|
12420
|
+
);
|
12421
|
+
for (const index4 of indexes) {
|
12422
|
+
const indexPart = index4.isUnique ? "UNIQUE INDEX" : "INDEX";
|
12423
|
+
const whereStatement = index4.where ? ` WHERE ${index4.where}` : "";
|
12424
|
+
const uniqueString = index4.columns.map((it) => `\`${it}\``).join(",");
|
12425
|
+
const tableName2 = index4.tableName;
|
12426
|
+
sqlStatements.push(
|
12427
|
+
`CREATE ${indexPart} \`${index4.name}\` ON \`${tableName2}\` (${uniqueString})${whereStatement};`
|
12428
|
+
);
|
12429
|
+
}
|
12430
|
+
return sqlStatements;
|
12431
|
+
}
|
12432
|
+
};
|
12408
12433
|
MySqlModifyColumn = class extends Convertor {
|
12409
12434
|
can(statement, dialect7) {
|
12410
12435
|
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" || statement.type === "alter_table_alter_column_set_generated" || statement.type === "alter_table_alter_column_drop_generated") && dialect7 === "mysql";
|
@@ -12542,21 +12567,6 @@ var init_sqlgenerator = __esm({
|
|
12542
12567
|
return `ALTER TABLE \`${tableName}\` MODIFY COLUMN \`${columnName}\`${columnType}${columnAutoincrement}${columnGenerated}${columnNotNull}${columnDefault}${columnOnUpdate};`;
|
12543
12568
|
}
|
12544
12569
|
};
|
12545
|
-
SqliteAlterTableAlterColumnDropDefaultConvertor = class extends Convertor {
|
12546
|
-
can(statement, dialect7) {
|
12547
|
-
return statement.type === "alter_table_alter_column_drop_default" && dialect7 === "sqlite";
|
12548
|
-
}
|
12549
|
-
convert(statement) {
|
12550
|
-
return `/*
|
12551
|
-
SQLite does not support "Drop default from column" out of the box, we do not generate automatic migration for that, so it has to be done manually
|
12552
|
-
Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
|
12553
|
-
https://www.sqlite.org/lang_altertable.html
|
12554
|
-
https://stackoverflow.com/questions/2083543/modify-a-columns-type-in-sqlite3
|
12555
|
-
|
12556
|
-
Due to that we don't generate migration automatically and it has to be done manually
|
12557
|
-
*/`;
|
12558
|
-
}
|
12559
|
-
};
|
12560
12570
|
PgAlterTableCreateCompositePrimaryKeyConvertor = class extends Convertor {
|
12561
12571
|
can(statement, dialect7) {
|
12562
12572
|
return statement.type === "create_composite_pk" && dialect7 === "postgresql";
|
@@ -12621,85 +12631,6 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
12621
12631
|
return `ALTER TABLE \`${statement.tableName}\` DROP PRIMARY KEY, ADD PRIMARY KEY(\`${newColumns.join("`,`")}\`);`;
|
12622
12632
|
}
|
12623
12633
|
};
|
12624
|
-
SqliteAlterTableCreateCompositePrimaryKeyConvertor = class extends Convertor {
|
12625
|
-
can(statement, dialect7) {
|
12626
|
-
return statement.type === "create_composite_pk" && dialect7 === "sqlite";
|
12627
|
-
}
|
12628
|
-
convert(statement) {
|
12629
|
-
let msg = "/*\n";
|
12630
|
-
msg += `You're trying to add PRIMARY KEY(${statement.data}) to '${statement.tableName}' table
|
12631
|
-
`;
|
12632
|
-
msg += "SQLite does not support adding primary key to an already created table\n";
|
12633
|
-
msg += "You can do it in 3 steps with drizzle orm:\n";
|
12634
|
-
msg += " - create new mirror table with needed pk, rename current table to old_table, generate SQL\n";
|
12635
|
-
msg += " - migrate old data from one table to another\n";
|
12636
|
-
msg += " - delete old_table in schema, generate sql\n\n";
|
12637
|
-
msg += "or create manual migration like below:\n\n";
|
12638
|
-
msg += "ALTER TABLE table_name RENAME TO old_table;\n";
|
12639
|
-
msg += "CREATE TABLE table_name (\n";
|
12640
|
-
msg += " column1 datatype [ NULL | NOT NULL ],\n";
|
12641
|
-
msg += " column2 datatype [ NULL | NOT NULL ],\n";
|
12642
|
-
msg += " ...\n";
|
12643
|
-
msg += " PRIMARY KEY (pk_col1, pk_col2, ... pk_col_n)\n";
|
12644
|
-
msg += " );\n";
|
12645
|
-
msg += "INSERT INTO table_name SELECT * FROM old_table;\n\n";
|
12646
|
-
msg += "Due to that we don't generate migration automatically and it has to be done manually\n";
|
12647
|
-
msg += "*/\n";
|
12648
|
-
return msg;
|
12649
|
-
}
|
12650
|
-
};
|
12651
|
-
SqliteAlterTableDeleteCompositePrimaryKeyConvertor = class extends Convertor {
|
12652
|
-
can(statement, dialect7) {
|
12653
|
-
return statement.type === "delete_composite_pk" && dialect7 === "sqlite";
|
12654
|
-
}
|
12655
|
-
convert(statement) {
|
12656
|
-
let msg = "/*\n";
|
12657
|
-
msg += `You're trying to delete PRIMARY KEY(${statement.data}) from '${statement.tableName}' table
|
12658
|
-
`;
|
12659
|
-
msg += "SQLite does not supportprimary key deletion from existing table\n";
|
12660
|
-
msg += "You can do it in 3 steps with drizzle orm:\n";
|
12661
|
-
msg += " - create new mirror table table without pk, rename current table to old_table, generate SQL\n";
|
12662
|
-
msg += " - migrate old data from one table to another\n";
|
12663
|
-
msg += " - delete old_table in schema, generate sql\n\n";
|
12664
|
-
msg += "or create manual migration like below:\n\n";
|
12665
|
-
msg += "ALTER TABLE table_name RENAME TO old_table;\n";
|
12666
|
-
msg += "CREATE TABLE table_name (\n";
|
12667
|
-
msg += " column1 datatype [ NULL | NOT NULL ],\n";
|
12668
|
-
msg += " column2 datatype [ NULL | NOT NULL ],\n";
|
12669
|
-
msg += " ...\n";
|
12670
|
-
msg += " PRIMARY KEY (pk_col1, pk_col2, ... pk_col_n)\n";
|
12671
|
-
msg += " );\n";
|
12672
|
-
msg += "INSERT INTO table_name SELECT * FROM old_table;\n\n";
|
12673
|
-
msg += "Due to that we don't generate migration automatically and it has to be done manually\n";
|
12674
|
-
msg += "*/\n";
|
12675
|
-
return msg;
|
12676
|
-
}
|
12677
|
-
};
|
12678
|
-
SqliteAlterTableAlterCompositePrimaryKeyConvertor = class extends Convertor {
|
12679
|
-
can(statement, dialect7) {
|
12680
|
-
return statement.type === "alter_composite_pk" && dialect7 === "sqlite";
|
12681
|
-
}
|
12682
|
-
convert(statement) {
|
12683
|
-
let msg = "/*\n";
|
12684
|
-
msg += "SQLite does not support altering primary key\n";
|
12685
|
-
msg += "You can do it in 3 steps with drizzle orm:\n";
|
12686
|
-
msg += " - create new mirror table with needed pk, rename current table to old_table, generate SQL\n";
|
12687
|
-
msg += " - migrate old data from one table to another\n";
|
12688
|
-
msg += " - delete old_table in schema, generate sql\n\n";
|
12689
|
-
msg += "or create manual migration like below:\n\n";
|
12690
|
-
msg += "ALTER TABLE table_name RENAME TO old_table;\n";
|
12691
|
-
msg += "CREATE TABLE table_name (\n";
|
12692
|
-
msg += " column1 datatype [ NULL | NOT NULL ],\n";
|
12693
|
-
msg += " column2 datatype [ NULL | NOT NULL ],\n";
|
12694
|
-
msg += " ...\n";
|
12695
|
-
msg += " PRIMARY KEY (pk_col1, pk_col2, ... pk_col_n)\n";
|
12696
|
-
msg += " );\n";
|
12697
|
-
msg += "INSERT INTO table_name SELECT * FROM old_table;\n\n";
|
12698
|
-
msg += "Due to that we don't generate migration automatically and it has to be done manually\n";
|
12699
|
-
msg += "*/\n";
|
12700
|
-
return msg;
|
12701
|
-
}
|
12702
|
-
};
|
12703
12634
|
PgAlterTableAlterColumnSetPrimaryKeyConvertor = class extends Convertor {
|
12704
12635
|
can(statement, dialect7) {
|
12705
12636
|
return statement.type === "alter_table_alter_column_set_pk" && dialect7 === "postgresql";
|
@@ -12744,51 +12675,6 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
12744
12675
|
return `ALTER TABLE ${tableNameWithSchema} ALTER COLUMN "${columnName}" SET NOT NULL;`;
|
12745
12676
|
}
|
12746
12677
|
};
|
12747
|
-
SqliteAlterTableAlterColumnSetNotNullConvertor = class extends Convertor {
|
12748
|
-
can(statement, dialect7) {
|
12749
|
-
return statement.type === "alter_table_alter_column_set_notnull" && dialect7 === "sqlite";
|
12750
|
-
}
|
12751
|
-
convert(statement) {
|
12752
|
-
return `/*
|
12753
|
-
SQLite does not support "Set not null to column" out of the box, we do not generate automatic migration for that, so it has to be done manually
|
12754
|
-
Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
|
12755
|
-
https://www.sqlite.org/lang_altertable.html
|
12756
|
-
https://stackoverflow.com/questions/2083543/modify-a-columns-type-in-sqlite3
|
12757
|
-
|
12758
|
-
Due to that we don't generate migration automatically and it has to be done manually
|
12759
|
-
*/`;
|
12760
|
-
}
|
12761
|
-
};
|
12762
|
-
SqliteAlterTableAlterColumnSetAutoincrementConvertor = class extends Convertor {
|
12763
|
-
can(statement, dialect7) {
|
12764
|
-
return statement.type === "alter_table_alter_column_set_autoincrement" && dialect7 === "sqlite";
|
12765
|
-
}
|
12766
|
-
convert(statement) {
|
12767
|
-
return `/*
|
12768
|
-
SQLite does not support "Set autoincrement to a column" out of the box, we do not generate automatic migration for that, so it has to be done manually
|
12769
|
-
Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
|
12770
|
-
https://www.sqlite.org/lang_altertable.html
|
12771
|
-
https://stackoverflow.com/questions/2083543/modify-a-columns-type-in-sqlite3
|
12772
|
-
|
12773
|
-
Due to that we don't generate migration automatically and it has to be done manually
|
12774
|
-
*/`;
|
12775
|
-
}
|
12776
|
-
};
|
12777
|
-
SqliteAlterTableAlterColumnDropAutoincrementConvertor = class extends Convertor {
|
12778
|
-
can(statement, dialect7) {
|
12779
|
-
return statement.type === "alter_table_alter_column_drop_autoincrement" && dialect7 === "sqlite";
|
12780
|
-
}
|
12781
|
-
convert(statement) {
|
12782
|
-
return `/*
|
12783
|
-
SQLite does not support "Drop autoincrement from a column" out of the box, we do not generate automatic migration for that, so it has to be done manually
|
12784
|
-
Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
|
12785
|
-
https://www.sqlite.org/lang_altertable.html
|
12786
|
-
https://stackoverflow.com/questions/2083543/modify-a-columns-type-in-sqlite3
|
12787
|
-
|
12788
|
-
Due to that we don't generate migration automatically and it has to be done manually
|
12789
|
-
*/`;
|
12790
|
-
}
|
12791
|
-
};
|
12792
12678
|
PgAlterTableAlterColumnDropNotNullConvertor = class extends Convertor {
|
12793
12679
|
can(statement, dialect7) {
|
12794
12680
|
return statement.type === "alter_table_alter_column_drop_notnull" && dialect7 === "postgresql";
|
@@ -12799,21 +12685,6 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
12799
12685
|
return `ALTER TABLE ${tableNameWithSchema} ALTER COLUMN "${columnName}" DROP NOT NULL;`;
|
12800
12686
|
}
|
12801
12687
|
};
|
12802
|
-
SqliteAlterTableAlterColumnDropNotNullConvertor = class extends Convertor {
|
12803
|
-
can(statement, dialect7) {
|
12804
|
-
return statement.type === "alter_table_alter_column_drop_notnull" && dialect7 === "sqlite";
|
12805
|
-
}
|
12806
|
-
convert(statement) {
|
12807
|
-
return `/*
|
12808
|
-
SQLite does not support "Drop not null from column" out of the box, we do not generate automatic migration for that, so it has to be done manually
|
12809
|
-
Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
|
12810
|
-
https://www.sqlite.org/lang_altertable.html
|
12811
|
-
https://stackoverflow.com/questions/2083543/modify-a-columns-type-in-sqlite3
|
12812
|
-
|
12813
|
-
Due to that we don't generate migration automatically and it has to be done manually
|
12814
|
-
*/`;
|
12815
|
-
}
|
12816
|
-
};
|
12817
12688
|
PgCreateForeignKeyConvertor = class extends Convertor {
|
12818
12689
|
can(statement, dialect7) {
|
12819
12690
|
return statement.type === "create_reference" && dialect7 === "postgresql";
|
@@ -12844,18 +12715,21 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
12844
12715
|
return sql2;
|
12845
12716
|
}
|
12846
12717
|
};
|
12847
|
-
|
12718
|
+
LibSQLCreateForeignKeyConvertor = class extends Convertor {
|
12848
12719
|
can(statement, dialect7) {
|
12849
|
-
return statement.type === "create_reference" && dialect7 === "
|
12720
|
+
return statement.type === "create_reference" && dialect7 === "turso";
|
12850
12721
|
}
|
12851
|
-
convert(statement) {
|
12852
|
-
|
12853
|
-
|
12854
|
-
|
12855
|
-
|
12856
|
-
|
12857
|
-
|
12858
|
-
|
12722
|
+
convert(statement, json2, action) {
|
12723
|
+
const { columnsFrom, columnsTo, tableFrom, onDelete, onUpdate, tableTo } = action === "push" ? SQLiteSquasher.unsquashPushFK(statement.data) : SQLiteSquasher.unsquashFK(statement.data);
|
12724
|
+
const { columnDefault, columnNotNull, columnType } = statement;
|
12725
|
+
const onDeleteStatement = onDelete ? ` ON DELETE ${onDelete}` : "";
|
12726
|
+
const onUpdateStatement = onUpdate ? ` ON UPDATE ${onUpdate}` : "";
|
12727
|
+
const columnsDefaultValue = columnDefault ? ` DEFAULT ${columnDefault}` : "";
|
12728
|
+
const columnNotNullValue = columnNotNull ? ` NOT NULL` : "";
|
12729
|
+
const columnTypeValue = columnType ? ` ${columnType}` : "";
|
12730
|
+
const columnFrom = columnsFrom[0];
|
12731
|
+
const columnTo = columnsTo[0];
|
12732
|
+
return `ALTER TABLE \`${tableFrom}\` ALTER COLUMN "${columnFrom}" TO "${columnFrom}"${columnTypeValue}${columnNotNullValue}${columnsDefaultValue} REFERENCES ${tableTo}(${columnTo})${onDeleteStatement}${onUpdateStatement};`;
|
12859
12733
|
}
|
12860
12734
|
};
|
12861
12735
|
MySqlCreateForeignKeyConvertor = class extends Convertor {
|
@@ -12904,20 +12778,6 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
12904
12778
|
return sql2;
|
12905
12779
|
}
|
12906
12780
|
};
|
12907
|
-
SqliteAlterForeignKeyConvertor = class extends Convertor {
|
12908
|
-
can(statement, dialect7) {
|
12909
|
-
return statement.type === "alter_reference" && dialect7 === "sqlite";
|
12910
|
-
}
|
12911
|
-
convert(statement) {
|
12912
|
-
return `/*
|
12913
|
-
SQLite does not support "Changing existing foreign key" out of the box, we do not generate automatic migration for that, so it has to be done manually
|
12914
|
-
Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
|
12915
|
-
https://www.sqlite.org/lang_altertable.html
|
12916
|
-
|
12917
|
-
Due to that we don't generate migration automatically and it has to be done manually
|
12918
|
-
*/`;
|
12919
|
-
}
|
12920
|
-
};
|
12921
12781
|
PgDeleteForeignKeyConvertor = class extends Convertor {
|
12922
12782
|
can(statement, dialect7) {
|
12923
12783
|
return statement.type === "delete_reference" && dialect7 === "postgresql";
|
@@ -12930,20 +12790,6 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
12930
12790
|
`;
|
12931
12791
|
}
|
12932
12792
|
};
|
12933
|
-
SqliteDeleteForeignKeyConvertor = class extends Convertor {
|
12934
|
-
can(statement, dialect7) {
|
12935
|
-
return statement.type === "delete_reference" && dialect7 === "sqlite";
|
12936
|
-
}
|
12937
|
-
convert(statement) {
|
12938
|
-
return `/*
|
12939
|
-
SQLite does not support "Dropping foreign key" out of the box, we do not generate automatic migration for that, so it has to be done manually
|
12940
|
-
Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
|
12941
|
-
https://www.sqlite.org/lang_altertable.html
|
12942
|
-
|
12943
|
-
Due to that we don't generate migration automatically and it has to be done manually
|
12944
|
-
*/`;
|
12945
|
-
}
|
12946
|
-
};
|
12947
12793
|
MySqlDeleteForeignKeyConvertor = class extends Convertor {
|
12948
12794
|
can(statement, dialect7) {
|
12949
12795
|
return statement.type === "delete_reference" && dialect7 === "mysql";
|
@@ -13004,7 +12850,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
13004
12850
|
};
|
13005
12851
|
CreateSqliteIndexConvertor = class extends Convertor {
|
13006
12852
|
can(statement, dialect7) {
|
13007
|
-
return statement.type === "create_index" && dialect7 === "sqlite";
|
12853
|
+
return statement.type === "create_index" && (dialect7 === "sqlite" || dialect7 === "turso");
|
13008
12854
|
}
|
13009
12855
|
convert(statement) {
|
13010
12856
|
const { name: name2, columns, isUnique, where } = SQLiteSquasher.unsquashIdx(
|
@@ -13091,7 +12937,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
13091
12937
|
};
|
13092
12938
|
SqliteDropIndexConvertor = class extends Convertor {
|
13093
12939
|
can(statement, dialect7) {
|
13094
|
-
return statement.type === "drop_index" && dialect7 === "sqlite";
|
12940
|
+
return statement.type === "drop_index" && (dialect7 === "sqlite" || dialect7 === "turso");
|
13095
12941
|
}
|
13096
12942
|
convert(statement) {
|
13097
12943
|
const { name: name2 } = PgSquasher.unsquashIdx(statement.data);
|
@@ -13107,10 +12953,96 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
13107
12953
|
return `DROP INDEX \`${name2}\` ON \`${statement.tableName}\`;`;
|
13108
12954
|
}
|
13109
12955
|
};
|
12956
|
+
SQLiteRecreateTableConvertor = class extends Convertor {
|
12957
|
+
can(statement, dialect7) {
|
12958
|
+
return statement.type === "recreate_table" && dialect7 === "sqlite";
|
12959
|
+
}
|
12960
|
+
convert(statement) {
|
12961
|
+
const { tableName, columns, compositePKs, referenceData } = statement;
|
12962
|
+
const columnNames = columns.map((it) => `"${it.name}"`).join(", ");
|
12963
|
+
const newTableName = `__new_${tableName}`;
|
12964
|
+
const sqlStatements = [];
|
12965
|
+
sqlStatements.push(`PRAGMA foreign_keys=OFF;`);
|
12966
|
+
sqlStatements.push(
|
12967
|
+
new SQLiteCreateTableConvertor().convert({
|
12968
|
+
type: "sqlite_create_table",
|
12969
|
+
tableName: newTableName,
|
12970
|
+
columns,
|
12971
|
+
referenceData,
|
12972
|
+
compositePKs
|
12973
|
+
})
|
12974
|
+
);
|
12975
|
+
sqlStatements.push(
|
12976
|
+
`INSERT INTO \`${newTableName}\`(${columnNames}) SELECT ${columnNames} FROM \`${tableName}\`;`
|
12977
|
+
);
|
12978
|
+
sqlStatements.push(
|
12979
|
+
new SQLiteDropTableConvertor().convert({
|
12980
|
+
type: "drop_table",
|
12981
|
+
tableName,
|
12982
|
+
schema: ""
|
12983
|
+
})
|
12984
|
+
);
|
12985
|
+
sqlStatements.push(
|
12986
|
+
new SqliteRenameTableConvertor().convert({
|
12987
|
+
fromSchema: "",
|
12988
|
+
tableNameFrom: newTableName,
|
12989
|
+
tableNameTo: tableName,
|
12990
|
+
toSchema: "",
|
12991
|
+
type: "rename_table"
|
12992
|
+
})
|
12993
|
+
);
|
12994
|
+
sqlStatements.push(`PRAGMA foreign_keys=ON;`);
|
12995
|
+
return sqlStatements;
|
12996
|
+
}
|
12997
|
+
};
|
12998
|
+
LibSQLRecreateTableConvertor = class extends Convertor {
|
12999
|
+
can(statement, dialect7) {
|
13000
|
+
return statement.type === "recreate_table" && dialect7 === "turso";
|
13001
|
+
}
|
13002
|
+
convert(statement) {
|
13003
|
+
const { tableName, columns, compositePKs, referenceData } = statement;
|
13004
|
+
const columnNames = columns.map((it) => `"${it.name}"`).join(", ");
|
13005
|
+
const newTableName = `__new_${tableName}`;
|
13006
|
+
const sqlStatements = [];
|
13007
|
+
sqlStatements.push(`PRAGMA foreign_keys=OFF;`);
|
13008
|
+
sqlStatements.push(
|
13009
|
+
new SQLiteCreateTableConvertor().convert({
|
13010
|
+
type: "sqlite_create_table",
|
13011
|
+
tableName: newTableName,
|
13012
|
+
columns,
|
13013
|
+
referenceData,
|
13014
|
+
compositePKs
|
13015
|
+
})
|
13016
|
+
);
|
13017
|
+
sqlStatements.push(
|
13018
|
+
`INSERT INTO \`${newTableName}\`(${columnNames}) SELECT ${columnNames} FROM \`${tableName}\`;`
|
13019
|
+
);
|
13020
|
+
sqlStatements.push(
|
13021
|
+
new SQLiteDropTableConvertor().convert({
|
13022
|
+
type: "drop_table",
|
13023
|
+
tableName,
|
13024
|
+
schema: ""
|
13025
|
+
})
|
13026
|
+
);
|
13027
|
+
sqlStatements.push(
|
13028
|
+
new SqliteRenameTableConvertor().convert({
|
13029
|
+
fromSchema: "",
|
13030
|
+
tableNameFrom: newTableName,
|
13031
|
+
tableNameTo: tableName,
|
13032
|
+
toSchema: "",
|
13033
|
+
type: "rename_table"
|
13034
|
+
})
|
13035
|
+
);
|
13036
|
+
sqlStatements.push(`PRAGMA foreign_keys=ON;`);
|
13037
|
+
return sqlStatements;
|
13038
|
+
}
|
13039
|
+
};
|
13110
13040
|
convertors = [];
|
13111
13041
|
convertors.push(new PgCreateTableConvertor());
|
13112
13042
|
convertors.push(new MySqlCreateTableConvertor());
|
13113
13043
|
convertors.push(new SQLiteCreateTableConvertor());
|
13044
|
+
convertors.push(new SQLiteRecreateTableConvertor());
|
13045
|
+
convertors.push(new LibSQLRecreateTableConvertor());
|
13114
13046
|
convertors.push(new CreateTypeEnumConvertor());
|
13115
13047
|
convertors.push(new CreatePgSequenceConvertor());
|
13116
13048
|
convertors.push(new DropPgSequenceConvertor());
|
@@ -13158,6 +13090,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
13158
13090
|
convertors.push(new SqliteAlterTableAlterColumnAlterGeneratedConvertor());
|
13159
13091
|
convertors.push(new SqliteAlterTableAlterColumnSetExpressionConvertor());
|
13160
13092
|
convertors.push(new MySqlModifyColumn());
|
13093
|
+
convertors.push(new LibSQLModifyColumn());
|
13161
13094
|
convertors.push(new PgCreateForeignKeyConvertor());
|
13162
13095
|
convertors.push(new MySqlCreateForeignKeyConvertor());
|
13163
13096
|
convertors.push(new PgAlterForeignKeyConvertor());
|
@@ -13169,24 +13102,10 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
13169
13102
|
convertors.push(new PgAlterTableSetSchemaConvertor());
|
13170
13103
|
convertors.push(new PgAlterTableSetNewSchemaConvertor());
|
13171
13104
|
convertors.push(new PgAlterTableRemoveFromSchemaConvertor());
|
13172
|
-
convertors.push(new
|
13173
|
-
convertors.push(new SqliteAlterForeignKeyConvertor());
|
13174
|
-
convertors.push(new SqliteDeleteForeignKeyConvertor());
|
13175
|
-
convertors.push(new SqliteCreateForeignKeyConvertor());
|
13176
|
-
convertors.push(new SQLiteAlterTableAddUniqueConstraintConvertor());
|
13177
|
-
convertors.push(new SQLiteAlterTableDropUniqueConstraintConvertor());
|
13105
|
+
convertors.push(new LibSQLCreateForeignKeyConvertor());
|
13178
13106
|
convertors.push(new PgAlterTableAlterColumnDropGenerated());
|
13179
13107
|
convertors.push(new PgAlterTableAlterColumnSetGenerated());
|
13180
13108
|
convertors.push(new PgAlterTableAlterColumnAlterGenerated());
|
13181
|
-
convertors.push(new SqliteAlterTableAlterColumnSetNotNullConvertor());
|
13182
|
-
convertors.push(new SqliteAlterTableAlterColumnDropNotNullConvertor());
|
13183
|
-
convertors.push(new SqliteAlterTableAlterColumnSetDefaultConvertor());
|
13184
|
-
convertors.push(new SqliteAlterTableAlterColumnDropDefaultConvertor());
|
13185
|
-
convertors.push(new SqliteAlterTableAlterColumnSetAutoincrementConvertor());
|
13186
|
-
convertors.push(new SqliteAlterTableAlterColumnDropAutoincrementConvertor());
|
13187
|
-
convertors.push(new SqliteAlterTableCreateCompositePrimaryKeyConvertor());
|
13188
|
-
convertors.push(new SqliteAlterTableDeleteCompositePrimaryKeyConvertor());
|
13189
|
-
convertors.push(new SqliteAlterTableAlterCompositePrimaryKeyConvertor());
|
13190
13109
|
convertors.push(new PgAlterTableCreateCompositePrimaryKeyConvertor());
|
13191
13110
|
convertors.push(new PgAlterTableDeleteCompositePrimaryKeyConvertor());
|
13192
13111
|
convertors.push(new PgAlterTableAlterCompositePrimaryKeyConvertor());
|
@@ -13195,19 +13114,6 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
13195
13114
|
convertors.push(new MySqlAlterTableCreateCompositePrimaryKeyConvertor());
|
13196
13115
|
convertors.push(new MySqlAlterTableAddPk());
|
13197
13116
|
convertors.push(new MySqlAlterTableAlterCompositePrimaryKeyConvertor());
|
13198
|
-
fromJson = (statements, dialect7) => {
|
13199
|
-
const result = statements.flatMap((statement) => {
|
13200
|
-
const filtered = convertors.filter((it) => {
|
13201
|
-
return it.can(statement, dialect7);
|
13202
|
-
});
|
13203
|
-
const convertor = filtered.length === 1 ? filtered[0] : void 0;
|
13204
|
-
if (!convertor) {
|
13205
|
-
return "";
|
13206
|
-
}
|
13207
|
-
return convertor.convert(statement);
|
13208
|
-
}).filter((it) => it !== "");
|
13209
|
-
return result;
|
13210
|
-
};
|
13211
13117
|
https: `
|
13212
13118
|
create table users (
|
13213
13119
|
id int,
|
@@ -13234,12 +13140,248 @@ drop type __venum;
|
|
13234
13140
|
}
|
13235
13141
|
});
|
13236
13142
|
|
13143
|
+
// src/cli/commands/sqlitePushUtils.ts
|
13144
|
+
var _moveDataStatements, getOldTableName, getNewTableName, logSuggestionsAndReturn;
|
13145
|
+
var init_sqlitePushUtils = __esm({
|
13146
|
+
"src/cli/commands/sqlitePushUtils.ts"() {
|
13147
|
+
"use strict";
|
13148
|
+
init_source();
|
13149
|
+
init_sqliteSchema();
|
13150
|
+
init_sqlgenerator();
|
13151
|
+
init_utils();
|
13152
|
+
_moveDataStatements = (tableName, json, dataLoss = false) => {
|
13153
|
+
const statements = [];
|
13154
|
+
const newTableName = `__new_${tableName}`;
|
13155
|
+
const tableColumns = Object.values(json.tables[tableName].columns);
|
13156
|
+
const referenceData = Object.values(json.tables[tableName].foreignKeys);
|
13157
|
+
const compositePKs = Object.values(
|
13158
|
+
json.tables[tableName].compositePrimaryKeys
|
13159
|
+
).map((it) => SQLiteSquasher.unsquashPK(it));
|
13160
|
+
const fks = referenceData.map((it) => SQLiteSquasher.unsquashPushFK(it));
|
13161
|
+
statements.push(
|
13162
|
+
new SQLiteCreateTableConvertor().convert({
|
13163
|
+
type: "sqlite_create_table",
|
13164
|
+
tableName: newTableName,
|
13165
|
+
columns: tableColumns,
|
13166
|
+
referenceData: fks,
|
13167
|
+
compositePKs
|
13168
|
+
})
|
13169
|
+
);
|
13170
|
+
if (!dataLoss) {
|
13171
|
+
const columns = Object.keys(json.tables[tableName].columns).map(
|
13172
|
+
(c) => `"${c}"`
|
13173
|
+
);
|
13174
|
+
statements.push(
|
13175
|
+
`INSERT INTO \`${newTableName}\`(${columns.join(
|
13176
|
+
", "
|
13177
|
+
)}) SELECT ${columns.join(", ")} FROM \`${tableName}\`;`
|
13178
|
+
);
|
13179
|
+
}
|
13180
|
+
statements.push(
|
13181
|
+
new SQLiteDropTableConvertor().convert({
|
13182
|
+
type: "drop_table",
|
13183
|
+
tableName,
|
13184
|
+
schema: ""
|
13185
|
+
})
|
13186
|
+
);
|
13187
|
+
statements.push(
|
13188
|
+
new SqliteRenameTableConvertor().convert({
|
13189
|
+
fromSchema: "",
|
13190
|
+
tableNameFrom: newTableName,
|
13191
|
+
tableNameTo: tableName,
|
13192
|
+
toSchema: "",
|
13193
|
+
type: "rename_table"
|
13194
|
+
})
|
13195
|
+
);
|
13196
|
+
for (const idx of Object.values(json.tables[tableName].indexes)) {
|
13197
|
+
statements.push(
|
13198
|
+
new CreateSqliteIndexConvertor().convert({
|
13199
|
+
type: "create_index",
|
13200
|
+
tableName,
|
13201
|
+
schema: "",
|
13202
|
+
data: idx
|
13203
|
+
})
|
13204
|
+
);
|
13205
|
+
}
|
13206
|
+
return statements;
|
13207
|
+
};
|
13208
|
+
getOldTableName = (tableName, meta) => {
|
13209
|
+
for (const key of Object.keys(meta.tables)) {
|
13210
|
+
const value = meta.tables[key];
|
13211
|
+
if (`"${tableName}"` === value) {
|
13212
|
+
return key.substring(1, key.length - 1);
|
13213
|
+
}
|
13214
|
+
}
|
13215
|
+
return tableName;
|
13216
|
+
};
|
13217
|
+
getNewTableName = (tableName, meta) => {
|
13218
|
+
if (typeof meta.tables[`"${tableName}"`] !== "undefined") {
|
13219
|
+
return meta.tables[`"${tableName}"`].substring(
|
13220
|
+
1,
|
13221
|
+
meta.tables[`"${tableName}"`].length - 1
|
13222
|
+
);
|
13223
|
+
}
|
13224
|
+
return tableName;
|
13225
|
+
};
|
13226
|
+
logSuggestionsAndReturn = async (connection, statements, json1, json2, meta) => {
|
13227
|
+
let shouldAskForApprove = false;
|
13228
|
+
const statementsToExecute = [];
|
13229
|
+
const infoToPrint = [];
|
13230
|
+
const tablesToRemove = [];
|
13231
|
+
const columnsToRemove = [];
|
13232
|
+
const schemasToRemove = [];
|
13233
|
+
const tablesToTruncate = [];
|
13234
|
+
for (const statement of statements) {
|
13235
|
+
if (statement.type === "drop_table") {
|
13236
|
+
const res = await connection.query(
|
13237
|
+
`select count(*) as count from \`${statement.tableName}\``
|
13238
|
+
);
|
13239
|
+
const count2 = Number(res[0].count);
|
13240
|
+
if (count2 > 0) {
|
13241
|
+
infoToPrint.push(
|
13242
|
+
`\xB7 You're about to delete ${source_default.underline(
|
13243
|
+
statement.tableName
|
13244
|
+
)} table with ${count2} items`
|
13245
|
+
);
|
13246
|
+
tablesToRemove.push(statement.tableName);
|
13247
|
+
shouldAskForApprove = true;
|
13248
|
+
}
|
13249
|
+
const fromJsonStatement = fromJson([statement], "sqlite", "push");
|
13250
|
+
statementsToExecute.push(
|
13251
|
+
...Array.isArray(fromJsonStatement) ? fromJsonStatement : [fromJsonStatement]
|
13252
|
+
);
|
13253
|
+
} else if (statement.type === "alter_table_drop_column") {
|
13254
|
+
const tableName = statement.tableName;
|
13255
|
+
const columnName = statement.columnName;
|
13256
|
+
const res = await connection.query(
|
13257
|
+
`select count(\`${tableName}\`.\`${columnName}\`) as count from \`${tableName}\``
|
13258
|
+
);
|
13259
|
+
const count2 = Number(res[0].count);
|
13260
|
+
if (count2 > 0) {
|
13261
|
+
infoToPrint.push(
|
13262
|
+
`\xB7 You're about to delete ${source_default.underline(
|
13263
|
+
columnName
|
13264
|
+
)} column in ${tableName} table with ${count2} items`
|
13265
|
+
);
|
13266
|
+
columnsToRemove.push(`${tableName}_${statement.columnName}`);
|
13267
|
+
shouldAskForApprove = true;
|
13268
|
+
}
|
13269
|
+
const fromJsonStatement = fromJson([statement], "sqlite", "push");
|
13270
|
+
statementsToExecute.push(
|
13271
|
+
...Array.isArray(fromJsonStatement) ? fromJsonStatement : [fromJsonStatement]
|
13272
|
+
);
|
13273
|
+
} else if (statement.type === "sqlite_alter_table_add_column" && (statement.column.notNull && !statement.column.default)) {
|
13274
|
+
const tableName = statement.tableName;
|
13275
|
+
const columnName = statement.column.name;
|
13276
|
+
const res = await connection.query(
|
13277
|
+
`select count(*) as count from \`${tableName}\``
|
13278
|
+
);
|
13279
|
+
const count2 = Number(res[0].count);
|
13280
|
+
if (count2 > 0) {
|
13281
|
+
infoToPrint.push(
|
13282
|
+
`\xB7 You're about to add not-null ${source_default.underline(
|
13283
|
+
columnName
|
13284
|
+
)} column without default value, which contains ${count2} items`
|
13285
|
+
);
|
13286
|
+
tablesToTruncate.push(tableName);
|
13287
|
+
statementsToExecute.push(`delete from ${tableName};`);
|
13288
|
+
shouldAskForApprove = true;
|
13289
|
+
}
|
13290
|
+
const fromJsonStatement = fromJson([statement], "sqlite", "push");
|
13291
|
+
statementsToExecute.push(
|
13292
|
+
...Array.isArray(fromJsonStatement) ? fromJsonStatement : [fromJsonStatement]
|
13293
|
+
);
|
13294
|
+
} else if (statement.type === "recreate_table") {
|
13295
|
+
const tableName = statement.tableName;
|
13296
|
+
const oldTableName = getOldTableName(tableName, meta);
|
13297
|
+
let dataLoss = false;
|
13298
|
+
const prevColumnNames = Object.keys(json1.tables[oldTableName].columns);
|
13299
|
+
const currentColumnNames = Object.keys(json2.tables[tableName].columns);
|
13300
|
+
const { removedColumns, addedColumns } = findAddedAndRemoved(
|
13301
|
+
prevColumnNames,
|
13302
|
+
currentColumnNames
|
13303
|
+
);
|
13304
|
+
if (removedColumns.length) {
|
13305
|
+
for (const removedColumn of removedColumns) {
|
13306
|
+
const res = await connection.query(
|
13307
|
+
`select count(\`${tableName}\`.\`${removedColumn}\`) as count from \`${tableName}\``
|
13308
|
+
);
|
13309
|
+
const count2 = Number(res[0].count);
|
13310
|
+
if (count2 > 0) {
|
13311
|
+
infoToPrint.push(
|
13312
|
+
`\xB7 You're about to delete ${source_default.underline(
|
13313
|
+
removedColumn
|
13314
|
+
)} column in ${tableName} table with ${count2} items`
|
13315
|
+
);
|
13316
|
+
columnsToRemove.push(removedColumn);
|
13317
|
+
shouldAskForApprove = true;
|
13318
|
+
}
|
13319
|
+
}
|
13320
|
+
}
|
13321
|
+
if (addedColumns.length) {
|
13322
|
+
for (const addedColumn of addedColumns) {
|
13323
|
+
const [res] = await connection.query(
|
13324
|
+
`select count(*) as count from \`${tableName}\``
|
13325
|
+
);
|
13326
|
+
const columnConf = json2.tables[tableName].columns[addedColumn];
|
13327
|
+
const count2 = Number(res.count);
|
13328
|
+
if (count2 > 0 && columnConf.notNull && !columnConf.default) {
|
13329
|
+
dataLoss = true;
|
13330
|
+
infoToPrint.push(
|
13331
|
+
`\xB7 You're about to add not-null ${source_default.underline(
|
13332
|
+
addedColumn
|
13333
|
+
)} column without default value to table, which contains ${count2} items`
|
13334
|
+
);
|
13335
|
+
shouldAskForApprove = true;
|
13336
|
+
tablesToTruncate.push(tableName);
|
13337
|
+
statementsToExecute.push(`DELETE FROM \`${tableName}\`;`);
|
13338
|
+
}
|
13339
|
+
}
|
13340
|
+
}
|
13341
|
+
const tablesReferencingCurrent = [];
|
13342
|
+
for (const table4 of Object.values(json2.tables)) {
|
13343
|
+
const tablesRefs = Object.values(json2.tables[table4.name].foreignKeys).filter((t) => SQLiteSquasher.unsquashPushFK(t).tableTo === tableName).map((it) => SQLiteSquasher.unsquashPushFK(it).tableFrom);
|
13344
|
+
tablesReferencingCurrent.push(...tablesRefs);
|
13345
|
+
}
|
13346
|
+
if (!tablesReferencingCurrent.length) {
|
13347
|
+
statementsToExecute.push(..._moveDataStatements(tableName, json2, dataLoss));
|
13348
|
+
continue;
|
13349
|
+
}
|
13350
|
+
const [{ foreign_keys: pragmaState }] = await connection.query(`PRAGMA foreign_keys;`);
|
13351
|
+
if (pragmaState) {
|
13352
|
+
statementsToExecute.push(`PRAGMA foreign_keys=OFF;`);
|
13353
|
+
}
|
13354
|
+
statementsToExecute.push(..._moveDataStatements(tableName, json2, dataLoss));
|
13355
|
+
if (pragmaState) {
|
13356
|
+
statementsToExecute.push(`PRAGMA foreign_keys=ON;`);
|
13357
|
+
}
|
13358
|
+
} else {
|
13359
|
+
const fromJsonStatement = fromJson([statement], "sqlite", "push");
|
13360
|
+
statementsToExecute.push(
|
13361
|
+
...Array.isArray(fromJsonStatement) ? fromJsonStatement : [fromJsonStatement]
|
13362
|
+
);
|
13363
|
+
}
|
13364
|
+
}
|
13365
|
+
return {
|
13366
|
+
statementsToExecute,
|
13367
|
+
shouldAskForApprove,
|
13368
|
+
infoToPrint,
|
13369
|
+
columnsToRemove: [...new Set(columnsToRemove)],
|
13370
|
+
schemasToRemove: [...new Set(schemasToRemove)],
|
13371
|
+
tablesToTruncate: [...new Set(tablesToTruncate)],
|
13372
|
+
tablesToRemove: [...new Set(tablesToRemove)]
|
13373
|
+
};
|
13374
|
+
};
|
13375
|
+
}
|
13376
|
+
});
|
13377
|
+
|
13237
13378
|
// src/jsonStatements.ts
|
13238
|
-
var preparePgCreateTableJson, prepareMySqlCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareDropEnumJson, prepareMoveEnumJson, prepareRenameEnumJson, prepareCreateSequenceJson, prepareAlterSequenceJson, prepareDropSequenceJson, prepareMoveSequenceJson, prepareRenameSequenceJson, prepareCreateSchemasJson, prepareRenameSchemasJson, prepareDeleteSchemasJson, prepareRenameColumns, _prepareDropColumns, _prepareAddColumns, _prepareSqliteAddColumns, prepareAlterColumnsMysql, preparePgAlterColumns, prepareSqliteAlterColumns, preparePgCreateIndexesJson, prepareCreateIndexesJson, prepareCreateReferencesJson, prepareDropReferencesJson, prepareAlterReferencesJson, prepareDropIndexesJson, prepareAddCompositePrimaryKeySqlite, prepareDeleteCompositePrimaryKeySqlite, prepareAlterCompositePrimaryKeySqlite, prepareAddCompositePrimaryKeyPg, prepareDeleteCompositePrimaryKeyPg, prepareAlterCompositePrimaryKeyPg, prepareAddUniqueConstraintPg, prepareDeleteUniqueConstraintPg, prepareAddCompositePrimaryKeyMySql, prepareDeleteCompositePrimaryKeyMySql, prepareAlterCompositePrimaryKeyMySql;
|
13379
|
+
var preparePgCreateTableJson, prepareMySqlCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareDropEnumJson, prepareMoveEnumJson, prepareRenameEnumJson, prepareCreateSequenceJson, prepareAlterSequenceJson, prepareDropSequenceJson, prepareMoveSequenceJson, prepareRenameSequenceJson, prepareCreateSchemasJson, prepareRenameSchemasJson, prepareDeleteSchemasJson, prepareRenameColumns, _prepareDropColumns, _prepareAddColumns, _prepareSqliteAddColumns, prepareAlterColumnsMysql, preparePgAlterColumns, prepareSqliteAlterColumns, preparePgCreateIndexesJson, prepareCreateIndexesJson, prepareCreateReferencesJson, prepareLibSQLCreateReferencesJson, prepareDropReferencesJson, prepareLibSQLDropReferencesJson, prepareAlterReferencesJson, prepareDropIndexesJson, prepareAddCompositePrimaryKeySqlite, prepareDeleteCompositePrimaryKeySqlite, prepareAlterCompositePrimaryKeySqlite, prepareAddCompositePrimaryKeyPg, prepareDeleteCompositePrimaryKeyPg, prepareAlterCompositePrimaryKeyPg, prepareAddUniqueConstraintPg, prepareDeleteUniqueConstraintPg, prepareAddCompositePrimaryKeyMySql, prepareDeleteCompositePrimaryKeyMySql, prepareAlterCompositePrimaryKeyMySql;
|
13239
13380
|
var init_jsonStatements = __esm({
|
13240
13381
|
"src/jsonStatements.ts"() {
|
13241
13382
|
"use strict";
|
13242
13383
|
init_source();
|
13384
|
+
init_sqlitePushUtils();
|
13243
13385
|
init_views();
|
13244
13386
|
init_mysqlSchema();
|
13245
13387
|
init_pgSchema();
|
@@ -14023,18 +14165,61 @@ var init_jsonStatements = __esm({
|
|
14023
14165
|
const columnPk = json2.tables[tableName].columns[columnName].primaryKey;
|
14024
14166
|
const columnGenerated = json2.tables[tableName].columns[columnName].generated;
|
14025
14167
|
const compositePk = json2.tables[tableName].compositePrimaryKeys[`${tableName}_${columnName}`];
|
14026
|
-
if (
|
14168
|
+
if (column4.autoincrement?.type === "added") {
|
14027
14169
|
statements.push({
|
14028
|
-
type: "
|
14170
|
+
type: "alter_table_alter_column_set_autoincrement",
|
14029
14171
|
tableName,
|
14030
|
-
|
14031
|
-
|
14032
|
-
|
14033
|
-
|
14034
|
-
|
14035
|
-
|
14036
|
-
|
14037
|
-
|
14172
|
+
columnName,
|
14173
|
+
schema: schema4,
|
14174
|
+
newDataType: columnType,
|
14175
|
+
columnDefault,
|
14176
|
+
columnOnUpdate,
|
14177
|
+
columnNotNull,
|
14178
|
+
columnAutoIncrement,
|
14179
|
+
columnPk
|
14180
|
+
});
|
14181
|
+
}
|
14182
|
+
if (column4.autoincrement?.type === "changed") {
|
14183
|
+
const type = column4.autoincrement.new ? "alter_table_alter_column_set_autoincrement" : "alter_table_alter_column_drop_autoincrement";
|
14184
|
+
statements.push({
|
14185
|
+
type,
|
14186
|
+
tableName,
|
14187
|
+
columnName,
|
14188
|
+
schema: schema4,
|
14189
|
+
newDataType: columnType,
|
14190
|
+
columnDefault,
|
14191
|
+
columnOnUpdate,
|
14192
|
+
columnNotNull,
|
14193
|
+
columnAutoIncrement,
|
14194
|
+
columnPk
|
14195
|
+
});
|
14196
|
+
}
|
14197
|
+
if (column4.autoincrement?.type === "deleted") {
|
14198
|
+
statements.push({
|
14199
|
+
type: "alter_table_alter_column_drop_autoincrement",
|
14200
|
+
tableName,
|
14201
|
+
columnName,
|
14202
|
+
schema: schema4,
|
14203
|
+
newDataType: columnType,
|
14204
|
+
columnDefault,
|
14205
|
+
columnOnUpdate,
|
14206
|
+
columnNotNull,
|
14207
|
+
columnAutoIncrement,
|
14208
|
+
columnPk
|
14209
|
+
});
|
14210
|
+
}
|
14211
|
+
if (typeof column4.name !== "string") {
|
14212
|
+
statements.push({
|
14213
|
+
type: "alter_table_rename_column",
|
14214
|
+
tableName,
|
14215
|
+
oldColumnName: column4.name.old,
|
14216
|
+
newColumnName: column4.name.new,
|
14217
|
+
schema: schema4
|
14218
|
+
});
|
14219
|
+
}
|
14220
|
+
if (column4.type?.type === "changed") {
|
14221
|
+
statements.push({
|
14222
|
+
type: "alter_table_alter_column_set_type",
|
14038
14223
|
tableName,
|
14039
14224
|
columnName,
|
14040
14225
|
newDataType: column4.type.new,
|
@@ -14286,6 +14471,37 @@ var init_jsonStatements = __esm({
|
|
14286
14471
|
};
|
14287
14472
|
});
|
14288
14473
|
};
|
14474
|
+
prepareLibSQLCreateReferencesJson = (tableName, schema4, foreignKeys, json2, action) => {
|
14475
|
+
return Object.values(foreignKeys).map((fkData) => {
|
14476
|
+
const { columnsFrom, tableFrom, columnsTo } = action === "push" ? SQLiteSquasher.unsquashPushFK(fkData) : SQLiteSquasher.unsquashFK(fkData);
|
14477
|
+
let isMulticolumn = false;
|
14478
|
+
if (columnsFrom.length > 1 || columnsTo.length > 1) {
|
14479
|
+
isMulticolumn = true;
|
14480
|
+
return {
|
14481
|
+
type: "create_reference",
|
14482
|
+
tableName,
|
14483
|
+
data: fkData,
|
14484
|
+
schema: schema4,
|
14485
|
+
isMulticolumn
|
14486
|
+
};
|
14487
|
+
}
|
14488
|
+
const columnFrom = columnsFrom[0];
|
14489
|
+
const {
|
14490
|
+
notNull: columnNotNull,
|
14491
|
+
default: columnDefault,
|
14492
|
+
type: columnType
|
14493
|
+
} = json2.tables[tableFrom].columns[columnFrom];
|
14494
|
+
return {
|
14495
|
+
type: "create_reference",
|
14496
|
+
tableName,
|
14497
|
+
data: fkData,
|
14498
|
+
schema: schema4,
|
14499
|
+
columnNotNull,
|
14500
|
+
columnDefault,
|
14501
|
+
columnType
|
14502
|
+
};
|
14503
|
+
});
|
14504
|
+
};
|
14289
14505
|
prepareDropReferencesJson = (tableName, schema4, foreignKeys) => {
|
14290
14506
|
return Object.values(foreignKeys).map((fkData) => {
|
14291
14507
|
return {
|
@@ -14296,6 +14512,53 @@ var init_jsonStatements = __esm({
|
|
14296
14512
|
};
|
14297
14513
|
});
|
14298
14514
|
};
|
14515
|
+
prepareLibSQLDropReferencesJson = (tableName, schema4, foreignKeys, json2, meta, action) => {
|
14516
|
+
const statements = Object.values(foreignKeys).map((fkData) => {
|
14517
|
+
const { columnsFrom, tableFrom, columnsTo, name: name2, tableTo, onDelete, onUpdate } = action === "push" ? SQLiteSquasher.unsquashPushFK(fkData) : SQLiteSquasher.unsquashFK(fkData);
|
14518
|
+
const keys = Object.keys(json2.tables[tableName].columns);
|
14519
|
+
const filtered = columnsFrom.filter((it) => keys.includes(it));
|
14520
|
+
const fullDrop = filtered.length === 0;
|
14521
|
+
if (fullDrop) return;
|
14522
|
+
let isMulticolumn = false;
|
14523
|
+
if (columnsFrom.length > 1 || columnsTo.length > 1) {
|
14524
|
+
isMulticolumn = true;
|
14525
|
+
return {
|
14526
|
+
type: "delete_reference",
|
14527
|
+
tableName,
|
14528
|
+
data: fkData,
|
14529
|
+
schema: schema4,
|
14530
|
+
isMulticolumn
|
14531
|
+
};
|
14532
|
+
}
|
14533
|
+
const columnFrom = columnsFrom[0];
|
14534
|
+
const newTableName = getNewTableName(tableFrom, meta);
|
14535
|
+
const {
|
14536
|
+
notNull: columnNotNull,
|
14537
|
+
default: columnDefault,
|
14538
|
+
type: columnType
|
14539
|
+
} = json2.tables[newTableName].columns[columnFrom];
|
14540
|
+
const fkToSquash = {
|
14541
|
+
columnsFrom,
|
14542
|
+
columnsTo,
|
14543
|
+
name: name2,
|
14544
|
+
tableFrom: newTableName,
|
14545
|
+
tableTo,
|
14546
|
+
onDelete,
|
14547
|
+
onUpdate
|
14548
|
+
};
|
14549
|
+
const foreignKey = action === "push" ? SQLiteSquasher.squashPushFK(fkToSquash) : SQLiteSquasher.squashFK(fkToSquash);
|
14550
|
+
return {
|
14551
|
+
type: "delete_reference",
|
14552
|
+
tableName,
|
14553
|
+
data: foreignKey,
|
14554
|
+
schema: schema4,
|
14555
|
+
columnNotNull,
|
14556
|
+
columnDefault,
|
14557
|
+
columnType
|
14558
|
+
};
|
14559
|
+
});
|
14560
|
+
return statements.filter((it) => it);
|
14561
|
+
};
|
14299
14562
|
prepareAlterReferencesJson = (tableName, schema4, foreignKeys) => {
|
14300
14563
|
const stmts = [];
|
14301
14564
|
Object.values(foreignKeys).map((val) => {
|
@@ -14449,10 +14712,292 @@ var init_jsonStatements = __esm({
|
|
14449
14712
|
}
|
14450
14713
|
});
|
14451
14714
|
|
14715
|
+
// src/statementCombiner.ts
|
14716
|
+
var prepareLibSQLRecreateTable, prepareSQLiteRecreateTable, libSQLCombineStatements, sqliteCombineStatements;
|
14717
|
+
var init_statementCombiner = __esm({
|
14718
|
+
"src/statementCombiner.ts"() {
|
14719
|
+
"use strict";
|
14720
|
+
init_jsonStatements();
|
14721
|
+
init_sqliteSchema();
|
14722
|
+
prepareLibSQLRecreateTable = (table4, action) => {
|
14723
|
+
const { name: name2, columns, uniqueConstraints, indexes } = table4;
|
14724
|
+
const composites = Object.values(table4.compositePrimaryKeys).map(
|
14725
|
+
(it) => SQLiteSquasher.unsquashPK(it)
|
14726
|
+
);
|
14727
|
+
const references2 = Object.values(table4.foreignKeys);
|
14728
|
+
const fks = references2.map(
|
14729
|
+
(it) => action === "push" ? SQLiteSquasher.unsquashPushFK(it) : SQLiteSquasher.unsquashFK(it)
|
14730
|
+
);
|
14731
|
+
const statements = [
|
14732
|
+
{
|
14733
|
+
type: "recreate_table",
|
14734
|
+
tableName: name2,
|
14735
|
+
columns: Object.values(columns),
|
14736
|
+
compositePKs: composites,
|
14737
|
+
referenceData: fks,
|
14738
|
+
uniqueConstraints: Object.values(uniqueConstraints)
|
14739
|
+
}
|
14740
|
+
];
|
14741
|
+
if (Object.keys(indexes).length) {
|
14742
|
+
statements.push(...prepareCreateIndexesJson(name2, "", indexes));
|
14743
|
+
}
|
14744
|
+
return statements;
|
14745
|
+
};
|
14746
|
+
prepareSQLiteRecreateTable = (table4, action) => {
|
14747
|
+
const { name: name2, columns, uniqueConstraints, indexes } = table4;
|
14748
|
+
const composites = Object.values(table4.compositePrimaryKeys).map(
|
14749
|
+
(it) => SQLiteSquasher.unsquashPK(it)
|
14750
|
+
);
|
14751
|
+
const references2 = Object.values(table4.foreignKeys);
|
14752
|
+
const fks = references2.map(
|
14753
|
+
(it) => action === "push" ? SQLiteSquasher.unsquashPushFK(it) : SQLiteSquasher.unsquashFK(it)
|
14754
|
+
);
|
14755
|
+
const statements = [
|
14756
|
+
{
|
14757
|
+
type: "recreate_table",
|
14758
|
+
tableName: name2,
|
14759
|
+
columns: Object.values(columns),
|
14760
|
+
compositePKs: composites,
|
14761
|
+
referenceData: fks,
|
14762
|
+
uniqueConstraints: Object.values(uniqueConstraints)
|
14763
|
+
}
|
14764
|
+
];
|
14765
|
+
if (Object.keys(indexes).length) {
|
14766
|
+
statements.push(...prepareCreateIndexesJson(name2, "", indexes));
|
14767
|
+
}
|
14768
|
+
return statements;
|
14769
|
+
};
|
14770
|
+
libSQLCombineStatements = (statements, json2, action) => {
|
14771
|
+
const newStatements = {};
|
14772
|
+
for (const statement of statements) {
|
14773
|
+
if (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" || statement.type === "create_composite_pk" || statement.type === "alter_composite_pk" || statement.type === "delete_composite_pk") {
|
14774
|
+
const tableName2 = statement.tableName;
|
14775
|
+
const statementsForTable2 = newStatements[tableName2];
|
14776
|
+
if (!statementsForTable2) {
|
14777
|
+
newStatements[tableName2] = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
|
14778
|
+
continue;
|
14779
|
+
}
|
14780
|
+
if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
|
14781
|
+
const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
|
14782
|
+
const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
|
14783
|
+
if (wasRename) {
|
14784
|
+
newStatements[tableName2].push(...preparedStatements);
|
14785
|
+
} else {
|
14786
|
+
newStatements[tableName2] = preparedStatements;
|
14787
|
+
}
|
14788
|
+
continue;
|
14789
|
+
}
|
14790
|
+
continue;
|
14791
|
+
}
|
14792
|
+
if (statement.type === "alter_table_alter_column_set_type" || statement.type === "alter_table_alter_column_drop_notnull" || statement.type === "alter_table_alter_column_set_notnull" || statement.type === "alter_table_alter_column_set_default" || statement.type === "alter_table_alter_column_drop_default") {
|
14793
|
+
const { tableName: tableName2, columnName, columnPk } = statement;
|
14794
|
+
const columnIsPartOfForeignKey = Object.values(
|
14795
|
+
json2.tables[tableName2].foreignKeys
|
14796
|
+
).some((it) => {
|
14797
|
+
const unsquashFk = action === "push" ? SQLiteSquasher.unsquashPushFK(it) : SQLiteSquasher.unsquashFK(it);
|
14798
|
+
return unsquashFk.columnsFrom.includes(columnName);
|
14799
|
+
});
|
14800
|
+
const statementsForTable2 = newStatements[tableName2];
|
14801
|
+
if (!statementsForTable2 && (columnIsPartOfForeignKey || columnPk)) {
|
14802
|
+
newStatements[tableName2] = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
|
14803
|
+
continue;
|
14804
|
+
}
|
14805
|
+
if (statementsForTable2 && (columnIsPartOfForeignKey || columnPk)) {
|
14806
|
+
if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
|
14807
|
+
const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
|
14808
|
+
const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
|
14809
|
+
if (wasRename) {
|
14810
|
+
newStatements[tableName2].push(...preparedStatements);
|
14811
|
+
} else {
|
14812
|
+
newStatements[tableName2] = preparedStatements;
|
14813
|
+
}
|
14814
|
+
}
|
14815
|
+
continue;
|
14816
|
+
}
|
14817
|
+
if (statementsForTable2 && !(columnIsPartOfForeignKey || columnPk)) {
|
14818
|
+
if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
|
14819
|
+
newStatements[tableName2].push(statement);
|
14820
|
+
}
|
14821
|
+
continue;
|
14822
|
+
}
|
14823
|
+
newStatements[tableName2] = [statement];
|
14824
|
+
continue;
|
14825
|
+
}
|
14826
|
+
if (statement.type === "create_reference") {
|
14827
|
+
const tableName2 = statement.tableName;
|
14828
|
+
const data = action === "push" ? SQLiteSquasher.unsquashPushFK(statement.data) : SQLiteSquasher.unsquashFK(statement.data);
|
14829
|
+
const statementsForTable2 = newStatements[tableName2];
|
14830
|
+
if (!statementsForTable2) {
|
14831
|
+
newStatements[tableName2] = statement.isMulticolumn ? prepareLibSQLRecreateTable(json2.tables[tableName2], action) : [statement];
|
14832
|
+
continue;
|
14833
|
+
}
|
14834
|
+
if (!statement.isMulticolumn && statementsForTable2.some(
|
14835
|
+
(st) => st.type === "sqlite_alter_table_add_column" && st.column.name === data.columnsFrom[0]
|
14836
|
+
)) {
|
14837
|
+
continue;
|
14838
|
+
}
|
14839
|
+
if (statement.isMulticolumn) {
|
14840
|
+
if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
|
14841
|
+
const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
|
14842
|
+
const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
|
14843
|
+
if (wasRename) {
|
14844
|
+
newStatements[tableName2].push(...preparedStatements);
|
14845
|
+
} else {
|
14846
|
+
newStatements[tableName2] = preparedStatements;
|
14847
|
+
}
|
14848
|
+
continue;
|
14849
|
+
}
|
14850
|
+
continue;
|
14851
|
+
}
|
14852
|
+
if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
|
14853
|
+
newStatements[tableName2].push(statement);
|
14854
|
+
}
|
14855
|
+
continue;
|
14856
|
+
}
|
14857
|
+
if (statement.type === "delete_reference") {
|
14858
|
+
const tableName2 = statement.tableName;
|
14859
|
+
const statementsForTable2 = newStatements[tableName2];
|
14860
|
+
if (!statementsForTable2) {
|
14861
|
+
newStatements[tableName2] = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
|
14862
|
+
continue;
|
14863
|
+
}
|
14864
|
+
if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
|
14865
|
+
const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
|
14866
|
+
const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
|
14867
|
+
if (wasRename) {
|
14868
|
+
newStatements[tableName2].push(...preparedStatements);
|
14869
|
+
} else {
|
14870
|
+
newStatements[tableName2] = preparedStatements;
|
14871
|
+
}
|
14872
|
+
continue;
|
14873
|
+
}
|
14874
|
+
continue;
|
14875
|
+
}
|
14876
|
+
if (statement.type === "sqlite_alter_table_add_column" && statement.column.primaryKey) {
|
14877
|
+
const tableName2 = statement.tableName;
|
14878
|
+
const statementsForTable2 = newStatements[tableName2];
|
14879
|
+
if (!statementsForTable2) {
|
14880
|
+
newStatements[tableName2] = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
|
14881
|
+
continue;
|
14882
|
+
}
|
14883
|
+
if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
|
14884
|
+
const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
|
14885
|
+
const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
|
14886
|
+
if (wasRename) {
|
14887
|
+
newStatements[tableName2].push(...preparedStatements);
|
14888
|
+
} else {
|
14889
|
+
newStatements[tableName2] = preparedStatements;
|
14890
|
+
}
|
14891
|
+
continue;
|
14892
|
+
}
|
14893
|
+
continue;
|
14894
|
+
}
|
14895
|
+
const tableName = statement.type === "rename_table" ? statement.tableNameTo : statement.tableName;
|
14896
|
+
const statementsForTable = newStatements[tableName];
|
14897
|
+
if (!statementsForTable) {
|
14898
|
+
newStatements[tableName] = [statement];
|
14899
|
+
continue;
|
14900
|
+
}
|
14901
|
+
if (!statementsForTable.some(({ type }) => type === "recreate_table")) {
|
14902
|
+
newStatements[tableName].push(statement);
|
14903
|
+
}
|
14904
|
+
}
|
14905
|
+
const combinedStatements = Object.values(newStatements).flat();
|
14906
|
+
const renamedTables = combinedStatements.filter((it) => it.type === "rename_table");
|
14907
|
+
const renamedColumns = combinedStatements.filter((it) => it.type === "alter_table_rename_column");
|
14908
|
+
const rest = combinedStatements.filter((it) => it.type !== "rename_table" && it.type !== "alter_table_rename_column");
|
14909
|
+
return [...renamedTables, ...renamedColumns, ...rest];
|
14910
|
+
};
|
14911
|
+
sqliteCombineStatements = (statements, json2, action) => {
|
14912
|
+
const newStatements = {};
|
14913
|
+
for (const statement of statements) {
|
14914
|
+
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" || statement.type === "delete_reference" || statement.type === "alter_reference" || statement.type === "create_composite_pk" || statement.type === "alter_composite_pk" || statement.type === "delete_composite_pk" || statement.type === "create_unique_constraint" || statement.type === "delete_unique_constraint") {
|
14915
|
+
const tableName2 = statement.tableName;
|
14916
|
+
const statementsForTable2 = newStatements[tableName2];
|
14917
|
+
if (!statementsForTable2) {
|
14918
|
+
newStatements[tableName2] = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
|
14919
|
+
continue;
|
14920
|
+
}
|
14921
|
+
if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
|
14922
|
+
const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
|
14923
|
+
const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
|
14924
|
+
if (wasRename) {
|
14925
|
+
newStatements[tableName2].push(...preparedStatements);
|
14926
|
+
} else {
|
14927
|
+
newStatements[tableName2] = preparedStatements;
|
14928
|
+
}
|
14929
|
+
continue;
|
14930
|
+
}
|
14931
|
+
continue;
|
14932
|
+
}
|
14933
|
+
if (statement.type === "sqlite_alter_table_add_column" && statement.column.primaryKey) {
|
14934
|
+
const tableName2 = statement.tableName;
|
14935
|
+
const statementsForTable2 = newStatements[tableName2];
|
14936
|
+
if (!statementsForTable2) {
|
14937
|
+
newStatements[tableName2] = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
|
14938
|
+
continue;
|
14939
|
+
}
|
14940
|
+
if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
|
14941
|
+
const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
|
14942
|
+
const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
|
14943
|
+
if (wasRename) {
|
14944
|
+
newStatements[tableName2].push(...preparedStatements);
|
14945
|
+
} else {
|
14946
|
+
newStatements[tableName2] = preparedStatements;
|
14947
|
+
}
|
14948
|
+
continue;
|
14949
|
+
}
|
14950
|
+
continue;
|
14951
|
+
}
|
14952
|
+
if (statement.type === "create_reference") {
|
14953
|
+
const tableName2 = statement.tableName;
|
14954
|
+
const data = action === "push" ? SQLiteSquasher.unsquashPushFK(statement.data) : SQLiteSquasher.unsquashFK(statement.data);
|
14955
|
+
const statementsForTable2 = newStatements[tableName2];
|
14956
|
+
if (!statementsForTable2) {
|
14957
|
+
newStatements[tableName2] = prepareSQLiteRecreateTable(json2.tables[tableName2], action);
|
14958
|
+
continue;
|
14959
|
+
}
|
14960
|
+
if (data.columnsFrom.length === 1 && statementsForTable2.some(
|
14961
|
+
(st) => st.type === "sqlite_alter_table_add_column" && st.column.name === data.columnsFrom[0]
|
14962
|
+
)) {
|
14963
|
+
continue;
|
14964
|
+
}
|
14965
|
+
if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
|
14966
|
+
const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
|
14967
|
+
const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
|
14968
|
+
if (wasRename) {
|
14969
|
+
newStatements[tableName2].push(...preparedStatements);
|
14970
|
+
} else {
|
14971
|
+
newStatements[tableName2] = preparedStatements;
|
14972
|
+
}
|
14973
|
+
continue;
|
14974
|
+
}
|
14975
|
+
continue;
|
14976
|
+
}
|
14977
|
+
const tableName = statement.type === "rename_table" ? statement.tableNameTo : statement.tableName;
|
14978
|
+
const statementsForTable = newStatements[tableName];
|
14979
|
+
if (!statementsForTable) {
|
14980
|
+
newStatements[tableName] = [statement];
|
14981
|
+
continue;
|
14982
|
+
}
|
14983
|
+
if (!statementsForTable.some(({ type }) => type === "recreate_table")) {
|
14984
|
+
newStatements[tableName].push(statement);
|
14985
|
+
}
|
14986
|
+
}
|
14987
|
+
const combinedStatements = Object.values(newStatements).flat();
|
14988
|
+
const renamedTables = combinedStatements.filter((it) => it.type === "rename_table");
|
14989
|
+
const renamedColumns = combinedStatements.filter((it) => it.type === "alter_table_rename_column");
|
14990
|
+
const rest = combinedStatements.filter((it) => it.type !== "rename_table" && it.type !== "alter_table_rename_column");
|
14991
|
+
return [...renamedTables, ...renamedColumns, ...rest];
|
14992
|
+
};
|
14993
|
+
}
|
14994
|
+
});
|
14995
|
+
|
14452
14996
|
// src/snapshotsDiffer.ts
|
14453
14997
|
var snapshotsDiffer_exports = {};
|
14454
14998
|
__export(snapshotsDiffer_exports, {
|
14455
14999
|
alteredTableScheme: () => alteredTableScheme,
|
15000
|
+
applyLibSQLSnapshotsDiff: () => applyLibSQLSnapshotsDiff,
|
14456
15001
|
applyMysqlSnapshotsDiff: () => applyMysqlSnapshotsDiff,
|
14457
15002
|
applyPgSnapshotsDiff: () => applyPgSnapshotsDiff,
|
14458
15003
|
applySqliteSnapshotsDiff: () => applySqliteSnapshotsDiff,
|
@@ -14462,7 +15007,7 @@ __export(snapshotsDiffer_exports, {
|
|
14462
15007
|
makePatched: () => makePatched,
|
14463
15008
|
makeSelfOrPatched: () => makeSelfOrPatched
|
14464
15009
|
});
|
14465
|
-
var makeChanged, makeSelfOrChanged, makePatched, makeSelfOrPatched, columnSchema, alteredColumnSchema, enumSchema2, changedEnumSchema, tableScheme, alteredTableScheme, diffResultScheme, diffResultSchemeMysql, diffResultSchemeSQLite, schemaChangeFor, nameChangeFor, nameSchemaChangeFor, columnChangeFor, applyPgSnapshotsDiff, applyMysqlSnapshotsDiff, applySqliteSnapshotsDiff;
|
15010
|
+
var makeChanged, makeSelfOrChanged, makePatched, makeSelfOrPatched, columnSchema, alteredColumnSchema, enumSchema2, changedEnumSchema, tableScheme, alteredTableScheme, diffResultScheme, diffResultSchemeMysql, diffResultSchemeSQLite, schemaChangeFor, nameChangeFor, nameSchemaChangeFor, columnChangeFor, applyPgSnapshotsDiff, applyMysqlSnapshotsDiff, applySqliteSnapshotsDiff, applyLibSQLSnapshotsDiff;
|
14466
15011
|
var init_snapshotsDiffer = __esm({
|
14467
15012
|
"src/snapshotsDiffer.ts"() {
|
14468
15013
|
"use strict";
|
@@ -14474,6 +15019,7 @@ var init_snapshotsDiffer = __esm({
|
|
14474
15019
|
init_mysqlSchema();
|
14475
15020
|
init_pgSchema();
|
14476
15021
|
init_sqliteSchema();
|
15022
|
+
init_statementCombiner();
|
14477
15023
|
init_utils();
|
14478
15024
|
makeChanged = (schema4) => {
|
14479
15025
|
return objectType({
|
@@ -15360,40 +15906,339 @@ var init_snapshotsDiffer = __esm({
|
|
15360
15906
|
const jsonAddedUniqueConstraints = [];
|
15361
15907
|
const jsonDeletedUniqueConstraints = [];
|
15362
15908
|
const jsonAlteredUniqueConstraints = [];
|
15363
|
-
const jsonRenameColumnsStatements = columnRenames.map((it) => prepareRenameColumns(it.table, "", it.renames)).flat();
|
15364
|
-
const jsonAddColumnsStatemets = columnCreates.map((it) => _prepareAddColumns(it.table, "", it.columns)).flat();
|
15365
|
-
const jsonDropColumnsStatemets = columnDeletes.map((it) => _prepareDropColumns(it.table, "", it.columns)).flat();
|
15366
|
-
alteredTables.forEach((it) => {
|
15909
|
+
const jsonRenameColumnsStatements = columnRenames.map((it) => prepareRenameColumns(it.table, "", it.renames)).flat();
|
15910
|
+
const jsonAddColumnsStatemets = columnCreates.map((it) => _prepareAddColumns(it.table, "", it.columns)).flat();
|
15911
|
+
const jsonDropColumnsStatemets = columnDeletes.map((it) => _prepareDropColumns(it.table, "", it.columns)).flat();
|
15912
|
+
alteredTables.forEach((it) => {
|
15913
|
+
let addedColumns = [];
|
15914
|
+
for (const addedPkName of Object.keys(it.addedCompositePKs)) {
|
15915
|
+
const addedPkColumns = it.addedCompositePKs[addedPkName];
|
15916
|
+
addedColumns = MySqlSquasher.unsquashPK(addedPkColumns).columns;
|
15917
|
+
}
|
15918
|
+
let deletedColumns = [];
|
15919
|
+
for (const deletedPkName of Object.keys(it.deletedCompositePKs)) {
|
15920
|
+
const deletedPkColumns = it.deletedCompositePKs[deletedPkName];
|
15921
|
+
deletedColumns = MySqlSquasher.unsquashPK(deletedPkColumns).columns;
|
15922
|
+
}
|
15923
|
+
const doPerformDeleteAndCreate = JSON.stringify(addedColumns) !== JSON.stringify(deletedColumns);
|
15924
|
+
let addedCompositePKs = [];
|
15925
|
+
let deletedCompositePKs = [];
|
15926
|
+
let alteredCompositePKs = [];
|
15927
|
+
addedCompositePKs = prepareAddCompositePrimaryKeyMySql(
|
15928
|
+
it.name,
|
15929
|
+
it.addedCompositePKs,
|
15930
|
+
prevFull,
|
15931
|
+
curFull
|
15932
|
+
);
|
15933
|
+
deletedCompositePKs = prepareDeleteCompositePrimaryKeyMySql(
|
15934
|
+
it.name,
|
15935
|
+
it.deletedCompositePKs,
|
15936
|
+
prevFull
|
15937
|
+
);
|
15938
|
+
alteredCompositePKs = prepareAlterCompositePrimaryKeyMySql(
|
15939
|
+
it.name,
|
15940
|
+
it.alteredCompositePKs,
|
15941
|
+
prevFull,
|
15942
|
+
curFull
|
15943
|
+
);
|
15944
|
+
let addedUniqueConstraints = [];
|
15945
|
+
let deletedUniqueConstraints = [];
|
15946
|
+
let alteredUniqueConstraints = [];
|
15947
|
+
addedUniqueConstraints = prepareAddUniqueConstraintPg(
|
15948
|
+
it.name,
|
15949
|
+
it.schema,
|
15950
|
+
it.addedUniqueConstraints
|
15951
|
+
);
|
15952
|
+
deletedUniqueConstraints = prepareDeleteUniqueConstraintPg(
|
15953
|
+
it.name,
|
15954
|
+
it.schema,
|
15955
|
+
it.deletedUniqueConstraints
|
15956
|
+
);
|
15957
|
+
if (it.alteredUniqueConstraints) {
|
15958
|
+
const added = {};
|
15959
|
+
const deleted = {};
|
15960
|
+
for (const k of Object.keys(it.alteredUniqueConstraints)) {
|
15961
|
+
added[k] = it.alteredUniqueConstraints[k].__new;
|
15962
|
+
deleted[k] = it.alteredUniqueConstraints[k].__old;
|
15963
|
+
}
|
15964
|
+
addedUniqueConstraints.push(
|
15965
|
+
...prepareAddUniqueConstraintPg(it.name, it.schema, added)
|
15966
|
+
);
|
15967
|
+
deletedUniqueConstraints.push(
|
15968
|
+
...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
|
15969
|
+
);
|
15970
|
+
}
|
15971
|
+
jsonAddedCompositePKs.push(...addedCompositePKs);
|
15972
|
+
jsonDeletedCompositePKs.push(...deletedCompositePKs);
|
15973
|
+
jsonAlteredCompositePKs.push(...alteredCompositePKs);
|
15974
|
+
jsonAddedUniqueConstraints.push(...addedUniqueConstraints);
|
15975
|
+
jsonDeletedUniqueConstraints.push(...deletedUniqueConstraints);
|
15976
|
+
jsonAlteredUniqueConstraints.push(...alteredUniqueConstraints);
|
15977
|
+
});
|
15978
|
+
const rColumns = jsonRenameColumnsStatements.map((it) => {
|
15979
|
+
const tableName = it.tableName;
|
15980
|
+
const schema4 = it.schema;
|
15981
|
+
return {
|
15982
|
+
from: { schema: schema4, table: tableName, column: it.oldColumnName },
|
15983
|
+
to: { schema: schema4, table: tableName, column: it.newColumnName }
|
15984
|
+
};
|
15985
|
+
});
|
15986
|
+
const jsonTableAlternations = alteredTables.map((it) => {
|
15987
|
+
return prepareAlterColumnsMysql(
|
15988
|
+
it.name,
|
15989
|
+
it.schema,
|
15990
|
+
it.altered,
|
15991
|
+
json1,
|
15992
|
+
json2,
|
15993
|
+
action
|
15994
|
+
);
|
15995
|
+
}).flat();
|
15996
|
+
const jsonCreateIndexesForAllAlteredTables = alteredTables.map((it) => {
|
15997
|
+
return prepareCreateIndexesJson(
|
15998
|
+
it.name,
|
15999
|
+
it.schema,
|
16000
|
+
it.addedIndexes || {},
|
16001
|
+
curFull.internal
|
16002
|
+
);
|
16003
|
+
}).flat();
|
16004
|
+
const jsonDropIndexesForAllAlteredTables = alteredTables.map((it) => {
|
16005
|
+
return prepareDropIndexesJson(
|
16006
|
+
it.name,
|
16007
|
+
it.schema,
|
16008
|
+
it.deletedIndexes || {}
|
16009
|
+
);
|
16010
|
+
}).flat();
|
16011
|
+
alteredTables.forEach((it) => {
|
16012
|
+
const droppedIndexes = Object.keys(it.alteredIndexes).reduce(
|
16013
|
+
(current, item) => {
|
16014
|
+
current[item] = it.alteredIndexes[item].__old;
|
16015
|
+
return current;
|
16016
|
+
},
|
16017
|
+
{}
|
16018
|
+
);
|
16019
|
+
const createdIndexes = Object.keys(it.alteredIndexes).reduce(
|
16020
|
+
(current, item) => {
|
16021
|
+
current[item] = it.alteredIndexes[item].__new;
|
16022
|
+
return current;
|
16023
|
+
},
|
16024
|
+
{}
|
16025
|
+
);
|
16026
|
+
jsonCreateIndexesForAllAlteredTables.push(
|
16027
|
+
...prepareCreateIndexesJson(it.name, it.schema, createdIndexes || {})
|
16028
|
+
);
|
16029
|
+
jsonDropIndexesForAllAlteredTables.push(
|
16030
|
+
...prepareDropIndexesJson(it.name, it.schema, droppedIndexes || {})
|
16031
|
+
);
|
16032
|
+
});
|
16033
|
+
const jsonCreateReferencesForCreatedTables = createdTables.map((it) => {
|
16034
|
+
return prepareCreateReferencesJson(it.name, it.schema, it.foreignKeys);
|
16035
|
+
}).flat();
|
16036
|
+
const jsonReferencesForAllAlteredTables = alteredTables.map((it) => {
|
16037
|
+
const forAdded = prepareCreateReferencesJson(
|
16038
|
+
it.name,
|
16039
|
+
it.schema,
|
16040
|
+
it.addedForeignKeys
|
16041
|
+
);
|
16042
|
+
const forAltered = prepareDropReferencesJson(
|
16043
|
+
it.name,
|
16044
|
+
it.schema,
|
16045
|
+
it.deletedForeignKeys
|
16046
|
+
);
|
16047
|
+
const alteredFKs = prepareAlterReferencesJson(
|
16048
|
+
it.name,
|
16049
|
+
it.schema,
|
16050
|
+
it.alteredForeignKeys
|
16051
|
+
);
|
16052
|
+
return [...forAdded, ...forAltered, ...alteredFKs];
|
16053
|
+
}).flat();
|
16054
|
+
const jsonCreatedReferencesForAlteredTables = jsonReferencesForAllAlteredTables.filter(
|
16055
|
+
(t) => t.type === "create_reference"
|
16056
|
+
);
|
16057
|
+
const jsonDroppedReferencesForAlteredTables = jsonReferencesForAllAlteredTables.filter(
|
16058
|
+
(t) => t.type === "delete_reference"
|
16059
|
+
);
|
16060
|
+
const jsonMySqlCreateTables = createdTables.map((it) => {
|
16061
|
+
return prepareMySqlCreateTableJson(
|
16062
|
+
it,
|
16063
|
+
curFull,
|
16064
|
+
curFull.internal
|
16065
|
+
);
|
16066
|
+
});
|
16067
|
+
jsonStatements.push(...jsonMySqlCreateTables);
|
16068
|
+
jsonStatements.push(...jsonDropTables);
|
16069
|
+
jsonStatements.push(...jsonRenameTables);
|
16070
|
+
jsonStatements.push(...jsonRenameColumnsStatements);
|
16071
|
+
jsonStatements.push(...jsonDeletedUniqueConstraints);
|
16072
|
+
jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
|
16073
|
+
jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
|
16074
|
+
jsonStatements.push(...jsonDeletedCompositePKs);
|
16075
|
+
jsonStatements.push(...jsonTableAlternations);
|
16076
|
+
jsonStatements.push(...jsonAddedCompositePKs);
|
16077
|
+
jsonStatements.push(...jsonAddedUniqueConstraints);
|
16078
|
+
jsonStatements.push(...jsonDeletedUniqueConstraints);
|
16079
|
+
jsonStatements.push(...jsonAddColumnsStatemets);
|
16080
|
+
jsonStatements.push(...jsonCreateReferencesForCreatedTables);
|
16081
|
+
jsonStatements.push(...jsonCreateIndexesForCreatedTables);
|
16082
|
+
jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
|
16083
|
+
jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
|
16084
|
+
jsonStatements.push(...jsonDropColumnsStatemets);
|
16085
|
+
jsonStatements.push(...jsonAlteredCompositePKs);
|
16086
|
+
jsonStatements.push(...jsonAddedUniqueConstraints);
|
16087
|
+
jsonStatements.push(...jsonAlteredUniqueConstraints);
|
16088
|
+
const sqlStatements = fromJson(jsonStatements, "mysql");
|
16089
|
+
const uniqueSqlStatements = [];
|
16090
|
+
sqlStatements.forEach((ss) => {
|
16091
|
+
if (!uniqueSqlStatements.includes(ss)) {
|
16092
|
+
uniqueSqlStatements.push(ss);
|
16093
|
+
}
|
16094
|
+
});
|
16095
|
+
const rTables = renamedTables.map((it) => {
|
16096
|
+
return { from: it.from, to: it.to };
|
16097
|
+
});
|
16098
|
+
const _meta = prepareMigrationMeta([], rTables, rColumns);
|
16099
|
+
return {
|
16100
|
+
statements: jsonStatements,
|
16101
|
+
sqlStatements: uniqueSqlStatements,
|
16102
|
+
_meta
|
16103
|
+
};
|
16104
|
+
};
|
16105
|
+
applySqliteSnapshotsDiff = async (json1, json2, tablesResolver2, columnsResolver2, prevFull, curFull, action) => {
|
16106
|
+
const tablesDiff = diffSchemasOrTables(json1.tables, json2.tables);
|
16107
|
+
const {
|
16108
|
+
created: createdTables,
|
16109
|
+
deleted: deletedTables,
|
16110
|
+
renamed: renamedTables
|
16111
|
+
} = await tablesResolver2({
|
16112
|
+
created: tablesDiff.added,
|
16113
|
+
deleted: tablesDiff.deleted
|
16114
|
+
});
|
16115
|
+
const tablesPatchedSnap1 = copy(json1);
|
16116
|
+
tablesPatchedSnap1.tables = mapEntries(tablesPatchedSnap1.tables, (_2, it) => {
|
16117
|
+
const { name: name2 } = nameChangeFor(it, renamedTables);
|
16118
|
+
it.name = name2;
|
16119
|
+
return [name2, it];
|
16120
|
+
});
|
16121
|
+
const res = diffColumns(tablesPatchedSnap1.tables, json2.tables);
|
16122
|
+
const columnRenames = [];
|
16123
|
+
const columnCreates = [];
|
16124
|
+
const columnDeletes = [];
|
16125
|
+
for (let entry of Object.values(res)) {
|
16126
|
+
const { renamed, created, deleted } = await columnsResolver2({
|
16127
|
+
tableName: entry.name,
|
16128
|
+
schema: entry.schema,
|
16129
|
+
deleted: entry.columns.deleted,
|
16130
|
+
created: entry.columns.added
|
16131
|
+
});
|
16132
|
+
if (created.length > 0) {
|
16133
|
+
columnCreates.push({
|
16134
|
+
table: entry.name,
|
16135
|
+
columns: created
|
16136
|
+
});
|
16137
|
+
}
|
16138
|
+
if (deleted.length > 0) {
|
16139
|
+
columnDeletes.push({
|
16140
|
+
table: entry.name,
|
16141
|
+
columns: deleted
|
16142
|
+
});
|
16143
|
+
}
|
16144
|
+
if (renamed.length > 0) {
|
16145
|
+
columnRenames.push({
|
16146
|
+
table: entry.name,
|
16147
|
+
renames: renamed
|
16148
|
+
});
|
16149
|
+
}
|
16150
|
+
}
|
16151
|
+
const columnRenamesDict = columnRenames.reduce(
|
16152
|
+
(acc, it) => {
|
16153
|
+
acc[it.table] = it.renames;
|
16154
|
+
return acc;
|
16155
|
+
},
|
16156
|
+
{}
|
16157
|
+
);
|
16158
|
+
const columnsPatchedSnap1 = copy(tablesPatchedSnap1);
|
16159
|
+
columnsPatchedSnap1.tables = mapEntries(
|
16160
|
+
columnsPatchedSnap1.tables,
|
16161
|
+
(tableKey2, tableValue) => {
|
16162
|
+
const patchedColumns = mapKeys(
|
16163
|
+
tableValue.columns,
|
16164
|
+
(columnKey, column4) => {
|
16165
|
+
const rens = columnRenamesDict[tableValue.name] || [];
|
16166
|
+
const newName = columnChangeFor(columnKey, rens);
|
16167
|
+
column4.name = newName;
|
16168
|
+
return newName;
|
16169
|
+
}
|
16170
|
+
);
|
16171
|
+
tableValue.columns = patchedColumns;
|
16172
|
+
return [tableKey2, tableValue];
|
16173
|
+
}
|
16174
|
+
);
|
16175
|
+
const diffResult = applyJsonDiff(columnsPatchedSnap1, json2);
|
16176
|
+
const typedResult = diffResultSchemeSQLite.parse(diffResult);
|
16177
|
+
const tablesMap = {};
|
16178
|
+
typedResult.alteredTablesWithColumns.forEach((obj) => {
|
16179
|
+
tablesMap[obj.name] = obj;
|
16180
|
+
});
|
16181
|
+
const jsonCreateTables = createdTables.map((it) => {
|
16182
|
+
return prepareSQLiteCreateTable(it, action);
|
16183
|
+
});
|
16184
|
+
const jsonCreateIndexesForCreatedTables = createdTables.map((it) => {
|
16185
|
+
return prepareCreateIndexesJson(
|
16186
|
+
it.name,
|
16187
|
+
it.schema,
|
16188
|
+
it.indexes,
|
16189
|
+
curFull.internal
|
16190
|
+
);
|
16191
|
+
}).flat();
|
16192
|
+
const jsonDropTables = deletedTables.map((it) => {
|
16193
|
+
return prepareDropTableJson(it);
|
16194
|
+
});
|
16195
|
+
const jsonRenameTables = renamedTables.map((it) => {
|
16196
|
+
return prepareRenameTableJson(it.from, it.to);
|
16197
|
+
});
|
16198
|
+
const jsonRenameColumnsStatements = columnRenames.map((it) => prepareRenameColumns(it.table, "", it.renames)).flat();
|
16199
|
+
const jsonDropColumnsStatemets = columnDeletes.map((it) => _prepareDropColumns(it.table, "", it.columns)).flat();
|
16200
|
+
const jsonAddColumnsStatemets = columnCreates.map((it) => {
|
16201
|
+
return _prepareSqliteAddColumns(
|
16202
|
+
it.table,
|
16203
|
+
it.columns,
|
16204
|
+
tablesMap[it.table] && tablesMap[it.table].addedForeignKeys ? Object.values(tablesMap[it.table].addedForeignKeys) : []
|
16205
|
+
);
|
16206
|
+
}).flat();
|
16207
|
+
const allAltered = typedResult.alteredTablesWithColumns;
|
16208
|
+
const jsonAddedCompositePKs = [];
|
16209
|
+
const jsonDeletedCompositePKs = [];
|
16210
|
+
const jsonAlteredCompositePKs = [];
|
16211
|
+
const jsonAddedUniqueConstraints = [];
|
16212
|
+
const jsonDeletedUniqueConstraints = [];
|
16213
|
+
const jsonAlteredUniqueConstraints = [];
|
16214
|
+
allAltered.forEach((it) => {
|
15367
16215
|
let addedColumns = [];
|
15368
16216
|
for (const addedPkName of Object.keys(it.addedCompositePKs)) {
|
15369
16217
|
const addedPkColumns = it.addedCompositePKs[addedPkName];
|
15370
|
-
addedColumns =
|
16218
|
+
addedColumns = SQLiteSquasher.unsquashPK(addedPkColumns);
|
15371
16219
|
}
|
15372
16220
|
let deletedColumns = [];
|
15373
16221
|
for (const deletedPkName of Object.keys(it.deletedCompositePKs)) {
|
15374
16222
|
const deletedPkColumns = it.deletedCompositePKs[deletedPkName];
|
15375
|
-
deletedColumns =
|
16223
|
+
deletedColumns = SQLiteSquasher.unsquashPK(deletedPkColumns);
|
15376
16224
|
}
|
15377
16225
|
const doPerformDeleteAndCreate = JSON.stringify(addedColumns) !== JSON.stringify(deletedColumns);
|
15378
16226
|
let addedCompositePKs = [];
|
15379
16227
|
let deletedCompositePKs = [];
|
15380
16228
|
let alteredCompositePKs = [];
|
15381
|
-
|
15382
|
-
|
15383
|
-
|
15384
|
-
|
15385
|
-
|
15386
|
-
|
15387
|
-
|
15388
|
-
|
15389
|
-
|
15390
|
-
|
15391
|
-
|
15392
|
-
alteredCompositePKs = prepareAlterCompositePrimaryKeyMySql(
|
16229
|
+
if (doPerformDeleteAndCreate) {
|
16230
|
+
addedCompositePKs = prepareAddCompositePrimaryKeySqlite(
|
16231
|
+
it.name,
|
16232
|
+
it.addedCompositePKs
|
16233
|
+
);
|
16234
|
+
deletedCompositePKs = prepareDeleteCompositePrimaryKeySqlite(
|
16235
|
+
it.name,
|
16236
|
+
it.deletedCompositePKs
|
16237
|
+
);
|
16238
|
+
}
|
16239
|
+
alteredCompositePKs = prepareAlterCompositePrimaryKeySqlite(
|
15393
16240
|
it.name,
|
15394
|
-
it.alteredCompositePKs
|
15395
|
-
prevFull,
|
15396
|
-
curFull
|
16241
|
+
it.alteredCompositePKs
|
15397
16242
|
);
|
15398
16243
|
let addedUniqueConstraints = [];
|
15399
16244
|
let deletedUniqueConstraints = [];
|
@@ -15437,17 +16282,10 @@ var init_snapshotsDiffer = __esm({
|
|
15437
16282
|
to: { schema: schema4, table: tableName, column: it.newColumnName }
|
15438
16283
|
};
|
15439
16284
|
});
|
15440
|
-
const jsonTableAlternations =
|
15441
|
-
return
|
15442
|
-
it.name,
|
15443
|
-
it.schema,
|
15444
|
-
it.altered,
|
15445
|
-
json1,
|
15446
|
-
json2,
|
15447
|
-
action
|
15448
|
-
);
|
16285
|
+
const jsonTableAlternations = allAltered.map((it) => {
|
16286
|
+
return prepareSqliteAlterColumns(it.name, it.schema, it.altered, json2);
|
15449
16287
|
}).flat();
|
15450
|
-
const jsonCreateIndexesForAllAlteredTables =
|
16288
|
+
const jsonCreateIndexesForAllAlteredTables = allAltered.map((it) => {
|
15451
16289
|
return prepareCreateIndexesJson(
|
15452
16290
|
it.name,
|
15453
16291
|
it.schema,
|
@@ -15455,14 +16293,14 @@ var init_snapshotsDiffer = __esm({
|
|
15455
16293
|
curFull.internal
|
15456
16294
|
);
|
15457
16295
|
}).flat();
|
15458
|
-
const jsonDropIndexesForAllAlteredTables =
|
16296
|
+
const jsonDropIndexesForAllAlteredTables = allAltered.map((it) => {
|
15459
16297
|
return prepareDropIndexesJson(
|
15460
16298
|
it.name,
|
15461
16299
|
it.schema,
|
15462
16300
|
it.deletedIndexes || {}
|
15463
16301
|
);
|
15464
16302
|
}).flat();
|
15465
|
-
|
16303
|
+
allAltered.forEach((it) => {
|
15466
16304
|
const droppedIndexes = Object.keys(it.alteredIndexes).reduce(
|
15467
16305
|
(current, item) => {
|
15468
16306
|
current[item] = it.alteredIndexes[item].__old;
|
@@ -15478,16 +16316,18 @@ var init_snapshotsDiffer = __esm({
|
|
15478
16316
|
{}
|
15479
16317
|
);
|
15480
16318
|
jsonCreateIndexesForAllAlteredTables.push(
|
15481
|
-
...prepareCreateIndexesJson(
|
16319
|
+
...prepareCreateIndexesJson(
|
16320
|
+
it.name,
|
16321
|
+
it.schema,
|
16322
|
+
createdIndexes || {},
|
16323
|
+
curFull.internal
|
16324
|
+
)
|
15482
16325
|
);
|
15483
16326
|
jsonDropIndexesForAllAlteredTables.push(
|
15484
16327
|
...prepareDropIndexesJson(it.name, it.schema, droppedIndexes || {})
|
15485
16328
|
);
|
15486
16329
|
});
|
15487
|
-
const
|
15488
|
-
return prepareCreateReferencesJson(it.name, it.schema, it.foreignKeys);
|
15489
|
-
}).flat();
|
15490
|
-
const jsonReferencesForAllAlteredTables = alteredTables.map((it) => {
|
16330
|
+
const jsonReferencesForAllAlteredTables = allAltered.map((it) => {
|
15491
16331
|
const forAdded = prepareCreateReferencesJson(
|
15492
16332
|
it.name,
|
15493
16333
|
it.schema,
|
@@ -15511,35 +16351,25 @@ var init_snapshotsDiffer = __esm({
|
|
15511
16351
|
const jsonDroppedReferencesForAlteredTables = jsonReferencesForAllAlteredTables.filter(
|
15512
16352
|
(t) => t.type === "delete_reference"
|
15513
16353
|
);
|
15514
|
-
const
|
15515
|
-
|
15516
|
-
it,
|
15517
|
-
curFull,
|
15518
|
-
curFull.internal
|
15519
|
-
);
|
15520
|
-
});
|
15521
|
-
jsonStatements.push(...jsonMySqlCreateTables);
|
16354
|
+
const jsonStatements = [];
|
16355
|
+
jsonStatements.push(...jsonCreateTables);
|
15522
16356
|
jsonStatements.push(...jsonDropTables);
|
15523
16357
|
jsonStatements.push(...jsonRenameTables);
|
15524
16358
|
jsonStatements.push(...jsonRenameColumnsStatements);
|
15525
|
-
jsonStatements.push(...jsonDeletedUniqueConstraints);
|
15526
16359
|
jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
|
15527
16360
|
jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
|
15528
16361
|
jsonStatements.push(...jsonDeletedCompositePKs);
|
15529
16362
|
jsonStatements.push(...jsonTableAlternations);
|
15530
16363
|
jsonStatements.push(...jsonAddedCompositePKs);
|
15531
|
-
jsonStatements.push(...jsonAddedUniqueConstraints);
|
15532
|
-
jsonStatements.push(...jsonDeletedUniqueConstraints);
|
15533
16364
|
jsonStatements.push(...jsonAddColumnsStatemets);
|
15534
|
-
jsonStatements.push(...jsonCreateReferencesForCreatedTables);
|
15535
16365
|
jsonStatements.push(...jsonCreateIndexesForCreatedTables);
|
15536
|
-
jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
|
15537
16366
|
jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
|
16367
|
+
jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
|
15538
16368
|
jsonStatements.push(...jsonDropColumnsStatemets);
|
15539
16369
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
15540
|
-
jsonStatements.push(...jsonAddedUniqueConstraints);
|
15541
16370
|
jsonStatements.push(...jsonAlteredUniqueConstraints);
|
15542
|
-
const
|
16371
|
+
const combinedJsonStatements = sqliteCombineStatements(jsonStatements, json2, action);
|
16372
|
+
const sqlStatements = fromJson(combinedJsonStatements, "sqlite");
|
15543
16373
|
const uniqueSqlStatements = [];
|
15544
16374
|
sqlStatements.forEach((ss) => {
|
15545
16375
|
if (!uniqueSqlStatements.includes(ss)) {
|
@@ -15551,12 +16381,12 @@ var init_snapshotsDiffer = __esm({
|
|
15551
16381
|
});
|
15552
16382
|
const _meta = prepareMigrationMeta([], rTables, rColumns);
|
15553
16383
|
return {
|
15554
|
-
statements:
|
16384
|
+
statements: combinedJsonStatements,
|
15555
16385
|
sqlStatements: uniqueSqlStatements,
|
15556
16386
|
_meta
|
15557
16387
|
};
|
15558
16388
|
};
|
15559
|
-
|
16389
|
+
applyLibSQLSnapshotsDiff = async (json1, json2, tablesResolver2, columnsResolver2, prevFull, curFull, action) => {
|
15560
16390
|
const tablesDiff = diffSchemasOrTables(json1.tables, json2.tables);
|
15561
16391
|
const {
|
15562
16392
|
created: createdTables,
|
@@ -15658,6 +16488,18 @@ var init_snapshotsDiffer = __esm({
|
|
15658
16488
|
tablesMap[it.table] && tablesMap[it.table].addedForeignKeys ? Object.values(tablesMap[it.table].addedForeignKeys) : []
|
15659
16489
|
);
|
15660
16490
|
}).flat();
|
16491
|
+
const rColumns = jsonRenameColumnsStatements.map((it) => {
|
16492
|
+
const tableName = it.tableName;
|
16493
|
+
const schema4 = it.schema;
|
16494
|
+
return {
|
16495
|
+
from: { schema: schema4, table: tableName, column: it.oldColumnName },
|
16496
|
+
to: { schema: schema4, table: tableName, column: it.newColumnName }
|
16497
|
+
};
|
16498
|
+
});
|
16499
|
+
const rTables = renamedTables.map((it) => {
|
16500
|
+
return { from: it.from, to: it.to };
|
16501
|
+
});
|
16502
|
+
const _meta = prepareMigrationMeta([], rTables, rColumns);
|
15661
16503
|
const allAltered = typedResult.alteredTablesWithColumns;
|
15662
16504
|
const jsonAddedCompositePKs = [];
|
15663
16505
|
const jsonDeletedCompositePKs = [];
|
@@ -15728,14 +16570,6 @@ var init_snapshotsDiffer = __esm({
|
|
15728
16570
|
jsonDeletedUniqueConstraints.push(...deletedUniqueConstraints);
|
15729
16571
|
jsonAlteredUniqueConstraints.push(...alteredUniqueConstraints);
|
15730
16572
|
});
|
15731
|
-
const rColumns = jsonRenameColumnsStatements.map((it) => {
|
15732
|
-
const tableName = it.tableName;
|
15733
|
-
const schema4 = it.schema;
|
15734
|
-
return {
|
15735
|
-
from: { schema: schema4, table: tableName, column: it.oldColumnName },
|
15736
|
-
to: { schema: schema4, table: tableName, column: it.newColumnName }
|
15737
|
-
};
|
15738
|
-
});
|
15739
16573
|
const jsonTableAlternations = allAltered.map((it) => {
|
15740
16574
|
return prepareSqliteAlterColumns(it.name, it.schema, it.altered, json2);
|
15741
16575
|
}).flat();
|
@@ -15782,21 +16616,22 @@ var init_snapshotsDiffer = __esm({
|
|
15782
16616
|
);
|
15783
16617
|
});
|
15784
16618
|
const jsonReferencesForAllAlteredTables = allAltered.map((it) => {
|
15785
|
-
const forAdded =
|
15786
|
-
it.name,
|
15787
|
-
it.schema,
|
15788
|
-
it.addedForeignKeys
|
15789
|
-
);
|
15790
|
-
const forAltered = prepareDropReferencesJson(
|
16619
|
+
const forAdded = prepareLibSQLCreateReferencesJson(
|
15791
16620
|
it.name,
|
15792
16621
|
it.schema,
|
15793
|
-
it.
|
16622
|
+
it.addedForeignKeys,
|
16623
|
+
json2,
|
16624
|
+
action
|
15794
16625
|
);
|
15795
|
-
const
|
16626
|
+
const forAltered = prepareLibSQLDropReferencesJson(
|
15796
16627
|
it.name,
|
15797
16628
|
it.schema,
|
15798
|
-
it.
|
16629
|
+
it.deletedForeignKeys,
|
16630
|
+
json2,
|
16631
|
+
_meta,
|
16632
|
+
action
|
15799
16633
|
);
|
16634
|
+
const alteredFKs = prepareAlterReferencesJson(it.name, it.schema, it.alteredForeignKeys);
|
15800
16635
|
return [...forAdded, ...forAltered, ...alteredFKs];
|
15801
16636
|
}).flat();
|
15802
16637
|
const jsonCreatedReferencesForAlteredTables = jsonReferencesForAllAlteredTables.filter(
|
@@ -15822,19 +16657,21 @@ var init_snapshotsDiffer = __esm({
|
|
15822
16657
|
jsonStatements.push(...jsonDropColumnsStatemets);
|
15823
16658
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
15824
16659
|
jsonStatements.push(...jsonAlteredUniqueConstraints);
|
15825
|
-
const
|
16660
|
+
const combinedJsonStatements = libSQLCombineStatements(jsonStatements, json2, action);
|
16661
|
+
const sqlStatements = fromJson(
|
16662
|
+
combinedJsonStatements,
|
16663
|
+
"turso",
|
16664
|
+
action,
|
16665
|
+
json2
|
16666
|
+
);
|
15826
16667
|
const uniqueSqlStatements = [];
|
15827
16668
|
sqlStatements.forEach((ss) => {
|
15828
16669
|
if (!uniqueSqlStatements.includes(ss)) {
|
15829
16670
|
uniqueSqlStatements.push(ss);
|
15830
16671
|
}
|
15831
16672
|
});
|
15832
|
-
const rTables = renamedTables.map((it) => {
|
15833
|
-
return { from: it.from, to: it.to };
|
15834
|
-
});
|
15835
|
-
const _meta = prepareMigrationMeta([], rTables, rColumns);
|
15836
16673
|
return {
|
15837
|
-
statements:
|
16674
|
+
statements: combinedJsonStatements,
|
15838
16675
|
sqlStatements: uniqueSqlStatements,
|
15839
16676
|
_meta
|
15840
16677
|
};
|
@@ -15858,7 +16695,7 @@ var init_schemaValidator = __esm({
|
|
15858
16695
|
init_mysqlSchema();
|
15859
16696
|
init_pgSchema();
|
15860
16697
|
init_sqliteSchema();
|
15861
|
-
dialects = ["postgresql", "mysql", "sqlite"];
|
16698
|
+
dialects = ["postgresql", "mysql", "sqlite", "turso"];
|
15862
16699
|
dialect3 = enumType(dialects);
|
15863
16700
|
commonSquashedSchema = unionType([
|
15864
16701
|
pgSchemaSquashed,
|
@@ -15878,7 +16715,6 @@ var init_common = __esm({
|
|
15878
16715
|
init_schemaValidator();
|
15879
16716
|
init_outputs();
|
15880
16717
|
sqliteDriversLiterals = [
|
15881
|
-
literalType("turso"),
|
15882
16718
|
literalType("d1-http"),
|
15883
16719
|
literalType("expo")
|
15884
16720
|
];
|
@@ -33960,6 +34796,21 @@ var init_cli = __esm({
|
|
33960
34796
|
}
|
33961
34797
|
});
|
33962
34798
|
|
34799
|
+
// src/cli/validations/libsql.ts
|
34800
|
+
var libSQLCredentials;
|
34801
|
+
var init_libsql = __esm({
|
34802
|
+
"src/cli/validations/libsql.ts"() {
|
34803
|
+
"use strict";
|
34804
|
+
init_lib();
|
34805
|
+
init_views();
|
34806
|
+
init_common();
|
34807
|
+
libSQLCredentials = objectType({
|
34808
|
+
url: stringType().min(1),
|
34809
|
+
authToken: stringType().min(1).optional()
|
34810
|
+
});
|
34811
|
+
}
|
34812
|
+
});
|
34813
|
+
|
33963
34814
|
// src/cli/validations/mysql.ts
|
33964
34815
|
var mysqlCredentials;
|
33965
34816
|
var init_mysql = __esm({
|
@@ -34131,6 +34982,8 @@ var init_utils8 = __esm({
|
|
34131
34982
|
init_serializer();
|
34132
34983
|
init_cli();
|
34133
34984
|
init_common();
|
34985
|
+
init_libsql();
|
34986
|
+
init_libsql();
|
34134
34987
|
init_mysql();
|
34135
34988
|
init_outputs();
|
34136
34989
|
init_postgres();
|
@@ -35088,284 +35941,8 @@ var sqlitePushIntrospect = async (db, filters) => {
|
|
35088
35941
|
return { schema: schema4 };
|
35089
35942
|
};
|
35090
35943
|
|
35091
|
-
// src/cli/commands/sqlitePushUtils.ts
|
35092
|
-
init_source();
|
35093
|
-
init_sqliteSchema();
|
35094
|
-
init_sqlgenerator();
|
35095
|
-
var _moveDataStatements = (tableName, json, dataLoss = false) => {
|
35096
|
-
const statements = [];
|
35097
|
-
statements.push(
|
35098
|
-
new SqliteRenameTableConvertor().convert({
|
35099
|
-
type: "rename_table",
|
35100
|
-
tableNameFrom: tableName,
|
35101
|
-
tableNameTo: `__old_push_${tableName}`,
|
35102
|
-
fromSchema: "",
|
35103
|
-
toSchema: ""
|
35104
|
-
})
|
35105
|
-
);
|
35106
|
-
const tableColumns = Object.values(json.tables[tableName].columns);
|
35107
|
-
const referenceData = Object.values(json.tables[tableName].foreignKeys);
|
35108
|
-
const compositePKs = Object.values(
|
35109
|
-
json.tables[tableName].compositePrimaryKeys
|
35110
|
-
).map((it) => SQLiteSquasher.unsquashPK(it));
|
35111
|
-
const fks = referenceData.map((it) => SQLiteSquasher.unsquashPushFK(it));
|
35112
|
-
statements.push(
|
35113
|
-
new SQLiteCreateTableConvertor().convert({
|
35114
|
-
type: "sqlite_create_table",
|
35115
|
-
tableName,
|
35116
|
-
columns: tableColumns,
|
35117
|
-
referenceData: fks,
|
35118
|
-
compositePKs
|
35119
|
-
})
|
35120
|
-
);
|
35121
|
-
if (!dataLoss) {
|
35122
|
-
statements.push(
|
35123
|
-
`INSERT INTO "${tableName}" SELECT * FROM "__old_push_${tableName}";`
|
35124
|
-
);
|
35125
|
-
}
|
35126
|
-
statements.push(
|
35127
|
-
new SQLiteDropTableConvertor().convert({
|
35128
|
-
type: "drop_table",
|
35129
|
-
tableName: `__old_push_${tableName}`,
|
35130
|
-
schema: ""
|
35131
|
-
})
|
35132
|
-
);
|
35133
|
-
for (const idx of Object.values(json.tables[tableName].indexes)) {
|
35134
|
-
statements.push(
|
35135
|
-
new CreateSqliteIndexConvertor().convert({
|
35136
|
-
type: "create_index",
|
35137
|
-
tableName,
|
35138
|
-
schema: "",
|
35139
|
-
data: idx
|
35140
|
-
})
|
35141
|
-
);
|
35142
|
-
}
|
35143
|
-
return statements;
|
35144
|
-
};
|
35145
|
-
var getOldTableName = (tableName, meta) => {
|
35146
|
-
for (const key of Object.keys(meta.tables)) {
|
35147
|
-
const value = meta.tables[key];
|
35148
|
-
if (`"${tableName}"` === value) {
|
35149
|
-
return key.substring(1, key.length - 1);
|
35150
|
-
}
|
35151
|
-
}
|
35152
|
-
return tableName;
|
35153
|
-
};
|
35154
|
-
var getNewTableName = (tableName, meta) => {
|
35155
|
-
if (typeof meta.tables[`"${tableName}"`] !== "undefined") {
|
35156
|
-
return meta.tables[`"${tableName}"`].substring(
|
35157
|
-
1,
|
35158
|
-
meta.tables[`"${tableName}"`].length - 1
|
35159
|
-
);
|
35160
|
-
}
|
35161
|
-
return tableName;
|
35162
|
-
};
|
35163
|
-
var logSuggestionsAndReturn = async (connection, statements, json1, json2, meta) => {
|
35164
|
-
let shouldAskForApprove = false;
|
35165
|
-
const statementsToExecute = [];
|
35166
|
-
const infoToPrint = [];
|
35167
|
-
const tablesToRemove = [];
|
35168
|
-
const columnsToRemove = [];
|
35169
|
-
const schemasToRemove = [];
|
35170
|
-
const tablesToTruncate = [];
|
35171
|
-
const tablesContext = {};
|
35172
|
-
for (const statement of statements) {
|
35173
|
-
if (statement.type === "drop_table") {
|
35174
|
-
const res = await connection.query(
|
35175
|
-
`select count(*) as count from \`${statement.tableName}\``
|
35176
|
-
);
|
35177
|
-
const count2 = Number(res[0].count);
|
35178
|
-
if (count2 > 0) {
|
35179
|
-
infoToPrint.push(
|
35180
|
-
`\xB7 You're about to delete ${source_default.underline(
|
35181
|
-
statement.tableName
|
35182
|
-
)} table with ${count2} items`
|
35183
|
-
);
|
35184
|
-
tablesToRemove.push(statement.tableName);
|
35185
|
-
shouldAskForApprove = true;
|
35186
|
-
}
|
35187
|
-
const stmnt = fromJson([statement], "sqlite")[0];
|
35188
|
-
statementsToExecute.push(stmnt);
|
35189
|
-
} else if (statement.type === "alter_table_drop_column") {
|
35190
|
-
const newTableName = getOldTableName(statement.tableName, meta);
|
35191
|
-
const columnIsPartOfPk = Object.values(
|
35192
|
-
json1.tables[newTableName].compositePrimaryKeys
|
35193
|
-
).find((c) => SQLiteSquasher.unsquashPK(c).includes(statement.columnName));
|
35194
|
-
const columnIsPartOfIndex = Object.values(
|
35195
|
-
json1.tables[newTableName].indexes
|
35196
|
-
).find((c) => SQLiteSquasher.unsquashIdx(c).columns.includes(statement.columnName));
|
35197
|
-
const columnIsPk = json1.tables[newTableName].columns[statement.columnName].primaryKey;
|
35198
|
-
const columnIsPartOfFk = Object.values(
|
35199
|
-
json1.tables[newTableName].foreignKeys
|
35200
|
-
).find(
|
35201
|
-
(t) => SQLiteSquasher.unsquashPushFK(t).columnsFrom.includes(
|
35202
|
-
statement.columnName
|
35203
|
-
)
|
35204
|
-
);
|
35205
|
-
const res = await connection.query(
|
35206
|
-
`select count(*) as count from \`${newTableName}\``
|
35207
|
-
);
|
35208
|
-
const count2 = Number(res[0].count);
|
35209
|
-
if (count2 > 0) {
|
35210
|
-
infoToPrint.push(
|
35211
|
-
`\xB7 You're about to delete ${source_default.underline(
|
35212
|
-
statement.columnName
|
35213
|
-
)} column in ${newTableName} table with ${count2} items`
|
35214
|
-
);
|
35215
|
-
columnsToRemove.push(`${newTableName}_${statement.columnName}`);
|
35216
|
-
shouldAskForApprove = true;
|
35217
|
-
}
|
35218
|
-
if (columnIsPk || columnIsPartOfPk || columnIsPartOfIndex || columnIsPartOfFk) {
|
35219
|
-
tablesContext[newTableName] = [
|
35220
|
-
..._moveDataStatements(statement.tableName, json2, true)
|
35221
|
-
];
|
35222
|
-
const tablesReferncingCurrent = [];
|
35223
|
-
for (const table4 of Object.values(json1.tables)) {
|
35224
|
-
const tablesRefs = Object.values(json1.tables[table4.name].foreignKeys).filter(
|
35225
|
-
(t) => SQLiteSquasher.unsquashPushFK(t).tableTo === newTableName
|
35226
|
-
).map((t) => SQLiteSquasher.unsquashPushFK(t).tableFrom);
|
35227
|
-
tablesReferncingCurrent.push(...tablesRefs);
|
35228
|
-
}
|
35229
|
-
const uniqueTableRefs = [...new Set(tablesReferncingCurrent)];
|
35230
|
-
for (const table4 of uniqueTableRefs) {
|
35231
|
-
if (typeof tablesContext[table4] === "undefined") {
|
35232
|
-
tablesContext[table4] = [..._moveDataStatements(table4, json2)];
|
35233
|
-
}
|
35234
|
-
}
|
35235
|
-
} else {
|
35236
|
-
if (typeof tablesContext[newTableName] === "undefined") {
|
35237
|
-
const stmnt = fromJson([statement], "sqlite")[0];
|
35238
|
-
statementsToExecute.push(stmnt);
|
35239
|
-
}
|
35240
|
-
}
|
35241
|
-
} else if (statement.type === "sqlite_alter_table_add_column") {
|
35242
|
-
const newTableName = getOldTableName(statement.tableName, meta);
|
35243
|
-
if (statement.column.notNull && !statement.column.default) {
|
35244
|
-
const res = await connection.query(
|
35245
|
-
`select count(*) as count from \`${newTableName}\``
|
35246
|
-
);
|
35247
|
-
const count2 = Number(res[0].count);
|
35248
|
-
if (count2 > 0) {
|
35249
|
-
infoToPrint.push(
|
35250
|
-
`\xB7 You're about to add not-null ${source_default.underline(
|
35251
|
-
statement.column.name
|
35252
|
-
)} column without default value, which contains ${count2} items`
|
35253
|
-
);
|
35254
|
-
tablesToTruncate.push(newTableName);
|
35255
|
-
statementsToExecute.push(`delete from ${newTableName};`);
|
35256
|
-
shouldAskForApprove = true;
|
35257
|
-
}
|
35258
|
-
}
|
35259
|
-
if (statement.column.primaryKey) {
|
35260
|
-
tablesContext[newTableName] = [
|
35261
|
-
..._moveDataStatements(statement.tableName, json2, true)
|
35262
|
-
];
|
35263
|
-
const tablesReferncingCurrent = [];
|
35264
|
-
for (const table4 of Object.values(json1.tables)) {
|
35265
|
-
const tablesRefs = Object.values(json1.tables[table4.name].foreignKeys).filter(
|
35266
|
-
(t) => SQLiteSquasher.unsquashPushFK(t).tableTo === newTableName
|
35267
|
-
).map((t) => SQLiteSquasher.unsquashPushFK(t).tableFrom);
|
35268
|
-
tablesReferncingCurrent.push(...tablesRefs);
|
35269
|
-
}
|
35270
|
-
const uniqueTableRefs = [...new Set(tablesReferncingCurrent)];
|
35271
|
-
for (const table4 of uniqueTableRefs) {
|
35272
|
-
if (typeof tablesContext[table4] === "undefined") {
|
35273
|
-
tablesContext[table4] = [..._moveDataStatements(table4, json2)];
|
35274
|
-
}
|
35275
|
-
}
|
35276
|
-
} else {
|
35277
|
-
if (typeof tablesContext[newTableName] === "undefined") {
|
35278
|
-
const stmnt = fromJson([statement], "sqlite")[0];
|
35279
|
-
statementsToExecute.push(stmnt);
|
35280
|
-
}
|
35281
|
-
}
|
35282
|
-
} 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") {
|
35283
|
-
if (!(statement.type === "alter_table_alter_column_set_notnull" && statement.columnPk)) {
|
35284
|
-
const newTableName = getOldTableName(statement.tableName, meta);
|
35285
|
-
if (statement.type === "alter_table_alter_column_set_notnull" && typeof statement.columnDefault === "undefined") {
|
35286
|
-
const res = await connection.query(
|
35287
|
-
`select count(*) as count from \`${newTableName}\``
|
35288
|
-
);
|
35289
|
-
const count2 = Number(res[0].count);
|
35290
|
-
if (count2 > 0) {
|
35291
|
-
infoToPrint.push(
|
35292
|
-
`\xB7 You're about to add not-null constraint to ${source_default.underline(
|
35293
|
-
statement.columnName
|
35294
|
-
)} column without default value, which contains ${count2} items`
|
35295
|
-
);
|
35296
|
-
tablesToTruncate.push(newTableName);
|
35297
|
-
shouldAskForApprove = true;
|
35298
|
-
}
|
35299
|
-
tablesContext[newTableName] = _moveDataStatements(
|
35300
|
-
statement.tableName,
|
35301
|
-
json1,
|
35302
|
-
true
|
35303
|
-
);
|
35304
|
-
} else {
|
35305
|
-
if (typeof tablesContext[newTableName] === "undefined") {
|
35306
|
-
tablesContext[newTableName] = _moveDataStatements(
|
35307
|
-
statement.tableName,
|
35308
|
-
json1
|
35309
|
-
);
|
35310
|
-
}
|
35311
|
-
}
|
35312
|
-
const tablesReferncingCurrent = [];
|
35313
|
-
for (const table4 of Object.values(json1.tables)) {
|
35314
|
-
const tablesRefs = Object.values(json1.tables[table4.name].foreignKeys).filter(
|
35315
|
-
(t) => SQLiteSquasher.unsquashPushFK(t).tableTo === newTableName
|
35316
|
-
).map((t) => {
|
35317
|
-
return getNewTableName(
|
35318
|
-
SQLiteSquasher.unsquashPushFK(t).tableFrom,
|
35319
|
-
meta
|
35320
|
-
);
|
35321
|
-
});
|
35322
|
-
tablesReferncingCurrent.push(...tablesRefs);
|
35323
|
-
}
|
35324
|
-
const uniqueTableRefs = [...new Set(tablesReferncingCurrent)];
|
35325
|
-
for (const table4 of uniqueTableRefs) {
|
35326
|
-
if (typeof tablesContext[table4] === "undefined") {
|
35327
|
-
tablesContext[table4] = [..._moveDataStatements(table4, json1)];
|
35328
|
-
}
|
35329
|
-
}
|
35330
|
-
}
|
35331
|
-
} else if (statement.type === "create_reference" || statement.type === "delete_reference" || statement.type === "alter_reference") {
|
35332
|
-
const fk4 = SQLiteSquasher.unsquashPushFK(statement.data);
|
35333
|
-
if (typeof tablesContext[statement.tableName] === "undefined") {
|
35334
|
-
tablesContext[statement.tableName] = _moveDataStatements(
|
35335
|
-
statement.tableName,
|
35336
|
-
json2
|
35337
|
-
);
|
35338
|
-
}
|
35339
|
-
} else if (statement.type === "create_composite_pk" || statement.type === "alter_composite_pk" || statement.type === "delete_composite_pk" || statement.type === "create_unique_constraint" || statement.type === "delete_unique_constraint") {
|
35340
|
-
const newTableName = getOldTableName(statement.tableName, meta);
|
35341
|
-
if (typeof tablesContext[newTableName] === "undefined") {
|
35342
|
-
tablesContext[newTableName] = _moveDataStatements(
|
35343
|
-
statement.tableName,
|
35344
|
-
json2
|
35345
|
-
);
|
35346
|
-
}
|
35347
|
-
} else {
|
35348
|
-
const stmnt = fromJson([statement], "sqlite");
|
35349
|
-
if (typeof stmnt !== "undefined") {
|
35350
|
-
statementsToExecute.push(...stmnt);
|
35351
|
-
}
|
35352
|
-
}
|
35353
|
-
}
|
35354
|
-
for (const context of Object.values(tablesContext)) {
|
35355
|
-
statementsToExecute.push(...context);
|
35356
|
-
}
|
35357
|
-
return {
|
35358
|
-
statementsToExecute,
|
35359
|
-
shouldAskForApprove,
|
35360
|
-
infoToPrint,
|
35361
|
-
columnsToRemove: [...new Set(columnsToRemove)],
|
35362
|
-
schemasToRemove: [...new Set(schemasToRemove)],
|
35363
|
-
tablesToTruncate: [...new Set(tablesToTruncate)],
|
35364
|
-
tablesToRemove: [...new Set(tablesToRemove)]
|
35365
|
-
};
|
35366
|
-
};
|
35367
|
-
|
35368
35944
|
// src/api.ts
|
35945
|
+
init_sqlitePushUtils();
|
35369
35946
|
init_global();
|
35370
35947
|
init_migrationPreparator();
|
35371
35948
|
init_mysqlSchema();
|