drizzle-kit 0.25.0-20acc2f → 0.25.0-22c3e40
Sign up to get free protection for your applications and to get access to all the features.
- package/api.d.mts +0 -82
- package/api.d.ts +0 -82
- package/api.js +95 -676
- package/api.mjs +95 -676
- package/bin.cjs +103 -759
- package/package.json +1 -1
- package/utils.js +6 -24
- package/utils.mjs +6 -24
package/api.mjs
CHANGED
@@ -7381,7 +7381,7 @@ var init_lib = __esm({
|
|
7381
7381
|
});
|
7382
7382
|
|
7383
7383
|
// src/serializer/mysqlSchema.ts
|
7384
|
-
var index, fk, column, tableV3, compositePK, uniqueConstraint,
|
7384
|
+
var index, fk, column, tableV3, compositePK, uniqueConstraint, tableV4, table, kitInternals, dialect, schemaHash, schemaInternalV3, schemaInternalV4, schemaInternalV5, schemaInternal, schemaV3, schemaV4, schemaV5, schema, tableSquashedV4, tableSquashed, schemaSquashed, schemaSquashedV4, MySqlSquasher, squashMysqlScheme, mysqlSchema, mysqlSchemaV5, mysqlSchemaSquashed, backwardCompatibleMysqlSchema, dryMySql;
|
7385
7385
|
var init_mysqlSchema = __esm({
|
7386
7386
|
"src/serializer/mysqlSchema.ts"() {
|
7387
7387
|
"use strict";
|
@@ -7431,10 +7431,6 @@ var init_mysqlSchema = __esm({
|
|
7431
7431
|
name: stringType(),
|
7432
7432
|
columns: stringType().array()
|
7433
7433
|
}).strict();
|
7434
|
-
checkConstraint = objectType({
|
7435
|
-
name: stringType(),
|
7436
|
-
value: stringType()
|
7437
|
-
}).strict();
|
7438
7434
|
tableV4 = objectType({
|
7439
7435
|
name: stringType(),
|
7440
7436
|
schema: stringType().optional(),
|
@@ -7448,8 +7444,7 @@ var init_mysqlSchema = __esm({
|
|
7448
7444
|
indexes: recordType(stringType(), index),
|
7449
7445
|
foreignKeys: recordType(stringType(), fk),
|
7450
7446
|
compositePrimaryKeys: recordType(stringType(), compositePK),
|
7451
|
-
uniqueConstraints: recordType(stringType(), uniqueConstraint).default({})
|
7452
|
-
checkConstraint: recordType(stringType(), checkConstraint).default({})
|
7447
|
+
uniqueConstraints: recordType(stringType(), uniqueConstraint).default({})
|
7453
7448
|
}).strict();
|
7454
7449
|
kitInternals = objectType({
|
7455
7450
|
tables: recordType(
|
@@ -7526,8 +7521,7 @@ var init_mysqlSchema = __esm({
|
|
7526
7521
|
indexes: recordType(stringType(), stringType()),
|
7527
7522
|
foreignKeys: recordType(stringType(), stringType()),
|
7528
7523
|
compositePrimaryKeys: recordType(stringType(), stringType()),
|
7529
|
-
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
7530
|
-
checkConstraints: recordType(stringType(), stringType()).default({})
|
7524
|
+
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
7531
7525
|
}).strict();
|
7532
7526
|
schemaSquashed = objectType({
|
7533
7527
|
version: literalType("5"),
|
@@ -7594,13 +7588,6 @@ var init_mysqlSchema = __esm({
|
|
7594
7588
|
onDelete
|
7595
7589
|
});
|
7596
7590
|
return result;
|
7597
|
-
},
|
7598
|
-
squashCheck: (input) => {
|
7599
|
-
return `${input.name};${input.value}`;
|
7600
|
-
},
|
7601
|
-
unsquashCheck: (input) => {
|
7602
|
-
const [name2, value] = input.split(";");
|
7603
|
-
return { name: name2, value };
|
7604
7591
|
}
|
7605
7592
|
};
|
7606
7593
|
squashMysqlScheme = (json3) => {
|
@@ -7621,9 +7608,6 @@ var init_mysqlSchema = __esm({
|
|
7621
7608
|
return MySqlSquasher.squashUnique(unq);
|
7622
7609
|
}
|
7623
7610
|
);
|
7624
|
-
const squashedCheckConstraints = mapValues(it[1].checkConstraint, (check) => {
|
7625
|
-
return MySqlSquasher.squashCheck(check);
|
7626
|
-
});
|
7627
7611
|
return [
|
7628
7612
|
it[0],
|
7629
7613
|
{
|
@@ -7632,8 +7616,7 @@ var init_mysqlSchema = __esm({
|
|
7632
7616
|
indexes: squashedIndexes,
|
7633
7617
|
foreignKeys: squashedFKs,
|
7634
7618
|
compositePrimaryKeys: squashedPKs,
|
7635
|
-
uniqueConstraints: squashedUniqueConstraints
|
7636
|
-
checkConstraints: squashedCheckConstraints
|
7619
|
+
uniqueConstraints: squashedUniqueConstraints
|
7637
7620
|
}
|
7638
7621
|
];
|
7639
7622
|
})
|
@@ -7683,7 +7666,7 @@ var init_vector = __esm({
|
|
7683
7666
|
});
|
7684
7667
|
|
7685
7668
|
// src/serializer/pgSchema.ts
|
7686
|
-
var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, indexColumn, index2, indexV4, indexV5, indexV6, fk2, sequenceSchema, sequenceSquashed, columnV7, column2,
|
7669
|
+
var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, indexColumn, index2, indexV4, indexV5, indexV6, fk2, sequenceSchema, sequenceSquashed, columnV7, column2, columnSquashed, tableV32, compositePK2, uniqueConstraint2, tableV42, tableV5, tableV6, tableV7, table2, schemaHash2, kitInternals2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternalV5, pgSchemaInternalV6, pgSchemaExternal, pgSchemaInternalV7, pgSchemaInternal, tableSquashed2, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashedV6, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchemaV5, pgSchemaV6, pgSchemaV7, pgSchema, backwardCompatiblePgSchema, PgSquasher, squashPgScheme, dryPg;
|
7687
7670
|
var init_pgSchema = __esm({
|
7688
7671
|
"src/serializer/pgSchema.ts"() {
|
7689
7672
|
"use strict";
|
@@ -7847,10 +7830,6 @@ var init_pgSchema = __esm({
|
|
7847
7830
|
}).optional(),
|
7848
7831
|
identity: sequenceSchema.merge(objectType({ type: enumType(["always", "byDefault"]) })).optional()
|
7849
7832
|
}).strict();
|
7850
|
-
checkConstraint2 = objectType({
|
7851
|
-
name: stringType(),
|
7852
|
-
value: stringType()
|
7853
|
-
}).strict();
|
7854
7833
|
columnSquashed = objectType({
|
7855
7834
|
name: stringType(),
|
7856
7835
|
type: stringType(),
|
@@ -7923,8 +7902,7 @@ var init_pgSchema = __esm({
|
|
7923
7902
|
indexes: recordType(stringType(), index2),
|
7924
7903
|
foreignKeys: recordType(stringType(), fk2),
|
7925
7904
|
compositePrimaryKeys: recordType(stringType(), compositePK2),
|
7926
|
-
uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
|
7927
|
-
checkConstraints: recordType(stringType(), checkConstraint2).default({})
|
7905
|
+
uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
|
7928
7906
|
}).strict();
|
7929
7907
|
schemaHash2 = objectType({
|
7930
7908
|
id: stringType(),
|
@@ -8032,8 +8010,7 @@ var init_pgSchema = __esm({
|
|
8032
8010
|
indexes: recordType(stringType(), stringType()),
|
8033
8011
|
foreignKeys: recordType(stringType(), stringType()),
|
8034
8012
|
compositePrimaryKeys: recordType(stringType(), stringType()),
|
8035
|
-
uniqueConstraints: recordType(stringType(), stringType())
|
8036
|
-
checkConstraints: recordType(stringType(), stringType())
|
8013
|
+
uniqueConstraints: recordType(stringType(), stringType())
|
8037
8014
|
}).strict();
|
8038
8015
|
tableSquashedV42 = objectType({
|
8039
8016
|
name: stringType(),
|
@@ -8215,16 +8192,6 @@ var init_pgSchema = __esm({
|
|
8215
8192
|
cache: splitted[6] !== "undefined" ? splitted[6] : void 0,
|
8216
8193
|
cycle: splitted[7] === "true"
|
8217
8194
|
};
|
8218
|
-
},
|
8219
|
-
squashCheck: (check) => {
|
8220
|
-
return `${check.name};${check.value}`;
|
8221
|
-
},
|
8222
|
-
unsquashCheck: (input) => {
|
8223
|
-
const [
|
8224
|
-
name2,
|
8225
|
-
value
|
8226
|
-
] = input.split(";");
|
8227
|
-
return { name: name2, value };
|
8228
8195
|
}
|
8229
8196
|
};
|
8230
8197
|
squashPgScheme = (json3, action) => {
|
@@ -8257,12 +8224,6 @@ var init_pgSchema = __esm({
|
|
8257
8224
|
return PgSquasher.squashUnique(unq);
|
8258
8225
|
}
|
8259
8226
|
);
|
8260
|
-
const squashedChecksContraints = mapValues(
|
8261
|
-
it[1].checkConstraints,
|
8262
|
-
(check) => {
|
8263
|
-
return PgSquasher.squashCheck(check);
|
8264
|
-
}
|
8265
|
-
);
|
8266
8227
|
return [
|
8267
8228
|
it[0],
|
8268
8229
|
{
|
@@ -8272,8 +8233,7 @@ var init_pgSchema = __esm({
|
|
8272
8233
|
indexes: squashedIndexes,
|
8273
8234
|
foreignKeys: squashedFKs,
|
8274
8235
|
compositePrimaryKeys: squashedPKs,
|
8275
|
-
uniqueConstraints: squashedUniqueConstraints
|
8276
|
-
checkConstraints: squashedChecksContraints
|
8236
|
+
uniqueConstraints: squashedUniqueConstraints
|
8277
8237
|
}
|
8278
8238
|
];
|
8279
8239
|
})
|
@@ -8318,7 +8278,7 @@ var init_pgSchema = __esm({
|
|
8318
8278
|
});
|
8319
8279
|
|
8320
8280
|
// src/serializer/sqliteSchema.ts
|
8321
|
-
var index3, fk3, compositePK3, column3, tableV33, uniqueConstraint3,
|
8281
|
+
var index3, fk3, compositePK3, column3, tableV33, uniqueConstraint3, table3, dialect2, schemaHash3, schemaInternalV32, schemaInternalV42, schemaInternalV52, kitInternals3, latestVersion, schemaInternal2, schemaV32, schemaV42, schemaV52, schema2, tableSquashed3, schemaSquashed2, SQLiteSquasher, squashSqliteScheme, drySQLite, sqliteSchemaV5, sqliteSchema, SQLiteSchemaSquashed, backwardCompatibleSqliteSchema;
|
8322
8282
|
var init_sqliteSchema = __esm({
|
8323
8283
|
"src/serializer/sqliteSchema.ts"() {
|
8324
8284
|
"use strict";
|
@@ -8365,18 +8325,13 @@ var init_sqliteSchema = __esm({
|
|
8365
8325
|
name: stringType(),
|
8366
8326
|
columns: stringType().array()
|
8367
8327
|
}).strict();
|
8368
|
-
checkConstraint3 = objectType({
|
8369
|
-
name: stringType(),
|
8370
|
-
value: stringType()
|
8371
|
-
}).strict();
|
8372
8328
|
table3 = objectType({
|
8373
8329
|
name: stringType(),
|
8374
8330
|
columns: recordType(stringType(), column3),
|
8375
8331
|
indexes: recordType(stringType(), index3),
|
8376
8332
|
foreignKeys: recordType(stringType(), fk3),
|
8377
8333
|
compositePrimaryKeys: recordType(stringType(), compositePK3),
|
8378
|
-
uniqueConstraints: recordType(stringType(), uniqueConstraint3).default({})
|
8379
|
-
checkConstraints: recordType(stringType(), checkConstraint3).default({})
|
8334
|
+
uniqueConstraints: recordType(stringType(), uniqueConstraint3).default({})
|
8380
8335
|
}).strict();
|
8381
8336
|
dialect2 = enumType(["sqlite"]);
|
8382
8337
|
schemaHash3 = objectType({
|
@@ -8438,8 +8393,7 @@ var init_sqliteSchema = __esm({
|
|
8438
8393
|
indexes: recordType(stringType(), stringType()),
|
8439
8394
|
foreignKeys: recordType(stringType(), stringType()),
|
8440
8395
|
compositePrimaryKeys: recordType(stringType(), stringType()),
|
8441
|
-
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
8442
|
-
checkConstraints: recordType(stringType(), stringType()).default({})
|
8396
|
+
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
8443
8397
|
}).strict();
|
8444
8398
|
schemaSquashed2 = objectType({
|
8445
8399
|
version: latestVersion,
|
@@ -8521,16 +8475,6 @@ var init_sqliteSchema = __esm({
|
|
8521
8475
|
},
|
8522
8476
|
unsquashPK: (pk) => {
|
8523
8477
|
return pk.split(",");
|
8524
|
-
},
|
8525
|
-
squashCheck: (check) => {
|
8526
|
-
return `${check.name};${check.value}`;
|
8527
|
-
},
|
8528
|
-
unsquashCheck: (input) => {
|
8529
|
-
const [
|
8530
|
-
name2,
|
8531
|
-
value
|
8532
|
-
] = input.split(";");
|
8533
|
-
return { name: name2, value };
|
8534
8478
|
}
|
8535
8479
|
};
|
8536
8480
|
squashSqliteScheme = (json3, action) => {
|
@@ -8557,12 +8501,6 @@ var init_sqliteSchema = __esm({
|
|
8557
8501
|
return SQLiteSquasher.squashUnique(unq);
|
8558
8502
|
}
|
8559
8503
|
);
|
8560
|
-
const squashedCheckConstraints = mapValues(
|
8561
|
-
it[1].checkConstraints,
|
8562
|
-
(check) => {
|
8563
|
-
return SQLiteSquasher.squashCheck(check);
|
8564
|
-
}
|
8565
|
-
);
|
8566
8504
|
return [
|
8567
8505
|
it[0],
|
8568
8506
|
{
|
@@ -8571,8 +8509,7 @@ var init_sqliteSchema = __esm({
|
|
8571
8509
|
indexes: squashedIndexes,
|
8572
8510
|
foreignKeys: squashedFKs,
|
8573
8511
|
compositePrimaryKeys: squashedPKs,
|
8574
|
-
uniqueConstraints: squashedUniqueConstraints
|
8575
|
-
checkConstraints: squashedCheckConstraints
|
8512
|
+
uniqueConstraints: squashedUniqueConstraints
|
8576
8513
|
}
|
8577
8514
|
];
|
8578
8515
|
})
|
@@ -11453,21 +11390,6 @@ var init_jsonDiffer = __esm({
|
|
11453
11390
|
return !it[0].endsWith("__deleted") && !it[0].endsWith("__added");
|
11454
11391
|
})
|
11455
11392
|
);
|
11456
|
-
const addedCheckConstraints = Object.fromEntries(
|
11457
|
-
Object.entries(table4.checkConstraints || {}).filter((it) => {
|
11458
|
-
return it[0].endsWith("__added");
|
11459
|
-
})
|
11460
|
-
);
|
11461
|
-
const deletedCheckConstraints = Object.fromEntries(
|
11462
|
-
Object.entries(table4.checkConstraints || {}).filter((it) => {
|
11463
|
-
return it[0].endsWith("__deleted");
|
11464
|
-
})
|
11465
|
-
);
|
11466
|
-
const alteredCheckConstraints = Object.fromEntries(
|
11467
|
-
Object.entries(table4.checkConstraints || {}).filter((it) => {
|
11468
|
-
return !it[0].endsWith("__deleted") && !it[0].endsWith("__added");
|
11469
|
-
})
|
11470
|
-
);
|
11471
11393
|
const mappedAltered = altered.map((it) => alternationsInColumn(it)).filter(Boolean);
|
11472
11394
|
return {
|
11473
11395
|
name: table4.name,
|
@@ -11484,10 +11406,7 @@ var init_jsonDiffer = __esm({
|
|
11484
11406
|
alteredCompositePKs,
|
11485
11407
|
addedUniqueConstraints,
|
11486
11408
|
deletedUniqueConstraints,
|
11487
|
-
alteredUniqueConstraints
|
11488
|
-
addedCheckConstraints,
|
11489
|
-
deletedCheckConstraints,
|
11490
|
-
alteredCheckConstraints
|
11409
|
+
alteredUniqueConstraints
|
11491
11410
|
};
|
11492
11411
|
};
|
11493
11412
|
alternationsInColumn = (column4) => {
|
@@ -11741,32 +11660,6 @@ var init_jsonDiffer = __esm({
|
|
11741
11660
|
};
|
11742
11661
|
}
|
11743
11662
|
return it;
|
11744
|
-
}).map((it) => {
|
11745
|
-
if ("" in it) {
|
11746
|
-
return {
|
11747
|
-
...it,
|
11748
|
-
autoincrement: {
|
11749
|
-
type: "changed",
|
11750
|
-
old: it.autoincrement.__old,
|
11751
|
-
new: it.autoincrement.__new
|
11752
|
-
}
|
11753
|
-
};
|
11754
|
-
}
|
11755
|
-
if ("autoincrement__added" in it) {
|
11756
|
-
const { autoincrement__added, ...others } = it;
|
11757
|
-
return {
|
11758
|
-
...others,
|
11759
|
-
autoincrement: { type: "added", value: it.autoincrement__added }
|
11760
|
-
};
|
11761
|
-
}
|
11762
|
-
if ("autoincrement__deleted" in it) {
|
11763
|
-
const { autoincrement__deleted, ...others } = it;
|
11764
|
-
return {
|
11765
|
-
...others,
|
11766
|
-
autoincrement: { type: "deleted", value: it.autoincrement__deleted }
|
11767
|
-
};
|
11768
|
-
}
|
11769
|
-
return it;
|
11770
11663
|
}).filter(Boolean);
|
11771
11664
|
return result[0];
|
11772
11665
|
};
|
@@ -11787,7 +11680,7 @@ function fromJson(statements, dialect4, action, json22) {
|
|
11787
11680
|
}).filter((it) => it !== "");
|
11788
11681
|
return result;
|
11789
11682
|
}
|
11790
|
-
var pgNativeTypes, isPgNativeType, Convertor, PgCreateTableConvertor, MySqlCreateTableConvertor, SQLiteCreateTableConvertor, PgAlterTableAlterColumnSetGenerated, PgAlterTableAlterColumnDropGenerated, PgAlterTableAlterColumnAlterGenerated, PgAlterTableAddUniqueConstraintConvertor, PgAlterTableDropUniqueConstraintConvertor,
|
11683
|
+
var pgNativeTypes, isPgNativeType, Convertor, PgCreateTableConvertor, MySqlCreateTableConvertor, SQLiteCreateTableConvertor, PgAlterTableAlterColumnSetGenerated, PgAlterTableAlterColumnDropGenerated, PgAlterTableAlterColumnAlterGenerated, PgAlterTableAddUniqueConstraintConvertor, PgAlterTableDropUniqueConstraintConvertor, MySQLAlterTableAddUniqueConstraintConvertor, MySQLAlterTableDropUniqueConstraintConvertor, CreatePgSequenceConvertor, DropPgSequenceConvertor, RenamePgSequenceConvertor, MovePgSequenceConvertor, AlterPgSequenceConvertor, CreateTypeEnumConvertor, DropTypeEnumConvertor, AlterTypeAddValueConvertor, AlterTypeSetSchemaConvertor, AlterRenameTypeConvertor, AlterTypeDropValueConvertor, 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;
|
11791
11684
|
var init_sqlgenerator = __esm({
|
11792
11685
|
"src/sqlgenerator.ts"() {
|
11793
11686
|
"use strict";
|
@@ -11848,7 +11741,7 @@ var init_sqlgenerator = __esm({
|
|
11848
11741
|
return statement.type === "create_table" && dialect4 === "postgresql";
|
11849
11742
|
}
|
11850
11743
|
convert(st) {
|
11851
|
-
const { tableName, schema: schema4, columns, compositePKs, uniqueConstraints
|
11744
|
+
const { tableName, schema: schema4, columns, compositePKs, uniqueConstraints } = st;
|
11852
11745
|
let statement = "";
|
11853
11746
|
const name2 = schema4 ? `"${schema4}"."${tableName}"` : `"${tableName}"`;
|
11854
11747
|
statement += `CREATE TABLE IF NOT EXISTS ${name2} (
|
@@ -11881,13 +11774,6 @@ var init_sqlgenerator = __esm({
|
|
11881
11774
|
statement += ` CONSTRAINT "${unsquashedUnique.name}" UNIQUE${unsquashedUnique.nullsNotDistinct ? " NULLS NOT DISTINCT" : ""}("${unsquashedUnique.columns.join(`","`)}")`;
|
11882
11775
|
}
|
11883
11776
|
}
|
11884
|
-
if (typeof checkConstraints !== "undefined" && checkConstraints.length > 0) {
|
11885
|
-
for (const checkConstraint4 of checkConstraints) {
|
11886
|
-
statement += ",\n";
|
11887
|
-
const unsquashedCheck = PgSquasher.unsquashCheck(checkConstraint4);
|
11888
|
-
statement += ` CONSTRAINT "${unsquashedCheck.name}" CHECK (${unsquashedCheck.value})`;
|
11889
|
-
}
|
11890
|
-
}
|
11891
11777
|
statement += `
|
11892
11778
|
);`;
|
11893
11779
|
statement += `
|
@@ -11904,7 +11790,6 @@ var init_sqlgenerator = __esm({
|
|
11904
11790
|
tableName,
|
11905
11791
|
columns,
|
11906
11792
|
schema: schema4,
|
11907
|
-
checkConstraints,
|
11908
11793
|
compositePKs,
|
11909
11794
|
uniqueConstraints,
|
11910
11795
|
internals
|
@@ -11938,13 +11823,6 @@ var init_sqlgenerator = __esm({
|
|
11938
11823
|
statement += ` CONSTRAINT \`${unsquashedUnique.name}\` UNIQUE(${uniqueString})`;
|
11939
11824
|
}
|
11940
11825
|
}
|
11941
|
-
if (typeof checkConstraints !== "undefined" && checkConstraints.length > 0) {
|
11942
|
-
for (const checkConstraint4 of checkConstraints) {
|
11943
|
-
statement += ",\n";
|
11944
|
-
const unsquashedCheck = MySqlSquasher.unsquashCheck(checkConstraint4);
|
11945
|
-
statement += ` CONSTRAINT \`${unsquashedCheck.name}\` CHECK(${unsquashedCheck.value})`;
|
11946
|
-
}
|
11947
|
-
}
|
11948
11826
|
statement += `
|
11949
11827
|
);`;
|
11950
11828
|
statement += `
|
@@ -11962,8 +11840,7 @@ var init_sqlgenerator = __esm({
|
|
11962
11840
|
columns,
|
11963
11841
|
referenceData,
|
11964
11842
|
compositePKs,
|
11965
|
-
uniqueConstraints
|
11966
|
-
checkConstraints
|
11843
|
+
uniqueConstraints
|
11967
11844
|
} = st;
|
11968
11845
|
let statement = "";
|
11969
11846
|
statement += `CREATE TABLE \`${tableName}\` (
|
@@ -12004,17 +11881,10 @@ var init_sqlgenerator = __esm({
|
|
12004
11881
|
if (typeof uniqueConstraints !== "undefined" && uniqueConstraints.length > 0) {
|
12005
11882
|
for (const uniqueConstraint4 of uniqueConstraints) {
|
12006
11883
|
statement += ",\n";
|
12007
|
-
const unsquashedUnique =
|
11884
|
+
const unsquashedUnique = MySqlSquasher.unsquashUnique(uniqueConstraint4);
|
12008
11885
|
statement += ` CONSTRAINT ${unsquashedUnique.name} UNIQUE(\`${unsquashedUnique.columns.join(`\`,\``)}\`)`;
|
12009
11886
|
}
|
12010
11887
|
}
|
12011
|
-
if (typeof checkConstraints !== "undefined" && checkConstraints.length > 0) {
|
12012
|
-
for (const check of checkConstraints) {
|
12013
|
-
statement += ",\n";
|
12014
|
-
const { value, name: name2 } = SQLiteSquasher.unsquashCheck(check);
|
12015
|
-
statement += ` CONSTRAINT "${name2}" CHECK(${value})`;
|
12016
|
-
}
|
12017
|
-
}
|
12018
11888
|
statement += `
|
12019
11889
|
`;
|
12020
11890
|
statement += `);`;
|
@@ -12114,25 +11984,6 @@ var init_sqlgenerator = __esm({
|
|
12114
11984
|
return `ALTER TABLE ${tableNameWithSchema} DROP CONSTRAINT "${unsquashed.name}";`;
|
12115
11985
|
}
|
12116
11986
|
};
|
12117
|
-
PgAlterTableAddCheckConstraintConvertor = class extends Convertor {
|
12118
|
-
can(statement, dialect4) {
|
12119
|
-
return statement.type === "create_check_constraint" && dialect4 === "postgresql";
|
12120
|
-
}
|
12121
|
-
convert(statement) {
|
12122
|
-
const unsquashed = PgSquasher.unsquashCheck(statement.data);
|
12123
|
-
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
12124
|
-
return `ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${unsquashed.name}" CHECK (${unsquashed.value});`;
|
12125
|
-
}
|
12126
|
-
};
|
12127
|
-
PgAlterTableDeleteCheckConstraintConvertor = class extends Convertor {
|
12128
|
-
can(statement, dialect4) {
|
12129
|
-
return statement.type === "delete_check_constraint" && dialect4 === "postgresql";
|
12130
|
-
}
|
12131
|
-
convert(statement) {
|
12132
|
-
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
12133
|
-
return `ALTER TABLE ${tableNameWithSchema} DROP CONSTRAINT "${statement.constraintName}";`;
|
12134
|
-
}
|
12135
|
-
};
|
12136
11987
|
MySQLAlterTableAddUniqueConstraintConvertor = class extends Convertor {
|
12137
11988
|
can(statement, dialect4) {
|
12138
11989
|
return statement.type === "create_unique_constraint" && dialect4 === "mysql";
|
@@ -12151,25 +12002,6 @@ var init_sqlgenerator = __esm({
|
|
12151
12002
|
return `ALTER TABLE \`${statement.tableName}\` DROP INDEX \`${unsquashed.name}\`;`;
|
12152
12003
|
}
|
12153
12004
|
};
|
12154
|
-
MySqlAlterTableAddCheckConstraintConvertor = class extends Convertor {
|
12155
|
-
can(statement, dialect4) {
|
12156
|
-
return statement.type === "create_check_constraint" && dialect4 === "mysql";
|
12157
|
-
}
|
12158
|
-
convert(statement) {
|
12159
|
-
const unsquashed = MySqlSquasher.unsquashCheck(statement.data);
|
12160
|
-
const { tableName } = statement;
|
12161
|
-
return `ALTER TABLE \`${tableName}\` ADD CONSTRAINT \`${unsquashed.name}\` CHECK (${unsquashed.value});`;
|
12162
|
-
}
|
12163
|
-
};
|
12164
|
-
MySqlAlterTableDeleteCheckConstraintConvertor = class extends Convertor {
|
12165
|
-
can(statement, dialect4) {
|
12166
|
-
return statement.type === "delete_check_constraint" && dialect4 === "mysql";
|
12167
|
-
}
|
12168
|
-
convert(statement) {
|
12169
|
-
const { tableName } = statement;
|
12170
|
-
return `ALTER TABLE \`${tableName}\` DROP CONSTRAINT \`${statement.constraintName}\`;`;
|
12171
|
-
}
|
12172
|
-
};
|
12173
12005
|
CreatePgSequenceConvertor = class extends Convertor {
|
12174
12006
|
can(statement, dialect4) {
|
12175
12007
|
return statement.type === "create_sequence" && dialect4 === "postgresql";
|
@@ -12773,7 +12605,7 @@ var init_sqlgenerator = __esm({
|
|
12773
12605
|
};
|
12774
12606
|
LibSQLModifyColumn = class extends Convertor {
|
12775
12607
|
can(statement, dialect4) {
|
12776
|
-
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"
|
12608
|
+
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") && dialect4 === "turso";
|
12777
12609
|
}
|
12778
12610
|
convert(statement, json22) {
|
12779
12611
|
const { tableName, columnName } = statement;
|
@@ -13360,22 +13192,18 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
13360
13192
|
return statement.type === "recreate_table" && dialect4 === "sqlite";
|
13361
13193
|
}
|
13362
13194
|
convert(statement) {
|
13363
|
-
const { tableName, columns, compositePKs, referenceData
|
13195
|
+
const { tableName, columns, compositePKs, referenceData } = statement;
|
13364
13196
|
const columnNames = columns.map((it) => `"${it.name}"`).join(", ");
|
13365
13197
|
const newTableName = `__new_${tableName}`;
|
13366
13198
|
const sqlStatements = [];
|
13367
13199
|
sqlStatements.push(`PRAGMA foreign_keys=OFF;`);
|
13368
|
-
const mappedCheckConstraints = checkConstraints.map(
|
13369
|
-
(it) => it.replaceAll(`"${tableName}".`, `"${newTableName}".`).replaceAll(`\`${tableName}\`.`, `\`${newTableName}\`.`).replaceAll(`${tableName}.`, `${newTableName}.`).replaceAll(`'${tableName}'.`, `'${newTableName}'.`)
|
13370
|
-
);
|
13371
13200
|
sqlStatements.push(
|
13372
13201
|
new SQLiteCreateTableConvertor().convert({
|
13373
13202
|
type: "sqlite_create_table",
|
13374
13203
|
tableName: newTableName,
|
13375
13204
|
columns,
|
13376
13205
|
referenceData,
|
13377
|
-
compositePKs
|
13378
|
-
checkConstraints: mappedCheckConstraints
|
13206
|
+
compositePKs
|
13379
13207
|
})
|
13380
13208
|
);
|
13381
13209
|
sqlStatements.push(
|
@@ -13406,13 +13234,10 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
13406
13234
|
return statement.type === "recreate_table" && dialect4 === "turso";
|
13407
13235
|
}
|
13408
13236
|
convert(statement) {
|
13409
|
-
const { tableName, columns, compositePKs, referenceData
|
13237
|
+
const { tableName, columns, compositePKs, referenceData } = statement;
|
13410
13238
|
const columnNames = columns.map((it) => `"${it.name}"`).join(", ");
|
13411
13239
|
const newTableName = `__new_${tableName}`;
|
13412
13240
|
const sqlStatements = [];
|
13413
|
-
const mappedCheckConstraints = checkConstraints.map(
|
13414
|
-
(it) => it.replaceAll(`"${tableName}".`, `"${newTableName}".`).replaceAll(`\`${tableName}\`.`, `\`${newTableName}\`.`).replaceAll(`${tableName}.`, `${newTableName}.`).replaceAll(`'${tableName}'.`, `\`${newTableName}\`.`)
|
13415
|
-
);
|
13416
13241
|
sqlStatements.push(`PRAGMA foreign_keys=OFF;`);
|
13417
13242
|
sqlStatements.push(
|
13418
13243
|
new SQLiteCreateTableConvertor().convert({
|
@@ -13420,8 +13245,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
13420
13245
|
tableName: newTableName,
|
13421
13246
|
columns,
|
13422
13247
|
referenceData,
|
13423
|
-
compositePKs
|
13424
|
-
checkConstraints: mappedCheckConstraints
|
13248
|
+
compositePKs
|
13425
13249
|
})
|
13426
13250
|
);
|
13427
13251
|
sqlStatements.push(
|
@@ -13482,10 +13306,6 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
13482
13306
|
convertors.push(new PgAlterTableAlterColumnSetTypeConvertor());
|
13483
13307
|
convertors.push(new PgAlterTableAddUniqueConstraintConvertor());
|
13484
13308
|
convertors.push(new PgAlterTableDropUniqueConstraintConvertor());
|
13485
|
-
convertors.push(new PgAlterTableAddCheckConstraintConvertor());
|
13486
|
-
convertors.push(new PgAlterTableDeleteCheckConstraintConvertor());
|
13487
|
-
convertors.push(new MySqlAlterTableAddCheckConstraintConvertor());
|
13488
|
-
convertors.push(new MySqlAlterTableDeleteCheckConstraintConvertor());
|
13489
13309
|
convertors.push(new MySQLAlterTableAddUniqueConstraintConvertor());
|
13490
13310
|
convertors.push(new MySQLAlterTableDropUniqueConstraintConvertor());
|
13491
13311
|
convertors.push(new CreatePgIndexConvertor());
|
@@ -13575,10 +13395,6 @@ var init_sqlitePushUtils = __esm({
|
|
13575
13395
|
const compositePKs = Object.values(
|
13576
13396
|
json3.tables[tableName].compositePrimaryKeys
|
13577
13397
|
).map((it) => SQLiteSquasher.unsquashPK(it));
|
13578
|
-
const checkConstraints = Object.values(json3.tables[tableName].checkConstraints);
|
13579
|
-
const mappedCheckConstraints = checkConstraints.map(
|
13580
|
-
(it) => it.replaceAll(`"${tableName}".`, `"${newTableName}".`).replaceAll(`\`${tableName}\`.`, `\`${newTableName}\`.`).replaceAll(`${tableName}.`, `${newTableName}.`).replaceAll(`'${tableName}'.`, `\`${newTableName}\`.`)
|
13581
|
-
);
|
13582
13398
|
const fks = referenceData.map((it) => SQLiteSquasher.unsquashPushFK(it));
|
13583
13399
|
statements.push(
|
13584
13400
|
new SQLiteCreateTableConvertor().convert({
|
@@ -13586,8 +13402,7 @@ var init_sqlitePushUtils = __esm({
|
|
13586
13402
|
tableName: newTableName,
|
13587
13403
|
columns: tableColumns,
|
13588
13404
|
referenceData: fks,
|
13589
|
-
compositePKs
|
13590
|
-
checkConstraints: mappedCheckConstraints
|
13405
|
+
compositePKs
|
13591
13406
|
})
|
13592
13407
|
);
|
13593
13408
|
if (!dataLoss) {
|
@@ -13799,7 +13614,7 @@ var init_sqlitePushUtils = __esm({
|
|
13799
13614
|
});
|
13800
13615
|
|
13801
13616
|
// src/jsonStatements.ts
|
13802
|
-
var preparePgCreateTableJson, prepareMySqlCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareDropEnumValues, 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,
|
13617
|
+
var preparePgCreateTableJson, prepareMySqlCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareDropEnumValues, 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;
|
13803
13618
|
var init_jsonStatements = __esm({
|
13804
13619
|
"src/jsonStatements.ts"() {
|
13805
13620
|
"use strict";
|
@@ -13810,7 +13625,7 @@ var init_jsonStatements = __esm({
|
|
13810
13625
|
init_pgSchema();
|
13811
13626
|
init_sqliteSchema();
|
13812
13627
|
preparePgCreateTableJson = (table4, json22) => {
|
13813
|
-
const { name: name2, schema: schema4, columns, compositePrimaryKeys, uniqueConstraints
|
13628
|
+
const { name: name2, schema: schema4, columns, compositePrimaryKeys, uniqueConstraints } = table4;
|
13814
13629
|
const tableKey2 = `${schema4 || "public"}.${name2}`;
|
13815
13630
|
const compositePkName = Object.values(compositePrimaryKeys).length > 0 ? json22.tables[tableKey2].compositePrimaryKeys[`${PgSquasher.unsquashPK(Object.values(compositePrimaryKeys)[0]).name}`].name : "";
|
13816
13631
|
return {
|
@@ -13820,12 +13635,11 @@ var init_jsonStatements = __esm({
|
|
13820
13635
|
columns: Object.values(columns),
|
13821
13636
|
compositePKs: Object.values(compositePrimaryKeys),
|
13822
13637
|
compositePkName,
|
13823
|
-
uniqueConstraints: Object.values(uniqueConstraints)
|
13824
|
-
checkConstraints: Object.values(checkConstraints)
|
13638
|
+
uniqueConstraints: Object.values(uniqueConstraints)
|
13825
13639
|
};
|
13826
13640
|
};
|
13827
13641
|
prepareMySqlCreateTableJson = (table4, json22, internals) => {
|
13828
|
-
const { name: name2, schema: schema4, columns, compositePrimaryKeys, uniqueConstraints
|
13642
|
+
const { name: name2, schema: schema4, columns, compositePrimaryKeys, uniqueConstraints } = table4;
|
13829
13643
|
return {
|
13830
13644
|
type: "create_table",
|
13831
13645
|
tableName: name2,
|
@@ -13834,12 +13648,11 @@ var init_jsonStatements = __esm({
|
|
13834
13648
|
compositePKs: Object.values(compositePrimaryKeys),
|
13835
13649
|
compositePkName: Object.values(compositePrimaryKeys).length > 0 ? json22.tables[name2].compositePrimaryKeys[MySqlSquasher.unsquashPK(Object.values(compositePrimaryKeys)[0]).name].name : "",
|
13836
13650
|
uniqueConstraints: Object.values(uniqueConstraints),
|
13837
|
-
internals
|
13838
|
-
checkConstraints: Object.values(checkConstraints)
|
13651
|
+
internals
|
13839
13652
|
};
|
13840
13653
|
};
|
13841
13654
|
prepareSQLiteCreateTable = (table4, action) => {
|
13842
|
-
const { name: name2, columns, uniqueConstraints
|
13655
|
+
const { name: name2, columns, uniqueConstraints } = table4;
|
13843
13656
|
const references2 = Object.values(table4.foreignKeys);
|
13844
13657
|
const composites = Object.values(table4.compositePrimaryKeys).map(
|
13845
13658
|
(it) => SQLiteSquasher.unsquashPK(it)
|
@@ -13853,8 +13666,7 @@ var init_jsonStatements = __esm({
|
|
13853
13666
|
columns: Object.values(columns),
|
13854
13667
|
referenceData: fks,
|
13855
13668
|
compositePKs: composites,
|
13856
|
-
uniqueConstraints: Object.values(uniqueConstraints)
|
13857
|
-
checkConstraints: Object.values(checkConstraints)
|
13669
|
+
uniqueConstraints: Object.values(uniqueConstraints)
|
13858
13670
|
};
|
13859
13671
|
};
|
13860
13672
|
prepareDropTableJson = (table4) => {
|
@@ -15118,26 +14930,6 @@ var init_jsonStatements = __esm({
|
|
15118
14930
|
};
|
15119
14931
|
});
|
15120
14932
|
};
|
15121
|
-
prepareAddCheckConstraint = (tableName, schema4, check) => {
|
15122
|
-
return Object.values(check).map((it) => {
|
15123
|
-
return {
|
15124
|
-
type: "create_check_constraint",
|
15125
|
-
tableName,
|
15126
|
-
data: it,
|
15127
|
-
schema: schema4
|
15128
|
-
};
|
15129
|
-
});
|
15130
|
-
};
|
15131
|
-
prepareDeleteCheckConstraint = (tableName, schema4, check) => {
|
15132
|
-
return Object.values(check).map((it) => {
|
15133
|
-
return {
|
15134
|
-
type: "delete_check_constraint",
|
15135
|
-
tableName,
|
15136
|
-
constraintName: PgSquasher.unsquashCheck(it).name,
|
15137
|
-
schema: schema4
|
15138
|
-
};
|
15139
|
-
});
|
15140
|
-
};
|
15141
14933
|
prepareAddCompositePrimaryKeyMySql = (tableName, pks, json1, json22) => {
|
15142
14934
|
const res = [];
|
15143
14935
|
for (const it of Object.values(pks)) {
|
@@ -15187,7 +14979,7 @@ var init_statementCombiner = __esm({
|
|
15187
14979
|
init_jsonStatements();
|
15188
14980
|
init_sqliteSchema();
|
15189
14981
|
prepareLibSQLRecreateTable = (table4, action) => {
|
15190
|
-
const { name: name2, columns, uniqueConstraints, indexes
|
14982
|
+
const { name: name2, columns, uniqueConstraints, indexes } = table4;
|
15191
14983
|
const composites = Object.values(table4.compositePrimaryKeys).map(
|
15192
14984
|
(it) => SQLiteSquasher.unsquashPK(it)
|
15193
14985
|
);
|
@@ -15202,8 +14994,7 @@ var init_statementCombiner = __esm({
|
|
15202
14994
|
columns: Object.values(columns),
|
15203
14995
|
compositePKs: composites,
|
15204
14996
|
referenceData: fks,
|
15205
|
-
uniqueConstraints: Object.values(uniqueConstraints)
|
15206
|
-
checkConstraints: Object.values(checkConstraints)
|
14997
|
+
uniqueConstraints: Object.values(uniqueConstraints)
|
15207
14998
|
}
|
15208
14999
|
];
|
15209
15000
|
if (Object.keys(indexes).length) {
|
@@ -15212,7 +15003,7 @@ var init_statementCombiner = __esm({
|
|
15212
15003
|
return statements;
|
15213
15004
|
};
|
15214
15005
|
prepareSQLiteRecreateTable = (table4, action) => {
|
15215
|
-
const { name: name2, columns, uniqueConstraints, indexes
|
15006
|
+
const { name: name2, columns, uniqueConstraints, indexes } = table4;
|
15216
15007
|
const composites = Object.values(table4.compositePrimaryKeys).map(
|
15217
15008
|
(it) => SQLiteSquasher.unsquashPK(it)
|
15218
15009
|
);
|
@@ -15227,8 +15018,7 @@ var init_statementCombiner = __esm({
|
|
15227
15018
|
columns: Object.values(columns),
|
15228
15019
|
compositePKs: composites,
|
15229
15020
|
referenceData: fks,
|
15230
|
-
uniqueConstraints: Object.values(uniqueConstraints)
|
15231
|
-
checkConstraints: Object.values(checkConstraints)
|
15021
|
+
uniqueConstraints: Object.values(uniqueConstraints)
|
15232
15022
|
}
|
15233
15023
|
];
|
15234
15024
|
if (Object.keys(indexes).length) {
|
@@ -15239,7 +15029,7 @@ var init_statementCombiner = __esm({
|
|
15239
15029
|
libSQLCombineStatements = (statements, json22, action) => {
|
15240
15030
|
const newStatements = {};
|
15241
15031
|
for (const statement of statements) {
|
15242
|
-
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"
|
15032
|
+
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") {
|
15243
15033
|
const tableName2 = statement.tableName;
|
15244
15034
|
const statementsForTable2 = newStatements[tableName2];
|
15245
15035
|
if (!statementsForTable2) {
|
@@ -15380,16 +15170,16 @@ var init_statementCombiner = __esm({
|
|
15380
15170
|
sqliteCombineStatements = (statements, json22, action) => {
|
15381
15171
|
const newStatements = {};
|
15382
15172
|
for (const statement of statements) {
|
15383
|
-
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"
|
15173
|
+
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") {
|
15384
15174
|
const tableName2 = statement.tableName;
|
15385
15175
|
const statementsForTable2 = newStatements[tableName2];
|
15386
15176
|
if (!statementsForTable2) {
|
15387
|
-
newStatements[tableName2] =
|
15177
|
+
newStatements[tableName2] = prepareLibSQLRecreateTable(json22.tables[tableName2], action);
|
15388
15178
|
continue;
|
15389
15179
|
}
|
15390
15180
|
if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
|
15391
15181
|
const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
|
15392
|
-
const preparedStatements =
|
15182
|
+
const preparedStatements = prepareLibSQLRecreateTable(json22.tables[tableName2], action);
|
15393
15183
|
if (wasRename) {
|
15394
15184
|
newStatements[tableName2].push(...preparedStatements);
|
15395
15185
|
} else {
|
@@ -15403,12 +15193,12 @@ var init_statementCombiner = __esm({
|
|
15403
15193
|
const tableName2 = statement.tableName;
|
15404
15194
|
const statementsForTable2 = newStatements[tableName2];
|
15405
15195
|
if (!statementsForTable2) {
|
15406
|
-
newStatements[tableName2] =
|
15196
|
+
newStatements[tableName2] = prepareLibSQLRecreateTable(json22.tables[tableName2], action);
|
15407
15197
|
continue;
|
15408
15198
|
}
|
15409
15199
|
if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
|
15410
15200
|
const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
|
15411
|
-
const preparedStatements =
|
15201
|
+
const preparedStatements = prepareLibSQLRecreateTable(json22.tables[tableName2], action);
|
15412
15202
|
if (wasRename) {
|
15413
15203
|
newStatements[tableName2].push(...preparedStatements);
|
15414
15204
|
} else {
|
@@ -15433,7 +15223,7 @@ var init_statementCombiner = __esm({
|
|
15433
15223
|
}
|
15434
15224
|
if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
|
15435
15225
|
const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
|
15436
|
-
const preparedStatements =
|
15226
|
+
const preparedStatements = prepareLibSQLRecreateTable(json22.tables[tableName2], action);
|
15437
15227
|
if (wasRename) {
|
15438
15228
|
newStatements[tableName2].push(...preparedStatements);
|
15439
15229
|
} else {
|
@@ -15602,8 +15392,7 @@ var init_snapshotsDiffer = __esm({
|
|
15602
15392
|
indexes: recordType(stringType(), stringType()),
|
15603
15393
|
foreignKeys: recordType(stringType(), stringType()),
|
15604
15394
|
compositePrimaryKeys: recordType(stringType(), stringType()).default({}),
|
15605
|
-
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
15606
|
-
checkConstraints: recordType(stringType(), stringType()).default({})
|
15395
|
+
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
15607
15396
|
}).strict();
|
15608
15397
|
alteredTableScheme = objectType({
|
15609
15398
|
name: stringType(),
|
@@ -15644,21 +15433,6 @@ var init_snapshotsDiffer = __esm({
|
|
15644
15433
|
__new: stringType(),
|
15645
15434
|
__old: stringType()
|
15646
15435
|
})
|
15647
|
-
),
|
15648
|
-
addedCheckConstraints: recordType(
|
15649
|
-
stringType(),
|
15650
|
-
stringType()
|
15651
|
-
),
|
15652
|
-
deletedCheckConstraints: recordType(
|
15653
|
-
stringType(),
|
15654
|
-
stringType()
|
15655
|
-
),
|
15656
|
-
alteredCheckConstraints: recordType(
|
15657
|
-
stringType(),
|
15658
|
-
objectType({
|
15659
|
-
__new: stringType(),
|
15660
|
-
__old: stringType()
|
15661
|
-
})
|
15662
15436
|
)
|
15663
15437
|
}).strict();
|
15664
15438
|
diffResultScheme = objectType({
|
@@ -15999,8 +15773,6 @@ var init_snapshotsDiffer = __esm({
|
|
15999
15773
|
schemaTo: it.schemaTo || "public"
|
16000
15774
|
});
|
16001
15775
|
}
|
16002
|
-
const jsonDeletedCheckConstraints = [];
|
16003
|
-
const jsonCreatedCheckConstraints = [];
|
16004
15776
|
for (let it of alteredTables) {
|
16005
15777
|
let addedColumns = [];
|
16006
15778
|
for (const addedPkName of Object.keys(it.addedCompositePKs)) {
|
@@ -16040,8 +15812,6 @@ var init_snapshotsDiffer = __esm({
|
|
16040
15812
|
let addedUniqueConstraints = [];
|
16041
15813
|
let deletedUniqueConstraints = [];
|
16042
15814
|
let alteredUniqueConstraints = [];
|
16043
|
-
let createCheckConstraints = [];
|
16044
|
-
let deleteCheckConstraints = [];
|
16045
15815
|
addedUniqueConstraints = prepareAddUniqueConstraintPg(
|
16046
15816
|
it.name,
|
16047
15817
|
it.schema,
|
@@ -16066,24 +15836,6 @@ var init_snapshotsDiffer = __esm({
|
|
16066
15836
|
...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
|
16067
15837
|
);
|
16068
15838
|
}
|
16069
|
-
createCheckConstraints = prepareAddCheckConstraint(it.name, it.schema, it.addedCheckConstraints);
|
16070
|
-
deleteCheckConstraints = prepareDeleteCheckConstraint(
|
16071
|
-
it.name,
|
16072
|
-
it.schema,
|
16073
|
-
it.deletedCheckConstraints
|
16074
|
-
);
|
16075
|
-
if (it.alteredCheckConstraints && action !== "push") {
|
16076
|
-
const added = {};
|
16077
|
-
const deleted = {};
|
16078
|
-
for (const k of Object.keys(it.alteredCheckConstraints)) {
|
16079
|
-
added[k] = it.alteredCheckConstraints[k].__new;
|
16080
|
-
deleted[k] = it.alteredCheckConstraints[k].__old;
|
16081
|
-
}
|
16082
|
-
createCheckConstraints.push(...prepareAddCheckConstraint(it.name, it.schema, added));
|
16083
|
-
deleteCheckConstraints.push(...prepareDeleteCheckConstraint(it.name, it.schema, deleted));
|
16084
|
-
}
|
16085
|
-
jsonCreatedCheckConstraints.push(...createCheckConstraints);
|
16086
|
-
jsonDeletedCheckConstraints.push(...deleteCheckConstraints);
|
16087
15839
|
jsonAddedCompositePKs.push(...addedCompositePKs);
|
16088
15840
|
jsonDeletedCompositePKs.push(...deletedCompositePKs);
|
16089
15841
|
jsonAlteredCompositePKs.push(...alteredCompositePKs);
|
@@ -16240,7 +15992,6 @@ var init_snapshotsDiffer = __esm({
|
|
16240
15992
|
jsonStatements.push(...jsonRenameTables);
|
16241
15993
|
jsonStatements.push(...jsonRenameColumnsStatements);
|
16242
15994
|
jsonStatements.push(...jsonDeletedUniqueConstraints);
|
16243
|
-
jsonStatements.push(...jsonDeletedCheckConstraints);
|
16244
15995
|
jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
|
16245
15996
|
jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
|
16246
15997
|
jsonStatements.push(...jsonDeletedCompositePKs);
|
@@ -16254,7 +16005,6 @@ var init_snapshotsDiffer = __esm({
|
|
16254
16005
|
jsonStatements.push(...jsonDropColumnsStatemets);
|
16255
16006
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
16256
16007
|
jsonStatements.push(...jsonAddedUniqueConstraints);
|
16257
|
-
jsonStatements.push(...jsonCreatedCheckConstraints);
|
16258
16008
|
jsonStatements.push(...jsonAlteredUniqueConstraints);
|
16259
16009
|
jsonStatements.push(...jsonAlterEnumsWithDroppedValues);
|
16260
16010
|
jsonStatements.push(...dropEnums);
|
@@ -16429,8 +16179,6 @@ var init_snapshotsDiffer = __esm({
|
|
16429
16179
|
const jsonAddedUniqueConstraints = [];
|
16430
16180
|
const jsonDeletedUniqueConstraints = [];
|
16431
16181
|
const jsonAlteredUniqueConstraints = [];
|
16432
|
-
const jsonCreatedCheckConstraints = [];
|
16433
|
-
const jsonDeletedCheckConstraints = [];
|
16434
16182
|
const jsonRenameColumnsStatements = columnRenames.map((it) => prepareRenameColumns(it.table, "", it.renames)).flat();
|
16435
16183
|
const jsonAddColumnsStatemets = columnCreates.map((it) => _prepareAddColumns(it.table, "", it.columns)).flat();
|
16436
16184
|
const jsonDropColumnsStatemets = columnDeletes.map((it) => _prepareDropColumns(it.table, "", it.columns)).flat();
|
@@ -16469,8 +16217,6 @@ var init_snapshotsDiffer = __esm({
|
|
16469
16217
|
let addedUniqueConstraints = [];
|
16470
16218
|
let deletedUniqueConstraints = [];
|
16471
16219
|
let alteredUniqueConstraints = [];
|
16472
|
-
let createdCheckConstraints = [];
|
16473
|
-
let deletedCheckConstraints = [];
|
16474
16220
|
addedUniqueConstraints = prepareAddUniqueConstraintPg(
|
16475
16221
|
it.name,
|
16476
16222
|
it.schema,
|
@@ -16495,30 +16241,12 @@ var init_snapshotsDiffer = __esm({
|
|
16495
16241
|
...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
|
16496
16242
|
);
|
16497
16243
|
}
|
16498
|
-
createdCheckConstraints = prepareAddCheckConstraint(it.name, it.schema, it.addedCheckConstraints);
|
16499
|
-
deletedCheckConstraints = prepareDeleteCheckConstraint(
|
16500
|
-
it.name,
|
16501
|
-
it.schema,
|
16502
|
-
it.deletedCheckConstraints
|
16503
|
-
);
|
16504
|
-
if (it.alteredCheckConstraints && action !== "push") {
|
16505
|
-
const added = {};
|
16506
|
-
const deleted = {};
|
16507
|
-
for (const k of Object.keys(it.alteredCheckConstraints)) {
|
16508
|
-
added[k] = it.alteredCheckConstraints[k].__new;
|
16509
|
-
deleted[k] = it.alteredCheckConstraints[k].__old;
|
16510
|
-
}
|
16511
|
-
createdCheckConstraints.push(...prepareAddCheckConstraint(it.name, it.schema, added));
|
16512
|
-
deletedCheckConstraints.push(...prepareDeleteCheckConstraint(it.name, it.schema, deleted));
|
16513
|
-
}
|
16514
16244
|
jsonAddedCompositePKs.push(...addedCompositePKs);
|
16515
16245
|
jsonDeletedCompositePKs.push(...deletedCompositePKs);
|
16516
16246
|
jsonAlteredCompositePKs.push(...alteredCompositePKs);
|
16517
16247
|
jsonAddedUniqueConstraints.push(...addedUniqueConstraints);
|
16518
16248
|
jsonDeletedUniqueConstraints.push(...deletedUniqueConstraints);
|
16519
16249
|
jsonAlteredUniqueConstraints.push(...alteredUniqueConstraints);
|
16520
|
-
jsonCreatedCheckConstraints.push(...createdCheckConstraints);
|
16521
|
-
jsonDeletedCheckConstraints.push(...deletedCheckConstraints);
|
16522
16250
|
});
|
16523
16251
|
const rColumns = jsonRenameColumnsStatements.map((it) => {
|
16524
16252
|
const tableName = it.tableName;
|
@@ -16614,7 +16342,6 @@ var init_snapshotsDiffer = __esm({
|
|
16614
16342
|
jsonStatements.push(...jsonRenameTables);
|
16615
16343
|
jsonStatements.push(...jsonRenameColumnsStatements);
|
16616
16344
|
jsonStatements.push(...jsonDeletedUniqueConstraints);
|
16617
|
-
jsonStatements.push(...jsonDeletedCheckConstraints);
|
16618
16345
|
jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
|
16619
16346
|
jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
|
16620
16347
|
jsonStatements.push(...jsonDeletedCompositePKs);
|
@@ -16625,11 +16352,11 @@ var init_snapshotsDiffer = __esm({
|
|
16625
16352
|
jsonStatements.push(...jsonAddColumnsStatemets);
|
16626
16353
|
jsonStatements.push(...jsonCreateReferencesForCreatedTables);
|
16627
16354
|
jsonStatements.push(...jsonCreateIndexesForCreatedTables);
|
16628
|
-
jsonStatements.push(...jsonCreatedCheckConstraints);
|
16629
16355
|
jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
|
16630
16356
|
jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
|
16631
16357
|
jsonStatements.push(...jsonDropColumnsStatemets);
|
16632
16358
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
16359
|
+
jsonStatements.push(...jsonAddedUniqueConstraints);
|
16633
16360
|
jsonStatements.push(...jsonAlteredUniqueConstraints);
|
16634
16361
|
const sqlStatements = fromJson(jsonStatements, "mysql");
|
16635
16362
|
const uniqueSqlStatements = [];
|
@@ -16757,8 +16484,6 @@ var init_snapshotsDiffer = __esm({
|
|
16757
16484
|
const jsonAddedUniqueConstraints = [];
|
16758
16485
|
const jsonDeletedUniqueConstraints = [];
|
16759
16486
|
const jsonAlteredUniqueConstraints = [];
|
16760
|
-
const jsonDeletedCheckConstraints = [];
|
16761
|
-
const jsonCreatedCheckConstraints = [];
|
16762
16487
|
allAltered.forEach((it) => {
|
16763
16488
|
let addedColumns = [];
|
16764
16489
|
for (const addedPkName of Object.keys(it.addedCompositePKs)) {
|
@@ -16815,56 +16540,12 @@ var init_snapshotsDiffer = __esm({
|
|
16815
16540
|
...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
|
16816
16541
|
);
|
16817
16542
|
}
|
16818
|
-
let createdCheckConstraints = [];
|
16819
|
-
let deletedCheckConstraints = [];
|
16820
|
-
addedUniqueConstraints = prepareAddUniqueConstraintPg(
|
16821
|
-
it.name,
|
16822
|
-
it.schema,
|
16823
|
-
it.addedUniqueConstraints
|
16824
|
-
);
|
16825
|
-
deletedUniqueConstraints = prepareDeleteUniqueConstraintPg(
|
16826
|
-
it.name,
|
16827
|
-
it.schema,
|
16828
|
-
it.deletedUniqueConstraints
|
16829
|
-
);
|
16830
|
-
if (it.alteredUniqueConstraints) {
|
16831
|
-
const added = {};
|
16832
|
-
const deleted = {};
|
16833
|
-
for (const k of Object.keys(it.alteredUniqueConstraints)) {
|
16834
|
-
added[k] = it.alteredUniqueConstraints[k].__new;
|
16835
|
-
deleted[k] = it.alteredUniqueConstraints[k].__old;
|
16836
|
-
}
|
16837
|
-
addedUniqueConstraints.push(
|
16838
|
-
...prepareAddUniqueConstraintPg(it.name, it.schema, added)
|
16839
|
-
);
|
16840
|
-
deletedUniqueConstraints.push(
|
16841
|
-
...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
|
16842
|
-
);
|
16843
|
-
}
|
16844
|
-
createdCheckConstraints = prepareAddCheckConstraint(it.name, it.schema, it.addedCheckConstraints);
|
16845
|
-
deletedCheckConstraints = prepareDeleteCheckConstraint(
|
16846
|
-
it.name,
|
16847
|
-
it.schema,
|
16848
|
-
it.deletedCheckConstraints
|
16849
|
-
);
|
16850
|
-
if (it.alteredCheckConstraints && action !== "push") {
|
16851
|
-
const added = {};
|
16852
|
-
const deleted = {};
|
16853
|
-
for (const k of Object.keys(it.alteredCheckConstraints)) {
|
16854
|
-
added[k] = it.alteredCheckConstraints[k].__new;
|
16855
|
-
deleted[k] = it.alteredCheckConstraints[k].__old;
|
16856
|
-
}
|
16857
|
-
createdCheckConstraints.push(...prepareAddCheckConstraint(it.name, it.schema, added));
|
16858
|
-
deletedCheckConstraints.push(...prepareDeleteCheckConstraint(it.name, it.schema, deleted));
|
16859
|
-
}
|
16860
16543
|
jsonAddedCompositePKs.push(...addedCompositePKs);
|
16861
16544
|
jsonDeletedCompositePKs.push(...deletedCompositePKs);
|
16862
16545
|
jsonAlteredCompositePKs.push(...alteredCompositePKs);
|
16863
16546
|
jsonAddedUniqueConstraints.push(...addedUniqueConstraints);
|
16864
16547
|
jsonDeletedUniqueConstraints.push(...deletedUniqueConstraints);
|
16865
16548
|
jsonAlteredUniqueConstraints.push(...alteredUniqueConstraints);
|
16866
|
-
jsonCreatedCheckConstraints.push(...createdCheckConstraints);
|
16867
|
-
jsonDeletedCheckConstraints.push(...deletedCheckConstraints);
|
16868
16549
|
});
|
16869
16550
|
const rColumns = jsonRenameColumnsStatements.map((it) => {
|
16870
16551
|
const tableName = it.tableName;
|
@@ -16949,7 +16630,6 @@ var init_snapshotsDiffer = __esm({
|
|
16949
16630
|
jsonStatements.push(...jsonRenameTables);
|
16950
16631
|
jsonStatements.push(...jsonRenameColumnsStatements);
|
16951
16632
|
jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
|
16952
|
-
jsonStatements.push(...jsonDeletedCheckConstraints);
|
16953
16633
|
jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
|
16954
16634
|
jsonStatements.push(...jsonDeletedCompositePKs);
|
16955
16635
|
jsonStatements.push(...jsonTableAlternations);
|
@@ -16957,7 +16637,6 @@ var init_snapshotsDiffer = __esm({
|
|
16957
16637
|
jsonStatements.push(...jsonAddColumnsStatemets);
|
16958
16638
|
jsonStatements.push(...jsonCreateIndexesForCreatedTables);
|
16959
16639
|
jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
|
16960
|
-
jsonStatements.push(...jsonCreatedCheckConstraints);
|
16961
16640
|
jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
|
16962
16641
|
jsonStatements.push(...jsonDropColumnsStatemets);
|
16963
16642
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
@@ -17101,8 +16780,6 @@ var init_snapshotsDiffer = __esm({
|
|
17101
16780
|
const jsonAddedUniqueConstraints = [];
|
17102
16781
|
const jsonDeletedUniqueConstraints = [];
|
17103
16782
|
const jsonAlteredUniqueConstraints = [];
|
17104
|
-
const jsonDeletedCheckConstraints = [];
|
17105
|
-
const jsonCreatedCheckConstraints = [];
|
17106
16783
|
allAltered.forEach((it) => {
|
17107
16784
|
let addedColumns = [];
|
17108
16785
|
for (const addedPkName of Object.keys(it.addedCompositePKs)) {
|
@@ -17135,8 +16812,6 @@ var init_snapshotsDiffer = __esm({
|
|
17135
16812
|
let addedUniqueConstraints = [];
|
17136
16813
|
let deletedUniqueConstraints = [];
|
17137
16814
|
let alteredUniqueConstraints = [];
|
17138
|
-
let createdCheckConstraints = [];
|
17139
|
-
let deletedCheckConstraints = [];
|
17140
16815
|
addedUniqueConstraints = prepareAddUniqueConstraintPg(
|
17141
16816
|
it.name,
|
17142
16817
|
it.schema,
|
@@ -17161,30 +16836,12 @@ var init_snapshotsDiffer = __esm({
|
|
17161
16836
|
...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
|
17162
16837
|
);
|
17163
16838
|
}
|
17164
|
-
createdCheckConstraints = prepareAddCheckConstraint(it.name, it.schema, it.addedCheckConstraints);
|
17165
|
-
deletedCheckConstraints = prepareDeleteCheckConstraint(
|
17166
|
-
it.name,
|
17167
|
-
it.schema,
|
17168
|
-
it.deletedCheckConstraints
|
17169
|
-
);
|
17170
|
-
if (it.alteredCheckConstraints && action !== "push") {
|
17171
|
-
const added = {};
|
17172
|
-
const deleted = {};
|
17173
|
-
for (const k of Object.keys(it.alteredCheckConstraints)) {
|
17174
|
-
added[k] = it.alteredCheckConstraints[k].__new;
|
17175
|
-
deleted[k] = it.alteredCheckConstraints[k].__old;
|
17176
|
-
}
|
17177
|
-
createdCheckConstraints.push(...prepareAddCheckConstraint(it.name, it.schema, added));
|
17178
|
-
deletedCheckConstraints.push(...prepareDeleteCheckConstraint(it.name, it.schema, deleted));
|
17179
|
-
}
|
17180
16839
|
jsonAddedCompositePKs.push(...addedCompositePKs);
|
17181
16840
|
jsonDeletedCompositePKs.push(...deletedCompositePKs);
|
17182
16841
|
jsonAlteredCompositePKs.push(...alteredCompositePKs);
|
17183
16842
|
jsonAddedUniqueConstraints.push(...addedUniqueConstraints);
|
17184
16843
|
jsonDeletedUniqueConstraints.push(...deletedUniqueConstraints);
|
17185
16844
|
jsonAlteredUniqueConstraints.push(...alteredUniqueConstraints);
|
17186
|
-
jsonCreatedCheckConstraints.push(...createdCheckConstraints);
|
17187
|
-
jsonDeletedCheckConstraints.push(...deletedCheckConstraints);
|
17188
16845
|
});
|
17189
16846
|
const jsonTableAlternations = allAltered.map((it) => {
|
17190
16847
|
return prepareSqliteAlterColumns(it.name, it.schema, it.altered, json22);
|
@@ -17262,7 +16919,6 @@ var init_snapshotsDiffer = __esm({
|
|
17262
16919
|
jsonStatements.push(...jsonRenameTables);
|
17263
16920
|
jsonStatements.push(...jsonRenameColumnsStatements);
|
17264
16921
|
jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
|
17265
|
-
jsonStatements.push(...jsonDeletedCheckConstraints);
|
17266
16922
|
jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
|
17267
16923
|
jsonStatements.push(...jsonDeletedCompositePKs);
|
17268
16924
|
jsonStatements.push(...jsonTableAlternations);
|
@@ -17270,7 +16926,6 @@ var init_snapshotsDiffer = __esm({
|
|
17270
16926
|
jsonStatements.push(...jsonAddColumnsStatemets);
|
17271
16927
|
jsonStatements.push(...jsonCreateIndexesForCreatedTables);
|
17272
16928
|
jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
|
17273
|
-
jsonStatements.push(...jsonCreatedCheckConstraints);
|
17274
16929
|
jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
|
17275
16930
|
jsonStatements.push(...jsonDropColumnsStatemets);
|
17276
16931
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
@@ -26388,7 +26043,6 @@ var init_pgSerializer = __esm({
|
|
26388
26043
|
const sequencesToReturn = {};
|
26389
26044
|
const indexesInSchema = {};
|
26390
26045
|
for (const table4 of tables) {
|
26391
|
-
const checksInTable = {};
|
26392
26046
|
const {
|
26393
26047
|
name: tableName,
|
26394
26048
|
columns,
|
@@ -26404,7 +26058,6 @@ var init_pgSerializer = __esm({
|
|
26404
26058
|
}
|
26405
26059
|
const columnsObject = {};
|
26406
26060
|
const indexesObject = {};
|
26407
|
-
const checksObject = {};
|
26408
26061
|
const foreignKeysObject = {};
|
26409
26062
|
const primaryKeysObject = {};
|
26410
26063
|
const uniqueConstraintObject = {};
|
@@ -26670,33 +26323,6 @@ ${withStyle.errorWarning(
|
|
26670
26323
|
with: value.config.with ?? {}
|
26671
26324
|
};
|
26672
26325
|
});
|
26673
|
-
checks.forEach((check) => {
|
26674
|
-
const checkName = check.name;
|
26675
|
-
if (typeof checksInTable[`"${schema4 ?? "public"}"."${tableName}"`] !== "undefined") {
|
26676
|
-
if (checksInTable[`"${schema4 ?? "public"}"."${tableName}"`].includes(check.name)) {
|
26677
|
-
console.log(
|
26678
|
-
`
|
26679
|
-
${withStyle.errorWarning(
|
26680
|
-
`We've found duplicated check constraint name across ${source_default.underline.blue(
|
26681
|
-
schema4 ?? "public"
|
26682
|
-
)} schema in ${source_default.underline.blue(
|
26683
|
-
tableName
|
26684
|
-
)}. Please rename your check constraint in either the ${source_default.underline.blue(
|
26685
|
-
tableName
|
26686
|
-
)} table or the table with the duplicated check contraint name`
|
26687
|
-
)}`
|
26688
|
-
);
|
26689
|
-
process.exit(1);
|
26690
|
-
}
|
26691
|
-
checksInTable[`"${schema4 ?? "public"}"."${tableName}"`].push(checkName);
|
26692
|
-
} else {
|
26693
|
-
checksInTable[`"${schema4 ?? "public"}"."${tableName}"`] = [check.name];
|
26694
|
-
}
|
26695
|
-
checksObject[checkName] = {
|
26696
|
-
name: checkName,
|
26697
|
-
value: dialect4.sqlToQuery(check.value).sql
|
26698
|
-
};
|
26699
|
-
});
|
26700
26326
|
const tableKey2 = `${schema4 ?? "public"}.${tableName}`;
|
26701
26327
|
result[tableKey2] = {
|
26702
26328
|
name: tableName,
|
@@ -26705,8 +26331,7 @@ ${withStyle.errorWarning(
|
|
26705
26331
|
indexes: indexesObject,
|
26706
26332
|
foreignKeys: foreignKeysObject,
|
26707
26333
|
compositePrimaryKeys: primaryKeysObject,
|
26708
|
-
uniqueConstraints: uniqueConstraintObject
|
26709
|
-
checkConstraints: checksObject
|
26334
|
+
uniqueConstraints: uniqueConstraintObject
|
26710
26335
|
};
|
26711
26336
|
}
|
26712
26337
|
for (const sequence of sequences) {
|
@@ -26795,7 +26420,6 @@ ${withStyle.errorWarning(
|
|
26795
26420
|
let indexesCount = 0;
|
26796
26421
|
let foreignKeysCount = 0;
|
26797
26422
|
let tableCount = 0;
|
26798
|
-
let checksCount = 0;
|
26799
26423
|
const sequencesToReturn = {};
|
26800
26424
|
const seqWhere = schemaFilters.map((t) => `schemaname = '${t}'`).join(" or ");
|
26801
26425
|
const allSequences = await db.query(
|
@@ -26865,8 +26489,7 @@ ${withStyle.errorWarning(
|
|
26865
26489
|
const indexToReturn = {};
|
26866
26490
|
const foreignKeysToReturn = {};
|
26867
26491
|
const primaryKeys = {};
|
26868
|
-
const
|
26869
|
-
const checkConstraints = {};
|
26492
|
+
const uniqueConstrains = {};
|
26870
26493
|
const tableResponse = await db.query(
|
26871
26494
|
`SELECT a.attrelid::regclass::text, a.attname, is_nullable, a.attndims as array_dimensions
|
26872
26495
|
, CASE WHEN a.atttypid = ANY ('{int,int8,int2}'::regtype[])
|
@@ -26904,97 +26527,55 @@ ${withStyle.errorWarning(
|
|
26904
26527
|
ORDER BY a.attnum;`
|
26905
26528
|
);
|
26906
26529
|
const tableConstraints = await db.query(
|
26907
|
-
`SELECT c.column_name,
|
26908
|
-
|
26909
|
-
|
26910
|
-
|
26911
|
-
|
26912
|
-
|
26913
|
-
FROM information_schema.table_constraints tc
|
26914
|
-
JOIN information_schema.constraint_column_usage AS ccu
|
26915
|
-
USING (constraint_schema, constraint_name)
|
26916
|
-
JOIN information_schema.columns AS c
|
26917
|
-
ON c.table_schema = tc.constraint_schema
|
26918
|
-
AND tc.table_name = c.table_name
|
26919
|
-
AND ccu.column_name = c.column_name
|
26920
|
-
JOIN pg_constraint con
|
26921
|
-
ON con.conname = tc.constraint_name
|
26922
|
-
AND con.conrelid = (
|
26923
|
-
SELECT oid
|
26924
|
-
FROM pg_class
|
26925
|
-
WHERE relname = tc.table_name
|
26926
|
-
AND relnamespace = (
|
26927
|
-
SELECT oid
|
26928
|
-
FROM pg_namespace
|
26929
|
-
WHERE nspname = tc.constraint_schema
|
26930
|
-
)
|
26931
|
-
)
|
26932
|
-
WHERE tc.table_name = '${tableName}' AND tc.constraint_schema = '${tableSchema}';`
|
26530
|
+
`SELECT c.column_name, c.data_type, constraint_type, constraint_name, constraint_schema
|
26531
|
+
FROM information_schema.table_constraints tc
|
26532
|
+
JOIN information_schema.constraint_column_usage AS ccu USING (constraint_schema, constraint_name)
|
26533
|
+
JOIN information_schema.columns AS c ON c.table_schema = tc.constraint_schema
|
26534
|
+
AND tc.table_name = c.table_name AND ccu.column_name = c.column_name
|
26535
|
+
WHERE tc.table_name = '${tableName}' and constraint_schema = '${tableSchema}';`
|
26933
26536
|
);
|
26934
|
-
const tableChecks = await db.query(`SELECT
|
26935
|
-
tc.constraint_name,
|
26936
|
-
tc.constraint_type,
|
26937
|
-
pg_get_constraintdef(con.oid) AS constraint_definition
|
26938
|
-
FROM
|
26939
|
-
information_schema.table_constraints AS tc
|
26940
|
-
JOIN pg_constraint AS con
|
26941
|
-
ON tc.constraint_name = con.conname
|
26942
|
-
AND con.conrelid = (
|
26943
|
-
SELECT oid
|
26944
|
-
FROM pg_class
|
26945
|
-
WHERE relname = tc.table_name
|
26946
|
-
AND relnamespace = (
|
26947
|
-
SELECT oid
|
26948
|
-
FROM pg_namespace
|
26949
|
-
WHERE nspname = tc.constraint_schema
|
26950
|
-
)
|
26951
|
-
)
|
26952
|
-
WHERE
|
26953
|
-
tc.table_name = '${tableName}'
|
26954
|
-
AND tc.constraint_schema = '${tableSchema}'
|
26955
|
-
AND tc.constraint_type = 'CHECK';`);
|
26956
26537
|
columnsCount += tableResponse.length;
|
26957
26538
|
if (progressCallback) {
|
26958
26539
|
progressCallback("columns", columnsCount, "fetching");
|
26959
26540
|
}
|
26960
26541
|
const tableForeignKeys = await db.query(
|
26961
26542
|
`SELECT
|
26962
|
-
|
26963
|
-
|
26964
|
-
|
26965
|
-
|
26966
|
-
|
26967
|
-
|
26968
|
-
|
26969
|
-
|
26970
|
-
|
26971
|
-
|
26972
|
-
|
26973
|
-
|
26974
|
-
|
26975
|
-
|
26976
|
-
|
26977
|
-
|
26978
|
-
|
26979
|
-
|
26980
|
-
|
26981
|
-
|
26982
|
-
|
26983
|
-
|
26984
|
-
|
26985
|
-
|
26986
|
-
|
26987
|
-
|
26988
|
-
|
26989
|
-
|
26990
|
-
|
26991
|
-
|
26992
|
-
|
26993
|
-
|
26994
|
-
|
26995
|
-
|
26996
|
-
|
26997
|
-
|
26543
|
+
con.contype AS constraint_type,
|
26544
|
+
nsp.nspname AS constraint_schema,
|
26545
|
+
con.conname AS constraint_name,
|
26546
|
+
rel.relname AS table_name,
|
26547
|
+
att.attname AS column_name,
|
26548
|
+
fnsp.nspname AS foreign_table_schema,
|
26549
|
+
frel.relname AS foreign_table_name,
|
26550
|
+
fatt.attname AS foreign_column_name,
|
26551
|
+
CASE con.confupdtype
|
26552
|
+
WHEN 'a' THEN 'NO ACTION'
|
26553
|
+
WHEN 'r' THEN 'RESTRICT'
|
26554
|
+
WHEN 'n' THEN 'SET NULL'
|
26555
|
+
WHEN 'c' THEN 'CASCADE'
|
26556
|
+
WHEN 'd' THEN 'SET DEFAULT'
|
26557
|
+
END AS update_rule,
|
26558
|
+
CASE con.confdeltype
|
26559
|
+
WHEN 'a' THEN 'NO ACTION'
|
26560
|
+
WHEN 'r' THEN 'RESTRICT'
|
26561
|
+
WHEN 'n' THEN 'SET NULL'
|
26562
|
+
WHEN 'c' THEN 'CASCADE'
|
26563
|
+
WHEN 'd' THEN 'SET DEFAULT'
|
26564
|
+
END AS delete_rule
|
26565
|
+
FROM
|
26566
|
+
pg_catalog.pg_constraint con
|
26567
|
+
JOIN pg_catalog.pg_class rel ON rel.oid = con.conrelid
|
26568
|
+
JOIN pg_catalog.pg_namespace nsp ON nsp.oid = con.connamespace
|
26569
|
+
LEFT JOIN pg_catalog.pg_attribute att ON att.attnum = ANY (con.conkey)
|
26570
|
+
AND att.attrelid = con.conrelid
|
26571
|
+
LEFT JOIN pg_catalog.pg_class frel ON frel.oid = con.confrelid
|
26572
|
+
LEFT JOIN pg_catalog.pg_namespace fnsp ON fnsp.oid = frel.relnamespace
|
26573
|
+
LEFT JOIN pg_catalog.pg_attribute fatt ON fatt.attnum = ANY (con.confkey)
|
26574
|
+
AND fatt.attrelid = con.confrelid
|
26575
|
+
WHERE
|
26576
|
+
nsp.nspname = '${tableSchema}'
|
26577
|
+
AND rel.relname = '${tableName}'
|
26578
|
+
AND con.contype IN ('f');`
|
26998
26579
|
);
|
26999
26580
|
foreignKeysCount += tableForeignKeys.length;
|
27000
26581
|
if (progressCallback) {
|
@@ -27036,29 +26617,16 @@ ${withStyle.errorWarning(
|
|
27036
26617
|
for (const unqs of uniqueConstrainsRows) {
|
27037
26618
|
const columnName = unqs.column_name;
|
27038
26619
|
const constraintName = unqs.constraint_name;
|
27039
|
-
if (typeof
|
27040
|
-
|
26620
|
+
if (typeof uniqueConstrains[constraintName] !== "undefined") {
|
26621
|
+
uniqueConstrains[constraintName].columns.push(columnName);
|
27041
26622
|
} else {
|
27042
|
-
|
26623
|
+
uniqueConstrains[constraintName] = {
|
27043
26624
|
columns: [columnName],
|
27044
26625
|
nullsNotDistinct: false,
|
27045
26626
|
name: constraintName
|
27046
26627
|
};
|
27047
26628
|
}
|
27048
26629
|
}
|
27049
|
-
checksCount += tableChecks.length;
|
27050
|
-
if (progressCallback) {
|
27051
|
-
progressCallback("checks", checksCount, "fetching");
|
27052
|
-
}
|
27053
|
-
for (const checks of tableChecks) {
|
27054
|
-
let checkValue = checks.constraint_definition;
|
27055
|
-
const constraintName = checks.constraint_name;
|
27056
|
-
checkValue = checkValue.replace(/^CHECK\s*\(\(/, "").replace(/\)\)\s*$/, "");
|
27057
|
-
checkConstraints[constraintName] = {
|
27058
|
-
name: constraintName,
|
27059
|
-
value: checkValue
|
27060
|
-
};
|
27061
|
-
}
|
27062
26630
|
for (const columnResponse of tableResponse) {
|
27063
26631
|
const columnName = columnResponse.attname;
|
27064
26632
|
const columnAdditionalDT = columnResponse.additional_dt;
|
@@ -27302,8 +26870,7 @@ ${withStyle.errorWarning(
|
|
27302
26870
|
indexes: indexToReturn,
|
27303
26871
|
foreignKeys: foreignKeysToReturn,
|
27304
26872
|
compositePrimaryKeys: primaryKeys,
|
27305
|
-
uniqueConstraints
|
27306
|
-
checkConstraints
|
26873
|
+
uniqueConstraints: uniqueConstrains
|
27307
26874
|
};
|
27308
26875
|
} catch (e) {
|
27309
26876
|
rej(e);
|
@@ -27321,7 +26888,6 @@ ${withStyle.errorWarning(
|
|
27321
26888
|
progressCallback("columns", columnsCount, "done");
|
27322
26889
|
progressCallback("indexes", indexesCount, "done");
|
27323
26890
|
progressCallback("fks", foreignKeysCount, "done");
|
27324
|
-
progressCallback("checks", checksCount, "done");
|
27325
26891
|
}
|
27326
26892
|
const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
|
27327
26893
|
return {
|
@@ -27393,8 +26959,6 @@ ${withStyle.errorWarning(
|
|
27393
26959
|
}
|
27394
26960
|
return columnDefaultAsString;
|
27395
26961
|
}
|
27396
|
-
} else if (column4.data_type.includes("numeric")) {
|
27397
|
-
return columnDefaultAsString.includes("'") ? columnDefaultAsString : `'${columnDefaultAsString}'`;
|
27398
26962
|
} else if (column4.data_type === "json" || column4.data_type === "jsonb") {
|
27399
26963
|
const jsonWithoutSpaces = JSON.stringify(JSON.parse(columnDefaultAsString.slice(1, -1)));
|
27400
26964
|
return `'${jsonWithoutSpaces}'::${column4.data_type}`;
|
@@ -30921,13 +30485,10 @@ var init_sqliteSerializer = __esm({
|
|
30921
30485
|
const foreignKeysObject = {};
|
30922
30486
|
const primaryKeysObject = {};
|
30923
30487
|
const uniqueConstraintObject = {};
|
30924
|
-
const checkConstraintObject = {};
|
30925
|
-
const checksInTable = {};
|
30926
30488
|
const {
|
30927
30489
|
name: tableName,
|
30928
30490
|
columns,
|
30929
30491
|
indexes,
|
30930
|
-
checks,
|
30931
30492
|
foreignKeys: tableForeignKeys,
|
30932
30493
|
primaryKeys,
|
30933
30494
|
uniqueConstraints
|
@@ -31103,39 +30664,13 @@ The unique constraint ${source_default.underline.blue(
|
|
31103
30664
|
columnsObject[getColumnCasing(it.columns[0], casing2)].primaryKey = true;
|
31104
30665
|
}
|
31105
30666
|
});
|
31106
|
-
checks.forEach((check) => {
|
31107
|
-
const checkName = check.name;
|
31108
|
-
if (typeof checksInTable[tableName] !== "undefined") {
|
31109
|
-
if (checksInTable[tableName].includes(check.name)) {
|
31110
|
-
console.log(
|
31111
|
-
`
|
31112
|
-
${withStyle.errorWarning(
|
31113
|
-
`We've found duplicated check constraint name in ${source_default.underline.blue(
|
31114
|
-
tableName
|
31115
|
-
)}. Please rename your check constraint in the ${source_default.underline.blue(
|
31116
|
-
tableName
|
31117
|
-
)} table`
|
31118
|
-
)}`
|
31119
|
-
);
|
31120
|
-
process.exit(1);
|
31121
|
-
}
|
31122
|
-
checksInTable[tableName].push(checkName);
|
31123
|
-
} else {
|
31124
|
-
checksInTable[tableName] = [check.name];
|
31125
|
-
}
|
31126
|
-
checkConstraintObject[checkName] = {
|
31127
|
-
name: checkName,
|
31128
|
-
value: dialect4.sqlToQuery(check.value).sql
|
31129
|
-
};
|
31130
|
-
});
|
31131
30667
|
result[tableName] = {
|
31132
30668
|
name: tableName,
|
31133
30669
|
columns: columnsObject,
|
31134
30670
|
indexes: indexesObject,
|
31135
30671
|
foreignKeys: foreignKeysObject,
|
31136
30672
|
compositePrimaryKeys: primaryKeysObject,
|
31137
|
-
uniqueConstraints: uniqueConstraintObject
|
31138
|
-
checkConstraints: checkConstraintObject
|
30673
|
+
uniqueConstraints: uniqueConstraintObject
|
31139
30674
|
};
|
31140
30675
|
}
|
31141
30676
|
return {
|
@@ -31182,7 +30717,6 @@ ${withStyle.errorWarning(
|
|
31182
30717
|
let tablesCount = /* @__PURE__ */ new Set();
|
31183
30718
|
let indexesCount = 0;
|
31184
30719
|
let foreignKeysCount = 0;
|
31185
|
-
let checksCount = 0;
|
31186
30720
|
const tableToPk = {};
|
31187
30721
|
let tableToGeneratedColumnsInfo = {};
|
31188
30722
|
for (const column4 of columns) {
|
@@ -31240,8 +30774,7 @@ ${withStyle.errorWarning(
|
|
31240
30774
|
compositePrimaryKeys: {},
|
31241
30775
|
indexes: {},
|
31242
30776
|
foreignKeys: {},
|
31243
|
-
uniqueConstraints: {}
|
31244
|
-
checkConstraints: {}
|
30777
|
+
uniqueConstraints: {}
|
31245
30778
|
};
|
31246
30779
|
} else {
|
31247
30780
|
result[tableName].columns[columnName] = newColumn;
|
@@ -31355,56 +30888,6 @@ WHERE
|
|
31355
30888
|
progressCallback("indexes", indexesCount, "done");
|
31356
30889
|
progressCallback("enums", 0, "done");
|
31357
30890
|
}
|
31358
|
-
const namedCheckPattern = /CONSTRAINT\s*["']?(\w+)["']?\s*CHECK\s*\((.*?)\)/gi;
|
31359
|
-
const unnamedCheckPattern = /CHECK\s*\((.*?)\)/gi;
|
31360
|
-
let checkCounter = 0;
|
31361
|
-
const checkConstraints = {};
|
31362
|
-
const checks = await db.query(`SELECT name as "tableName", sql as "sql"
|
31363
|
-
FROM sqlite_master
|
31364
|
-
WHERE type = 'table' AND name != 'sqlite_sequence';`);
|
31365
|
-
for (const check of checks) {
|
31366
|
-
if (!tablesFilter(check.tableName)) continue;
|
31367
|
-
const { tableName, sql: sql2 } = check;
|
31368
|
-
let namedChecks = [...sql2.matchAll(namedCheckPattern)];
|
31369
|
-
if (namedChecks.length > 0) {
|
31370
|
-
namedChecks.forEach(([_2, checkName, checkValue]) => {
|
31371
|
-
checkConstraints[checkName] = {
|
31372
|
-
name: checkName,
|
31373
|
-
value: checkValue.trim()
|
31374
|
-
};
|
31375
|
-
});
|
31376
|
-
} else {
|
31377
|
-
let unnamedChecks = [...sql2.matchAll(unnamedCheckPattern)];
|
31378
|
-
unnamedChecks.forEach(([_2, checkValue]) => {
|
31379
|
-
let checkName = `${tableName}_check_${++checkCounter}`;
|
31380
|
-
checkConstraints[checkName] = {
|
31381
|
-
name: checkName,
|
31382
|
-
value: checkValue.trim()
|
31383
|
-
};
|
31384
|
-
});
|
31385
|
-
}
|
31386
|
-
checksCount += Object.values(checkConstraints).length;
|
31387
|
-
if (progressCallback) {
|
31388
|
-
progressCallback("checks", checksCount, "fetching");
|
31389
|
-
}
|
31390
|
-
const table4 = result[tableName];
|
31391
|
-
if (!table4) {
|
31392
|
-
result[tableName] = {
|
31393
|
-
name: tableName,
|
31394
|
-
columns: {},
|
31395
|
-
compositePrimaryKeys: {},
|
31396
|
-
indexes: {},
|
31397
|
-
foreignKeys: {},
|
31398
|
-
uniqueConstraints: {},
|
31399
|
-
checkConstraints
|
31400
|
-
};
|
31401
|
-
} else {
|
31402
|
-
result[tableName].checkConstraints = checkConstraints;
|
31403
|
-
}
|
31404
|
-
}
|
31405
|
-
if (progressCallback) {
|
31406
|
-
progressCallback("checks", checksCount, "done");
|
31407
|
-
}
|
31408
30891
|
return {
|
31409
30892
|
version: "6",
|
31410
30893
|
dialect: "sqlite",
|
@@ -35700,7 +35183,6 @@ var init_mysqlSerializer = __esm({
|
|
35700
35183
|
indexes,
|
35701
35184
|
foreignKeys,
|
35702
35185
|
schema: schema4,
|
35703
|
-
checks,
|
35704
35186
|
primaryKeys,
|
35705
35187
|
uniqueConstraints
|
35706
35188
|
} = getTableConfig3(table4);
|
@@ -35709,8 +35191,6 @@ var init_mysqlSerializer = __esm({
|
|
35709
35191
|
const foreignKeysObject = {};
|
35710
35192
|
const primaryKeysObject = {};
|
35711
35193
|
const uniqueConstraintObject = {};
|
35712
|
-
const checkConstraintObject = {};
|
35713
|
-
let checksInTable = {};
|
35714
35194
|
columns.forEach((column4) => {
|
35715
35195
|
const name2 = getColumnCasing(column4, casing2);
|
35716
35196
|
const notNull = column4.notNull;
|
@@ -35941,32 +35421,6 @@ We have encountered a collision between the index name on columns ${source_defau
|
|
35941
35421
|
lock: value.config.lock
|
35942
35422
|
};
|
35943
35423
|
});
|
35944
|
-
checks.forEach((check) => {
|
35945
|
-
check;
|
35946
|
-
const checkName = check.name;
|
35947
|
-
if (typeof checksInTable[tableName] !== "undefined") {
|
35948
|
-
if (checksInTable[tableName].includes(check.name)) {
|
35949
|
-
console.log(
|
35950
|
-
`
|
35951
|
-
${withStyle.errorWarning(
|
35952
|
-
`We've found duplicated check constraint name in ${source_default.underline.blue(
|
35953
|
-
tableName
|
35954
|
-
)}. Please rename your check constraint in the ${source_default.underline.blue(
|
35955
|
-
tableName
|
35956
|
-
)} table`
|
35957
|
-
)}`
|
35958
|
-
);
|
35959
|
-
process.exit(1);
|
35960
|
-
}
|
35961
|
-
checksInTable[tableName].push(checkName);
|
35962
|
-
} else {
|
35963
|
-
checksInTable[tableName] = [check.name];
|
35964
|
-
}
|
35965
|
-
checkConstraintObject[checkName] = {
|
35966
|
-
name: checkName,
|
35967
|
-
value: dialect4.sqlToQuery(check.value).sql
|
35968
|
-
};
|
35969
|
-
});
|
35970
35424
|
if (!schema4) {
|
35971
35425
|
result[tableName] = {
|
35972
35426
|
name: tableName,
|
@@ -35974,8 +35428,7 @@ ${withStyle.errorWarning(
|
|
35974
35428
|
indexes: indexesObject,
|
35975
35429
|
foreignKeys: foreignKeysObject,
|
35976
35430
|
compositePrimaryKeys: primaryKeysObject,
|
35977
|
-
uniqueConstraints: uniqueConstraintObject
|
35978
|
-
checkConstraint: checkConstraintObject
|
35431
|
+
uniqueConstraints: uniqueConstraintObject
|
35979
35432
|
};
|
35980
35433
|
}
|
35981
35434
|
}
|
@@ -36002,7 +35455,6 @@ ${withStyle.errorWarning(
|
|
36002
35455
|
let tablesCount = /* @__PURE__ */ new Set();
|
36003
35456
|
let indexesCount = 0;
|
36004
35457
|
let foreignKeysCount = 0;
|
36005
|
-
let checksCount = 0;
|
36006
35458
|
const idxs = await db.query(
|
36007
35459
|
`select * from INFORMATION_SCHEMA.STATISTICS
|
36008
35460
|
WHERE INFORMATION_SCHEMA.STATISTICS.TABLE_SCHEMA = '${inputSchema}' and INFORMATION_SCHEMA.STATISTICS.INDEX_NAME != 'PRIMARY';`
|
@@ -36097,8 +35549,7 @@ ${withStyle.errorWarning(
|
|
36097
35549
|
compositePrimaryKeys: {},
|
36098
35550
|
indexes: {},
|
36099
35551
|
foreignKeys: {},
|
36100
|
-
uniqueConstraints: {}
|
36101
|
-
checkConstraint: {}
|
35552
|
+
uniqueConstraints: {}
|
36102
35553
|
};
|
36103
35554
|
} else {
|
36104
35555
|
result[tableName].columns[columnName] = newColumn;
|
@@ -36247,38 +35698,6 @@ ${withStyle.errorWarning(
|
|
36247
35698
|
progressCallback("indexes", indexesCount, "done");
|
36248
35699
|
progressCallback("enums", 0, "done");
|
36249
35700
|
}
|
36250
|
-
const checkConstraints = await db.query(
|
36251
|
-
`SELECT
|
36252
|
-
tc.table_name,
|
36253
|
-
tc.constraint_name,
|
36254
|
-
cc.check_clause
|
36255
|
-
FROM
|
36256
|
-
information_schema.table_constraints tc
|
36257
|
-
JOIN
|
36258
|
-
information_schema.check_constraints cc
|
36259
|
-
ON tc.constraint_name = cc.constraint_name
|
36260
|
-
WHERE
|
36261
|
-
tc.constraint_schema = '${inputSchema}'
|
36262
|
-
AND
|
36263
|
-
tc.constraint_type = 'CHECK';`
|
36264
|
-
);
|
36265
|
-
checksCount += checkConstraints.length;
|
36266
|
-
if (progressCallback) {
|
36267
|
-
progressCallback("checks", checksCount, "fetching");
|
36268
|
-
}
|
36269
|
-
for (const checkConstraintRow of checkConstraints) {
|
36270
|
-
const constraintName = checkConstraintRow["CONSTRAINT_NAME"];
|
36271
|
-
const constraintValue = checkConstraintRow["CHECK_CLAUSE"];
|
36272
|
-
const tableName = checkConstraintRow["TABLE_NAME"];
|
36273
|
-
const tableInResult = result[tableName];
|
36274
|
-
tableInResult.checkConstraint[constraintName] = {
|
36275
|
-
name: constraintName,
|
36276
|
-
value: constraintValue
|
36277
|
-
};
|
36278
|
-
}
|
36279
|
-
if (progressCallback) {
|
36280
|
-
progressCallback("checks", checksCount, "done");
|
36281
|
-
}
|
36282
35701
|
return {
|
36283
35702
|
version: "5",
|
36284
35703
|
dialect: "mysql",
|