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.js
CHANGED
@@ -7376,7 +7376,7 @@ var init_lib = __esm({
|
|
7376
7376
|
});
|
7377
7377
|
|
7378
7378
|
// src/serializer/mysqlSchema.ts
|
7379
|
-
var index, fk, column, tableV3, compositePK, uniqueConstraint,
|
7379
|
+
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;
|
7380
7380
|
var init_mysqlSchema = __esm({
|
7381
7381
|
"src/serializer/mysqlSchema.ts"() {
|
7382
7382
|
"use strict";
|
@@ -7426,10 +7426,6 @@ var init_mysqlSchema = __esm({
|
|
7426
7426
|
name: stringType(),
|
7427
7427
|
columns: stringType().array()
|
7428
7428
|
}).strict();
|
7429
|
-
checkConstraint = objectType({
|
7430
|
-
name: stringType(),
|
7431
|
-
value: stringType()
|
7432
|
-
}).strict();
|
7433
7429
|
tableV4 = objectType({
|
7434
7430
|
name: stringType(),
|
7435
7431
|
schema: stringType().optional(),
|
@@ -7443,8 +7439,7 @@ var init_mysqlSchema = __esm({
|
|
7443
7439
|
indexes: recordType(stringType(), index),
|
7444
7440
|
foreignKeys: recordType(stringType(), fk),
|
7445
7441
|
compositePrimaryKeys: recordType(stringType(), compositePK),
|
7446
|
-
uniqueConstraints: recordType(stringType(), uniqueConstraint).default({})
|
7447
|
-
checkConstraint: recordType(stringType(), checkConstraint).default({})
|
7442
|
+
uniqueConstraints: recordType(stringType(), uniqueConstraint).default({})
|
7448
7443
|
}).strict();
|
7449
7444
|
kitInternals = objectType({
|
7450
7445
|
tables: recordType(
|
@@ -7521,8 +7516,7 @@ var init_mysqlSchema = __esm({
|
|
7521
7516
|
indexes: recordType(stringType(), stringType()),
|
7522
7517
|
foreignKeys: recordType(stringType(), stringType()),
|
7523
7518
|
compositePrimaryKeys: recordType(stringType(), stringType()),
|
7524
|
-
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
7525
|
-
checkConstraints: recordType(stringType(), stringType()).default({})
|
7519
|
+
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
7526
7520
|
}).strict();
|
7527
7521
|
schemaSquashed = objectType({
|
7528
7522
|
version: literalType("5"),
|
@@ -7589,13 +7583,6 @@ var init_mysqlSchema = __esm({
|
|
7589
7583
|
onDelete
|
7590
7584
|
});
|
7591
7585
|
return result;
|
7592
|
-
},
|
7593
|
-
squashCheck: (input) => {
|
7594
|
-
return `${input.name};${input.value}`;
|
7595
|
-
},
|
7596
|
-
unsquashCheck: (input) => {
|
7597
|
-
const [name2, value] = input.split(";");
|
7598
|
-
return { name: name2, value };
|
7599
7586
|
}
|
7600
7587
|
};
|
7601
7588
|
squashMysqlScheme = (json3) => {
|
@@ -7616,9 +7603,6 @@ var init_mysqlSchema = __esm({
|
|
7616
7603
|
return MySqlSquasher.squashUnique(unq);
|
7617
7604
|
}
|
7618
7605
|
);
|
7619
|
-
const squashedCheckConstraints = mapValues(it[1].checkConstraint, (check) => {
|
7620
|
-
return MySqlSquasher.squashCheck(check);
|
7621
|
-
});
|
7622
7606
|
return [
|
7623
7607
|
it[0],
|
7624
7608
|
{
|
@@ -7627,8 +7611,7 @@ var init_mysqlSchema = __esm({
|
|
7627
7611
|
indexes: squashedIndexes,
|
7628
7612
|
foreignKeys: squashedFKs,
|
7629
7613
|
compositePrimaryKeys: squashedPKs,
|
7630
|
-
uniqueConstraints: squashedUniqueConstraints
|
7631
|
-
checkConstraints: squashedCheckConstraints
|
7614
|
+
uniqueConstraints: squashedUniqueConstraints
|
7632
7615
|
}
|
7633
7616
|
];
|
7634
7617
|
})
|
@@ -7678,7 +7661,7 @@ var init_vector = __esm({
|
|
7678
7661
|
});
|
7679
7662
|
|
7680
7663
|
// src/serializer/pgSchema.ts
|
7681
|
-
var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, indexColumn, index2, indexV4, indexV5, indexV6, fk2, sequenceSchema, sequenceSquashed, columnV7, column2,
|
7664
|
+
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;
|
7682
7665
|
var init_pgSchema = __esm({
|
7683
7666
|
"src/serializer/pgSchema.ts"() {
|
7684
7667
|
"use strict";
|
@@ -7842,10 +7825,6 @@ var init_pgSchema = __esm({
|
|
7842
7825
|
}).optional(),
|
7843
7826
|
identity: sequenceSchema.merge(objectType({ type: enumType(["always", "byDefault"]) })).optional()
|
7844
7827
|
}).strict();
|
7845
|
-
checkConstraint2 = objectType({
|
7846
|
-
name: stringType(),
|
7847
|
-
value: stringType()
|
7848
|
-
}).strict();
|
7849
7828
|
columnSquashed = objectType({
|
7850
7829
|
name: stringType(),
|
7851
7830
|
type: stringType(),
|
@@ -7918,8 +7897,7 @@ var init_pgSchema = __esm({
|
|
7918
7897
|
indexes: recordType(stringType(), index2),
|
7919
7898
|
foreignKeys: recordType(stringType(), fk2),
|
7920
7899
|
compositePrimaryKeys: recordType(stringType(), compositePK2),
|
7921
|
-
uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
|
7922
|
-
checkConstraints: recordType(stringType(), checkConstraint2).default({})
|
7900
|
+
uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
|
7923
7901
|
}).strict();
|
7924
7902
|
schemaHash2 = objectType({
|
7925
7903
|
id: stringType(),
|
@@ -8027,8 +8005,7 @@ var init_pgSchema = __esm({
|
|
8027
8005
|
indexes: recordType(stringType(), stringType()),
|
8028
8006
|
foreignKeys: recordType(stringType(), stringType()),
|
8029
8007
|
compositePrimaryKeys: recordType(stringType(), stringType()),
|
8030
|
-
uniqueConstraints: recordType(stringType(), stringType())
|
8031
|
-
checkConstraints: recordType(stringType(), stringType())
|
8008
|
+
uniqueConstraints: recordType(stringType(), stringType())
|
8032
8009
|
}).strict();
|
8033
8010
|
tableSquashedV42 = objectType({
|
8034
8011
|
name: stringType(),
|
@@ -8210,16 +8187,6 @@ var init_pgSchema = __esm({
|
|
8210
8187
|
cache: splitted[6] !== "undefined" ? splitted[6] : void 0,
|
8211
8188
|
cycle: splitted[7] === "true"
|
8212
8189
|
};
|
8213
|
-
},
|
8214
|
-
squashCheck: (check) => {
|
8215
|
-
return `${check.name};${check.value}`;
|
8216
|
-
},
|
8217
|
-
unsquashCheck: (input) => {
|
8218
|
-
const [
|
8219
|
-
name2,
|
8220
|
-
value
|
8221
|
-
] = input.split(";");
|
8222
|
-
return { name: name2, value };
|
8223
8190
|
}
|
8224
8191
|
};
|
8225
8192
|
squashPgScheme = (json3, action) => {
|
@@ -8252,12 +8219,6 @@ var init_pgSchema = __esm({
|
|
8252
8219
|
return PgSquasher.squashUnique(unq);
|
8253
8220
|
}
|
8254
8221
|
);
|
8255
|
-
const squashedChecksContraints = mapValues(
|
8256
|
-
it[1].checkConstraints,
|
8257
|
-
(check) => {
|
8258
|
-
return PgSquasher.squashCheck(check);
|
8259
|
-
}
|
8260
|
-
);
|
8261
8222
|
return [
|
8262
8223
|
it[0],
|
8263
8224
|
{
|
@@ -8267,8 +8228,7 @@ var init_pgSchema = __esm({
|
|
8267
8228
|
indexes: squashedIndexes,
|
8268
8229
|
foreignKeys: squashedFKs,
|
8269
8230
|
compositePrimaryKeys: squashedPKs,
|
8270
|
-
uniqueConstraints: squashedUniqueConstraints
|
8271
|
-
checkConstraints: squashedChecksContraints
|
8231
|
+
uniqueConstraints: squashedUniqueConstraints
|
8272
8232
|
}
|
8273
8233
|
];
|
8274
8234
|
})
|
@@ -8313,7 +8273,7 @@ var init_pgSchema = __esm({
|
|
8313
8273
|
});
|
8314
8274
|
|
8315
8275
|
// src/serializer/sqliteSchema.ts
|
8316
|
-
var index3, fk3, compositePK3, column3, tableV33, uniqueConstraint3,
|
8276
|
+
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;
|
8317
8277
|
var init_sqliteSchema = __esm({
|
8318
8278
|
"src/serializer/sqliteSchema.ts"() {
|
8319
8279
|
"use strict";
|
@@ -8360,18 +8320,13 @@ var init_sqliteSchema = __esm({
|
|
8360
8320
|
name: stringType(),
|
8361
8321
|
columns: stringType().array()
|
8362
8322
|
}).strict();
|
8363
|
-
checkConstraint3 = objectType({
|
8364
|
-
name: stringType(),
|
8365
|
-
value: stringType()
|
8366
|
-
}).strict();
|
8367
8323
|
table3 = objectType({
|
8368
8324
|
name: stringType(),
|
8369
8325
|
columns: recordType(stringType(), column3),
|
8370
8326
|
indexes: recordType(stringType(), index3),
|
8371
8327
|
foreignKeys: recordType(stringType(), fk3),
|
8372
8328
|
compositePrimaryKeys: recordType(stringType(), compositePK3),
|
8373
|
-
uniqueConstraints: recordType(stringType(), uniqueConstraint3).default({})
|
8374
|
-
checkConstraints: recordType(stringType(), checkConstraint3).default({})
|
8329
|
+
uniqueConstraints: recordType(stringType(), uniqueConstraint3).default({})
|
8375
8330
|
}).strict();
|
8376
8331
|
dialect2 = enumType(["sqlite"]);
|
8377
8332
|
schemaHash3 = objectType({
|
@@ -8433,8 +8388,7 @@ var init_sqliteSchema = __esm({
|
|
8433
8388
|
indexes: recordType(stringType(), stringType()),
|
8434
8389
|
foreignKeys: recordType(stringType(), stringType()),
|
8435
8390
|
compositePrimaryKeys: recordType(stringType(), stringType()),
|
8436
|
-
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
8437
|
-
checkConstraints: recordType(stringType(), stringType()).default({})
|
8391
|
+
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
8438
8392
|
}).strict();
|
8439
8393
|
schemaSquashed2 = objectType({
|
8440
8394
|
version: latestVersion,
|
@@ -8516,16 +8470,6 @@ var init_sqliteSchema = __esm({
|
|
8516
8470
|
},
|
8517
8471
|
unsquashPK: (pk) => {
|
8518
8472
|
return pk.split(",");
|
8519
|
-
},
|
8520
|
-
squashCheck: (check) => {
|
8521
|
-
return `${check.name};${check.value}`;
|
8522
|
-
},
|
8523
|
-
unsquashCheck: (input) => {
|
8524
|
-
const [
|
8525
|
-
name2,
|
8526
|
-
value
|
8527
|
-
] = input.split(";");
|
8528
|
-
return { name: name2, value };
|
8529
8473
|
}
|
8530
8474
|
};
|
8531
8475
|
squashSqliteScheme = (json3, action) => {
|
@@ -8552,12 +8496,6 @@ var init_sqliteSchema = __esm({
|
|
8552
8496
|
return SQLiteSquasher.squashUnique(unq);
|
8553
8497
|
}
|
8554
8498
|
);
|
8555
|
-
const squashedCheckConstraints = mapValues(
|
8556
|
-
it[1].checkConstraints,
|
8557
|
-
(check) => {
|
8558
|
-
return SQLiteSquasher.squashCheck(check);
|
8559
|
-
}
|
8560
|
-
);
|
8561
8499
|
return [
|
8562
8500
|
it[0],
|
8563
8501
|
{
|
@@ -8566,8 +8504,7 @@ var init_sqliteSchema = __esm({
|
|
8566
8504
|
indexes: squashedIndexes,
|
8567
8505
|
foreignKeys: squashedFKs,
|
8568
8506
|
compositePrimaryKeys: squashedPKs,
|
8569
|
-
uniqueConstraints: squashedUniqueConstraints
|
8570
|
-
checkConstraints: squashedCheckConstraints
|
8507
|
+
uniqueConstraints: squashedUniqueConstraints
|
8571
8508
|
}
|
8572
8509
|
];
|
8573
8510
|
})
|
@@ -11448,21 +11385,6 @@ var init_jsonDiffer = __esm({
|
|
11448
11385
|
return !it[0].endsWith("__deleted") && !it[0].endsWith("__added");
|
11449
11386
|
})
|
11450
11387
|
);
|
11451
|
-
const addedCheckConstraints = Object.fromEntries(
|
11452
|
-
Object.entries(table4.checkConstraints || {}).filter((it) => {
|
11453
|
-
return it[0].endsWith("__added");
|
11454
|
-
})
|
11455
|
-
);
|
11456
|
-
const deletedCheckConstraints = Object.fromEntries(
|
11457
|
-
Object.entries(table4.checkConstraints || {}).filter((it) => {
|
11458
|
-
return it[0].endsWith("__deleted");
|
11459
|
-
})
|
11460
|
-
);
|
11461
|
-
const alteredCheckConstraints = Object.fromEntries(
|
11462
|
-
Object.entries(table4.checkConstraints || {}).filter((it) => {
|
11463
|
-
return !it[0].endsWith("__deleted") && !it[0].endsWith("__added");
|
11464
|
-
})
|
11465
|
-
);
|
11466
11388
|
const mappedAltered = altered.map((it) => alternationsInColumn(it)).filter(Boolean);
|
11467
11389
|
return {
|
11468
11390
|
name: table4.name,
|
@@ -11479,10 +11401,7 @@ var init_jsonDiffer = __esm({
|
|
11479
11401
|
alteredCompositePKs,
|
11480
11402
|
addedUniqueConstraints,
|
11481
11403
|
deletedUniqueConstraints,
|
11482
|
-
alteredUniqueConstraints
|
11483
|
-
addedCheckConstraints,
|
11484
|
-
deletedCheckConstraints,
|
11485
|
-
alteredCheckConstraints
|
11404
|
+
alteredUniqueConstraints
|
11486
11405
|
};
|
11487
11406
|
};
|
11488
11407
|
alternationsInColumn = (column4) => {
|
@@ -11736,32 +11655,6 @@ var init_jsonDiffer = __esm({
|
|
11736
11655
|
};
|
11737
11656
|
}
|
11738
11657
|
return it;
|
11739
|
-
}).map((it) => {
|
11740
|
-
if ("" in it) {
|
11741
|
-
return {
|
11742
|
-
...it,
|
11743
|
-
autoincrement: {
|
11744
|
-
type: "changed",
|
11745
|
-
old: it.autoincrement.__old,
|
11746
|
-
new: it.autoincrement.__new
|
11747
|
-
}
|
11748
|
-
};
|
11749
|
-
}
|
11750
|
-
if ("autoincrement__added" in it) {
|
11751
|
-
const { autoincrement__added, ...others } = it;
|
11752
|
-
return {
|
11753
|
-
...others,
|
11754
|
-
autoincrement: { type: "added", value: it.autoincrement__added }
|
11755
|
-
};
|
11756
|
-
}
|
11757
|
-
if ("autoincrement__deleted" in it) {
|
11758
|
-
const { autoincrement__deleted, ...others } = it;
|
11759
|
-
return {
|
11760
|
-
...others,
|
11761
|
-
autoincrement: { type: "deleted", value: it.autoincrement__deleted }
|
11762
|
-
};
|
11763
|
-
}
|
11764
|
-
return it;
|
11765
11658
|
}).filter(Boolean);
|
11766
11659
|
return result[0];
|
11767
11660
|
};
|
@@ -11782,7 +11675,7 @@ function fromJson(statements, dialect4, action, json22) {
|
|
11782
11675
|
}).filter((it) => it !== "");
|
11783
11676
|
return result;
|
11784
11677
|
}
|
11785
|
-
var pgNativeTypes, isPgNativeType, Convertor, PgCreateTableConvertor, MySqlCreateTableConvertor, SQLiteCreateTableConvertor, PgAlterTableAlterColumnSetGenerated, PgAlterTableAlterColumnDropGenerated, PgAlterTableAlterColumnAlterGenerated, PgAlterTableAddUniqueConstraintConvertor, PgAlterTableDropUniqueConstraintConvertor,
|
11678
|
+
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;
|
11786
11679
|
var init_sqlgenerator = __esm({
|
11787
11680
|
"src/sqlgenerator.ts"() {
|
11788
11681
|
"use strict";
|
@@ -11843,7 +11736,7 @@ var init_sqlgenerator = __esm({
|
|
11843
11736
|
return statement.type === "create_table" && dialect4 === "postgresql";
|
11844
11737
|
}
|
11845
11738
|
convert(st) {
|
11846
|
-
const { tableName, schema: schema4, columns, compositePKs, uniqueConstraints
|
11739
|
+
const { tableName, schema: schema4, columns, compositePKs, uniqueConstraints } = st;
|
11847
11740
|
let statement = "";
|
11848
11741
|
const name2 = schema4 ? `"${schema4}"."${tableName}"` : `"${tableName}"`;
|
11849
11742
|
statement += `CREATE TABLE IF NOT EXISTS ${name2} (
|
@@ -11876,13 +11769,6 @@ var init_sqlgenerator = __esm({
|
|
11876
11769
|
statement += ` CONSTRAINT "${unsquashedUnique.name}" UNIQUE${unsquashedUnique.nullsNotDistinct ? " NULLS NOT DISTINCT" : ""}("${unsquashedUnique.columns.join(`","`)}")`;
|
11877
11770
|
}
|
11878
11771
|
}
|
11879
|
-
if (typeof checkConstraints !== "undefined" && checkConstraints.length > 0) {
|
11880
|
-
for (const checkConstraint4 of checkConstraints) {
|
11881
|
-
statement += ",\n";
|
11882
|
-
const unsquashedCheck = PgSquasher.unsquashCheck(checkConstraint4);
|
11883
|
-
statement += ` CONSTRAINT "${unsquashedCheck.name}" CHECK (${unsquashedCheck.value})`;
|
11884
|
-
}
|
11885
|
-
}
|
11886
11772
|
statement += `
|
11887
11773
|
);`;
|
11888
11774
|
statement += `
|
@@ -11899,7 +11785,6 @@ var init_sqlgenerator = __esm({
|
|
11899
11785
|
tableName,
|
11900
11786
|
columns,
|
11901
11787
|
schema: schema4,
|
11902
|
-
checkConstraints,
|
11903
11788
|
compositePKs,
|
11904
11789
|
uniqueConstraints,
|
11905
11790
|
internals
|
@@ -11933,13 +11818,6 @@ var init_sqlgenerator = __esm({
|
|
11933
11818
|
statement += ` CONSTRAINT \`${unsquashedUnique.name}\` UNIQUE(${uniqueString})`;
|
11934
11819
|
}
|
11935
11820
|
}
|
11936
|
-
if (typeof checkConstraints !== "undefined" && checkConstraints.length > 0) {
|
11937
|
-
for (const checkConstraint4 of checkConstraints) {
|
11938
|
-
statement += ",\n";
|
11939
|
-
const unsquashedCheck = MySqlSquasher.unsquashCheck(checkConstraint4);
|
11940
|
-
statement += ` CONSTRAINT \`${unsquashedCheck.name}\` CHECK(${unsquashedCheck.value})`;
|
11941
|
-
}
|
11942
|
-
}
|
11943
11821
|
statement += `
|
11944
11822
|
);`;
|
11945
11823
|
statement += `
|
@@ -11957,8 +11835,7 @@ var init_sqlgenerator = __esm({
|
|
11957
11835
|
columns,
|
11958
11836
|
referenceData,
|
11959
11837
|
compositePKs,
|
11960
|
-
uniqueConstraints
|
11961
|
-
checkConstraints
|
11838
|
+
uniqueConstraints
|
11962
11839
|
} = st;
|
11963
11840
|
let statement = "";
|
11964
11841
|
statement += `CREATE TABLE \`${tableName}\` (
|
@@ -11999,17 +11876,10 @@ var init_sqlgenerator = __esm({
|
|
11999
11876
|
if (typeof uniqueConstraints !== "undefined" && uniqueConstraints.length > 0) {
|
12000
11877
|
for (const uniqueConstraint4 of uniqueConstraints) {
|
12001
11878
|
statement += ",\n";
|
12002
|
-
const unsquashedUnique =
|
11879
|
+
const unsquashedUnique = MySqlSquasher.unsquashUnique(uniqueConstraint4);
|
12003
11880
|
statement += ` CONSTRAINT ${unsquashedUnique.name} UNIQUE(\`${unsquashedUnique.columns.join(`\`,\``)}\`)`;
|
12004
11881
|
}
|
12005
11882
|
}
|
12006
|
-
if (typeof checkConstraints !== "undefined" && checkConstraints.length > 0) {
|
12007
|
-
for (const check of checkConstraints) {
|
12008
|
-
statement += ",\n";
|
12009
|
-
const { value, name: name2 } = SQLiteSquasher.unsquashCheck(check);
|
12010
|
-
statement += ` CONSTRAINT "${name2}" CHECK(${value})`;
|
12011
|
-
}
|
12012
|
-
}
|
12013
11883
|
statement += `
|
12014
11884
|
`;
|
12015
11885
|
statement += `);`;
|
@@ -12109,25 +11979,6 @@ var init_sqlgenerator = __esm({
|
|
12109
11979
|
return `ALTER TABLE ${tableNameWithSchema} DROP CONSTRAINT "${unsquashed.name}";`;
|
12110
11980
|
}
|
12111
11981
|
};
|
12112
|
-
PgAlterTableAddCheckConstraintConvertor = class extends Convertor {
|
12113
|
-
can(statement, dialect4) {
|
12114
|
-
return statement.type === "create_check_constraint" && dialect4 === "postgresql";
|
12115
|
-
}
|
12116
|
-
convert(statement) {
|
12117
|
-
const unsquashed = PgSquasher.unsquashCheck(statement.data);
|
12118
|
-
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
12119
|
-
return `ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${unsquashed.name}" CHECK (${unsquashed.value});`;
|
12120
|
-
}
|
12121
|
-
};
|
12122
|
-
PgAlterTableDeleteCheckConstraintConvertor = class extends Convertor {
|
12123
|
-
can(statement, dialect4) {
|
12124
|
-
return statement.type === "delete_check_constraint" && dialect4 === "postgresql";
|
12125
|
-
}
|
12126
|
-
convert(statement) {
|
12127
|
-
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
12128
|
-
return `ALTER TABLE ${tableNameWithSchema} DROP CONSTRAINT "${statement.constraintName}";`;
|
12129
|
-
}
|
12130
|
-
};
|
12131
11982
|
MySQLAlterTableAddUniqueConstraintConvertor = class extends Convertor {
|
12132
11983
|
can(statement, dialect4) {
|
12133
11984
|
return statement.type === "create_unique_constraint" && dialect4 === "mysql";
|
@@ -12146,25 +11997,6 @@ var init_sqlgenerator = __esm({
|
|
12146
11997
|
return `ALTER TABLE \`${statement.tableName}\` DROP INDEX \`${unsquashed.name}\`;`;
|
12147
11998
|
}
|
12148
11999
|
};
|
12149
|
-
MySqlAlterTableAddCheckConstraintConvertor = class extends Convertor {
|
12150
|
-
can(statement, dialect4) {
|
12151
|
-
return statement.type === "create_check_constraint" && dialect4 === "mysql";
|
12152
|
-
}
|
12153
|
-
convert(statement) {
|
12154
|
-
const unsquashed = MySqlSquasher.unsquashCheck(statement.data);
|
12155
|
-
const { tableName } = statement;
|
12156
|
-
return `ALTER TABLE \`${tableName}\` ADD CONSTRAINT \`${unsquashed.name}\` CHECK (${unsquashed.value});`;
|
12157
|
-
}
|
12158
|
-
};
|
12159
|
-
MySqlAlterTableDeleteCheckConstraintConvertor = class extends Convertor {
|
12160
|
-
can(statement, dialect4) {
|
12161
|
-
return statement.type === "delete_check_constraint" && dialect4 === "mysql";
|
12162
|
-
}
|
12163
|
-
convert(statement) {
|
12164
|
-
const { tableName } = statement;
|
12165
|
-
return `ALTER TABLE \`${tableName}\` DROP CONSTRAINT \`${statement.constraintName}\`;`;
|
12166
|
-
}
|
12167
|
-
};
|
12168
12000
|
CreatePgSequenceConvertor = class extends Convertor {
|
12169
12001
|
can(statement, dialect4) {
|
12170
12002
|
return statement.type === "create_sequence" && dialect4 === "postgresql";
|
@@ -12768,7 +12600,7 @@ var init_sqlgenerator = __esm({
|
|
12768
12600
|
};
|
12769
12601
|
LibSQLModifyColumn = class extends Convertor {
|
12770
12602
|
can(statement, dialect4) {
|
12771
|
-
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"
|
12603
|
+
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";
|
12772
12604
|
}
|
12773
12605
|
convert(statement, json22) {
|
12774
12606
|
const { tableName, columnName } = statement;
|
@@ -13355,22 +13187,18 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
13355
13187
|
return statement.type === "recreate_table" && dialect4 === "sqlite";
|
13356
13188
|
}
|
13357
13189
|
convert(statement) {
|
13358
|
-
const { tableName, columns, compositePKs, referenceData
|
13190
|
+
const { tableName, columns, compositePKs, referenceData } = statement;
|
13359
13191
|
const columnNames = columns.map((it) => `"${it.name}"`).join(", ");
|
13360
13192
|
const newTableName = `__new_${tableName}`;
|
13361
13193
|
const sqlStatements = [];
|
13362
13194
|
sqlStatements.push(`PRAGMA foreign_keys=OFF;`);
|
13363
|
-
const mappedCheckConstraints = checkConstraints.map(
|
13364
|
-
(it) => it.replaceAll(`"${tableName}".`, `"${newTableName}".`).replaceAll(`\`${tableName}\`.`, `\`${newTableName}\`.`).replaceAll(`${tableName}.`, `${newTableName}.`).replaceAll(`'${tableName}'.`, `'${newTableName}'.`)
|
13365
|
-
);
|
13366
13195
|
sqlStatements.push(
|
13367
13196
|
new SQLiteCreateTableConvertor().convert({
|
13368
13197
|
type: "sqlite_create_table",
|
13369
13198
|
tableName: newTableName,
|
13370
13199
|
columns,
|
13371
13200
|
referenceData,
|
13372
|
-
compositePKs
|
13373
|
-
checkConstraints: mappedCheckConstraints
|
13201
|
+
compositePKs
|
13374
13202
|
})
|
13375
13203
|
);
|
13376
13204
|
sqlStatements.push(
|
@@ -13401,13 +13229,10 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
13401
13229
|
return statement.type === "recreate_table" && dialect4 === "turso";
|
13402
13230
|
}
|
13403
13231
|
convert(statement) {
|
13404
|
-
const { tableName, columns, compositePKs, referenceData
|
13232
|
+
const { tableName, columns, compositePKs, referenceData } = statement;
|
13405
13233
|
const columnNames = columns.map((it) => `"${it.name}"`).join(", ");
|
13406
13234
|
const newTableName = `__new_${tableName}`;
|
13407
13235
|
const sqlStatements = [];
|
13408
|
-
const mappedCheckConstraints = checkConstraints.map(
|
13409
|
-
(it) => it.replaceAll(`"${tableName}".`, `"${newTableName}".`).replaceAll(`\`${tableName}\`.`, `\`${newTableName}\`.`).replaceAll(`${tableName}.`, `${newTableName}.`).replaceAll(`'${tableName}'.`, `\`${newTableName}\`.`)
|
13410
|
-
);
|
13411
13236
|
sqlStatements.push(`PRAGMA foreign_keys=OFF;`);
|
13412
13237
|
sqlStatements.push(
|
13413
13238
|
new SQLiteCreateTableConvertor().convert({
|
@@ -13415,8 +13240,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
13415
13240
|
tableName: newTableName,
|
13416
13241
|
columns,
|
13417
13242
|
referenceData,
|
13418
|
-
compositePKs
|
13419
|
-
checkConstraints: mappedCheckConstraints
|
13243
|
+
compositePKs
|
13420
13244
|
})
|
13421
13245
|
);
|
13422
13246
|
sqlStatements.push(
|
@@ -13477,10 +13301,6 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
13477
13301
|
convertors.push(new PgAlterTableAlterColumnSetTypeConvertor());
|
13478
13302
|
convertors.push(new PgAlterTableAddUniqueConstraintConvertor());
|
13479
13303
|
convertors.push(new PgAlterTableDropUniqueConstraintConvertor());
|
13480
|
-
convertors.push(new PgAlterTableAddCheckConstraintConvertor());
|
13481
|
-
convertors.push(new PgAlterTableDeleteCheckConstraintConvertor());
|
13482
|
-
convertors.push(new MySqlAlterTableAddCheckConstraintConvertor());
|
13483
|
-
convertors.push(new MySqlAlterTableDeleteCheckConstraintConvertor());
|
13484
13304
|
convertors.push(new MySQLAlterTableAddUniqueConstraintConvertor());
|
13485
13305
|
convertors.push(new MySQLAlterTableDropUniqueConstraintConvertor());
|
13486
13306
|
convertors.push(new CreatePgIndexConvertor());
|
@@ -13570,10 +13390,6 @@ var init_sqlitePushUtils = __esm({
|
|
13570
13390
|
const compositePKs = Object.values(
|
13571
13391
|
json3.tables[tableName].compositePrimaryKeys
|
13572
13392
|
).map((it) => SQLiteSquasher.unsquashPK(it));
|
13573
|
-
const checkConstraints = Object.values(json3.tables[tableName].checkConstraints);
|
13574
|
-
const mappedCheckConstraints = checkConstraints.map(
|
13575
|
-
(it) => it.replaceAll(`"${tableName}".`, `"${newTableName}".`).replaceAll(`\`${tableName}\`.`, `\`${newTableName}\`.`).replaceAll(`${tableName}.`, `${newTableName}.`).replaceAll(`'${tableName}'.`, `\`${newTableName}\`.`)
|
13576
|
-
);
|
13577
13393
|
const fks = referenceData.map((it) => SQLiteSquasher.unsquashPushFK(it));
|
13578
13394
|
statements.push(
|
13579
13395
|
new SQLiteCreateTableConvertor().convert({
|
@@ -13581,8 +13397,7 @@ var init_sqlitePushUtils = __esm({
|
|
13581
13397
|
tableName: newTableName,
|
13582
13398
|
columns: tableColumns,
|
13583
13399
|
referenceData: fks,
|
13584
|
-
compositePKs
|
13585
|
-
checkConstraints: mappedCheckConstraints
|
13400
|
+
compositePKs
|
13586
13401
|
})
|
13587
13402
|
);
|
13588
13403
|
if (!dataLoss) {
|
@@ -13794,7 +13609,7 @@ var init_sqlitePushUtils = __esm({
|
|
13794
13609
|
});
|
13795
13610
|
|
13796
13611
|
// src/jsonStatements.ts
|
13797
|
-
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,
|
13612
|
+
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;
|
13798
13613
|
var init_jsonStatements = __esm({
|
13799
13614
|
"src/jsonStatements.ts"() {
|
13800
13615
|
"use strict";
|
@@ -13805,7 +13620,7 @@ var init_jsonStatements = __esm({
|
|
13805
13620
|
init_pgSchema();
|
13806
13621
|
init_sqliteSchema();
|
13807
13622
|
preparePgCreateTableJson = (table4, json22) => {
|
13808
|
-
const { name: name2, schema: schema4, columns, compositePrimaryKeys, uniqueConstraints
|
13623
|
+
const { name: name2, schema: schema4, columns, compositePrimaryKeys, uniqueConstraints } = table4;
|
13809
13624
|
const tableKey2 = `${schema4 || "public"}.${name2}`;
|
13810
13625
|
const compositePkName = Object.values(compositePrimaryKeys).length > 0 ? json22.tables[tableKey2].compositePrimaryKeys[`${PgSquasher.unsquashPK(Object.values(compositePrimaryKeys)[0]).name}`].name : "";
|
13811
13626
|
return {
|
@@ -13815,12 +13630,11 @@ var init_jsonStatements = __esm({
|
|
13815
13630
|
columns: Object.values(columns),
|
13816
13631
|
compositePKs: Object.values(compositePrimaryKeys),
|
13817
13632
|
compositePkName,
|
13818
|
-
uniqueConstraints: Object.values(uniqueConstraints)
|
13819
|
-
checkConstraints: Object.values(checkConstraints)
|
13633
|
+
uniqueConstraints: Object.values(uniqueConstraints)
|
13820
13634
|
};
|
13821
13635
|
};
|
13822
13636
|
prepareMySqlCreateTableJson = (table4, json22, internals) => {
|
13823
|
-
const { name: name2, schema: schema4, columns, compositePrimaryKeys, uniqueConstraints
|
13637
|
+
const { name: name2, schema: schema4, columns, compositePrimaryKeys, uniqueConstraints } = table4;
|
13824
13638
|
return {
|
13825
13639
|
type: "create_table",
|
13826
13640
|
tableName: name2,
|
@@ -13829,12 +13643,11 @@ var init_jsonStatements = __esm({
|
|
13829
13643
|
compositePKs: Object.values(compositePrimaryKeys),
|
13830
13644
|
compositePkName: Object.values(compositePrimaryKeys).length > 0 ? json22.tables[name2].compositePrimaryKeys[MySqlSquasher.unsquashPK(Object.values(compositePrimaryKeys)[0]).name].name : "",
|
13831
13645
|
uniqueConstraints: Object.values(uniqueConstraints),
|
13832
|
-
internals
|
13833
|
-
checkConstraints: Object.values(checkConstraints)
|
13646
|
+
internals
|
13834
13647
|
};
|
13835
13648
|
};
|
13836
13649
|
prepareSQLiteCreateTable = (table4, action) => {
|
13837
|
-
const { name: name2, columns, uniqueConstraints
|
13650
|
+
const { name: name2, columns, uniqueConstraints } = table4;
|
13838
13651
|
const references2 = Object.values(table4.foreignKeys);
|
13839
13652
|
const composites = Object.values(table4.compositePrimaryKeys).map(
|
13840
13653
|
(it) => SQLiteSquasher.unsquashPK(it)
|
@@ -13848,8 +13661,7 @@ var init_jsonStatements = __esm({
|
|
13848
13661
|
columns: Object.values(columns),
|
13849
13662
|
referenceData: fks,
|
13850
13663
|
compositePKs: composites,
|
13851
|
-
uniqueConstraints: Object.values(uniqueConstraints)
|
13852
|
-
checkConstraints: Object.values(checkConstraints)
|
13664
|
+
uniqueConstraints: Object.values(uniqueConstraints)
|
13853
13665
|
};
|
13854
13666
|
};
|
13855
13667
|
prepareDropTableJson = (table4) => {
|
@@ -15113,26 +14925,6 @@ var init_jsonStatements = __esm({
|
|
15113
14925
|
};
|
15114
14926
|
});
|
15115
14927
|
};
|
15116
|
-
prepareAddCheckConstraint = (tableName, schema4, check) => {
|
15117
|
-
return Object.values(check).map((it) => {
|
15118
|
-
return {
|
15119
|
-
type: "create_check_constraint",
|
15120
|
-
tableName,
|
15121
|
-
data: it,
|
15122
|
-
schema: schema4
|
15123
|
-
};
|
15124
|
-
});
|
15125
|
-
};
|
15126
|
-
prepareDeleteCheckConstraint = (tableName, schema4, check) => {
|
15127
|
-
return Object.values(check).map((it) => {
|
15128
|
-
return {
|
15129
|
-
type: "delete_check_constraint",
|
15130
|
-
tableName,
|
15131
|
-
constraintName: PgSquasher.unsquashCheck(it).name,
|
15132
|
-
schema: schema4
|
15133
|
-
};
|
15134
|
-
});
|
15135
|
-
};
|
15136
14928
|
prepareAddCompositePrimaryKeyMySql = (tableName, pks, json1, json22) => {
|
15137
14929
|
const res = [];
|
15138
14930
|
for (const it of Object.values(pks)) {
|
@@ -15182,7 +14974,7 @@ var init_statementCombiner = __esm({
|
|
15182
14974
|
init_jsonStatements();
|
15183
14975
|
init_sqliteSchema();
|
15184
14976
|
prepareLibSQLRecreateTable = (table4, action) => {
|
15185
|
-
const { name: name2, columns, uniqueConstraints, indexes
|
14977
|
+
const { name: name2, columns, uniqueConstraints, indexes } = table4;
|
15186
14978
|
const composites = Object.values(table4.compositePrimaryKeys).map(
|
15187
14979
|
(it) => SQLiteSquasher.unsquashPK(it)
|
15188
14980
|
);
|
@@ -15197,8 +14989,7 @@ var init_statementCombiner = __esm({
|
|
15197
14989
|
columns: Object.values(columns),
|
15198
14990
|
compositePKs: composites,
|
15199
14991
|
referenceData: fks,
|
15200
|
-
uniqueConstraints: Object.values(uniqueConstraints)
|
15201
|
-
checkConstraints: Object.values(checkConstraints)
|
14992
|
+
uniqueConstraints: Object.values(uniqueConstraints)
|
15202
14993
|
}
|
15203
14994
|
];
|
15204
14995
|
if (Object.keys(indexes).length) {
|
@@ -15207,7 +14998,7 @@ var init_statementCombiner = __esm({
|
|
15207
14998
|
return statements;
|
15208
14999
|
};
|
15209
15000
|
prepareSQLiteRecreateTable = (table4, action) => {
|
15210
|
-
const { name: name2, columns, uniqueConstraints, indexes
|
15001
|
+
const { name: name2, columns, uniqueConstraints, indexes } = table4;
|
15211
15002
|
const composites = Object.values(table4.compositePrimaryKeys).map(
|
15212
15003
|
(it) => SQLiteSquasher.unsquashPK(it)
|
15213
15004
|
);
|
@@ -15222,8 +15013,7 @@ var init_statementCombiner = __esm({
|
|
15222
15013
|
columns: Object.values(columns),
|
15223
15014
|
compositePKs: composites,
|
15224
15015
|
referenceData: fks,
|
15225
|
-
uniqueConstraints: Object.values(uniqueConstraints)
|
15226
|
-
checkConstraints: Object.values(checkConstraints)
|
15016
|
+
uniqueConstraints: Object.values(uniqueConstraints)
|
15227
15017
|
}
|
15228
15018
|
];
|
15229
15019
|
if (Object.keys(indexes).length) {
|
@@ -15234,7 +15024,7 @@ var init_statementCombiner = __esm({
|
|
15234
15024
|
libSQLCombineStatements = (statements, json22, action) => {
|
15235
15025
|
const newStatements = {};
|
15236
15026
|
for (const statement of statements) {
|
15237
|
-
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"
|
15027
|
+
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") {
|
15238
15028
|
const tableName2 = statement.tableName;
|
15239
15029
|
const statementsForTable2 = newStatements[tableName2];
|
15240
15030
|
if (!statementsForTable2) {
|
@@ -15375,16 +15165,16 @@ var init_statementCombiner = __esm({
|
|
15375
15165
|
sqliteCombineStatements = (statements, json22, action) => {
|
15376
15166
|
const newStatements = {};
|
15377
15167
|
for (const statement of statements) {
|
15378
|
-
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"
|
15168
|
+
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") {
|
15379
15169
|
const tableName2 = statement.tableName;
|
15380
15170
|
const statementsForTable2 = newStatements[tableName2];
|
15381
15171
|
if (!statementsForTable2) {
|
15382
|
-
newStatements[tableName2] =
|
15172
|
+
newStatements[tableName2] = prepareLibSQLRecreateTable(json22.tables[tableName2], action);
|
15383
15173
|
continue;
|
15384
15174
|
}
|
15385
15175
|
if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
|
15386
15176
|
const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
|
15387
|
-
const preparedStatements =
|
15177
|
+
const preparedStatements = prepareLibSQLRecreateTable(json22.tables[tableName2], action);
|
15388
15178
|
if (wasRename) {
|
15389
15179
|
newStatements[tableName2].push(...preparedStatements);
|
15390
15180
|
} else {
|
@@ -15398,12 +15188,12 @@ var init_statementCombiner = __esm({
|
|
15398
15188
|
const tableName2 = statement.tableName;
|
15399
15189
|
const statementsForTable2 = newStatements[tableName2];
|
15400
15190
|
if (!statementsForTable2) {
|
15401
|
-
newStatements[tableName2] =
|
15191
|
+
newStatements[tableName2] = prepareLibSQLRecreateTable(json22.tables[tableName2], action);
|
15402
15192
|
continue;
|
15403
15193
|
}
|
15404
15194
|
if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
|
15405
15195
|
const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
|
15406
|
-
const preparedStatements =
|
15196
|
+
const preparedStatements = prepareLibSQLRecreateTable(json22.tables[tableName2], action);
|
15407
15197
|
if (wasRename) {
|
15408
15198
|
newStatements[tableName2].push(...preparedStatements);
|
15409
15199
|
} else {
|
@@ -15428,7 +15218,7 @@ var init_statementCombiner = __esm({
|
|
15428
15218
|
}
|
15429
15219
|
if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
|
15430
15220
|
const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
|
15431
|
-
const preparedStatements =
|
15221
|
+
const preparedStatements = prepareLibSQLRecreateTable(json22.tables[tableName2], action);
|
15432
15222
|
if (wasRename) {
|
15433
15223
|
newStatements[tableName2].push(...preparedStatements);
|
15434
15224
|
} else {
|
@@ -15597,8 +15387,7 @@ var init_snapshotsDiffer = __esm({
|
|
15597
15387
|
indexes: recordType(stringType(), stringType()),
|
15598
15388
|
foreignKeys: recordType(stringType(), stringType()),
|
15599
15389
|
compositePrimaryKeys: recordType(stringType(), stringType()).default({}),
|
15600
|
-
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
15601
|
-
checkConstraints: recordType(stringType(), stringType()).default({})
|
15390
|
+
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
15602
15391
|
}).strict();
|
15603
15392
|
alteredTableScheme = objectType({
|
15604
15393
|
name: stringType(),
|
@@ -15639,21 +15428,6 @@ var init_snapshotsDiffer = __esm({
|
|
15639
15428
|
__new: stringType(),
|
15640
15429
|
__old: stringType()
|
15641
15430
|
})
|
15642
|
-
),
|
15643
|
-
addedCheckConstraints: recordType(
|
15644
|
-
stringType(),
|
15645
|
-
stringType()
|
15646
|
-
),
|
15647
|
-
deletedCheckConstraints: recordType(
|
15648
|
-
stringType(),
|
15649
|
-
stringType()
|
15650
|
-
),
|
15651
|
-
alteredCheckConstraints: recordType(
|
15652
|
-
stringType(),
|
15653
|
-
objectType({
|
15654
|
-
__new: stringType(),
|
15655
|
-
__old: stringType()
|
15656
|
-
})
|
15657
15431
|
)
|
15658
15432
|
}).strict();
|
15659
15433
|
diffResultScheme = objectType({
|
@@ -15994,8 +15768,6 @@ var init_snapshotsDiffer = __esm({
|
|
15994
15768
|
schemaTo: it.schemaTo || "public"
|
15995
15769
|
});
|
15996
15770
|
}
|
15997
|
-
const jsonDeletedCheckConstraints = [];
|
15998
|
-
const jsonCreatedCheckConstraints = [];
|
15999
15771
|
for (let it of alteredTables) {
|
16000
15772
|
let addedColumns = [];
|
16001
15773
|
for (const addedPkName of Object.keys(it.addedCompositePKs)) {
|
@@ -16035,8 +15807,6 @@ var init_snapshotsDiffer = __esm({
|
|
16035
15807
|
let addedUniqueConstraints = [];
|
16036
15808
|
let deletedUniqueConstraints = [];
|
16037
15809
|
let alteredUniqueConstraints = [];
|
16038
|
-
let createCheckConstraints = [];
|
16039
|
-
let deleteCheckConstraints = [];
|
16040
15810
|
addedUniqueConstraints = prepareAddUniqueConstraintPg(
|
16041
15811
|
it.name,
|
16042
15812
|
it.schema,
|
@@ -16061,24 +15831,6 @@ var init_snapshotsDiffer = __esm({
|
|
16061
15831
|
...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
|
16062
15832
|
);
|
16063
15833
|
}
|
16064
|
-
createCheckConstraints = prepareAddCheckConstraint(it.name, it.schema, it.addedCheckConstraints);
|
16065
|
-
deleteCheckConstraints = prepareDeleteCheckConstraint(
|
16066
|
-
it.name,
|
16067
|
-
it.schema,
|
16068
|
-
it.deletedCheckConstraints
|
16069
|
-
);
|
16070
|
-
if (it.alteredCheckConstraints && action !== "push") {
|
16071
|
-
const added = {};
|
16072
|
-
const deleted = {};
|
16073
|
-
for (const k of Object.keys(it.alteredCheckConstraints)) {
|
16074
|
-
added[k] = it.alteredCheckConstraints[k].__new;
|
16075
|
-
deleted[k] = it.alteredCheckConstraints[k].__old;
|
16076
|
-
}
|
16077
|
-
createCheckConstraints.push(...prepareAddCheckConstraint(it.name, it.schema, added));
|
16078
|
-
deleteCheckConstraints.push(...prepareDeleteCheckConstraint(it.name, it.schema, deleted));
|
16079
|
-
}
|
16080
|
-
jsonCreatedCheckConstraints.push(...createCheckConstraints);
|
16081
|
-
jsonDeletedCheckConstraints.push(...deleteCheckConstraints);
|
16082
15834
|
jsonAddedCompositePKs.push(...addedCompositePKs);
|
16083
15835
|
jsonDeletedCompositePKs.push(...deletedCompositePKs);
|
16084
15836
|
jsonAlteredCompositePKs.push(...alteredCompositePKs);
|
@@ -16235,7 +15987,6 @@ var init_snapshotsDiffer = __esm({
|
|
16235
15987
|
jsonStatements.push(...jsonRenameTables);
|
16236
15988
|
jsonStatements.push(...jsonRenameColumnsStatements);
|
16237
15989
|
jsonStatements.push(...jsonDeletedUniqueConstraints);
|
16238
|
-
jsonStatements.push(...jsonDeletedCheckConstraints);
|
16239
15990
|
jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
|
16240
15991
|
jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
|
16241
15992
|
jsonStatements.push(...jsonDeletedCompositePKs);
|
@@ -16249,7 +16000,6 @@ var init_snapshotsDiffer = __esm({
|
|
16249
16000
|
jsonStatements.push(...jsonDropColumnsStatemets);
|
16250
16001
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
16251
16002
|
jsonStatements.push(...jsonAddedUniqueConstraints);
|
16252
|
-
jsonStatements.push(...jsonCreatedCheckConstraints);
|
16253
16003
|
jsonStatements.push(...jsonAlteredUniqueConstraints);
|
16254
16004
|
jsonStatements.push(...jsonAlterEnumsWithDroppedValues);
|
16255
16005
|
jsonStatements.push(...dropEnums);
|
@@ -16424,8 +16174,6 @@ var init_snapshotsDiffer = __esm({
|
|
16424
16174
|
const jsonAddedUniqueConstraints = [];
|
16425
16175
|
const jsonDeletedUniqueConstraints = [];
|
16426
16176
|
const jsonAlteredUniqueConstraints = [];
|
16427
|
-
const jsonCreatedCheckConstraints = [];
|
16428
|
-
const jsonDeletedCheckConstraints = [];
|
16429
16177
|
const jsonRenameColumnsStatements = columnRenames.map((it) => prepareRenameColumns(it.table, "", it.renames)).flat();
|
16430
16178
|
const jsonAddColumnsStatemets = columnCreates.map((it) => _prepareAddColumns(it.table, "", it.columns)).flat();
|
16431
16179
|
const jsonDropColumnsStatemets = columnDeletes.map((it) => _prepareDropColumns(it.table, "", it.columns)).flat();
|
@@ -16464,8 +16212,6 @@ var init_snapshotsDiffer = __esm({
|
|
16464
16212
|
let addedUniqueConstraints = [];
|
16465
16213
|
let deletedUniqueConstraints = [];
|
16466
16214
|
let alteredUniqueConstraints = [];
|
16467
|
-
let createdCheckConstraints = [];
|
16468
|
-
let deletedCheckConstraints = [];
|
16469
16215
|
addedUniqueConstraints = prepareAddUniqueConstraintPg(
|
16470
16216
|
it.name,
|
16471
16217
|
it.schema,
|
@@ -16490,30 +16236,12 @@ var init_snapshotsDiffer = __esm({
|
|
16490
16236
|
...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
|
16491
16237
|
);
|
16492
16238
|
}
|
16493
|
-
createdCheckConstraints = prepareAddCheckConstraint(it.name, it.schema, it.addedCheckConstraints);
|
16494
|
-
deletedCheckConstraints = prepareDeleteCheckConstraint(
|
16495
|
-
it.name,
|
16496
|
-
it.schema,
|
16497
|
-
it.deletedCheckConstraints
|
16498
|
-
);
|
16499
|
-
if (it.alteredCheckConstraints && action !== "push") {
|
16500
|
-
const added = {};
|
16501
|
-
const deleted = {};
|
16502
|
-
for (const k of Object.keys(it.alteredCheckConstraints)) {
|
16503
|
-
added[k] = it.alteredCheckConstraints[k].__new;
|
16504
|
-
deleted[k] = it.alteredCheckConstraints[k].__old;
|
16505
|
-
}
|
16506
|
-
createdCheckConstraints.push(...prepareAddCheckConstraint(it.name, it.schema, added));
|
16507
|
-
deletedCheckConstraints.push(...prepareDeleteCheckConstraint(it.name, it.schema, deleted));
|
16508
|
-
}
|
16509
16239
|
jsonAddedCompositePKs.push(...addedCompositePKs);
|
16510
16240
|
jsonDeletedCompositePKs.push(...deletedCompositePKs);
|
16511
16241
|
jsonAlteredCompositePKs.push(...alteredCompositePKs);
|
16512
16242
|
jsonAddedUniqueConstraints.push(...addedUniqueConstraints);
|
16513
16243
|
jsonDeletedUniqueConstraints.push(...deletedUniqueConstraints);
|
16514
16244
|
jsonAlteredUniqueConstraints.push(...alteredUniqueConstraints);
|
16515
|
-
jsonCreatedCheckConstraints.push(...createdCheckConstraints);
|
16516
|
-
jsonDeletedCheckConstraints.push(...deletedCheckConstraints);
|
16517
16245
|
});
|
16518
16246
|
const rColumns = jsonRenameColumnsStatements.map((it) => {
|
16519
16247
|
const tableName = it.tableName;
|
@@ -16609,7 +16337,6 @@ var init_snapshotsDiffer = __esm({
|
|
16609
16337
|
jsonStatements.push(...jsonRenameTables);
|
16610
16338
|
jsonStatements.push(...jsonRenameColumnsStatements);
|
16611
16339
|
jsonStatements.push(...jsonDeletedUniqueConstraints);
|
16612
|
-
jsonStatements.push(...jsonDeletedCheckConstraints);
|
16613
16340
|
jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
|
16614
16341
|
jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
|
16615
16342
|
jsonStatements.push(...jsonDeletedCompositePKs);
|
@@ -16620,11 +16347,11 @@ var init_snapshotsDiffer = __esm({
|
|
16620
16347
|
jsonStatements.push(...jsonAddColumnsStatemets);
|
16621
16348
|
jsonStatements.push(...jsonCreateReferencesForCreatedTables);
|
16622
16349
|
jsonStatements.push(...jsonCreateIndexesForCreatedTables);
|
16623
|
-
jsonStatements.push(...jsonCreatedCheckConstraints);
|
16624
16350
|
jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
|
16625
16351
|
jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
|
16626
16352
|
jsonStatements.push(...jsonDropColumnsStatemets);
|
16627
16353
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
16354
|
+
jsonStatements.push(...jsonAddedUniqueConstraints);
|
16628
16355
|
jsonStatements.push(...jsonAlteredUniqueConstraints);
|
16629
16356
|
const sqlStatements = fromJson(jsonStatements, "mysql");
|
16630
16357
|
const uniqueSqlStatements = [];
|
@@ -16752,8 +16479,6 @@ var init_snapshotsDiffer = __esm({
|
|
16752
16479
|
const jsonAddedUniqueConstraints = [];
|
16753
16480
|
const jsonDeletedUniqueConstraints = [];
|
16754
16481
|
const jsonAlteredUniqueConstraints = [];
|
16755
|
-
const jsonDeletedCheckConstraints = [];
|
16756
|
-
const jsonCreatedCheckConstraints = [];
|
16757
16482
|
allAltered.forEach((it) => {
|
16758
16483
|
let addedColumns = [];
|
16759
16484
|
for (const addedPkName of Object.keys(it.addedCompositePKs)) {
|
@@ -16810,56 +16535,12 @@ var init_snapshotsDiffer = __esm({
|
|
16810
16535
|
...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
|
16811
16536
|
);
|
16812
16537
|
}
|
16813
|
-
let createdCheckConstraints = [];
|
16814
|
-
let deletedCheckConstraints = [];
|
16815
|
-
addedUniqueConstraints = prepareAddUniqueConstraintPg(
|
16816
|
-
it.name,
|
16817
|
-
it.schema,
|
16818
|
-
it.addedUniqueConstraints
|
16819
|
-
);
|
16820
|
-
deletedUniqueConstraints = prepareDeleteUniqueConstraintPg(
|
16821
|
-
it.name,
|
16822
|
-
it.schema,
|
16823
|
-
it.deletedUniqueConstraints
|
16824
|
-
);
|
16825
|
-
if (it.alteredUniqueConstraints) {
|
16826
|
-
const added = {};
|
16827
|
-
const deleted = {};
|
16828
|
-
for (const k of Object.keys(it.alteredUniqueConstraints)) {
|
16829
|
-
added[k] = it.alteredUniqueConstraints[k].__new;
|
16830
|
-
deleted[k] = it.alteredUniqueConstraints[k].__old;
|
16831
|
-
}
|
16832
|
-
addedUniqueConstraints.push(
|
16833
|
-
...prepareAddUniqueConstraintPg(it.name, it.schema, added)
|
16834
|
-
);
|
16835
|
-
deletedUniqueConstraints.push(
|
16836
|
-
...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
|
16837
|
-
);
|
16838
|
-
}
|
16839
|
-
createdCheckConstraints = prepareAddCheckConstraint(it.name, it.schema, it.addedCheckConstraints);
|
16840
|
-
deletedCheckConstraints = prepareDeleteCheckConstraint(
|
16841
|
-
it.name,
|
16842
|
-
it.schema,
|
16843
|
-
it.deletedCheckConstraints
|
16844
|
-
);
|
16845
|
-
if (it.alteredCheckConstraints && action !== "push") {
|
16846
|
-
const added = {};
|
16847
|
-
const deleted = {};
|
16848
|
-
for (const k of Object.keys(it.alteredCheckConstraints)) {
|
16849
|
-
added[k] = it.alteredCheckConstraints[k].__new;
|
16850
|
-
deleted[k] = it.alteredCheckConstraints[k].__old;
|
16851
|
-
}
|
16852
|
-
createdCheckConstraints.push(...prepareAddCheckConstraint(it.name, it.schema, added));
|
16853
|
-
deletedCheckConstraints.push(...prepareDeleteCheckConstraint(it.name, it.schema, deleted));
|
16854
|
-
}
|
16855
16538
|
jsonAddedCompositePKs.push(...addedCompositePKs);
|
16856
16539
|
jsonDeletedCompositePKs.push(...deletedCompositePKs);
|
16857
16540
|
jsonAlteredCompositePKs.push(...alteredCompositePKs);
|
16858
16541
|
jsonAddedUniqueConstraints.push(...addedUniqueConstraints);
|
16859
16542
|
jsonDeletedUniqueConstraints.push(...deletedUniqueConstraints);
|
16860
16543
|
jsonAlteredUniqueConstraints.push(...alteredUniqueConstraints);
|
16861
|
-
jsonCreatedCheckConstraints.push(...createdCheckConstraints);
|
16862
|
-
jsonDeletedCheckConstraints.push(...deletedCheckConstraints);
|
16863
16544
|
});
|
16864
16545
|
const rColumns = jsonRenameColumnsStatements.map((it) => {
|
16865
16546
|
const tableName = it.tableName;
|
@@ -16944,7 +16625,6 @@ var init_snapshotsDiffer = __esm({
|
|
16944
16625
|
jsonStatements.push(...jsonRenameTables);
|
16945
16626
|
jsonStatements.push(...jsonRenameColumnsStatements);
|
16946
16627
|
jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
|
16947
|
-
jsonStatements.push(...jsonDeletedCheckConstraints);
|
16948
16628
|
jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
|
16949
16629
|
jsonStatements.push(...jsonDeletedCompositePKs);
|
16950
16630
|
jsonStatements.push(...jsonTableAlternations);
|
@@ -16952,7 +16632,6 @@ var init_snapshotsDiffer = __esm({
|
|
16952
16632
|
jsonStatements.push(...jsonAddColumnsStatemets);
|
16953
16633
|
jsonStatements.push(...jsonCreateIndexesForCreatedTables);
|
16954
16634
|
jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
|
16955
|
-
jsonStatements.push(...jsonCreatedCheckConstraints);
|
16956
16635
|
jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
|
16957
16636
|
jsonStatements.push(...jsonDropColumnsStatemets);
|
16958
16637
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
@@ -17096,8 +16775,6 @@ var init_snapshotsDiffer = __esm({
|
|
17096
16775
|
const jsonAddedUniqueConstraints = [];
|
17097
16776
|
const jsonDeletedUniqueConstraints = [];
|
17098
16777
|
const jsonAlteredUniqueConstraints = [];
|
17099
|
-
const jsonDeletedCheckConstraints = [];
|
17100
|
-
const jsonCreatedCheckConstraints = [];
|
17101
16778
|
allAltered.forEach((it) => {
|
17102
16779
|
let addedColumns = [];
|
17103
16780
|
for (const addedPkName of Object.keys(it.addedCompositePKs)) {
|
@@ -17130,8 +16807,6 @@ var init_snapshotsDiffer = __esm({
|
|
17130
16807
|
let addedUniqueConstraints = [];
|
17131
16808
|
let deletedUniqueConstraints = [];
|
17132
16809
|
let alteredUniqueConstraints = [];
|
17133
|
-
let createdCheckConstraints = [];
|
17134
|
-
let deletedCheckConstraints = [];
|
17135
16810
|
addedUniqueConstraints = prepareAddUniqueConstraintPg(
|
17136
16811
|
it.name,
|
17137
16812
|
it.schema,
|
@@ -17156,30 +16831,12 @@ var init_snapshotsDiffer = __esm({
|
|
17156
16831
|
...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
|
17157
16832
|
);
|
17158
16833
|
}
|
17159
|
-
createdCheckConstraints = prepareAddCheckConstraint(it.name, it.schema, it.addedCheckConstraints);
|
17160
|
-
deletedCheckConstraints = prepareDeleteCheckConstraint(
|
17161
|
-
it.name,
|
17162
|
-
it.schema,
|
17163
|
-
it.deletedCheckConstraints
|
17164
|
-
);
|
17165
|
-
if (it.alteredCheckConstraints && action !== "push") {
|
17166
|
-
const added = {};
|
17167
|
-
const deleted = {};
|
17168
|
-
for (const k of Object.keys(it.alteredCheckConstraints)) {
|
17169
|
-
added[k] = it.alteredCheckConstraints[k].__new;
|
17170
|
-
deleted[k] = it.alteredCheckConstraints[k].__old;
|
17171
|
-
}
|
17172
|
-
createdCheckConstraints.push(...prepareAddCheckConstraint(it.name, it.schema, added));
|
17173
|
-
deletedCheckConstraints.push(...prepareDeleteCheckConstraint(it.name, it.schema, deleted));
|
17174
|
-
}
|
17175
16834
|
jsonAddedCompositePKs.push(...addedCompositePKs);
|
17176
16835
|
jsonDeletedCompositePKs.push(...deletedCompositePKs);
|
17177
16836
|
jsonAlteredCompositePKs.push(...alteredCompositePKs);
|
17178
16837
|
jsonAddedUniqueConstraints.push(...addedUniqueConstraints);
|
17179
16838
|
jsonDeletedUniqueConstraints.push(...deletedUniqueConstraints);
|
17180
16839
|
jsonAlteredUniqueConstraints.push(...alteredUniqueConstraints);
|
17181
|
-
jsonCreatedCheckConstraints.push(...createdCheckConstraints);
|
17182
|
-
jsonDeletedCheckConstraints.push(...deletedCheckConstraints);
|
17183
16840
|
});
|
17184
16841
|
const jsonTableAlternations = allAltered.map((it) => {
|
17185
16842
|
return prepareSqliteAlterColumns(it.name, it.schema, it.altered, json22);
|
@@ -17257,7 +16914,6 @@ var init_snapshotsDiffer = __esm({
|
|
17257
16914
|
jsonStatements.push(...jsonRenameTables);
|
17258
16915
|
jsonStatements.push(...jsonRenameColumnsStatements);
|
17259
16916
|
jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
|
17260
|
-
jsonStatements.push(...jsonDeletedCheckConstraints);
|
17261
16917
|
jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
|
17262
16918
|
jsonStatements.push(...jsonDeletedCompositePKs);
|
17263
16919
|
jsonStatements.push(...jsonTableAlternations);
|
@@ -17265,7 +16921,6 @@ var init_snapshotsDiffer = __esm({
|
|
17265
16921
|
jsonStatements.push(...jsonAddColumnsStatemets);
|
17266
16922
|
jsonStatements.push(...jsonCreateIndexesForCreatedTables);
|
17267
16923
|
jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
|
17268
|
-
jsonStatements.push(...jsonCreatedCheckConstraints);
|
17269
16924
|
jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
|
17270
16925
|
jsonStatements.push(...jsonDropColumnsStatemets);
|
17271
16926
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
@@ -26383,7 +26038,6 @@ var init_pgSerializer = __esm({
|
|
26383
26038
|
const sequencesToReturn = {};
|
26384
26039
|
const indexesInSchema = {};
|
26385
26040
|
for (const table4 of tables) {
|
26386
|
-
const checksInTable = {};
|
26387
26041
|
const {
|
26388
26042
|
name: tableName,
|
26389
26043
|
columns,
|
@@ -26399,7 +26053,6 @@ var init_pgSerializer = __esm({
|
|
26399
26053
|
}
|
26400
26054
|
const columnsObject = {};
|
26401
26055
|
const indexesObject = {};
|
26402
|
-
const checksObject = {};
|
26403
26056
|
const foreignKeysObject = {};
|
26404
26057
|
const primaryKeysObject = {};
|
26405
26058
|
const uniqueConstraintObject = {};
|
@@ -26665,33 +26318,6 @@ ${withStyle.errorWarning(
|
|
26665
26318
|
with: value.config.with ?? {}
|
26666
26319
|
};
|
26667
26320
|
});
|
26668
|
-
checks.forEach((check) => {
|
26669
|
-
const checkName = check.name;
|
26670
|
-
if (typeof checksInTable[`"${schema4 ?? "public"}"."${tableName}"`] !== "undefined") {
|
26671
|
-
if (checksInTable[`"${schema4 ?? "public"}"."${tableName}"`].includes(check.name)) {
|
26672
|
-
console.log(
|
26673
|
-
`
|
26674
|
-
${withStyle.errorWarning(
|
26675
|
-
`We've found duplicated check constraint name across ${source_default.underline.blue(
|
26676
|
-
schema4 ?? "public"
|
26677
|
-
)} schema in ${source_default.underline.blue(
|
26678
|
-
tableName
|
26679
|
-
)}. Please rename your check constraint in either the ${source_default.underline.blue(
|
26680
|
-
tableName
|
26681
|
-
)} table or the table with the duplicated check contraint name`
|
26682
|
-
)}`
|
26683
|
-
);
|
26684
|
-
process.exit(1);
|
26685
|
-
}
|
26686
|
-
checksInTable[`"${schema4 ?? "public"}"."${tableName}"`].push(checkName);
|
26687
|
-
} else {
|
26688
|
-
checksInTable[`"${schema4 ?? "public"}"."${tableName}"`] = [check.name];
|
26689
|
-
}
|
26690
|
-
checksObject[checkName] = {
|
26691
|
-
name: checkName,
|
26692
|
-
value: dialect4.sqlToQuery(check.value).sql
|
26693
|
-
};
|
26694
|
-
});
|
26695
26321
|
const tableKey2 = `${schema4 ?? "public"}.${tableName}`;
|
26696
26322
|
result[tableKey2] = {
|
26697
26323
|
name: tableName,
|
@@ -26700,8 +26326,7 @@ ${withStyle.errorWarning(
|
|
26700
26326
|
indexes: indexesObject,
|
26701
26327
|
foreignKeys: foreignKeysObject,
|
26702
26328
|
compositePrimaryKeys: primaryKeysObject,
|
26703
|
-
uniqueConstraints: uniqueConstraintObject
|
26704
|
-
checkConstraints: checksObject
|
26329
|
+
uniqueConstraints: uniqueConstraintObject
|
26705
26330
|
};
|
26706
26331
|
}
|
26707
26332
|
for (const sequence of sequences) {
|
@@ -26790,7 +26415,6 @@ ${withStyle.errorWarning(
|
|
26790
26415
|
let indexesCount = 0;
|
26791
26416
|
let foreignKeysCount = 0;
|
26792
26417
|
let tableCount = 0;
|
26793
|
-
let checksCount = 0;
|
26794
26418
|
const sequencesToReturn = {};
|
26795
26419
|
const seqWhere = schemaFilters.map((t) => `schemaname = '${t}'`).join(" or ");
|
26796
26420
|
const allSequences = await db.query(
|
@@ -26860,8 +26484,7 @@ ${withStyle.errorWarning(
|
|
26860
26484
|
const indexToReturn = {};
|
26861
26485
|
const foreignKeysToReturn = {};
|
26862
26486
|
const primaryKeys = {};
|
26863
|
-
const
|
26864
|
-
const checkConstraints = {};
|
26487
|
+
const uniqueConstrains = {};
|
26865
26488
|
const tableResponse = await db.query(
|
26866
26489
|
`SELECT a.attrelid::regclass::text, a.attname, is_nullable, a.attndims as array_dimensions
|
26867
26490
|
, CASE WHEN a.atttypid = ANY ('{int,int8,int2}'::regtype[])
|
@@ -26899,97 +26522,55 @@ ${withStyle.errorWarning(
|
|
26899
26522
|
ORDER BY a.attnum;`
|
26900
26523
|
);
|
26901
26524
|
const tableConstraints = await db.query(
|
26902
|
-
`SELECT c.column_name,
|
26903
|
-
|
26904
|
-
|
26905
|
-
|
26906
|
-
|
26907
|
-
|
26908
|
-
FROM information_schema.table_constraints tc
|
26909
|
-
JOIN information_schema.constraint_column_usage AS ccu
|
26910
|
-
USING (constraint_schema, constraint_name)
|
26911
|
-
JOIN information_schema.columns AS c
|
26912
|
-
ON c.table_schema = tc.constraint_schema
|
26913
|
-
AND tc.table_name = c.table_name
|
26914
|
-
AND ccu.column_name = c.column_name
|
26915
|
-
JOIN pg_constraint con
|
26916
|
-
ON con.conname = tc.constraint_name
|
26917
|
-
AND con.conrelid = (
|
26918
|
-
SELECT oid
|
26919
|
-
FROM pg_class
|
26920
|
-
WHERE relname = tc.table_name
|
26921
|
-
AND relnamespace = (
|
26922
|
-
SELECT oid
|
26923
|
-
FROM pg_namespace
|
26924
|
-
WHERE nspname = tc.constraint_schema
|
26925
|
-
)
|
26926
|
-
)
|
26927
|
-
WHERE tc.table_name = '${tableName}' AND tc.constraint_schema = '${tableSchema}';`
|
26525
|
+
`SELECT c.column_name, c.data_type, constraint_type, constraint_name, constraint_schema
|
26526
|
+
FROM information_schema.table_constraints tc
|
26527
|
+
JOIN information_schema.constraint_column_usage AS ccu USING (constraint_schema, constraint_name)
|
26528
|
+
JOIN information_schema.columns AS c ON c.table_schema = tc.constraint_schema
|
26529
|
+
AND tc.table_name = c.table_name AND ccu.column_name = c.column_name
|
26530
|
+
WHERE tc.table_name = '${tableName}' and constraint_schema = '${tableSchema}';`
|
26928
26531
|
);
|
26929
|
-
const tableChecks = await db.query(`SELECT
|
26930
|
-
tc.constraint_name,
|
26931
|
-
tc.constraint_type,
|
26932
|
-
pg_get_constraintdef(con.oid) AS constraint_definition
|
26933
|
-
FROM
|
26934
|
-
information_schema.table_constraints AS tc
|
26935
|
-
JOIN pg_constraint AS con
|
26936
|
-
ON tc.constraint_name = con.conname
|
26937
|
-
AND con.conrelid = (
|
26938
|
-
SELECT oid
|
26939
|
-
FROM pg_class
|
26940
|
-
WHERE relname = tc.table_name
|
26941
|
-
AND relnamespace = (
|
26942
|
-
SELECT oid
|
26943
|
-
FROM pg_namespace
|
26944
|
-
WHERE nspname = tc.constraint_schema
|
26945
|
-
)
|
26946
|
-
)
|
26947
|
-
WHERE
|
26948
|
-
tc.table_name = '${tableName}'
|
26949
|
-
AND tc.constraint_schema = '${tableSchema}'
|
26950
|
-
AND tc.constraint_type = 'CHECK';`);
|
26951
26532
|
columnsCount += tableResponse.length;
|
26952
26533
|
if (progressCallback) {
|
26953
26534
|
progressCallback("columns", columnsCount, "fetching");
|
26954
26535
|
}
|
26955
26536
|
const tableForeignKeys = await db.query(
|
26956
26537
|
`SELECT
|
26957
|
-
|
26958
|
-
|
26959
|
-
|
26960
|
-
|
26961
|
-
|
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
|
-
|
26538
|
+
con.contype AS constraint_type,
|
26539
|
+
nsp.nspname AS constraint_schema,
|
26540
|
+
con.conname AS constraint_name,
|
26541
|
+
rel.relname AS table_name,
|
26542
|
+
att.attname AS column_name,
|
26543
|
+
fnsp.nspname AS foreign_table_schema,
|
26544
|
+
frel.relname AS foreign_table_name,
|
26545
|
+
fatt.attname AS foreign_column_name,
|
26546
|
+
CASE con.confupdtype
|
26547
|
+
WHEN 'a' THEN 'NO ACTION'
|
26548
|
+
WHEN 'r' THEN 'RESTRICT'
|
26549
|
+
WHEN 'n' THEN 'SET NULL'
|
26550
|
+
WHEN 'c' THEN 'CASCADE'
|
26551
|
+
WHEN 'd' THEN 'SET DEFAULT'
|
26552
|
+
END AS update_rule,
|
26553
|
+
CASE con.confdeltype
|
26554
|
+
WHEN 'a' THEN 'NO ACTION'
|
26555
|
+
WHEN 'r' THEN 'RESTRICT'
|
26556
|
+
WHEN 'n' THEN 'SET NULL'
|
26557
|
+
WHEN 'c' THEN 'CASCADE'
|
26558
|
+
WHEN 'd' THEN 'SET DEFAULT'
|
26559
|
+
END AS delete_rule
|
26560
|
+
FROM
|
26561
|
+
pg_catalog.pg_constraint con
|
26562
|
+
JOIN pg_catalog.pg_class rel ON rel.oid = con.conrelid
|
26563
|
+
JOIN pg_catalog.pg_namespace nsp ON nsp.oid = con.connamespace
|
26564
|
+
LEFT JOIN pg_catalog.pg_attribute att ON att.attnum = ANY (con.conkey)
|
26565
|
+
AND att.attrelid = con.conrelid
|
26566
|
+
LEFT JOIN pg_catalog.pg_class frel ON frel.oid = con.confrelid
|
26567
|
+
LEFT JOIN pg_catalog.pg_namespace fnsp ON fnsp.oid = frel.relnamespace
|
26568
|
+
LEFT JOIN pg_catalog.pg_attribute fatt ON fatt.attnum = ANY (con.confkey)
|
26569
|
+
AND fatt.attrelid = con.confrelid
|
26570
|
+
WHERE
|
26571
|
+
nsp.nspname = '${tableSchema}'
|
26572
|
+
AND rel.relname = '${tableName}'
|
26573
|
+
AND con.contype IN ('f');`
|
26993
26574
|
);
|
26994
26575
|
foreignKeysCount += tableForeignKeys.length;
|
26995
26576
|
if (progressCallback) {
|
@@ -27031,29 +26612,16 @@ ${withStyle.errorWarning(
|
|
27031
26612
|
for (const unqs of uniqueConstrainsRows) {
|
27032
26613
|
const columnName = unqs.column_name;
|
27033
26614
|
const constraintName = unqs.constraint_name;
|
27034
|
-
if (typeof
|
27035
|
-
|
26615
|
+
if (typeof uniqueConstrains[constraintName] !== "undefined") {
|
26616
|
+
uniqueConstrains[constraintName].columns.push(columnName);
|
27036
26617
|
} else {
|
27037
|
-
|
26618
|
+
uniqueConstrains[constraintName] = {
|
27038
26619
|
columns: [columnName],
|
27039
26620
|
nullsNotDistinct: false,
|
27040
26621
|
name: constraintName
|
27041
26622
|
};
|
27042
26623
|
}
|
27043
26624
|
}
|
27044
|
-
checksCount += tableChecks.length;
|
27045
|
-
if (progressCallback) {
|
27046
|
-
progressCallback("checks", checksCount, "fetching");
|
27047
|
-
}
|
27048
|
-
for (const checks of tableChecks) {
|
27049
|
-
let checkValue = checks.constraint_definition;
|
27050
|
-
const constraintName = checks.constraint_name;
|
27051
|
-
checkValue = checkValue.replace(/^CHECK\s*\(\(/, "").replace(/\)\)\s*$/, "");
|
27052
|
-
checkConstraints[constraintName] = {
|
27053
|
-
name: constraintName,
|
27054
|
-
value: checkValue
|
27055
|
-
};
|
27056
|
-
}
|
27057
26625
|
for (const columnResponse of tableResponse) {
|
27058
26626
|
const columnName = columnResponse.attname;
|
27059
26627
|
const columnAdditionalDT = columnResponse.additional_dt;
|
@@ -27297,8 +26865,7 @@ ${withStyle.errorWarning(
|
|
27297
26865
|
indexes: indexToReturn,
|
27298
26866
|
foreignKeys: foreignKeysToReturn,
|
27299
26867
|
compositePrimaryKeys: primaryKeys,
|
27300
|
-
uniqueConstraints
|
27301
|
-
checkConstraints
|
26868
|
+
uniqueConstraints: uniqueConstrains
|
27302
26869
|
};
|
27303
26870
|
} catch (e) {
|
27304
26871
|
rej(e);
|
@@ -27316,7 +26883,6 @@ ${withStyle.errorWarning(
|
|
27316
26883
|
progressCallback("columns", columnsCount, "done");
|
27317
26884
|
progressCallback("indexes", indexesCount, "done");
|
27318
26885
|
progressCallback("fks", foreignKeysCount, "done");
|
27319
|
-
progressCallback("checks", checksCount, "done");
|
27320
26886
|
}
|
27321
26887
|
const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
|
27322
26888
|
return {
|
@@ -27388,8 +26954,6 @@ ${withStyle.errorWarning(
|
|
27388
26954
|
}
|
27389
26955
|
return columnDefaultAsString;
|
27390
26956
|
}
|
27391
|
-
} else if (column4.data_type.includes("numeric")) {
|
27392
|
-
return columnDefaultAsString.includes("'") ? columnDefaultAsString : `'${columnDefaultAsString}'`;
|
27393
26957
|
} else if (column4.data_type === "json" || column4.data_type === "jsonb") {
|
27394
26958
|
const jsonWithoutSpaces = JSON.stringify(JSON.parse(columnDefaultAsString.slice(1, -1)));
|
27395
26959
|
return `'${jsonWithoutSpaces}'::${column4.data_type}`;
|
@@ -30916,13 +30480,10 @@ var init_sqliteSerializer = __esm({
|
|
30916
30480
|
const foreignKeysObject = {};
|
30917
30481
|
const primaryKeysObject = {};
|
30918
30482
|
const uniqueConstraintObject = {};
|
30919
|
-
const checkConstraintObject = {};
|
30920
|
-
const checksInTable = {};
|
30921
30483
|
const {
|
30922
30484
|
name: tableName,
|
30923
30485
|
columns,
|
30924
30486
|
indexes,
|
30925
|
-
checks,
|
30926
30487
|
foreignKeys: tableForeignKeys,
|
30927
30488
|
primaryKeys,
|
30928
30489
|
uniqueConstraints
|
@@ -31098,39 +30659,13 @@ The unique constraint ${source_default.underline.blue(
|
|
31098
30659
|
columnsObject[getColumnCasing(it.columns[0], casing2)].primaryKey = true;
|
31099
30660
|
}
|
31100
30661
|
});
|
31101
|
-
checks.forEach((check) => {
|
31102
|
-
const checkName = check.name;
|
31103
|
-
if (typeof checksInTable[tableName] !== "undefined") {
|
31104
|
-
if (checksInTable[tableName].includes(check.name)) {
|
31105
|
-
console.log(
|
31106
|
-
`
|
31107
|
-
${withStyle.errorWarning(
|
31108
|
-
`We've found duplicated check constraint name in ${source_default.underline.blue(
|
31109
|
-
tableName
|
31110
|
-
)}. Please rename your check constraint in the ${source_default.underline.blue(
|
31111
|
-
tableName
|
31112
|
-
)} table`
|
31113
|
-
)}`
|
31114
|
-
);
|
31115
|
-
process.exit(1);
|
31116
|
-
}
|
31117
|
-
checksInTable[tableName].push(checkName);
|
31118
|
-
} else {
|
31119
|
-
checksInTable[tableName] = [check.name];
|
31120
|
-
}
|
31121
|
-
checkConstraintObject[checkName] = {
|
31122
|
-
name: checkName,
|
31123
|
-
value: dialect4.sqlToQuery(check.value).sql
|
31124
|
-
};
|
31125
|
-
});
|
31126
30662
|
result[tableName] = {
|
31127
30663
|
name: tableName,
|
31128
30664
|
columns: columnsObject,
|
31129
30665
|
indexes: indexesObject,
|
31130
30666
|
foreignKeys: foreignKeysObject,
|
31131
30667
|
compositePrimaryKeys: primaryKeysObject,
|
31132
|
-
uniqueConstraints: uniqueConstraintObject
|
31133
|
-
checkConstraints: checkConstraintObject
|
30668
|
+
uniqueConstraints: uniqueConstraintObject
|
31134
30669
|
};
|
31135
30670
|
}
|
31136
30671
|
return {
|
@@ -31177,7 +30712,6 @@ ${withStyle.errorWarning(
|
|
31177
30712
|
let tablesCount = /* @__PURE__ */ new Set();
|
31178
30713
|
let indexesCount = 0;
|
31179
30714
|
let foreignKeysCount = 0;
|
31180
|
-
let checksCount = 0;
|
31181
30715
|
const tableToPk = {};
|
31182
30716
|
let tableToGeneratedColumnsInfo = {};
|
31183
30717
|
for (const column4 of columns) {
|
@@ -31235,8 +30769,7 @@ ${withStyle.errorWarning(
|
|
31235
30769
|
compositePrimaryKeys: {},
|
31236
30770
|
indexes: {},
|
31237
30771
|
foreignKeys: {},
|
31238
|
-
uniqueConstraints: {}
|
31239
|
-
checkConstraints: {}
|
30772
|
+
uniqueConstraints: {}
|
31240
30773
|
};
|
31241
30774
|
} else {
|
31242
30775
|
result[tableName].columns[columnName] = newColumn;
|
@@ -31350,56 +30883,6 @@ WHERE
|
|
31350
30883
|
progressCallback("indexes", indexesCount, "done");
|
31351
30884
|
progressCallback("enums", 0, "done");
|
31352
30885
|
}
|
31353
|
-
const namedCheckPattern = /CONSTRAINT\s*["']?(\w+)["']?\s*CHECK\s*\((.*?)\)/gi;
|
31354
|
-
const unnamedCheckPattern = /CHECK\s*\((.*?)\)/gi;
|
31355
|
-
let checkCounter = 0;
|
31356
|
-
const checkConstraints = {};
|
31357
|
-
const checks = await db.query(`SELECT name as "tableName", sql as "sql"
|
31358
|
-
FROM sqlite_master
|
31359
|
-
WHERE type = 'table' AND name != 'sqlite_sequence';`);
|
31360
|
-
for (const check of checks) {
|
31361
|
-
if (!tablesFilter(check.tableName)) continue;
|
31362
|
-
const { tableName, sql: sql2 } = check;
|
31363
|
-
let namedChecks = [...sql2.matchAll(namedCheckPattern)];
|
31364
|
-
if (namedChecks.length > 0) {
|
31365
|
-
namedChecks.forEach(([_2, checkName, checkValue]) => {
|
31366
|
-
checkConstraints[checkName] = {
|
31367
|
-
name: checkName,
|
31368
|
-
value: checkValue.trim()
|
31369
|
-
};
|
31370
|
-
});
|
31371
|
-
} else {
|
31372
|
-
let unnamedChecks = [...sql2.matchAll(unnamedCheckPattern)];
|
31373
|
-
unnamedChecks.forEach(([_2, checkValue]) => {
|
31374
|
-
let checkName = `${tableName}_check_${++checkCounter}`;
|
31375
|
-
checkConstraints[checkName] = {
|
31376
|
-
name: checkName,
|
31377
|
-
value: checkValue.trim()
|
31378
|
-
};
|
31379
|
-
});
|
31380
|
-
}
|
31381
|
-
checksCount += Object.values(checkConstraints).length;
|
31382
|
-
if (progressCallback) {
|
31383
|
-
progressCallback("checks", checksCount, "fetching");
|
31384
|
-
}
|
31385
|
-
const table4 = result[tableName];
|
31386
|
-
if (!table4) {
|
31387
|
-
result[tableName] = {
|
31388
|
-
name: tableName,
|
31389
|
-
columns: {},
|
31390
|
-
compositePrimaryKeys: {},
|
31391
|
-
indexes: {},
|
31392
|
-
foreignKeys: {},
|
31393
|
-
uniqueConstraints: {},
|
31394
|
-
checkConstraints
|
31395
|
-
};
|
31396
|
-
} else {
|
31397
|
-
result[tableName].checkConstraints = checkConstraints;
|
31398
|
-
}
|
31399
|
-
}
|
31400
|
-
if (progressCallback) {
|
31401
|
-
progressCallback("checks", checksCount, "done");
|
31402
|
-
}
|
31403
30886
|
return {
|
31404
30887
|
version: "6",
|
31405
30888
|
dialect: "sqlite",
|
@@ -35695,7 +35178,6 @@ var init_mysqlSerializer = __esm({
|
|
35695
35178
|
indexes,
|
35696
35179
|
foreignKeys,
|
35697
35180
|
schema: schema4,
|
35698
|
-
checks,
|
35699
35181
|
primaryKeys,
|
35700
35182
|
uniqueConstraints
|
35701
35183
|
} = getTableConfig3(table4);
|
@@ -35704,8 +35186,6 @@ var init_mysqlSerializer = __esm({
|
|
35704
35186
|
const foreignKeysObject = {};
|
35705
35187
|
const primaryKeysObject = {};
|
35706
35188
|
const uniqueConstraintObject = {};
|
35707
|
-
const checkConstraintObject = {};
|
35708
|
-
let checksInTable = {};
|
35709
35189
|
columns.forEach((column4) => {
|
35710
35190
|
const name2 = getColumnCasing(column4, casing2);
|
35711
35191
|
const notNull = column4.notNull;
|
@@ -35936,32 +35416,6 @@ We have encountered a collision between the index name on columns ${source_defau
|
|
35936
35416
|
lock: value.config.lock
|
35937
35417
|
};
|
35938
35418
|
});
|
35939
|
-
checks.forEach((check) => {
|
35940
|
-
check;
|
35941
|
-
const checkName = check.name;
|
35942
|
-
if (typeof checksInTable[tableName] !== "undefined") {
|
35943
|
-
if (checksInTable[tableName].includes(check.name)) {
|
35944
|
-
console.log(
|
35945
|
-
`
|
35946
|
-
${withStyle.errorWarning(
|
35947
|
-
`We've found duplicated check constraint name in ${source_default.underline.blue(
|
35948
|
-
tableName
|
35949
|
-
)}. Please rename your check constraint in the ${source_default.underline.blue(
|
35950
|
-
tableName
|
35951
|
-
)} table`
|
35952
|
-
)}`
|
35953
|
-
);
|
35954
|
-
process.exit(1);
|
35955
|
-
}
|
35956
|
-
checksInTable[tableName].push(checkName);
|
35957
|
-
} else {
|
35958
|
-
checksInTable[tableName] = [check.name];
|
35959
|
-
}
|
35960
|
-
checkConstraintObject[checkName] = {
|
35961
|
-
name: checkName,
|
35962
|
-
value: dialect4.sqlToQuery(check.value).sql
|
35963
|
-
};
|
35964
|
-
});
|
35965
35419
|
if (!schema4) {
|
35966
35420
|
result[tableName] = {
|
35967
35421
|
name: tableName,
|
@@ -35969,8 +35423,7 @@ ${withStyle.errorWarning(
|
|
35969
35423
|
indexes: indexesObject,
|
35970
35424
|
foreignKeys: foreignKeysObject,
|
35971
35425
|
compositePrimaryKeys: primaryKeysObject,
|
35972
|
-
uniqueConstraints: uniqueConstraintObject
|
35973
|
-
checkConstraint: checkConstraintObject
|
35426
|
+
uniqueConstraints: uniqueConstraintObject
|
35974
35427
|
};
|
35975
35428
|
}
|
35976
35429
|
}
|
@@ -35997,7 +35450,6 @@ ${withStyle.errorWarning(
|
|
35997
35450
|
let tablesCount = /* @__PURE__ */ new Set();
|
35998
35451
|
let indexesCount = 0;
|
35999
35452
|
let foreignKeysCount = 0;
|
36000
|
-
let checksCount = 0;
|
36001
35453
|
const idxs = await db.query(
|
36002
35454
|
`select * from INFORMATION_SCHEMA.STATISTICS
|
36003
35455
|
WHERE INFORMATION_SCHEMA.STATISTICS.TABLE_SCHEMA = '${inputSchema}' and INFORMATION_SCHEMA.STATISTICS.INDEX_NAME != 'PRIMARY';`
|
@@ -36092,8 +35544,7 @@ ${withStyle.errorWarning(
|
|
36092
35544
|
compositePrimaryKeys: {},
|
36093
35545
|
indexes: {},
|
36094
35546
|
foreignKeys: {},
|
36095
|
-
uniqueConstraints: {}
|
36096
|
-
checkConstraint: {}
|
35547
|
+
uniqueConstraints: {}
|
36097
35548
|
};
|
36098
35549
|
} else {
|
36099
35550
|
result[tableName].columns[columnName] = newColumn;
|
@@ -36242,38 +35693,6 @@ ${withStyle.errorWarning(
|
|
36242
35693
|
progressCallback("indexes", indexesCount, "done");
|
36243
35694
|
progressCallback("enums", 0, "done");
|
36244
35695
|
}
|
36245
|
-
const checkConstraints = await db.query(
|
36246
|
-
`SELECT
|
36247
|
-
tc.table_name,
|
36248
|
-
tc.constraint_name,
|
36249
|
-
cc.check_clause
|
36250
|
-
FROM
|
36251
|
-
information_schema.table_constraints tc
|
36252
|
-
JOIN
|
36253
|
-
information_schema.check_constraints cc
|
36254
|
-
ON tc.constraint_name = cc.constraint_name
|
36255
|
-
WHERE
|
36256
|
-
tc.constraint_schema = '${inputSchema}'
|
36257
|
-
AND
|
36258
|
-
tc.constraint_type = 'CHECK';`
|
36259
|
-
);
|
36260
|
-
checksCount += checkConstraints.length;
|
36261
|
-
if (progressCallback) {
|
36262
|
-
progressCallback("checks", checksCount, "fetching");
|
36263
|
-
}
|
36264
|
-
for (const checkConstraintRow of checkConstraints) {
|
36265
|
-
const constraintName = checkConstraintRow["CONSTRAINT_NAME"];
|
36266
|
-
const constraintValue = checkConstraintRow["CHECK_CLAUSE"];
|
36267
|
-
const tableName = checkConstraintRow["TABLE_NAME"];
|
36268
|
-
const tableInResult = result[tableName];
|
36269
|
-
tableInResult.checkConstraint[constraintName] = {
|
36270
|
-
name: constraintName,
|
36271
|
-
value: constraintValue
|
36272
|
-
};
|
36273
|
-
}
|
36274
|
-
if (progressCallback) {
|
36275
|
-
progressCallback("checks", checksCount, "done");
|
36276
|
-
}
|
36277
35696
|
return {
|
36278
35697
|
version: "5",
|
36279
35698
|
dialect: "mysql",
|