drizzle-kit 0.25.0-5a1c5d3 → 0.25.0-680d055
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 -674
- package/api.mjs +95 -674
- package/bin.cjs +103 -757
- package/package.json +1 -1
- package/utils.js +6 -24
- package/utils.mjs +6 -24
package/api.js
CHANGED
@@ -7214,7 +7214,7 @@ var init_lib = __esm({
|
|
7214
7214
|
});
|
7215
7215
|
|
7216
7216
|
// src/serializer/mysqlSchema.ts
|
7217
|
-
var index, fk, column, tableV3, compositePK, uniqueConstraint,
|
7217
|
+
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;
|
7218
7218
|
var init_mysqlSchema = __esm({
|
7219
7219
|
"src/serializer/mysqlSchema.ts"() {
|
7220
7220
|
"use strict";
|
@@ -7264,10 +7264,6 @@ var init_mysqlSchema = __esm({
|
|
7264
7264
|
name: stringType(),
|
7265
7265
|
columns: stringType().array()
|
7266
7266
|
}).strict();
|
7267
|
-
checkConstraint = objectType({
|
7268
|
-
name: stringType(),
|
7269
|
-
value: stringType()
|
7270
|
-
}).strict();
|
7271
7267
|
tableV4 = objectType({
|
7272
7268
|
name: stringType(),
|
7273
7269
|
schema: stringType().optional(),
|
@@ -7281,8 +7277,7 @@ var init_mysqlSchema = __esm({
|
|
7281
7277
|
indexes: recordType(stringType(), index),
|
7282
7278
|
foreignKeys: recordType(stringType(), fk),
|
7283
7279
|
compositePrimaryKeys: recordType(stringType(), compositePK),
|
7284
|
-
uniqueConstraints: recordType(stringType(), uniqueConstraint).default({})
|
7285
|
-
checkConstraint: recordType(stringType(), checkConstraint).default({})
|
7280
|
+
uniqueConstraints: recordType(stringType(), uniqueConstraint).default({})
|
7286
7281
|
}).strict();
|
7287
7282
|
kitInternals = objectType({
|
7288
7283
|
tables: recordType(
|
@@ -7359,8 +7354,7 @@ var init_mysqlSchema = __esm({
|
|
7359
7354
|
indexes: recordType(stringType(), stringType()),
|
7360
7355
|
foreignKeys: recordType(stringType(), stringType()),
|
7361
7356
|
compositePrimaryKeys: recordType(stringType(), stringType()),
|
7362
|
-
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
7363
|
-
checkConstraints: recordType(stringType(), stringType()).default({})
|
7357
|
+
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
7364
7358
|
}).strict();
|
7365
7359
|
schemaSquashed = objectType({
|
7366
7360
|
version: literalType("5"),
|
@@ -7427,13 +7421,6 @@ var init_mysqlSchema = __esm({
|
|
7427
7421
|
onDelete
|
7428
7422
|
});
|
7429
7423
|
return result;
|
7430
|
-
},
|
7431
|
-
squashCheck: (input) => {
|
7432
|
-
return `${input.name};${input.value}`;
|
7433
|
-
},
|
7434
|
-
unsquashCheck: (input) => {
|
7435
|
-
const [name2, value] = input.split(";");
|
7436
|
-
return { name: name2, value };
|
7437
7424
|
}
|
7438
7425
|
};
|
7439
7426
|
squashMysqlScheme = (json) => {
|
@@ -7454,9 +7441,6 @@ var init_mysqlSchema = __esm({
|
|
7454
7441
|
return MySqlSquasher.squashUnique(unq);
|
7455
7442
|
}
|
7456
7443
|
);
|
7457
|
-
const squashedCheckConstraints = mapValues(it[1].checkConstraint, (check) => {
|
7458
|
-
return MySqlSquasher.squashCheck(check);
|
7459
|
-
});
|
7460
7444
|
return [
|
7461
7445
|
it[0],
|
7462
7446
|
{
|
@@ -7465,8 +7449,7 @@ var init_mysqlSchema = __esm({
|
|
7465
7449
|
indexes: squashedIndexes,
|
7466
7450
|
foreignKeys: squashedFKs,
|
7467
7451
|
compositePrimaryKeys: squashedPKs,
|
7468
|
-
uniqueConstraints: squashedUniqueConstraints
|
7469
|
-
checkConstraints: squashedCheckConstraints
|
7452
|
+
uniqueConstraints: squashedUniqueConstraints
|
7470
7453
|
}
|
7471
7454
|
];
|
7472
7455
|
})
|
@@ -7516,7 +7499,7 @@ var init_vector = __esm({
|
|
7516
7499
|
});
|
7517
7500
|
|
7518
7501
|
// src/serializer/pgSchema.ts
|
7519
|
-
var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, indexColumn, index2, indexV4, indexV5, indexV6, fk2, sequenceSchema, sequenceSquashed, columnV7, column2,
|
7502
|
+
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;
|
7520
7503
|
var init_pgSchema = __esm({
|
7521
7504
|
"src/serializer/pgSchema.ts"() {
|
7522
7505
|
"use strict";
|
@@ -7680,10 +7663,6 @@ var init_pgSchema = __esm({
|
|
7680
7663
|
}).optional(),
|
7681
7664
|
identity: sequenceSchema.merge(objectType({ type: enumType(["always", "byDefault"]) })).optional()
|
7682
7665
|
}).strict();
|
7683
|
-
checkConstraint2 = objectType({
|
7684
|
-
name: stringType(),
|
7685
|
-
value: stringType()
|
7686
|
-
}).strict();
|
7687
7666
|
columnSquashed = objectType({
|
7688
7667
|
name: stringType(),
|
7689
7668
|
type: stringType(),
|
@@ -7756,8 +7735,7 @@ var init_pgSchema = __esm({
|
|
7756
7735
|
indexes: recordType(stringType(), index2),
|
7757
7736
|
foreignKeys: recordType(stringType(), fk2),
|
7758
7737
|
compositePrimaryKeys: recordType(stringType(), compositePK2),
|
7759
|
-
uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
|
7760
|
-
checkConstraints: recordType(stringType(), checkConstraint2).default({})
|
7738
|
+
uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
|
7761
7739
|
}).strict();
|
7762
7740
|
schemaHash2 = objectType({
|
7763
7741
|
id: stringType(),
|
@@ -7865,8 +7843,7 @@ var init_pgSchema = __esm({
|
|
7865
7843
|
indexes: recordType(stringType(), stringType()),
|
7866
7844
|
foreignKeys: recordType(stringType(), stringType()),
|
7867
7845
|
compositePrimaryKeys: recordType(stringType(), stringType()),
|
7868
|
-
uniqueConstraints: recordType(stringType(), stringType())
|
7869
|
-
checkConstraints: recordType(stringType(), stringType())
|
7846
|
+
uniqueConstraints: recordType(stringType(), stringType())
|
7870
7847
|
}).strict();
|
7871
7848
|
tableSquashedV42 = objectType({
|
7872
7849
|
name: stringType(),
|
@@ -8048,16 +8025,6 @@ var init_pgSchema = __esm({
|
|
8048
8025
|
cache: splitted[6] !== "undefined" ? splitted[6] : void 0,
|
8049
8026
|
cycle: splitted[7] === "true"
|
8050
8027
|
};
|
8051
|
-
},
|
8052
|
-
squashCheck: (check) => {
|
8053
|
-
return `${check.name};${check.value}`;
|
8054
|
-
},
|
8055
|
-
unsquashCheck: (input) => {
|
8056
|
-
const [
|
8057
|
-
name2,
|
8058
|
-
value
|
8059
|
-
] = input.split(";");
|
8060
|
-
return { name: name2, value };
|
8061
8028
|
}
|
8062
8029
|
};
|
8063
8030
|
squashPgScheme = (json, action) => {
|
@@ -8090,12 +8057,6 @@ var init_pgSchema = __esm({
|
|
8090
8057
|
return PgSquasher.squashUnique(unq);
|
8091
8058
|
}
|
8092
8059
|
);
|
8093
|
-
const squashedChecksContraints = mapValues(
|
8094
|
-
it[1].checkConstraints,
|
8095
|
-
(check) => {
|
8096
|
-
return PgSquasher.squashCheck(check);
|
8097
|
-
}
|
8098
|
-
);
|
8099
8060
|
return [
|
8100
8061
|
it[0],
|
8101
8062
|
{
|
@@ -8105,8 +8066,7 @@ var init_pgSchema = __esm({
|
|
8105
8066
|
indexes: squashedIndexes,
|
8106
8067
|
foreignKeys: squashedFKs,
|
8107
8068
|
compositePrimaryKeys: squashedPKs,
|
8108
|
-
uniqueConstraints: squashedUniqueConstraints
|
8109
|
-
checkConstraints: squashedChecksContraints
|
8069
|
+
uniqueConstraints: squashedUniqueConstraints
|
8110
8070
|
}
|
8111
8071
|
];
|
8112
8072
|
})
|
@@ -8151,7 +8111,7 @@ var init_pgSchema = __esm({
|
|
8151
8111
|
});
|
8152
8112
|
|
8153
8113
|
// src/serializer/sqliteSchema.ts
|
8154
|
-
var index3, fk3, compositePK3, column3, tableV33, uniqueConstraint3,
|
8114
|
+
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;
|
8155
8115
|
var init_sqliteSchema = __esm({
|
8156
8116
|
"src/serializer/sqliteSchema.ts"() {
|
8157
8117
|
"use strict";
|
@@ -8198,18 +8158,13 @@ var init_sqliteSchema = __esm({
|
|
8198
8158
|
name: stringType(),
|
8199
8159
|
columns: stringType().array()
|
8200
8160
|
}).strict();
|
8201
|
-
checkConstraint3 = objectType({
|
8202
|
-
name: stringType(),
|
8203
|
-
value: stringType()
|
8204
|
-
}).strict();
|
8205
8161
|
table3 = objectType({
|
8206
8162
|
name: stringType(),
|
8207
8163
|
columns: recordType(stringType(), column3),
|
8208
8164
|
indexes: recordType(stringType(), index3),
|
8209
8165
|
foreignKeys: recordType(stringType(), fk3),
|
8210
8166
|
compositePrimaryKeys: recordType(stringType(), compositePK3),
|
8211
|
-
uniqueConstraints: recordType(stringType(), uniqueConstraint3).default({})
|
8212
|
-
checkConstraints: recordType(stringType(), checkConstraint3).default({})
|
8167
|
+
uniqueConstraints: recordType(stringType(), uniqueConstraint3).default({})
|
8213
8168
|
}).strict();
|
8214
8169
|
dialect2 = enumType(["sqlite"]);
|
8215
8170
|
schemaHash3 = objectType({
|
@@ -8271,8 +8226,7 @@ var init_sqliteSchema = __esm({
|
|
8271
8226
|
indexes: recordType(stringType(), stringType()),
|
8272
8227
|
foreignKeys: recordType(stringType(), stringType()),
|
8273
8228
|
compositePrimaryKeys: recordType(stringType(), stringType()),
|
8274
|
-
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
8275
|
-
checkConstraints: recordType(stringType(), stringType()).default({})
|
8229
|
+
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
8276
8230
|
}).strict();
|
8277
8231
|
schemaSquashed2 = objectType({
|
8278
8232
|
version: latestVersion,
|
@@ -8354,16 +8308,6 @@ var init_sqliteSchema = __esm({
|
|
8354
8308
|
},
|
8355
8309
|
unsquashPK: (pk) => {
|
8356
8310
|
return pk.split(",");
|
8357
|
-
},
|
8358
|
-
squashCheck: (check) => {
|
8359
|
-
return `${check.name};${check.value}`;
|
8360
|
-
},
|
8361
|
-
unsquashCheck: (input) => {
|
8362
|
-
const [
|
8363
|
-
name2,
|
8364
|
-
value
|
8365
|
-
] = input.split(";");
|
8366
|
-
return { name: name2, value };
|
8367
8311
|
}
|
8368
8312
|
};
|
8369
8313
|
squashSqliteScheme = (json, action) => {
|
@@ -8390,12 +8334,6 @@ var init_sqliteSchema = __esm({
|
|
8390
8334
|
return SQLiteSquasher.squashUnique(unq);
|
8391
8335
|
}
|
8392
8336
|
);
|
8393
|
-
const squashedCheckConstraints = mapValues(
|
8394
|
-
it[1].checkConstraints,
|
8395
|
-
(check) => {
|
8396
|
-
return SQLiteSquasher.squashCheck(check);
|
8397
|
-
}
|
8398
|
-
);
|
8399
8337
|
return [
|
8400
8338
|
it[0],
|
8401
8339
|
{
|
@@ -8404,8 +8342,7 @@ var init_sqliteSchema = __esm({
|
|
8404
8342
|
indexes: squashedIndexes,
|
8405
8343
|
foreignKeys: squashedFKs,
|
8406
8344
|
compositePrimaryKeys: squashedPKs,
|
8407
|
-
uniqueConstraints: squashedUniqueConstraints
|
8408
|
-
checkConstraints: squashedCheckConstraints
|
8345
|
+
uniqueConstraints: squashedUniqueConstraints
|
8409
8346
|
}
|
8410
8347
|
];
|
8411
8348
|
})
|
@@ -11279,21 +11216,6 @@ var init_jsonDiffer = __esm({
|
|
11279
11216
|
return !it[0].endsWith("__deleted") && !it[0].endsWith("__added");
|
11280
11217
|
})
|
11281
11218
|
);
|
11282
|
-
const addedCheckConstraints = Object.fromEntries(
|
11283
|
-
Object.entries(table4.checkConstraints || {}).filter((it) => {
|
11284
|
-
return it[0].endsWith("__added");
|
11285
|
-
})
|
11286
|
-
);
|
11287
|
-
const deletedCheckConstraints = Object.fromEntries(
|
11288
|
-
Object.entries(table4.checkConstraints || {}).filter((it) => {
|
11289
|
-
return it[0].endsWith("__deleted");
|
11290
|
-
})
|
11291
|
-
);
|
11292
|
-
const alteredCheckConstraints = Object.fromEntries(
|
11293
|
-
Object.entries(table4.checkConstraints || {}).filter((it) => {
|
11294
|
-
return !it[0].endsWith("__deleted") && !it[0].endsWith("__added");
|
11295
|
-
})
|
11296
|
-
);
|
11297
11219
|
const mappedAltered = altered.map((it) => alternationsInColumn(it)).filter(Boolean);
|
11298
11220
|
return {
|
11299
11221
|
name: table4.name,
|
@@ -11310,10 +11232,7 @@ var init_jsonDiffer = __esm({
|
|
11310
11232
|
alteredCompositePKs,
|
11311
11233
|
addedUniqueConstraints,
|
11312
11234
|
deletedUniqueConstraints,
|
11313
|
-
alteredUniqueConstraints
|
11314
|
-
addedCheckConstraints,
|
11315
|
-
deletedCheckConstraints,
|
11316
|
-
alteredCheckConstraints
|
11235
|
+
alteredUniqueConstraints
|
11317
11236
|
};
|
11318
11237
|
};
|
11319
11238
|
alternationsInColumn = (column4) => {
|
@@ -11567,32 +11486,6 @@ var init_jsonDiffer = __esm({
|
|
11567
11486
|
};
|
11568
11487
|
}
|
11569
11488
|
return it;
|
11570
|
-
}).map((it) => {
|
11571
|
-
if ("" in it) {
|
11572
|
-
return {
|
11573
|
-
...it,
|
11574
|
-
autoincrement: {
|
11575
|
-
type: "changed",
|
11576
|
-
old: it.autoincrement.__old,
|
11577
|
-
new: it.autoincrement.__new
|
11578
|
-
}
|
11579
|
-
};
|
11580
|
-
}
|
11581
|
-
if ("autoincrement__added" in it) {
|
11582
|
-
const { autoincrement__added, ...others } = it;
|
11583
|
-
return {
|
11584
|
-
...others,
|
11585
|
-
autoincrement: { type: "added", value: it.autoincrement__added }
|
11586
|
-
};
|
11587
|
-
}
|
11588
|
-
if ("autoincrement__deleted" in it) {
|
11589
|
-
const { autoincrement__deleted, ...others } = it;
|
11590
|
-
return {
|
11591
|
-
...others,
|
11592
|
-
autoincrement: { type: "deleted", value: it.autoincrement__deleted }
|
11593
|
-
};
|
11594
|
-
}
|
11595
|
-
return it;
|
11596
11489
|
}).filter(Boolean);
|
11597
11490
|
return result[0];
|
11598
11491
|
};
|
@@ -11613,7 +11506,7 @@ function fromJson(statements, dialect7, action, json2) {
|
|
11613
11506
|
}).filter((it) => it !== "");
|
11614
11507
|
return result;
|
11615
11508
|
}
|
11616
|
-
var pgNativeTypes, isPgNativeType, Convertor, PgCreateTableConvertor, MySqlCreateTableConvertor, SQLiteCreateTableConvertor, PgAlterTableAlterColumnSetGenerated, PgAlterTableAlterColumnDropGenerated, PgAlterTableAlterColumnAlterGenerated, PgAlterTableAddUniqueConstraintConvertor, PgAlterTableDropUniqueConstraintConvertor,
|
11509
|
+
var pgNativeTypes, isPgNativeType, Convertor, PgCreateTableConvertor, MySqlCreateTableConvertor, SQLiteCreateTableConvertor, PgAlterTableAlterColumnSetGenerated, PgAlterTableAlterColumnDropGenerated, PgAlterTableAlterColumnAlterGenerated, PgAlterTableAddUniqueConstraintConvertor, PgAlterTableDropUniqueConstraintConvertor, MySQLAlterTableAddUniqueConstraintConvertor, MySQLAlterTableDropUniqueConstraintConvertor, CreatePgSequenceConvertor, DropPgSequenceConvertor, RenamePgSequenceConvertor, MovePgSequenceConvertor, AlterPgSequenceConvertor, CreateTypeEnumConvertor, AlterTypeAddValueConvertor, PgDropTableConvertor, MySQLDropTableConvertor, SQLiteDropTableConvertor, PgRenameTableConvertor, SqliteRenameTableConvertor, MySqlRenameTableConvertor, PgAlterTableRenameColumnConvertor, MySqlAlterTableRenameColumnConvertor, SQLiteAlterTableRenameColumnConvertor, PgAlterTableDropColumnConvertor, MySqlAlterTableDropColumnConvertor, SQLiteAlterTableDropColumnConvertor, PgAlterTableAddColumnConvertor, MySqlAlterTableAddColumnConvertor, SQLiteAlterTableAddColumnConvertor, PgAlterTableAlterColumnSetTypeConvertor, PgAlterTableAlterColumnSetDefaultConvertor, PgAlterTableAlterColumnDropDefaultConvertor, PgAlterTableAlterColumnDropGeneratedConvertor, PgAlterTableAlterColumnSetExpressionConvertor, PgAlterTableAlterColumnAlterrGeneratedConvertor, SqliteAlterTableAlterColumnDropGeneratedConvertor, SqliteAlterTableAlterColumnSetExpressionConvertor, SqliteAlterTableAlterColumnAlterGeneratedConvertor, MySqlAlterTableAlterColumnAlterrGeneratedConvertor, MySqlAlterTableAddPk, MySqlAlterTableDropPk, LibSQLModifyColumn, MySqlModifyColumn, PgAlterTableCreateCompositePrimaryKeyConvertor, PgAlterTableDeleteCompositePrimaryKeyConvertor, PgAlterTableAlterCompositePrimaryKeyConvertor, MySqlAlterTableCreateCompositePrimaryKeyConvertor, MySqlAlterTableDeleteCompositePrimaryKeyConvertor, MySqlAlterTableAlterCompositePrimaryKeyConvertor, PgAlterTableAlterColumnSetPrimaryKeyConvertor, PgAlterTableAlterColumnDropPrimaryKeyConvertor, PgAlterTableAlterColumnSetNotNullConvertor, PgAlterTableAlterColumnDropNotNullConvertor, PgCreateForeignKeyConvertor, LibSQLCreateForeignKeyConvertor, MySqlCreateForeignKeyConvertor, PgAlterForeignKeyConvertor, PgDeleteForeignKeyConvertor, MySqlDeleteForeignKeyConvertor, CreatePgIndexConvertor, CreateMySqlIndexConvertor, CreateSqliteIndexConvertor, PgDropIndexConvertor, PgCreateSchemaConvertor, PgRenameSchemaConvertor, PgDropSchemaConvertor, PgAlterTableSetSchemaConvertor, PgAlterTableSetNewSchemaConvertor, PgAlterTableRemoveFromSchemaConvertor, SqliteDropIndexConvertor, MySqlDropIndexConvertor, SQLiteRecreateTableConvertor, LibSQLRecreateTableConvertor, convertors;
|
11617
11510
|
var init_sqlgenerator = __esm({
|
11618
11511
|
"src/sqlgenerator.ts"() {
|
11619
11512
|
"use strict";
|
@@ -11674,7 +11567,7 @@ var init_sqlgenerator = __esm({
|
|
11674
11567
|
return statement.type === "create_table" && dialect7 === "postgresql";
|
11675
11568
|
}
|
11676
11569
|
convert(st) {
|
11677
|
-
const { tableName, schema: schema4, columns, compositePKs, uniqueConstraints
|
11570
|
+
const { tableName, schema: schema4, columns, compositePKs, uniqueConstraints } = st;
|
11678
11571
|
let statement = "";
|
11679
11572
|
const name2 = schema4 ? `"${schema4}"."${tableName}"` : `"${tableName}"`;
|
11680
11573
|
statement += `CREATE TABLE IF NOT EXISTS ${name2} (
|
@@ -11707,13 +11600,6 @@ var init_sqlgenerator = __esm({
|
|
11707
11600
|
statement += ` CONSTRAINT "${unsquashedUnique.name}" UNIQUE${unsquashedUnique.nullsNotDistinct ? " NULLS NOT DISTINCT" : ""}("${unsquashedUnique.columns.join(`","`)}")`;
|
11708
11601
|
}
|
11709
11602
|
}
|
11710
|
-
if (typeof checkConstraints !== "undefined" && checkConstraints.length > 0) {
|
11711
|
-
for (const checkConstraint4 of checkConstraints) {
|
11712
|
-
statement += ",\n";
|
11713
|
-
const unsquashedCheck = PgSquasher.unsquashCheck(checkConstraint4);
|
11714
|
-
statement += ` CONSTRAINT "${unsquashedCheck.name}" CHECK (${unsquashedCheck.value})`;
|
11715
|
-
}
|
11716
|
-
}
|
11717
11603
|
statement += `
|
11718
11604
|
);`;
|
11719
11605
|
statement += `
|
@@ -11730,7 +11616,6 @@ var init_sqlgenerator = __esm({
|
|
11730
11616
|
tableName,
|
11731
11617
|
columns,
|
11732
11618
|
schema: schema4,
|
11733
|
-
checkConstraints,
|
11734
11619
|
compositePKs,
|
11735
11620
|
uniqueConstraints,
|
11736
11621
|
internals
|
@@ -11764,13 +11649,6 @@ var init_sqlgenerator = __esm({
|
|
11764
11649
|
statement += ` CONSTRAINT \`${unsquashedUnique.name}\` UNIQUE(${uniqueString})`;
|
11765
11650
|
}
|
11766
11651
|
}
|
11767
|
-
if (typeof checkConstraints !== "undefined" && checkConstraints.length > 0) {
|
11768
|
-
for (const checkConstraint4 of checkConstraints) {
|
11769
|
-
statement += ",\n";
|
11770
|
-
const unsquashedCheck = MySqlSquasher.unsquashCheck(checkConstraint4);
|
11771
|
-
statement += ` CONSTRAINT \`${unsquashedCheck.name}\` CHECK(${unsquashedCheck.value})`;
|
11772
|
-
}
|
11773
|
-
}
|
11774
11652
|
statement += `
|
11775
11653
|
);`;
|
11776
11654
|
statement += `
|
@@ -11788,8 +11666,7 @@ var init_sqlgenerator = __esm({
|
|
11788
11666
|
columns,
|
11789
11667
|
referenceData,
|
11790
11668
|
compositePKs,
|
11791
|
-
uniqueConstraints
|
11792
|
-
checkConstraints
|
11669
|
+
uniqueConstraints
|
11793
11670
|
} = st;
|
11794
11671
|
let statement = "";
|
11795
11672
|
statement += `CREATE TABLE \`${tableName}\` (
|
@@ -11830,17 +11707,10 @@ var init_sqlgenerator = __esm({
|
|
11830
11707
|
if (typeof uniqueConstraints !== "undefined" && uniqueConstraints.length > 0) {
|
11831
11708
|
for (const uniqueConstraint4 of uniqueConstraints) {
|
11832
11709
|
statement += ",\n";
|
11833
|
-
const unsquashedUnique =
|
11710
|
+
const unsquashedUnique = MySqlSquasher.unsquashUnique(uniqueConstraint4);
|
11834
11711
|
statement += ` CONSTRAINT ${unsquashedUnique.name} UNIQUE(\`${unsquashedUnique.columns.join(`\`,\``)}\`)`;
|
11835
11712
|
}
|
11836
11713
|
}
|
11837
|
-
if (typeof checkConstraints !== "undefined" && checkConstraints.length > 0) {
|
11838
|
-
for (const check of checkConstraints) {
|
11839
|
-
statement += ",\n";
|
11840
|
-
const { value, name: name2 } = SQLiteSquasher.unsquashCheck(check);
|
11841
|
-
statement += ` CONSTRAINT "${name2}" CHECK(${value})`;
|
11842
|
-
}
|
11843
|
-
}
|
11844
11714
|
statement += `
|
11845
11715
|
`;
|
11846
11716
|
statement += `);`;
|
@@ -11940,25 +11810,6 @@ var init_sqlgenerator = __esm({
|
|
11940
11810
|
return `ALTER TABLE ${tableNameWithSchema} DROP CONSTRAINT "${unsquashed.name}";`;
|
11941
11811
|
}
|
11942
11812
|
};
|
11943
|
-
PgAlterTableAddCheckConstraintConvertor = class extends Convertor {
|
11944
|
-
can(statement, dialect7) {
|
11945
|
-
return statement.type === "create_check_constraint" && dialect7 === "postgresql";
|
11946
|
-
}
|
11947
|
-
convert(statement) {
|
11948
|
-
const unsquashed = PgSquasher.unsquashCheck(statement.data);
|
11949
|
-
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
11950
|
-
return `ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${unsquashed.name}" CHECK (${unsquashed.value});`;
|
11951
|
-
}
|
11952
|
-
};
|
11953
|
-
PgAlterTableDeleteCheckConstraintConvertor = class extends Convertor {
|
11954
|
-
can(statement, dialect7) {
|
11955
|
-
return statement.type === "delete_check_constraint" && dialect7 === "postgresql";
|
11956
|
-
}
|
11957
|
-
convert(statement) {
|
11958
|
-
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
11959
|
-
return `ALTER TABLE ${tableNameWithSchema} DROP CONSTRAINT "${statement.constraintName}";`;
|
11960
|
-
}
|
11961
|
-
};
|
11962
11813
|
MySQLAlterTableAddUniqueConstraintConvertor = class extends Convertor {
|
11963
11814
|
can(statement, dialect7) {
|
11964
11815
|
return statement.type === "create_unique_constraint" && dialect7 === "mysql";
|
@@ -11977,25 +11828,6 @@ var init_sqlgenerator = __esm({
|
|
11977
11828
|
return `ALTER TABLE \`${statement.tableName}\` DROP INDEX \`${unsquashed.name}\`;`;
|
11978
11829
|
}
|
11979
11830
|
};
|
11980
|
-
MySqlAlterTableAddCheckConstraintConvertor = class extends Convertor {
|
11981
|
-
can(statement, dialect7) {
|
11982
|
-
return statement.type === "create_check_constraint" && dialect7 === "mysql";
|
11983
|
-
}
|
11984
|
-
convert(statement) {
|
11985
|
-
const unsquashed = MySqlSquasher.unsquashCheck(statement.data);
|
11986
|
-
const { tableName } = statement;
|
11987
|
-
return `ALTER TABLE \`${tableName}\` ADD CONSTRAINT \`${unsquashed.name}\` CHECK (${unsquashed.value});`;
|
11988
|
-
}
|
11989
|
-
};
|
11990
|
-
MySqlAlterTableDeleteCheckConstraintConvertor = class extends Convertor {
|
11991
|
-
can(statement, dialect7) {
|
11992
|
-
return statement.type === "delete_check_constraint" && dialect7 === "mysql";
|
11993
|
-
}
|
11994
|
-
convert(statement) {
|
11995
|
-
const { tableName } = statement;
|
11996
|
-
return `ALTER TABLE \`${tableName}\` DROP CONSTRAINT \`${statement.constraintName}\`;`;
|
11997
|
-
}
|
11998
|
-
};
|
11999
11831
|
CreatePgSequenceConvertor = class extends Convertor {
|
12000
11832
|
can(statement, dialect7) {
|
12001
11833
|
return statement.type === "create_sequence" && dialect7 === "postgresql";
|
@@ -12550,7 +12382,7 @@ var init_sqlgenerator = __esm({
|
|
12550
12382
|
};
|
12551
12383
|
LibSQLModifyColumn = class extends Convertor {
|
12552
12384
|
can(statement, dialect7) {
|
12553
|
-
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"
|
12385
|
+
return (statement.type === "alter_table_alter_column_set_type" || statement.type === "alter_table_alter_column_drop_notnull" || statement.type === "alter_table_alter_column_set_notnull" || statement.type === "alter_table_alter_column_set_default" || statement.type === "alter_table_alter_column_drop_default") && dialect7 === "turso";
|
12554
12386
|
}
|
12555
12387
|
convert(statement, json2) {
|
12556
12388
|
const { tableName, columnName } = statement;
|
@@ -13137,22 +12969,18 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
13137
12969
|
return statement.type === "recreate_table" && dialect7 === "sqlite";
|
13138
12970
|
}
|
13139
12971
|
convert(statement) {
|
13140
|
-
const { tableName, columns, compositePKs, referenceData
|
12972
|
+
const { tableName, columns, compositePKs, referenceData } = statement;
|
13141
12973
|
const columnNames = columns.map((it) => `"${it.name}"`).join(", ");
|
13142
12974
|
const newTableName = `__new_${tableName}`;
|
13143
12975
|
const sqlStatements = [];
|
13144
12976
|
sqlStatements.push(`PRAGMA foreign_keys=OFF;`);
|
13145
|
-
const mappedCheckConstraints = checkConstraints.map(
|
13146
|
-
(it) => it.replaceAll(`"${tableName}".`, `"${newTableName}".`).replaceAll(`\`${tableName}\`.`, `\`${newTableName}\`.`).replaceAll(`${tableName}.`, `${newTableName}.`).replaceAll(`'${tableName}'.`, `'${newTableName}'.`)
|
13147
|
-
);
|
13148
12977
|
sqlStatements.push(
|
13149
12978
|
new SQLiteCreateTableConvertor().convert({
|
13150
12979
|
type: "sqlite_create_table",
|
13151
12980
|
tableName: newTableName,
|
13152
12981
|
columns,
|
13153
12982
|
referenceData,
|
13154
|
-
compositePKs
|
13155
|
-
checkConstraints: mappedCheckConstraints
|
12983
|
+
compositePKs
|
13156
12984
|
})
|
13157
12985
|
);
|
13158
12986
|
sqlStatements.push(
|
@@ -13183,13 +13011,10 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
13183
13011
|
return statement.type === "recreate_table" && dialect7 === "turso";
|
13184
13012
|
}
|
13185
13013
|
convert(statement) {
|
13186
|
-
const { tableName, columns, compositePKs, referenceData
|
13014
|
+
const { tableName, columns, compositePKs, referenceData } = statement;
|
13187
13015
|
const columnNames = columns.map((it) => `"${it.name}"`).join(", ");
|
13188
13016
|
const newTableName = `__new_${tableName}`;
|
13189
13017
|
const sqlStatements = [];
|
13190
|
-
const mappedCheckConstraints = checkConstraints.map(
|
13191
|
-
(it) => it.replaceAll(`"${tableName}".`, `"${newTableName}".`).replaceAll(`\`${tableName}\`.`, `\`${newTableName}\`.`).replaceAll(`${tableName}.`, `${newTableName}.`).replaceAll(`'${tableName}'.`, `\`${newTableName}\`.`)
|
13192
|
-
);
|
13193
13018
|
sqlStatements.push(`PRAGMA foreign_keys=OFF;`);
|
13194
13019
|
sqlStatements.push(
|
13195
13020
|
new SQLiteCreateTableConvertor().convert({
|
@@ -13197,8 +13022,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
13197
13022
|
tableName: newTableName,
|
13198
13023
|
columns,
|
13199
13024
|
referenceData,
|
13200
|
-
compositePKs
|
13201
|
-
checkConstraints: mappedCheckConstraints
|
13025
|
+
compositePKs
|
13202
13026
|
})
|
13203
13027
|
);
|
13204
13028
|
sqlStatements.push(
|
@@ -13254,10 +13078,6 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
13254
13078
|
convertors.push(new PgAlterTableAlterColumnSetTypeConvertor());
|
13255
13079
|
convertors.push(new PgAlterTableAddUniqueConstraintConvertor());
|
13256
13080
|
convertors.push(new PgAlterTableDropUniqueConstraintConvertor());
|
13257
|
-
convertors.push(new PgAlterTableAddCheckConstraintConvertor());
|
13258
|
-
convertors.push(new PgAlterTableDeleteCheckConstraintConvertor());
|
13259
|
-
convertors.push(new MySqlAlterTableAddCheckConstraintConvertor());
|
13260
|
-
convertors.push(new MySqlAlterTableDeleteCheckConstraintConvertor());
|
13261
13081
|
convertors.push(new MySQLAlterTableAddUniqueConstraintConvertor());
|
13262
13082
|
convertors.push(new MySQLAlterTableDropUniqueConstraintConvertor());
|
13263
13083
|
convertors.push(new CreatePgIndexConvertor());
|
@@ -13348,10 +13168,6 @@ var init_sqlitePushUtils = __esm({
|
|
13348
13168
|
const compositePKs = Object.values(
|
13349
13169
|
json.tables[tableName].compositePrimaryKeys
|
13350
13170
|
).map((it) => SQLiteSquasher.unsquashPK(it));
|
13351
|
-
const checkConstraints = Object.values(json.tables[tableName].checkConstraints);
|
13352
|
-
const mappedCheckConstraints = checkConstraints.map(
|
13353
|
-
(it) => it.replaceAll(`"${tableName}".`, `"${newTableName}".`).replaceAll(`\`${tableName}\`.`, `\`${newTableName}\`.`).replaceAll(`${tableName}.`, `${newTableName}.`).replaceAll(`'${tableName}'.`, `\`${newTableName}\`.`)
|
13354
|
-
);
|
13355
13171
|
const fks = referenceData.map((it) => SQLiteSquasher.unsquashPushFK(it));
|
13356
13172
|
statements.push(
|
13357
13173
|
new SQLiteCreateTableConvertor().convert({
|
@@ -13359,8 +13175,7 @@ var init_sqlitePushUtils = __esm({
|
|
13359
13175
|
tableName: newTableName,
|
13360
13176
|
columns: tableColumns,
|
13361
13177
|
referenceData: fks,
|
13362
|
-
compositePKs
|
13363
|
-
checkConstraints: mappedCheckConstraints
|
13178
|
+
compositePKs
|
13364
13179
|
})
|
13365
13180
|
);
|
13366
13181
|
if (!dataLoss) {
|
@@ -13572,7 +13387,7 @@ var init_sqlitePushUtils = __esm({
|
|
13572
13387
|
});
|
13573
13388
|
|
13574
13389
|
// src/jsonStatements.ts
|
13575
|
-
var preparePgCreateTableJson, prepareMySqlCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareDropEnumJson, prepareMoveEnumJson, prepareRenameEnumJson, prepareCreateSequenceJson, prepareAlterSequenceJson, prepareDropSequenceJson, prepareMoveSequenceJson, prepareRenameSequenceJson, prepareCreateSchemasJson, prepareRenameSchemasJson, prepareDeleteSchemasJson, prepareRenameColumns, _prepareDropColumns, _prepareAddColumns, _prepareSqliteAddColumns, prepareAlterColumnsMysql, preparePgAlterColumns, prepareSqliteAlterColumns, preparePgCreateIndexesJson, prepareCreateIndexesJson, prepareCreateReferencesJson, prepareLibSQLCreateReferencesJson, prepareDropReferencesJson, prepareLibSQLDropReferencesJson, prepareAlterReferencesJson, prepareDropIndexesJson, prepareAddCompositePrimaryKeySqlite, prepareDeleteCompositePrimaryKeySqlite, prepareAlterCompositePrimaryKeySqlite, prepareAddCompositePrimaryKeyPg, prepareDeleteCompositePrimaryKeyPg, prepareAlterCompositePrimaryKeyPg, prepareAddUniqueConstraintPg, prepareDeleteUniqueConstraintPg,
|
13390
|
+
var preparePgCreateTableJson, prepareMySqlCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareDropEnumJson, prepareMoveEnumJson, prepareRenameEnumJson, prepareCreateSequenceJson, prepareAlterSequenceJson, prepareDropSequenceJson, prepareMoveSequenceJson, prepareRenameSequenceJson, prepareCreateSchemasJson, prepareRenameSchemasJson, prepareDeleteSchemasJson, prepareRenameColumns, _prepareDropColumns, _prepareAddColumns, _prepareSqliteAddColumns, prepareAlterColumnsMysql, preparePgAlterColumns, prepareSqliteAlterColumns, preparePgCreateIndexesJson, prepareCreateIndexesJson, prepareCreateReferencesJson, prepareLibSQLCreateReferencesJson, prepareDropReferencesJson, prepareLibSQLDropReferencesJson, prepareAlterReferencesJson, prepareDropIndexesJson, prepareAddCompositePrimaryKeySqlite, prepareDeleteCompositePrimaryKeySqlite, prepareAlterCompositePrimaryKeySqlite, prepareAddCompositePrimaryKeyPg, prepareDeleteCompositePrimaryKeyPg, prepareAlterCompositePrimaryKeyPg, prepareAddUniqueConstraintPg, prepareDeleteUniqueConstraintPg, prepareAddCompositePrimaryKeyMySql, prepareDeleteCompositePrimaryKeyMySql, prepareAlterCompositePrimaryKeyMySql;
|
13576
13391
|
var init_jsonStatements = __esm({
|
13577
13392
|
"src/jsonStatements.ts"() {
|
13578
13393
|
"use strict";
|
@@ -13583,7 +13398,7 @@ var init_jsonStatements = __esm({
|
|
13583
13398
|
init_pgSchema();
|
13584
13399
|
init_sqliteSchema();
|
13585
13400
|
preparePgCreateTableJson = (table4, json2) => {
|
13586
|
-
const { name: name2, schema: schema4, columns, compositePrimaryKeys, uniqueConstraints
|
13401
|
+
const { name: name2, schema: schema4, columns, compositePrimaryKeys, uniqueConstraints } = table4;
|
13587
13402
|
const tableKey2 = `${schema4 || "public"}.${name2}`;
|
13588
13403
|
const compositePkName = Object.values(compositePrimaryKeys).length > 0 ? json2.tables[tableKey2].compositePrimaryKeys[`${PgSquasher.unsquashPK(Object.values(compositePrimaryKeys)[0]).name}`].name : "";
|
13589
13404
|
return {
|
@@ -13593,12 +13408,11 @@ var init_jsonStatements = __esm({
|
|
13593
13408
|
columns: Object.values(columns),
|
13594
13409
|
compositePKs: Object.values(compositePrimaryKeys),
|
13595
13410
|
compositePkName,
|
13596
|
-
uniqueConstraints: Object.values(uniqueConstraints)
|
13597
|
-
checkConstraints: Object.values(checkConstraints)
|
13411
|
+
uniqueConstraints: Object.values(uniqueConstraints)
|
13598
13412
|
};
|
13599
13413
|
};
|
13600
13414
|
prepareMySqlCreateTableJson = (table4, json2, internals) => {
|
13601
|
-
const { name: name2, schema: schema4, columns, compositePrimaryKeys, uniqueConstraints
|
13415
|
+
const { name: name2, schema: schema4, columns, compositePrimaryKeys, uniqueConstraints } = table4;
|
13602
13416
|
return {
|
13603
13417
|
type: "create_table",
|
13604
13418
|
tableName: name2,
|
@@ -13607,12 +13421,11 @@ var init_jsonStatements = __esm({
|
|
13607
13421
|
compositePKs: Object.values(compositePrimaryKeys),
|
13608
13422
|
compositePkName: Object.values(compositePrimaryKeys).length > 0 ? json2.tables[name2].compositePrimaryKeys[MySqlSquasher.unsquashPK(Object.values(compositePrimaryKeys)[0]).name].name : "",
|
13609
13423
|
uniqueConstraints: Object.values(uniqueConstraints),
|
13610
|
-
internals
|
13611
|
-
checkConstraints: Object.values(checkConstraints)
|
13424
|
+
internals
|
13612
13425
|
};
|
13613
13426
|
};
|
13614
13427
|
prepareSQLiteCreateTable = (table4, action) => {
|
13615
|
-
const { name: name2, columns, uniqueConstraints
|
13428
|
+
const { name: name2, columns, uniqueConstraints } = table4;
|
13616
13429
|
const references2 = Object.values(table4.foreignKeys);
|
13617
13430
|
const composites = Object.values(table4.compositePrimaryKeys).map(
|
13618
13431
|
(it) => SQLiteSquasher.unsquashPK(it)
|
@@ -13626,8 +13439,7 @@ var init_jsonStatements = __esm({
|
|
13626
13439
|
columns: Object.values(columns),
|
13627
13440
|
referenceData: fks,
|
13628
13441
|
compositePKs: composites,
|
13629
|
-
uniqueConstraints: Object.values(uniqueConstraints)
|
13630
|
-
checkConstraints: Object.values(checkConstraints)
|
13442
|
+
uniqueConstraints: Object.values(uniqueConstraints)
|
13631
13443
|
};
|
13632
13444
|
};
|
13633
13445
|
prepareDropTableJson = (table4) => {
|
@@ -14870,26 +14682,6 @@ var init_jsonStatements = __esm({
|
|
14870
14682
|
};
|
14871
14683
|
});
|
14872
14684
|
};
|
14873
|
-
prepareAddCheckConstraint = (tableName, schema4, check) => {
|
14874
|
-
return Object.values(check).map((it) => {
|
14875
|
-
return {
|
14876
|
-
type: "create_check_constraint",
|
14877
|
-
tableName,
|
14878
|
-
data: it,
|
14879
|
-
schema: schema4
|
14880
|
-
};
|
14881
|
-
});
|
14882
|
-
};
|
14883
|
-
prepareDeleteCheckConstraint = (tableName, schema4, check) => {
|
14884
|
-
return Object.values(check).map((it) => {
|
14885
|
-
return {
|
14886
|
-
type: "delete_check_constraint",
|
14887
|
-
tableName,
|
14888
|
-
constraintName: PgSquasher.unsquashCheck(it).name,
|
14889
|
-
schema: schema4
|
14890
|
-
};
|
14891
|
-
});
|
14892
|
-
};
|
14893
14685
|
prepareAddCompositePrimaryKeyMySql = (tableName, pks, json1, json2) => {
|
14894
14686
|
const res = [];
|
14895
14687
|
for (const it of Object.values(pks)) {
|
@@ -14939,7 +14731,7 @@ var init_statementCombiner = __esm({
|
|
14939
14731
|
init_jsonStatements();
|
14940
14732
|
init_sqliteSchema();
|
14941
14733
|
prepareLibSQLRecreateTable = (table4, action) => {
|
14942
|
-
const { name: name2, columns, uniqueConstraints, indexes
|
14734
|
+
const { name: name2, columns, uniqueConstraints, indexes } = table4;
|
14943
14735
|
const composites = Object.values(table4.compositePrimaryKeys).map(
|
14944
14736
|
(it) => SQLiteSquasher.unsquashPK(it)
|
14945
14737
|
);
|
@@ -14954,8 +14746,7 @@ var init_statementCombiner = __esm({
|
|
14954
14746
|
columns: Object.values(columns),
|
14955
14747
|
compositePKs: composites,
|
14956
14748
|
referenceData: fks,
|
14957
|
-
uniqueConstraints: Object.values(uniqueConstraints)
|
14958
|
-
checkConstraints: Object.values(checkConstraints)
|
14749
|
+
uniqueConstraints: Object.values(uniqueConstraints)
|
14959
14750
|
}
|
14960
14751
|
];
|
14961
14752
|
if (Object.keys(indexes).length) {
|
@@ -14964,7 +14755,7 @@ var init_statementCombiner = __esm({
|
|
14964
14755
|
return statements;
|
14965
14756
|
};
|
14966
14757
|
prepareSQLiteRecreateTable = (table4, action) => {
|
14967
|
-
const { name: name2, columns, uniqueConstraints, indexes
|
14758
|
+
const { name: name2, columns, uniqueConstraints, indexes } = table4;
|
14968
14759
|
const composites = Object.values(table4.compositePrimaryKeys).map(
|
14969
14760
|
(it) => SQLiteSquasher.unsquashPK(it)
|
14970
14761
|
);
|
@@ -14979,8 +14770,7 @@ var init_statementCombiner = __esm({
|
|
14979
14770
|
columns: Object.values(columns),
|
14980
14771
|
compositePKs: composites,
|
14981
14772
|
referenceData: fks,
|
14982
|
-
uniqueConstraints: Object.values(uniqueConstraints)
|
14983
|
-
checkConstraints: Object.values(checkConstraints)
|
14773
|
+
uniqueConstraints: Object.values(uniqueConstraints)
|
14984
14774
|
}
|
14985
14775
|
];
|
14986
14776
|
if (Object.keys(indexes).length) {
|
@@ -14991,7 +14781,7 @@ var init_statementCombiner = __esm({
|
|
14991
14781
|
libSQLCombineStatements = (statements, json2, action) => {
|
14992
14782
|
const newStatements = {};
|
14993
14783
|
for (const statement of statements) {
|
14994
|
-
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"
|
14784
|
+
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") {
|
14995
14785
|
const tableName2 = statement.tableName;
|
14996
14786
|
const statementsForTable2 = newStatements[tableName2];
|
14997
14787
|
if (!statementsForTable2) {
|
@@ -15132,16 +14922,16 @@ var init_statementCombiner = __esm({
|
|
15132
14922
|
sqliteCombineStatements = (statements, json2, action) => {
|
15133
14923
|
const newStatements = {};
|
15134
14924
|
for (const statement of statements) {
|
15135
|
-
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"
|
14925
|
+
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") {
|
15136
14926
|
const tableName2 = statement.tableName;
|
15137
14927
|
const statementsForTable2 = newStatements[tableName2];
|
15138
14928
|
if (!statementsForTable2) {
|
15139
|
-
newStatements[tableName2] =
|
14929
|
+
newStatements[tableName2] = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
|
15140
14930
|
continue;
|
15141
14931
|
}
|
15142
14932
|
if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
|
15143
14933
|
const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
|
15144
|
-
const preparedStatements =
|
14934
|
+
const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
|
15145
14935
|
if (wasRename) {
|
15146
14936
|
newStatements[tableName2].push(...preparedStatements);
|
15147
14937
|
} else {
|
@@ -15155,12 +14945,12 @@ var init_statementCombiner = __esm({
|
|
15155
14945
|
const tableName2 = statement.tableName;
|
15156
14946
|
const statementsForTable2 = newStatements[tableName2];
|
15157
14947
|
if (!statementsForTable2) {
|
15158
|
-
newStatements[tableName2] =
|
14948
|
+
newStatements[tableName2] = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
|
15159
14949
|
continue;
|
15160
14950
|
}
|
15161
14951
|
if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
|
15162
14952
|
const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
|
15163
|
-
const preparedStatements =
|
14953
|
+
const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
|
15164
14954
|
if (wasRename) {
|
15165
14955
|
newStatements[tableName2].push(...preparedStatements);
|
15166
14956
|
} else {
|
@@ -15185,7 +14975,7 @@ var init_statementCombiner = __esm({
|
|
15185
14975
|
}
|
15186
14976
|
if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
|
15187
14977
|
const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
|
15188
|
-
const preparedStatements =
|
14978
|
+
const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
|
15189
14979
|
if (wasRename) {
|
15190
14980
|
newStatements[tableName2].push(...preparedStatements);
|
15191
14981
|
} else {
|
@@ -15354,8 +15144,7 @@ var init_snapshotsDiffer = __esm({
|
|
15354
15144
|
indexes: recordType(stringType(), stringType()),
|
15355
15145
|
foreignKeys: recordType(stringType(), stringType()),
|
15356
15146
|
compositePrimaryKeys: recordType(stringType(), stringType()).default({}),
|
15357
|
-
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
15358
|
-
checkConstraints: recordType(stringType(), stringType()).default({})
|
15147
|
+
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
15359
15148
|
}).strict();
|
15360
15149
|
alteredTableScheme = objectType({
|
15361
15150
|
name: stringType(),
|
@@ -15396,21 +15185,6 @@ var init_snapshotsDiffer = __esm({
|
|
15396
15185
|
__new: stringType(),
|
15397
15186
|
__old: stringType()
|
15398
15187
|
})
|
15399
|
-
),
|
15400
|
-
addedCheckConstraints: recordType(
|
15401
|
-
stringType(),
|
15402
|
-
stringType()
|
15403
|
-
),
|
15404
|
-
deletedCheckConstraints: recordType(
|
15405
|
-
stringType(),
|
15406
|
-
stringType()
|
15407
|
-
),
|
15408
|
-
alteredCheckConstraints: recordType(
|
15409
|
-
stringType(),
|
15410
|
-
objectType({
|
15411
|
-
__new: stringType(),
|
15412
|
-
__old: stringType()
|
15413
|
-
})
|
15414
15188
|
)
|
15415
15189
|
}).strict();
|
15416
15190
|
diffResultScheme = objectType({
|
@@ -15751,8 +15525,6 @@ var init_snapshotsDiffer = __esm({
|
|
15751
15525
|
schemaTo: it.schemaTo || "public"
|
15752
15526
|
});
|
15753
15527
|
}
|
15754
|
-
const jsonDeletedCheckConstraints = [];
|
15755
|
-
const jsonCreatedCheckConstraints = [];
|
15756
15528
|
for (let it of alteredTables) {
|
15757
15529
|
let addedColumns = [];
|
15758
15530
|
for (const addedPkName of Object.keys(it.addedCompositePKs)) {
|
@@ -15792,8 +15564,6 @@ var init_snapshotsDiffer = __esm({
|
|
15792
15564
|
let addedUniqueConstraints = [];
|
15793
15565
|
let deletedUniqueConstraints = [];
|
15794
15566
|
let alteredUniqueConstraints = [];
|
15795
|
-
let createCheckConstraints = [];
|
15796
|
-
let deleteCheckConstraints = [];
|
15797
15567
|
addedUniqueConstraints = prepareAddUniqueConstraintPg(
|
15798
15568
|
it.name,
|
15799
15569
|
it.schema,
|
@@ -15818,24 +15588,6 @@ var init_snapshotsDiffer = __esm({
|
|
15818
15588
|
...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
|
15819
15589
|
);
|
15820
15590
|
}
|
15821
|
-
createCheckConstraints = prepareAddCheckConstraint(it.name, it.schema, it.addedCheckConstraints);
|
15822
|
-
deleteCheckConstraints = prepareDeleteCheckConstraint(
|
15823
|
-
it.name,
|
15824
|
-
it.schema,
|
15825
|
-
it.deletedCheckConstraints
|
15826
|
-
);
|
15827
|
-
if (it.alteredCheckConstraints && action !== "push") {
|
15828
|
-
const added = {};
|
15829
|
-
const deleted = {};
|
15830
|
-
for (const k6 of Object.keys(it.alteredCheckConstraints)) {
|
15831
|
-
added[k6] = it.alteredCheckConstraints[k6].__new;
|
15832
|
-
deleted[k6] = it.alteredCheckConstraints[k6].__old;
|
15833
|
-
}
|
15834
|
-
createCheckConstraints.push(...prepareAddCheckConstraint(it.name, it.schema, added));
|
15835
|
-
deleteCheckConstraints.push(...prepareDeleteCheckConstraint(it.name, it.schema, deleted));
|
15836
|
-
}
|
15837
|
-
jsonCreatedCheckConstraints.push(...createCheckConstraints);
|
15838
|
-
jsonDeletedCheckConstraints.push(...deleteCheckConstraints);
|
15839
15591
|
jsonAddedCompositePKs.push(...addedCompositePKs);
|
15840
15592
|
jsonDeletedCompositePKs.push(...deletedCompositePKs);
|
15841
15593
|
jsonAlteredCompositePKs.push(...alteredCompositePKs);
|
@@ -15989,7 +15741,6 @@ var init_snapshotsDiffer = __esm({
|
|
15989
15741
|
jsonStatements.push(...jsonRenameTables);
|
15990
15742
|
jsonStatements.push(...jsonRenameColumnsStatements);
|
15991
15743
|
jsonStatements.push(...jsonDeletedUniqueConstraints);
|
15992
|
-
jsonStatements.push(...jsonDeletedCheckConstraints);
|
15993
15744
|
jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
|
15994
15745
|
jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
|
15995
15746
|
jsonStatements.push(...jsonDeletedCompositePKs);
|
@@ -16003,7 +15754,6 @@ var init_snapshotsDiffer = __esm({
|
|
16003
15754
|
jsonStatements.push(...jsonDropColumnsStatemets);
|
16004
15755
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
16005
15756
|
jsonStatements.push(...jsonAddedUniqueConstraints);
|
16006
|
-
jsonStatements.push(...jsonCreatedCheckConstraints);
|
16007
15757
|
jsonStatements.push(...jsonAlteredUniqueConstraints);
|
16008
15758
|
jsonStatements.push(...dropEnums);
|
16009
15759
|
jsonStatements.push(...dropSequences);
|
@@ -16167,8 +15917,6 @@ var init_snapshotsDiffer = __esm({
|
|
16167
15917
|
const jsonAddedUniqueConstraints = [];
|
16168
15918
|
const jsonDeletedUniqueConstraints = [];
|
16169
15919
|
const jsonAlteredUniqueConstraints = [];
|
16170
|
-
const jsonCreatedCheckConstraints = [];
|
16171
|
-
const jsonDeletedCheckConstraints = [];
|
16172
15920
|
const jsonRenameColumnsStatements = columnRenames.map((it) => prepareRenameColumns(it.table, "", it.renames)).flat();
|
16173
15921
|
const jsonAddColumnsStatemets = columnCreates.map((it) => _prepareAddColumns(it.table, "", it.columns)).flat();
|
16174
15922
|
const jsonDropColumnsStatemets = columnDeletes.map((it) => _prepareDropColumns(it.table, "", it.columns)).flat();
|
@@ -16207,8 +15955,6 @@ var init_snapshotsDiffer = __esm({
|
|
16207
15955
|
let addedUniqueConstraints = [];
|
16208
15956
|
let deletedUniqueConstraints = [];
|
16209
15957
|
let alteredUniqueConstraints = [];
|
16210
|
-
let createdCheckConstraints = [];
|
16211
|
-
let deletedCheckConstraints = [];
|
16212
15958
|
addedUniqueConstraints = prepareAddUniqueConstraintPg(
|
16213
15959
|
it.name,
|
16214
15960
|
it.schema,
|
@@ -16233,30 +15979,12 @@ var init_snapshotsDiffer = __esm({
|
|
16233
15979
|
...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
|
16234
15980
|
);
|
16235
15981
|
}
|
16236
|
-
createdCheckConstraints = prepareAddCheckConstraint(it.name, it.schema, it.addedCheckConstraints);
|
16237
|
-
deletedCheckConstraints = prepareDeleteCheckConstraint(
|
16238
|
-
it.name,
|
16239
|
-
it.schema,
|
16240
|
-
it.deletedCheckConstraints
|
16241
|
-
);
|
16242
|
-
if (it.alteredCheckConstraints && action !== "push") {
|
16243
|
-
const added = {};
|
16244
|
-
const deleted = {};
|
16245
|
-
for (const k6 of Object.keys(it.alteredCheckConstraints)) {
|
16246
|
-
added[k6] = it.alteredCheckConstraints[k6].__new;
|
16247
|
-
deleted[k6] = it.alteredCheckConstraints[k6].__old;
|
16248
|
-
}
|
16249
|
-
createdCheckConstraints.push(...prepareAddCheckConstraint(it.name, it.schema, added));
|
16250
|
-
deletedCheckConstraints.push(...prepareDeleteCheckConstraint(it.name, it.schema, deleted));
|
16251
|
-
}
|
16252
15982
|
jsonAddedCompositePKs.push(...addedCompositePKs);
|
16253
15983
|
jsonDeletedCompositePKs.push(...deletedCompositePKs);
|
16254
15984
|
jsonAlteredCompositePKs.push(...alteredCompositePKs);
|
16255
15985
|
jsonAddedUniqueConstraints.push(...addedUniqueConstraints);
|
16256
15986
|
jsonDeletedUniqueConstraints.push(...deletedUniqueConstraints);
|
16257
15987
|
jsonAlteredUniqueConstraints.push(...alteredUniqueConstraints);
|
16258
|
-
jsonCreatedCheckConstraints.push(...createdCheckConstraints);
|
16259
|
-
jsonDeletedCheckConstraints.push(...deletedCheckConstraints);
|
16260
15988
|
});
|
16261
15989
|
const rColumns = jsonRenameColumnsStatements.map((it) => {
|
16262
15990
|
const tableName = it.tableName;
|
@@ -16352,7 +16080,6 @@ var init_snapshotsDiffer = __esm({
|
|
16352
16080
|
jsonStatements.push(...jsonRenameTables);
|
16353
16081
|
jsonStatements.push(...jsonRenameColumnsStatements);
|
16354
16082
|
jsonStatements.push(...jsonDeletedUniqueConstraints);
|
16355
|
-
jsonStatements.push(...jsonDeletedCheckConstraints);
|
16356
16083
|
jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
|
16357
16084
|
jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
|
16358
16085
|
jsonStatements.push(...jsonDeletedCompositePKs);
|
@@ -16363,11 +16090,11 @@ var init_snapshotsDiffer = __esm({
|
|
16363
16090
|
jsonStatements.push(...jsonAddColumnsStatemets);
|
16364
16091
|
jsonStatements.push(...jsonCreateReferencesForCreatedTables);
|
16365
16092
|
jsonStatements.push(...jsonCreateIndexesForCreatedTables);
|
16366
|
-
jsonStatements.push(...jsonCreatedCheckConstraints);
|
16367
16093
|
jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
|
16368
16094
|
jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
|
16369
16095
|
jsonStatements.push(...jsonDropColumnsStatemets);
|
16370
16096
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
16097
|
+
jsonStatements.push(...jsonAddedUniqueConstraints);
|
16371
16098
|
jsonStatements.push(...jsonAlteredUniqueConstraints);
|
16372
16099
|
const sqlStatements = fromJson(jsonStatements, "mysql");
|
16373
16100
|
const uniqueSqlStatements = [];
|
@@ -16495,8 +16222,6 @@ var init_snapshotsDiffer = __esm({
|
|
16495
16222
|
const jsonAddedUniqueConstraints = [];
|
16496
16223
|
const jsonDeletedUniqueConstraints = [];
|
16497
16224
|
const jsonAlteredUniqueConstraints = [];
|
16498
|
-
const jsonDeletedCheckConstraints = [];
|
16499
|
-
const jsonCreatedCheckConstraints = [];
|
16500
16225
|
allAltered.forEach((it) => {
|
16501
16226
|
let addedColumns = [];
|
16502
16227
|
for (const addedPkName of Object.keys(it.addedCompositePKs)) {
|
@@ -16553,56 +16278,12 @@ var init_snapshotsDiffer = __esm({
|
|
16553
16278
|
...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
|
16554
16279
|
);
|
16555
16280
|
}
|
16556
|
-
let createdCheckConstraints = [];
|
16557
|
-
let deletedCheckConstraints = [];
|
16558
|
-
addedUniqueConstraints = prepareAddUniqueConstraintPg(
|
16559
|
-
it.name,
|
16560
|
-
it.schema,
|
16561
|
-
it.addedUniqueConstraints
|
16562
|
-
);
|
16563
|
-
deletedUniqueConstraints = prepareDeleteUniqueConstraintPg(
|
16564
|
-
it.name,
|
16565
|
-
it.schema,
|
16566
|
-
it.deletedUniqueConstraints
|
16567
|
-
);
|
16568
|
-
if (it.alteredUniqueConstraints) {
|
16569
|
-
const added = {};
|
16570
|
-
const deleted = {};
|
16571
|
-
for (const k6 of Object.keys(it.alteredUniqueConstraints)) {
|
16572
|
-
added[k6] = it.alteredUniqueConstraints[k6].__new;
|
16573
|
-
deleted[k6] = it.alteredUniqueConstraints[k6].__old;
|
16574
|
-
}
|
16575
|
-
addedUniqueConstraints.push(
|
16576
|
-
...prepareAddUniqueConstraintPg(it.name, it.schema, added)
|
16577
|
-
);
|
16578
|
-
deletedUniqueConstraints.push(
|
16579
|
-
...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
|
16580
|
-
);
|
16581
|
-
}
|
16582
|
-
createdCheckConstraints = prepareAddCheckConstraint(it.name, it.schema, it.addedCheckConstraints);
|
16583
|
-
deletedCheckConstraints = prepareDeleteCheckConstraint(
|
16584
|
-
it.name,
|
16585
|
-
it.schema,
|
16586
|
-
it.deletedCheckConstraints
|
16587
|
-
);
|
16588
|
-
if (it.alteredCheckConstraints && action !== "push") {
|
16589
|
-
const added = {};
|
16590
|
-
const deleted = {};
|
16591
|
-
for (const k6 of Object.keys(it.alteredCheckConstraints)) {
|
16592
|
-
added[k6] = it.alteredCheckConstraints[k6].__new;
|
16593
|
-
deleted[k6] = it.alteredCheckConstraints[k6].__old;
|
16594
|
-
}
|
16595
|
-
createdCheckConstraints.push(...prepareAddCheckConstraint(it.name, it.schema, added));
|
16596
|
-
deletedCheckConstraints.push(...prepareDeleteCheckConstraint(it.name, it.schema, deleted));
|
16597
|
-
}
|
16598
16281
|
jsonAddedCompositePKs.push(...addedCompositePKs);
|
16599
16282
|
jsonDeletedCompositePKs.push(...deletedCompositePKs);
|
16600
16283
|
jsonAlteredCompositePKs.push(...alteredCompositePKs);
|
16601
16284
|
jsonAddedUniqueConstraints.push(...addedUniqueConstraints);
|
16602
16285
|
jsonDeletedUniqueConstraints.push(...deletedUniqueConstraints);
|
16603
16286
|
jsonAlteredUniqueConstraints.push(...alteredUniqueConstraints);
|
16604
|
-
jsonCreatedCheckConstraints.push(...createdCheckConstraints);
|
16605
|
-
jsonDeletedCheckConstraints.push(...deletedCheckConstraints);
|
16606
16287
|
});
|
16607
16288
|
const rColumns = jsonRenameColumnsStatements.map((it) => {
|
16608
16289
|
const tableName = it.tableName;
|
@@ -16687,7 +16368,6 @@ var init_snapshotsDiffer = __esm({
|
|
16687
16368
|
jsonStatements.push(...jsonRenameTables);
|
16688
16369
|
jsonStatements.push(...jsonRenameColumnsStatements);
|
16689
16370
|
jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
|
16690
|
-
jsonStatements.push(...jsonDeletedCheckConstraints);
|
16691
16371
|
jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
|
16692
16372
|
jsonStatements.push(...jsonDeletedCompositePKs);
|
16693
16373
|
jsonStatements.push(...jsonTableAlternations);
|
@@ -16695,7 +16375,6 @@ var init_snapshotsDiffer = __esm({
|
|
16695
16375
|
jsonStatements.push(...jsonAddColumnsStatemets);
|
16696
16376
|
jsonStatements.push(...jsonCreateIndexesForCreatedTables);
|
16697
16377
|
jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
|
16698
|
-
jsonStatements.push(...jsonCreatedCheckConstraints);
|
16699
16378
|
jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
|
16700
16379
|
jsonStatements.push(...jsonDropColumnsStatemets);
|
16701
16380
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
@@ -16839,8 +16518,6 @@ var init_snapshotsDiffer = __esm({
|
|
16839
16518
|
const jsonAddedUniqueConstraints = [];
|
16840
16519
|
const jsonDeletedUniqueConstraints = [];
|
16841
16520
|
const jsonAlteredUniqueConstraints = [];
|
16842
|
-
const jsonDeletedCheckConstraints = [];
|
16843
|
-
const jsonCreatedCheckConstraints = [];
|
16844
16521
|
allAltered.forEach((it) => {
|
16845
16522
|
let addedColumns = [];
|
16846
16523
|
for (const addedPkName of Object.keys(it.addedCompositePKs)) {
|
@@ -16873,8 +16550,6 @@ var init_snapshotsDiffer = __esm({
|
|
16873
16550
|
let addedUniqueConstraints = [];
|
16874
16551
|
let deletedUniqueConstraints = [];
|
16875
16552
|
let alteredUniqueConstraints = [];
|
16876
|
-
let createdCheckConstraints = [];
|
16877
|
-
let deletedCheckConstraints = [];
|
16878
16553
|
addedUniqueConstraints = prepareAddUniqueConstraintPg(
|
16879
16554
|
it.name,
|
16880
16555
|
it.schema,
|
@@ -16899,30 +16574,12 @@ var init_snapshotsDiffer = __esm({
|
|
16899
16574
|
...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
|
16900
16575
|
);
|
16901
16576
|
}
|
16902
|
-
createdCheckConstraints = prepareAddCheckConstraint(it.name, it.schema, it.addedCheckConstraints);
|
16903
|
-
deletedCheckConstraints = prepareDeleteCheckConstraint(
|
16904
|
-
it.name,
|
16905
|
-
it.schema,
|
16906
|
-
it.deletedCheckConstraints
|
16907
|
-
);
|
16908
|
-
if (it.alteredCheckConstraints && action !== "push") {
|
16909
|
-
const added = {};
|
16910
|
-
const deleted = {};
|
16911
|
-
for (const k6 of Object.keys(it.alteredCheckConstraints)) {
|
16912
|
-
added[k6] = it.alteredCheckConstraints[k6].__new;
|
16913
|
-
deleted[k6] = it.alteredCheckConstraints[k6].__old;
|
16914
|
-
}
|
16915
|
-
createdCheckConstraints.push(...prepareAddCheckConstraint(it.name, it.schema, added));
|
16916
|
-
deletedCheckConstraints.push(...prepareDeleteCheckConstraint(it.name, it.schema, deleted));
|
16917
|
-
}
|
16918
16577
|
jsonAddedCompositePKs.push(...addedCompositePKs);
|
16919
16578
|
jsonDeletedCompositePKs.push(...deletedCompositePKs);
|
16920
16579
|
jsonAlteredCompositePKs.push(...alteredCompositePKs);
|
16921
16580
|
jsonAddedUniqueConstraints.push(...addedUniqueConstraints);
|
16922
16581
|
jsonDeletedUniqueConstraints.push(...deletedUniqueConstraints);
|
16923
16582
|
jsonAlteredUniqueConstraints.push(...alteredUniqueConstraints);
|
16924
|
-
jsonCreatedCheckConstraints.push(...createdCheckConstraints);
|
16925
|
-
jsonDeletedCheckConstraints.push(...deletedCheckConstraints);
|
16926
16583
|
});
|
16927
16584
|
const jsonTableAlternations = allAltered.map((it) => {
|
16928
16585
|
return prepareSqliteAlterColumns(it.name, it.schema, it.altered, json2);
|
@@ -17000,7 +16657,6 @@ var init_snapshotsDiffer = __esm({
|
|
17000
16657
|
jsonStatements.push(...jsonRenameTables);
|
17001
16658
|
jsonStatements.push(...jsonRenameColumnsStatements);
|
17002
16659
|
jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
|
17003
|
-
jsonStatements.push(...jsonDeletedCheckConstraints);
|
17004
16660
|
jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
|
17005
16661
|
jsonStatements.push(...jsonDeletedCompositePKs);
|
17006
16662
|
jsonStatements.push(...jsonTableAlternations);
|
@@ -17008,7 +16664,6 @@ var init_snapshotsDiffer = __esm({
|
|
17008
16664
|
jsonStatements.push(...jsonAddColumnsStatemets);
|
17009
16665
|
jsonStatements.push(...jsonCreateIndexesForCreatedTables);
|
17010
16666
|
jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
|
17011
|
-
jsonStatements.push(...jsonCreatedCheckConstraints);
|
17012
16667
|
jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
|
17013
16668
|
jsonStatements.push(...jsonDropColumnsStatemets);
|
17014
16669
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
@@ -105680,7 +105335,6 @@ var init_pgSerializer = __esm({
|
|
105680
105335
|
const sequencesToReturn = {};
|
105681
105336
|
const indexesInSchema = {};
|
105682
105337
|
for (const table4 of tables) {
|
105683
|
-
const checksInTable = {};
|
105684
105338
|
const {
|
105685
105339
|
name: tableName,
|
105686
105340
|
columns,
|
@@ -105696,7 +105350,6 @@ var init_pgSerializer = __esm({
|
|
105696
105350
|
}
|
105697
105351
|
const columnsObject = {};
|
105698
105352
|
const indexesObject = {};
|
105699
|
-
const checksObject = {};
|
105700
105353
|
const foreignKeysObject = {};
|
105701
105354
|
const primaryKeysObject = {};
|
105702
105355
|
const uniqueConstraintObject = {};
|
@@ -105943,33 +105596,6 @@ ${withStyle.errorWarning(
|
|
105943
105596
|
with: value.config.with ?? {}
|
105944
105597
|
};
|
105945
105598
|
});
|
105946
|
-
checks.forEach((check) => {
|
105947
|
-
const checkName = check.name;
|
105948
|
-
if (typeof checksInTable[`"${schema4 ?? "public"}"."${tableName}"`] !== "undefined") {
|
105949
|
-
if (checksInTable[`"${schema4 ?? "public"}"."${tableName}"`].includes(check.name)) {
|
105950
|
-
console.log(
|
105951
|
-
`
|
105952
|
-
${withStyle.errorWarning(
|
105953
|
-
`We've found duplicated check constraint name across ${source_default.underline.blue(
|
105954
|
-
schema4 ?? "public"
|
105955
|
-
)} schema in ${source_default.underline.blue(
|
105956
|
-
tableName
|
105957
|
-
)}. Please rename your check constraint in either the ${source_default.underline.blue(
|
105958
|
-
tableName
|
105959
|
-
)} table or the table with the duplicated check contraint name`
|
105960
|
-
)}`
|
105961
|
-
);
|
105962
|
-
process.exit(1);
|
105963
|
-
}
|
105964
|
-
checksInTable[`"${schema4 ?? "public"}"."${tableName}"`].push(checkName);
|
105965
|
-
} else {
|
105966
|
-
checksInTable[`"${schema4 ?? "public"}"."${tableName}"`] = [check.name];
|
105967
|
-
}
|
105968
|
-
checksObject[checkName] = {
|
105969
|
-
name: checkName,
|
105970
|
-
value: dialect4.sqlToQuery(check.value).sql
|
105971
|
-
};
|
105972
|
-
});
|
105973
105599
|
const tableKey2 = `${schema4 ?? "public"}.${tableName}`;
|
105974
105600
|
result[tableKey2] = {
|
105975
105601
|
name: tableName,
|
@@ -105978,8 +105604,7 @@ ${withStyle.errorWarning(
|
|
105978
105604
|
indexes: indexesObject,
|
105979
105605
|
foreignKeys: foreignKeysObject,
|
105980
105606
|
compositePrimaryKeys: primaryKeysObject,
|
105981
|
-
uniqueConstraints: uniqueConstraintObject
|
105982
|
-
checkConstraints: checksObject
|
105607
|
+
uniqueConstraints: uniqueConstraintObject
|
105983
105608
|
};
|
105984
105609
|
}
|
105985
105610
|
for (const sequence of sequences) {
|
@@ -106068,7 +105693,6 @@ ${withStyle.errorWarning(
|
|
106068
105693
|
let indexesCount = 0;
|
106069
105694
|
let foreignKeysCount = 0;
|
106070
105695
|
let tableCount = 0;
|
106071
|
-
let checksCount = 0;
|
106072
105696
|
const sequencesToReturn = {};
|
106073
105697
|
const seqWhere = schemaFilters.map((t5) => `schemaname = '${t5}'`).join(" or ");
|
106074
105698
|
const allSequences = await db2.query(
|
@@ -106138,8 +105762,7 @@ ${withStyle.errorWarning(
|
|
106138
105762
|
const indexToReturn = {};
|
106139
105763
|
const foreignKeysToReturn = {};
|
106140
105764
|
const primaryKeys = {};
|
106141
|
-
const
|
106142
|
-
const checkConstraints = {};
|
105765
|
+
const uniqueConstrains = {};
|
106143
105766
|
const tableResponse = await db2.query(
|
106144
105767
|
`SELECT a.attrelid::regclass::text, a.attname, is_nullable, a.attndims as array_dimensions
|
106145
105768
|
, CASE WHEN a.atttypid = ANY ('{int,int8,int2}'::regtype[])
|
@@ -106177,97 +105800,55 @@ ${withStyle.errorWarning(
|
|
106177
105800
|
ORDER BY a.attnum;`
|
106178
105801
|
);
|
106179
105802
|
const tableConstraints = await db2.query(
|
106180
|
-
`SELECT c.column_name,
|
106181
|
-
|
106182
|
-
|
106183
|
-
|
106184
|
-
|
106185
|
-
|
106186
|
-
FROM information_schema.table_constraints tc
|
106187
|
-
JOIN information_schema.constraint_column_usage AS ccu
|
106188
|
-
USING (constraint_schema, constraint_name)
|
106189
|
-
JOIN information_schema.columns AS c
|
106190
|
-
ON c.table_schema = tc.constraint_schema
|
106191
|
-
AND tc.table_name = c.table_name
|
106192
|
-
AND ccu.column_name = c.column_name
|
106193
|
-
JOIN pg_constraint con
|
106194
|
-
ON con.conname = tc.constraint_name
|
106195
|
-
AND con.conrelid = (
|
106196
|
-
SELECT oid
|
106197
|
-
FROM pg_class
|
106198
|
-
WHERE relname = tc.table_name
|
106199
|
-
AND relnamespace = (
|
106200
|
-
SELECT oid
|
106201
|
-
FROM pg_namespace
|
106202
|
-
WHERE nspname = tc.constraint_schema
|
106203
|
-
)
|
106204
|
-
)
|
106205
|
-
WHERE tc.table_name = '${tableName}' AND tc.constraint_schema = '${tableSchema}';`
|
105803
|
+
`SELECT c.column_name, c.data_type, constraint_type, constraint_name, constraint_schema
|
105804
|
+
FROM information_schema.table_constraints tc
|
105805
|
+
JOIN information_schema.constraint_column_usage AS ccu USING (constraint_schema, constraint_name)
|
105806
|
+
JOIN information_schema.columns AS c ON c.table_schema = tc.constraint_schema
|
105807
|
+
AND tc.table_name = c.table_name AND ccu.column_name = c.column_name
|
105808
|
+
WHERE tc.table_name = '${tableName}' and constraint_schema = '${tableSchema}';`
|
106206
105809
|
);
|
106207
|
-
const tableChecks = await db2.query(`SELECT
|
106208
|
-
tc.constraint_name,
|
106209
|
-
tc.constraint_type,
|
106210
|
-
pg_get_constraintdef(con.oid) AS constraint_definition
|
106211
|
-
FROM
|
106212
|
-
information_schema.table_constraints AS tc
|
106213
|
-
JOIN pg_constraint AS con
|
106214
|
-
ON tc.constraint_name = con.conname
|
106215
|
-
AND con.conrelid = (
|
106216
|
-
SELECT oid
|
106217
|
-
FROM pg_class
|
106218
|
-
WHERE relname = tc.table_name
|
106219
|
-
AND relnamespace = (
|
106220
|
-
SELECT oid
|
106221
|
-
FROM pg_namespace
|
106222
|
-
WHERE nspname = tc.constraint_schema
|
106223
|
-
)
|
106224
|
-
)
|
106225
|
-
WHERE
|
106226
|
-
tc.table_name = '${tableName}'
|
106227
|
-
AND tc.constraint_schema = '${tableSchema}'
|
106228
|
-
AND tc.constraint_type = 'CHECK';`);
|
106229
105810
|
columnsCount += tableResponse.length;
|
106230
105811
|
if (progressCallback) {
|
106231
105812
|
progressCallback("columns", columnsCount, "fetching");
|
106232
105813
|
}
|
106233
105814
|
const tableForeignKeys = await db2.query(
|
106234
105815
|
`SELECT
|
106235
|
-
|
106236
|
-
|
106237
|
-
|
106238
|
-
|
106239
|
-
|
106240
|
-
|
106241
|
-
|
106242
|
-
|
106243
|
-
|
106244
|
-
|
106245
|
-
|
106246
|
-
|
106247
|
-
|
106248
|
-
|
106249
|
-
|
106250
|
-
|
106251
|
-
|
106252
|
-
|
106253
|
-
|
106254
|
-
|
106255
|
-
|
106256
|
-
|
106257
|
-
|
106258
|
-
|
106259
|
-
|
106260
|
-
|
106261
|
-
|
106262
|
-
|
106263
|
-
|
106264
|
-
|
106265
|
-
|
106266
|
-
|
106267
|
-
|
106268
|
-
|
106269
|
-
|
106270
|
-
|
105816
|
+
con.contype AS constraint_type,
|
105817
|
+
nsp.nspname AS constraint_schema,
|
105818
|
+
con.conname AS constraint_name,
|
105819
|
+
rel.relname AS table_name,
|
105820
|
+
att.attname AS column_name,
|
105821
|
+
fnsp.nspname AS foreign_table_schema,
|
105822
|
+
frel.relname AS foreign_table_name,
|
105823
|
+
fatt.attname AS foreign_column_name,
|
105824
|
+
CASE con.confupdtype
|
105825
|
+
WHEN 'a' THEN 'NO ACTION'
|
105826
|
+
WHEN 'r' THEN 'RESTRICT'
|
105827
|
+
WHEN 'n' THEN 'SET NULL'
|
105828
|
+
WHEN 'c' THEN 'CASCADE'
|
105829
|
+
WHEN 'd' THEN 'SET DEFAULT'
|
105830
|
+
END AS update_rule,
|
105831
|
+
CASE con.confdeltype
|
105832
|
+
WHEN 'a' THEN 'NO ACTION'
|
105833
|
+
WHEN 'r' THEN 'RESTRICT'
|
105834
|
+
WHEN 'n' THEN 'SET NULL'
|
105835
|
+
WHEN 'c' THEN 'CASCADE'
|
105836
|
+
WHEN 'd' THEN 'SET DEFAULT'
|
105837
|
+
END AS delete_rule
|
105838
|
+
FROM
|
105839
|
+
pg_catalog.pg_constraint con
|
105840
|
+
JOIN pg_catalog.pg_class rel ON rel.oid = con.conrelid
|
105841
|
+
JOIN pg_catalog.pg_namespace nsp ON nsp.oid = con.connamespace
|
105842
|
+
LEFT JOIN pg_catalog.pg_attribute att ON att.attnum = ANY (con.conkey)
|
105843
|
+
AND att.attrelid = con.conrelid
|
105844
|
+
LEFT JOIN pg_catalog.pg_class frel ON frel.oid = con.confrelid
|
105845
|
+
LEFT JOIN pg_catalog.pg_namespace fnsp ON fnsp.oid = frel.relnamespace
|
105846
|
+
LEFT JOIN pg_catalog.pg_attribute fatt ON fatt.attnum = ANY (con.confkey)
|
105847
|
+
AND fatt.attrelid = con.confrelid
|
105848
|
+
WHERE
|
105849
|
+
nsp.nspname = '${tableSchema}'
|
105850
|
+
AND rel.relname = '${tableName}'
|
105851
|
+
AND con.contype IN ('f');`
|
106271
105852
|
);
|
106272
105853
|
foreignKeysCount += tableForeignKeys.length;
|
106273
105854
|
if (progressCallback) {
|
@@ -106309,29 +105890,16 @@ ${withStyle.errorWarning(
|
|
106309
105890
|
for (const unqs of uniqueConstrainsRows) {
|
106310
105891
|
const columnName = unqs.column_name;
|
106311
105892
|
const constraintName = unqs.constraint_name;
|
106312
|
-
if (typeof
|
106313
|
-
|
105893
|
+
if (typeof uniqueConstrains[constraintName] !== "undefined") {
|
105894
|
+
uniqueConstrains[constraintName].columns.push(columnName);
|
106314
105895
|
} else {
|
106315
|
-
|
105896
|
+
uniqueConstrains[constraintName] = {
|
106316
105897
|
columns: [columnName],
|
106317
105898
|
nullsNotDistinct: false,
|
106318
105899
|
name: constraintName
|
106319
105900
|
};
|
106320
105901
|
}
|
106321
105902
|
}
|
106322
|
-
checksCount += tableChecks.length;
|
106323
|
-
if (progressCallback) {
|
106324
|
-
progressCallback("checks", checksCount, "fetching");
|
106325
|
-
}
|
106326
|
-
for (const checks of tableChecks) {
|
106327
|
-
let checkValue = checks.constraint_definition;
|
106328
|
-
const constraintName = checks.constraint_name;
|
106329
|
-
checkValue = checkValue.replace(/^CHECK\s*\(\(/, "").replace(/\)\)\s*$/, "");
|
106330
|
-
checkConstraints[constraintName] = {
|
106331
|
-
name: constraintName,
|
106332
|
-
value: checkValue
|
106333
|
-
};
|
106334
|
-
}
|
106335
105903
|
for (const columnResponse of tableResponse) {
|
106336
105904
|
const columnName = columnResponse.attname;
|
106337
105905
|
const columnAdditionalDT = columnResponse.additional_dt;
|
@@ -106575,8 +106143,7 @@ ${withStyle.errorWarning(
|
|
106575
106143
|
indexes: indexToReturn,
|
106576
106144
|
foreignKeys: foreignKeysToReturn,
|
106577
106145
|
compositePrimaryKeys: primaryKeys,
|
106578
|
-
uniqueConstraints
|
106579
|
-
checkConstraints
|
106146
|
+
uniqueConstraints: uniqueConstrains
|
106580
106147
|
};
|
106581
106148
|
} catch (e5) {
|
106582
106149
|
rej(e5);
|
@@ -106594,7 +106161,6 @@ ${withStyle.errorWarning(
|
|
106594
106161
|
progressCallback("columns", columnsCount, "done");
|
106595
106162
|
progressCallback("indexes", indexesCount, "done");
|
106596
106163
|
progressCallback("fks", foreignKeysCount, "done");
|
106597
|
-
progressCallback("checks", checksCount, "done");
|
106598
106164
|
}
|
106599
106165
|
const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
|
106600
106166
|
return {
|
@@ -106799,13 +106365,10 @@ var init_sqliteSerializer = __esm({
|
|
106799
106365
|
const foreignKeysObject = {};
|
106800
106366
|
const primaryKeysObject = {};
|
106801
106367
|
const uniqueConstraintObject = {};
|
106802
|
-
const checkConstraintObject = {};
|
106803
|
-
const checksInTable = {};
|
106804
106368
|
const {
|
106805
106369
|
name: tableName,
|
106806
106370
|
columns,
|
106807
106371
|
indexes,
|
106808
|
-
checks,
|
106809
106372
|
foreignKeys: tableForeignKeys,
|
106810
106373
|
primaryKeys,
|
106811
106374
|
uniqueConstraints
|
@@ -106962,39 +106525,13 @@ The unique constraint ${source_default.underline.blue(
|
|
106962
106525
|
columnsObject[it.columns[0].name].primaryKey = true;
|
106963
106526
|
}
|
106964
106527
|
});
|
106965
|
-
checks.forEach((check) => {
|
106966
|
-
const checkName = check.name;
|
106967
|
-
if (typeof checksInTable[tableName] !== "undefined") {
|
106968
|
-
if (checksInTable[tableName].includes(check.name)) {
|
106969
|
-
console.log(
|
106970
|
-
`
|
106971
|
-
${withStyle.errorWarning(
|
106972
|
-
`We've found duplicated check constraint name in ${source_default.underline.blue(
|
106973
|
-
tableName
|
106974
|
-
)}. Please rename your check constraint in the ${source_default.underline.blue(
|
106975
|
-
tableName
|
106976
|
-
)} table`
|
106977
|
-
)}`
|
106978
|
-
);
|
106979
|
-
process.exit(1);
|
106980
|
-
}
|
106981
|
-
checksInTable[tableName].push(checkName);
|
106982
|
-
} else {
|
106983
|
-
checksInTable[tableName] = [check.name];
|
106984
|
-
}
|
106985
|
-
checkConstraintObject[checkName] = {
|
106986
|
-
name: checkName,
|
106987
|
-
value: dialect5.sqlToQuery(check.value).sql
|
106988
|
-
};
|
106989
|
-
});
|
106990
106528
|
result[tableName] = {
|
106991
106529
|
name: tableName,
|
106992
106530
|
columns: columnsObject,
|
106993
106531
|
indexes: indexesObject,
|
106994
106532
|
foreignKeys: foreignKeysObject,
|
106995
106533
|
compositePrimaryKeys: primaryKeysObject,
|
106996
|
-
uniqueConstraints: uniqueConstraintObject
|
106997
|
-
checkConstraints: checkConstraintObject
|
106534
|
+
uniqueConstraints: uniqueConstraintObject
|
106998
106535
|
};
|
106999
106536
|
}
|
107000
106537
|
return {
|
@@ -107041,7 +106578,6 @@ ${withStyle.errorWarning(
|
|
107041
106578
|
let tablesCount = /* @__PURE__ */ new Set();
|
107042
106579
|
let indexesCount = 0;
|
107043
106580
|
let foreignKeysCount = 0;
|
107044
|
-
let checksCount = 0;
|
107045
106581
|
const tableToPk = {};
|
107046
106582
|
let tableToGeneratedColumnsInfo = {};
|
107047
106583
|
for (const column4 of columns) {
|
@@ -107099,8 +106635,7 @@ ${withStyle.errorWarning(
|
|
107099
106635
|
compositePrimaryKeys: {},
|
107100
106636
|
indexes: {},
|
107101
106637
|
foreignKeys: {},
|
107102
|
-
uniqueConstraints: {}
|
107103
|
-
checkConstraints: {}
|
106638
|
+
uniqueConstraints: {}
|
107104
106639
|
};
|
107105
106640
|
} else {
|
107106
106641
|
result[tableName].columns[columnName] = newColumn;
|
@@ -107214,56 +106749,6 @@ WHERE
|
|
107214
106749
|
progressCallback("indexes", indexesCount, "done");
|
107215
106750
|
progressCallback("enums", 0, "done");
|
107216
106751
|
}
|
107217
|
-
const namedCheckPattern = /CONSTRAINT\s*["']?(\w+)["']?\s*CHECK\s*\((.*?)\)/gi;
|
107218
|
-
const unnamedCheckPattern = /CHECK\s*\((.*?)\)/gi;
|
107219
|
-
let checkCounter = 0;
|
107220
|
-
const checkConstraints = {};
|
107221
|
-
const checks = await db2.query(`SELECT name as "tableName", sql as "sql"
|
107222
|
-
FROM sqlite_master
|
107223
|
-
WHERE type = 'table' AND name != 'sqlite_sequence';`);
|
107224
|
-
for (const check of checks) {
|
107225
|
-
if (!tablesFilter(check.tableName)) continue;
|
107226
|
-
const { tableName, sql: sql3 } = check;
|
107227
|
-
let namedChecks = [...sql3.matchAll(namedCheckPattern)];
|
107228
|
-
if (namedChecks.length > 0) {
|
107229
|
-
namedChecks.forEach(([_3, checkName, checkValue]) => {
|
107230
|
-
checkConstraints[checkName] = {
|
107231
|
-
name: checkName,
|
107232
|
-
value: checkValue.trim()
|
107233
|
-
};
|
107234
|
-
});
|
107235
|
-
} else {
|
107236
|
-
let unnamedChecks = [...sql3.matchAll(unnamedCheckPattern)];
|
107237
|
-
unnamedChecks.forEach(([_3, checkValue]) => {
|
107238
|
-
let checkName = `${tableName}_check_${++checkCounter}`;
|
107239
|
-
checkConstraints[checkName] = {
|
107240
|
-
name: checkName,
|
107241
|
-
value: checkValue.trim()
|
107242
|
-
};
|
107243
|
-
});
|
107244
|
-
}
|
107245
|
-
checksCount += Object.values(checkConstraints).length;
|
107246
|
-
if (progressCallback) {
|
107247
|
-
progressCallback("checks", checksCount, "fetching");
|
107248
|
-
}
|
107249
|
-
const table4 = result[tableName];
|
107250
|
-
if (!table4) {
|
107251
|
-
result[tableName] = {
|
107252
|
-
name: tableName,
|
107253
|
-
columns: {},
|
107254
|
-
compositePrimaryKeys: {},
|
107255
|
-
indexes: {},
|
107256
|
-
foreignKeys: {},
|
107257
|
-
uniqueConstraints: {},
|
107258
|
-
checkConstraints
|
107259
|
-
};
|
107260
|
-
} else {
|
107261
|
-
result[tableName].checkConstraints = checkConstraints;
|
107262
|
-
}
|
107263
|
-
}
|
107264
|
-
if (progressCallback) {
|
107265
|
-
progressCallback("checks", checksCount, "done");
|
107266
|
-
}
|
107267
106752
|
return {
|
107268
106753
|
version: "6",
|
107269
106754
|
dialect: "sqlite",
|
@@ -108705,7 +108190,6 @@ var init_mysqlSerializer = __esm({
|
|
108705
108190
|
indexes,
|
108706
108191
|
foreignKeys,
|
108707
108192
|
schema: schema4,
|
108708
|
-
checks,
|
108709
108193
|
primaryKeys,
|
108710
108194
|
uniqueConstraints
|
108711
108195
|
} = getTableConfig3(table4);
|
@@ -108714,8 +108198,6 @@ var init_mysqlSerializer = __esm({
|
|
108714
108198
|
const foreignKeysObject = {};
|
108715
108199
|
const primaryKeysObject = {};
|
108716
108200
|
const uniqueConstraintObject = {};
|
108717
|
-
const checkConstraintObject = {};
|
108718
|
-
let checksInTable = {};
|
108719
108201
|
columns.forEach((column4) => {
|
108720
108202
|
const notNull = column4.notNull;
|
108721
108203
|
const sqlTypeLowered = column4.getSQLType().toLowerCase();
|
@@ -108928,32 +108410,6 @@ We have encountered a collision between the index name on columns ${source_defau
|
|
108928
108410
|
lock: value.config.lock
|
108929
108411
|
};
|
108930
108412
|
});
|
108931
|
-
checks.forEach((check) => {
|
108932
|
-
check;
|
108933
|
-
const checkName = check.name;
|
108934
|
-
if (typeof checksInTable[tableName] !== "undefined") {
|
108935
|
-
if (checksInTable[tableName].includes(check.name)) {
|
108936
|
-
console.log(
|
108937
|
-
`
|
108938
|
-
${withStyle.errorWarning(
|
108939
|
-
`We've found duplicated check constraint name in ${source_default.underline.blue(
|
108940
|
-
tableName
|
108941
|
-
)}. Please rename your check constraint in the ${source_default.underline.blue(
|
108942
|
-
tableName
|
108943
|
-
)} table`
|
108944
|
-
)}`
|
108945
|
-
);
|
108946
|
-
process.exit(1);
|
108947
|
-
}
|
108948
|
-
checksInTable[tableName].push(checkName);
|
108949
|
-
} else {
|
108950
|
-
checksInTable[tableName] = [check.name];
|
108951
|
-
}
|
108952
|
-
checkConstraintObject[checkName] = {
|
108953
|
-
name: checkName,
|
108954
|
-
value: dialect6.sqlToQuery(check.value).sql
|
108955
|
-
};
|
108956
|
-
});
|
108957
108413
|
if (!schema4) {
|
108958
108414
|
result[tableName] = {
|
108959
108415
|
name: tableName,
|
@@ -108961,8 +108417,7 @@ ${withStyle.errorWarning(
|
|
108961
108417
|
indexes: indexesObject,
|
108962
108418
|
foreignKeys: foreignKeysObject,
|
108963
108419
|
compositePrimaryKeys: primaryKeysObject,
|
108964
|
-
uniqueConstraints: uniqueConstraintObject
|
108965
|
-
checkConstraint: checkConstraintObject
|
108420
|
+
uniqueConstraints: uniqueConstraintObject
|
108966
108421
|
};
|
108967
108422
|
}
|
108968
108423
|
}
|
@@ -108989,7 +108444,6 @@ ${withStyle.errorWarning(
|
|
108989
108444
|
let tablesCount = /* @__PURE__ */ new Set();
|
108990
108445
|
let indexesCount = 0;
|
108991
108446
|
let foreignKeysCount = 0;
|
108992
|
-
let checksCount = 0;
|
108993
108447
|
const idxs = await db2.query(
|
108994
108448
|
`select * from INFORMATION_SCHEMA.STATISTICS
|
108995
108449
|
WHERE INFORMATION_SCHEMA.STATISTICS.TABLE_SCHEMA = '${inputSchema}' and INFORMATION_SCHEMA.STATISTICS.INDEX_NAME != 'PRIMARY';`
|
@@ -109084,8 +108538,7 @@ ${withStyle.errorWarning(
|
|
109084
108538
|
compositePrimaryKeys: {},
|
109085
108539
|
indexes: {},
|
109086
108540
|
foreignKeys: {},
|
109087
|
-
uniqueConstraints: {}
|
109088
|
-
checkConstraint: {}
|
108541
|
+
uniqueConstraints: {}
|
109089
108542
|
};
|
109090
108543
|
} else {
|
109091
108544
|
result[tableName].columns[columnName] = newColumn;
|
@@ -109234,38 +108687,6 @@ ${withStyle.errorWarning(
|
|
109234
108687
|
progressCallback("indexes", indexesCount, "done");
|
109235
108688
|
progressCallback("enums", 0, "done");
|
109236
108689
|
}
|
109237
|
-
const checkConstraints = await db2.query(
|
109238
|
-
`SELECT
|
109239
|
-
tc.table_name,
|
109240
|
-
tc.constraint_name,
|
109241
|
-
cc.check_clause
|
109242
|
-
FROM
|
109243
|
-
information_schema.table_constraints tc
|
109244
|
-
JOIN
|
109245
|
-
information_schema.check_constraints cc
|
109246
|
-
ON tc.constraint_name = cc.constraint_name
|
109247
|
-
WHERE
|
109248
|
-
tc.constraint_schema = '${inputSchema}'
|
109249
|
-
AND
|
109250
|
-
tc.constraint_type = 'CHECK';`
|
109251
|
-
);
|
109252
|
-
checksCount += checkConstraints.length;
|
109253
|
-
if (progressCallback) {
|
109254
|
-
progressCallback("checks", checksCount, "fetching");
|
109255
|
-
}
|
109256
|
-
for (const checkConstraintRow of checkConstraints) {
|
109257
|
-
const constraintName = checkConstraintRow["CONSTRAINT_NAME"];
|
109258
|
-
const constraintValue = checkConstraintRow["CHECK_CLAUSE"];
|
109259
|
-
const tableName = checkConstraintRow["TABLE_NAME"];
|
109260
|
-
const tableInResult = result[tableName];
|
109261
|
-
tableInResult.checkConstraint[constraintName] = {
|
109262
|
-
name: constraintName,
|
109263
|
-
value: constraintValue
|
109264
|
-
};
|
109265
|
-
}
|
109266
|
-
if (progressCallback) {
|
109267
|
-
progressCallback("checks", checksCount, "done");
|
109268
|
-
}
|
109269
108690
|
return {
|
109270
108691
|
version: "5",
|
109271
108692
|
dialect: "mysql",
|