drizzle-kit 0.25.0-5a1c5d3 → 0.25.0-605ef48
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 +170 -687
- package/api.mjs +170 -687
- 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);
|
@@ -27186,6 +26841,46 @@ var init_dialect = __esm({
|
|
27186
26841
|
});
|
27187
26842
|
return sql.join(chunks);
|
27188
26843
|
}
|
26844
|
+
buildOptimizedSelection(fields, { isSingleTable = false } = {}) {
|
26845
|
+
const columnsLen = fields.length;
|
26846
|
+
const chunks = fields.flatMap(({ field }, i5) => {
|
26847
|
+
const chunk = [];
|
26848
|
+
if (is(field, SQL.Aliased) && field.isSelectionField) {
|
26849
|
+
chunk.push(sql.identifier(field.fieldAlias));
|
26850
|
+
} else if (is(field, SQL.Aliased) || is(field, SQL)) {
|
26851
|
+
const query = is(field, SQL.Aliased) ? field.sql : field;
|
26852
|
+
if (isSingleTable) {
|
26853
|
+
const parts = [];
|
26854
|
+
for (const c5 of query.queryChunks) {
|
26855
|
+
if (is(c5, PgColumn)) {
|
26856
|
+
parts.push(sql.raw(c5.name), sql`, `, sql.identifier(c5.name));
|
26857
|
+
continue;
|
26858
|
+
}
|
26859
|
+
parts.push(c5);
|
26860
|
+
}
|
26861
|
+
chunk.push(new SQL(parts));
|
26862
|
+
} else {
|
26863
|
+
chunk.push(query);
|
26864
|
+
}
|
26865
|
+
if (is(field, SQL.Aliased)) {
|
26866
|
+
chunk.push(sql` as ${sql.identifier(field.fieldAlias)}`);
|
26867
|
+
}
|
26868
|
+
} else if (is(field, Column2)) {
|
26869
|
+
if (isSingleTable) {
|
26870
|
+
chunk.push(sql`'${sql.raw(field.name)}', ${sql.identifier(field.name)}`);
|
26871
|
+
} else {
|
26872
|
+
chunk.push(field);
|
26873
|
+
}
|
26874
|
+
}
|
26875
|
+
if (i5 < columnsLen - 1) {
|
26876
|
+
chunk.push(sql`, `);
|
26877
|
+
}
|
26878
|
+
return chunk;
|
26879
|
+
});
|
26880
|
+
chunks.unshift(sql`json_build_object(`);
|
26881
|
+
chunks.push(sql`)`);
|
26882
|
+
return sql.join(chunks);
|
26883
|
+
}
|
27189
26884
|
buildSelectQuery({
|
27190
26885
|
withList,
|
27191
26886
|
fields,
|
@@ -27200,7 +26895,8 @@ var init_dialect = __esm({
|
|
27200
26895
|
offset,
|
27201
26896
|
lockingClause,
|
27202
26897
|
distinct,
|
27203
|
-
setOperators
|
26898
|
+
setOperators,
|
26899
|
+
optimize
|
27204
26900
|
}) {
|
27205
26901
|
const fieldsList = fieldsFlat ?? orderSelectedFields(fields);
|
27206
26902
|
for (const f5 of fieldsList) {
|
@@ -27219,7 +26915,9 @@ var init_dialect = __esm({
|
|
27219
26915
|
if (distinct) {
|
27220
26916
|
distinctSql = distinct === true ? sql` distinct` : sql` distinct on (${sql.join(distinct.on, sql`, `)})`;
|
27221
26917
|
}
|
27222
|
-
const selection = this.
|
26918
|
+
const selection = optimize ? this.buildOptimizedSelection(fieldsList, {
|
26919
|
+
isSingleTable
|
26920
|
+
}) : this.buildSelection(fieldsList, { isSingleTable });
|
27223
26921
|
const tableSql = (() => {
|
27224
26922
|
if (is(table4, Table2) && table4[Table2.Symbol.OriginalName] !== table4[Table2.Symbol.Name]) {
|
27225
26923
|
let fullName = sql`${sql.identifier(table4[Table2.Symbol.OriginalName])}`;
|
@@ -28900,6 +28598,10 @@ var init_select2 = __esm({
|
|
28900
28598
|
$dynamic() {
|
28901
28599
|
return this;
|
28902
28600
|
}
|
28601
|
+
$optimize() {
|
28602
|
+
this.config.optimize = true;
|
28603
|
+
return this;
|
28604
|
+
}
|
28903
28605
|
};
|
28904
28606
|
__publicField(PgSelectQueryBuilderBase, _a130, "PgSelectQueryBuilder");
|
28905
28607
|
PgSelectBase = class extends (_b101 = PgSelectQueryBuilderBase, _a131 = entityKind, _b101) {
|
@@ -28919,7 +28621,7 @@ var init_select2 = __esm({
|
|
28919
28621
|
}
|
28920
28622
|
return tracer.startActiveSpan("drizzle.prepareQuery", () => {
|
28921
28623
|
const fieldsList = orderSelectedFields(config.fields);
|
28922
|
-
const query = session.prepareQuery(dialect7.sqlToQuery(this.getSQL()), fieldsList, name2, true);
|
28624
|
+
const query = session.prepareQuery(dialect7.sqlToQuery(this.getSQL()), fieldsList, name2, true, void 0, config.optimize);
|
28923
28625
|
query.joinsNotNullableMap = joinsNotNullableMap;
|
28924
28626
|
return query;
|
28925
28627
|
});
|
@@ -30395,7 +30097,7 @@ var init_session2 = __esm({
|
|
30395
30097
|
init_utils2();
|
30396
30098
|
({ Pool } = import_pg.default);
|
30397
30099
|
NodePgPreparedQuery = class extends (_b114 = PgPreparedQuery, _a159 = entityKind, _b114) {
|
30398
|
-
constructor(client, queryString, params, logger2, fields, name2, _isResponseInArrayMode, customResultMapper) {
|
30100
|
+
constructor(client, queryString, params, logger2, fields, name2, _isResponseInArrayMode, customResultMapper, isOptimized) {
|
30399
30101
|
super({ sql: queryString, params });
|
30400
30102
|
__publicField(this, "rawQueryConfig");
|
30401
30103
|
__publicField(this, "queryConfig");
|
@@ -30405,6 +30107,7 @@ var init_session2 = __esm({
|
|
30405
30107
|
this.fields = fields;
|
30406
30108
|
this._isResponseInArrayMode = _isResponseInArrayMode;
|
30407
30109
|
this.customResultMapper = customResultMapper;
|
30110
|
+
this.isOptimized = isOptimized;
|
30408
30111
|
this.rawQueryConfig = {
|
30409
30112
|
name: name2,
|
30410
30113
|
text: queryString
|
@@ -30419,7 +30122,15 @@ var init_session2 = __esm({
|
|
30419
30122
|
return tracer.startActiveSpan("drizzle.execute", async () => {
|
30420
30123
|
const params = fillPlaceholders(this.params, placeholderValues);
|
30421
30124
|
this.logger.logQuery(this.rawQueryConfig.text, params);
|
30422
|
-
const {
|
30125
|
+
const {
|
30126
|
+
fields,
|
30127
|
+
rawQueryConfig: rawQuery,
|
30128
|
+
client,
|
30129
|
+
queryConfig: query,
|
30130
|
+
joinsNotNullableMap,
|
30131
|
+
customResultMapper,
|
30132
|
+
isOptimized
|
30133
|
+
} = this;
|
30423
30134
|
if (!fields && !customResultMapper) {
|
30424
30135
|
return tracer.startActiveSpan("drizzle.driver.execute", async (span) => {
|
30425
30136
|
span?.setAttributes({
|
@@ -30439,7 +30150,7 @@ var init_session2 = __esm({
|
|
30439
30150
|
return client.query(query, params);
|
30440
30151
|
});
|
30441
30152
|
return tracer.startActiveSpan("drizzle.mapResponse", () => {
|
30442
|
-
return customResultMapper ? customResultMapper(result.rows) : result.rows.map((row) => mapResultRow(fields, row, joinsNotNullableMap));
|
30153
|
+
return isOptimized ? result.rows.flat(1) : customResultMapper ? customResultMapper(result.rows) : result.rows.map((row) => mapResultRow(fields, row, joinsNotNullableMap));
|
30443
30154
|
});
|
30444
30155
|
});
|
30445
30156
|
}
|
@@ -30472,7 +30183,7 @@ var init_session2 = __esm({
|
|
30472
30183
|
this.options = options;
|
30473
30184
|
this.logger = options.logger ?? new NoopLogger();
|
30474
30185
|
}
|
30475
|
-
prepareQuery(query, fields, name2, isResponseInArrayMode, customResultMapper) {
|
30186
|
+
prepareQuery(query, fields, name2, isResponseInArrayMode, customResultMapper, isOptimized) {
|
30476
30187
|
return new NodePgPreparedQuery(
|
30477
30188
|
this.client,
|
30478
30189
|
query.sql,
|
@@ -30481,7 +30192,8 @@ var init_session2 = __esm({
|
|
30481
30192
|
fields,
|
30482
30193
|
name2,
|
30483
30194
|
isResponseInArrayMode,
|
30484
|
-
customResultMapper
|
30195
|
+
customResultMapper,
|
30196
|
+
isOptimized
|
30485
30197
|
);
|
30486
30198
|
}
|
30487
30199
|
async transaction(transaction, config) {
|
@@ -48960,6 +48672,7 @@ var init_session3 = __esm({
|
|
48960
48672
|
database: options.database
|
48961
48673
|
};
|
48962
48674
|
}
|
48675
|
+
// @ts-ignore
|
48963
48676
|
prepareQuery(query, fields, name2, isResponseInArrayMode, customResultMapper, transactionId) {
|
48964
48677
|
return new AwsDataApiPreparedQuery(
|
48965
48678
|
this.client,
|
@@ -48980,6 +48693,8 @@ var init_session3 = __esm({
|
|
48980
48693
|
void 0,
|
48981
48694
|
false,
|
48982
48695
|
void 0,
|
48696
|
+
void 0,
|
48697
|
+
// @ts-ignore
|
48983
48698
|
this.transactionId
|
48984
48699
|
).execute();
|
48985
48700
|
}
|
@@ -94865,7 +94580,7 @@ var init_session14 = __esm({
|
|
94865
94580
|
init_tracing();
|
94866
94581
|
init_utils2();
|
94867
94582
|
PostgresJsPreparedQuery = class extends (_b213 = PgPreparedQuery, _a299 = entityKind, _b213) {
|
94868
|
-
constructor(client, queryString, params, logger2, fields, _isResponseInArrayMode, customResultMapper) {
|
94583
|
+
constructor(client, queryString, params, logger2, fields, _isResponseInArrayMode, customResultMapper, isOptimized) {
|
94869
94584
|
super({ sql: queryString, params });
|
94870
94585
|
this.client = client;
|
94871
94586
|
this.queryString = queryString;
|
@@ -94874,6 +94589,7 @@ var init_session14 = __esm({
|
|
94874
94589
|
this.fields = fields;
|
94875
94590
|
this._isResponseInArrayMode = _isResponseInArrayMode;
|
94876
94591
|
this.customResultMapper = customResultMapper;
|
94592
|
+
this.isOptimized = isOptimized;
|
94877
94593
|
}
|
94878
94594
|
async execute(placeholderValues = {}) {
|
94879
94595
|
return tracer.startActiveSpan("drizzle.execute", async (span) => {
|
@@ -94883,7 +94599,7 @@ var init_session14 = __esm({
|
|
94883
94599
|
"drizzle.query.params": JSON.stringify(params)
|
94884
94600
|
});
|
94885
94601
|
this.logger.logQuery(this.queryString, params);
|
94886
|
-
const { fields, queryString: query, client, joinsNotNullableMap, customResultMapper } = this;
|
94602
|
+
const { fields, queryString: query, client, joinsNotNullableMap, customResultMapper, isOptimized } = this;
|
94887
94603
|
if (!fields && !customResultMapper) {
|
94888
94604
|
return tracer.startActiveSpan("drizzle.driver.execute", () => {
|
94889
94605
|
return client.unsafe(query, params);
|
@@ -94897,7 +94613,7 @@ var init_session14 = __esm({
|
|
94897
94613
|
return client.unsafe(query, params).values();
|
94898
94614
|
});
|
94899
94615
|
return tracer.startActiveSpan("drizzle.mapResponse", () => {
|
94900
|
-
return customResultMapper ? customResultMapper(rows) : rows.map((row) => mapResultRow(fields, row, joinsNotNullableMap));
|
94616
|
+
return isOptimized ? rows.flat(1) : customResultMapper ? customResultMapper(rows) : rows.map((row) => mapResultRow(fields, row, joinsNotNullableMap));
|
94901
94617
|
});
|
94902
94618
|
});
|
94903
94619
|
}
|
@@ -94933,7 +94649,7 @@ var init_session14 = __esm({
|
|
94933
94649
|
this.options = options;
|
94934
94650
|
this.logger = options.logger ?? new NoopLogger();
|
94935
94651
|
}
|
94936
|
-
prepareQuery(query, fields, name2, isResponseInArrayMode, customResultMapper) {
|
94652
|
+
prepareQuery(query, fields, name2, isResponseInArrayMode, customResultMapper, isOptimized) {
|
94937
94653
|
return new PostgresJsPreparedQuery(
|
94938
94654
|
this.client,
|
94939
94655
|
query.sql,
|
@@ -94941,7 +94657,8 @@ var init_session14 = __esm({
|
|
94941
94657
|
this.logger,
|
94942
94658
|
fields,
|
94943
94659
|
isResponseInArrayMode,
|
94944
|
-
customResultMapper
|
94660
|
+
customResultMapper,
|
94661
|
+
isOptimized
|
94945
94662
|
);
|
94946
94663
|
}
|
94947
94664
|
query(query, params) {
|
@@ -105680,7 +105397,6 @@ var init_pgSerializer = __esm({
|
|
105680
105397
|
const sequencesToReturn = {};
|
105681
105398
|
const indexesInSchema = {};
|
105682
105399
|
for (const table4 of tables) {
|
105683
|
-
const checksInTable = {};
|
105684
105400
|
const {
|
105685
105401
|
name: tableName,
|
105686
105402
|
columns,
|
@@ -105696,7 +105412,6 @@ var init_pgSerializer = __esm({
|
|
105696
105412
|
}
|
105697
105413
|
const columnsObject = {};
|
105698
105414
|
const indexesObject = {};
|
105699
|
-
const checksObject = {};
|
105700
105415
|
const foreignKeysObject = {};
|
105701
105416
|
const primaryKeysObject = {};
|
105702
105417
|
const uniqueConstraintObject = {};
|
@@ -105943,33 +105658,6 @@ ${withStyle.errorWarning(
|
|
105943
105658
|
with: value.config.with ?? {}
|
105944
105659
|
};
|
105945
105660
|
});
|
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
105661
|
const tableKey2 = `${schema4 ?? "public"}.${tableName}`;
|
105974
105662
|
result[tableKey2] = {
|
105975
105663
|
name: tableName,
|
@@ -105978,8 +105666,7 @@ ${withStyle.errorWarning(
|
|
105978
105666
|
indexes: indexesObject,
|
105979
105667
|
foreignKeys: foreignKeysObject,
|
105980
105668
|
compositePrimaryKeys: primaryKeysObject,
|
105981
|
-
uniqueConstraints: uniqueConstraintObject
|
105982
|
-
checkConstraints: checksObject
|
105669
|
+
uniqueConstraints: uniqueConstraintObject
|
105983
105670
|
};
|
105984
105671
|
}
|
105985
105672
|
for (const sequence of sequences) {
|
@@ -106068,7 +105755,6 @@ ${withStyle.errorWarning(
|
|
106068
105755
|
let indexesCount = 0;
|
106069
105756
|
let foreignKeysCount = 0;
|
106070
105757
|
let tableCount = 0;
|
106071
|
-
let checksCount = 0;
|
106072
105758
|
const sequencesToReturn = {};
|
106073
105759
|
const seqWhere = schemaFilters.map((t5) => `schemaname = '${t5}'`).join(" or ");
|
106074
105760
|
const allSequences = await db2.query(
|
@@ -106138,8 +105824,7 @@ ${withStyle.errorWarning(
|
|
106138
105824
|
const indexToReturn = {};
|
106139
105825
|
const foreignKeysToReturn = {};
|
106140
105826
|
const primaryKeys = {};
|
106141
|
-
const
|
106142
|
-
const checkConstraints = {};
|
105827
|
+
const uniqueConstrains = {};
|
106143
105828
|
const tableResponse = await db2.query(
|
106144
105829
|
`SELECT a.attrelid::regclass::text, a.attname, is_nullable, a.attndims as array_dimensions
|
106145
105830
|
, CASE WHEN a.atttypid = ANY ('{int,int8,int2}'::regtype[])
|
@@ -106177,97 +105862,55 @@ ${withStyle.errorWarning(
|
|
106177
105862
|
ORDER BY a.attnum;`
|
106178
105863
|
);
|
106179
105864
|
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}';`
|
105865
|
+
`SELECT c.column_name, c.data_type, constraint_type, constraint_name, constraint_schema
|
105866
|
+
FROM information_schema.table_constraints tc
|
105867
|
+
JOIN information_schema.constraint_column_usage AS ccu USING (constraint_schema, constraint_name)
|
105868
|
+
JOIN information_schema.columns AS c ON c.table_schema = tc.constraint_schema
|
105869
|
+
AND tc.table_name = c.table_name AND ccu.column_name = c.column_name
|
105870
|
+
WHERE tc.table_name = '${tableName}' and constraint_schema = '${tableSchema}';`
|
106206
105871
|
);
|
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
105872
|
columnsCount += tableResponse.length;
|
106230
105873
|
if (progressCallback) {
|
106231
105874
|
progressCallback("columns", columnsCount, "fetching");
|
106232
105875
|
}
|
106233
105876
|
const tableForeignKeys = await db2.query(
|
106234
105877
|
`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
|
-
|
105878
|
+
con.contype AS constraint_type,
|
105879
|
+
nsp.nspname AS constraint_schema,
|
105880
|
+
con.conname AS constraint_name,
|
105881
|
+
rel.relname AS table_name,
|
105882
|
+
att.attname AS column_name,
|
105883
|
+
fnsp.nspname AS foreign_table_schema,
|
105884
|
+
frel.relname AS foreign_table_name,
|
105885
|
+
fatt.attname AS foreign_column_name,
|
105886
|
+
CASE con.confupdtype
|
105887
|
+
WHEN 'a' THEN 'NO ACTION'
|
105888
|
+
WHEN 'r' THEN 'RESTRICT'
|
105889
|
+
WHEN 'n' THEN 'SET NULL'
|
105890
|
+
WHEN 'c' THEN 'CASCADE'
|
105891
|
+
WHEN 'd' THEN 'SET DEFAULT'
|
105892
|
+
END AS update_rule,
|
105893
|
+
CASE con.confdeltype
|
105894
|
+
WHEN 'a' THEN 'NO ACTION'
|
105895
|
+
WHEN 'r' THEN 'RESTRICT'
|
105896
|
+
WHEN 'n' THEN 'SET NULL'
|
105897
|
+
WHEN 'c' THEN 'CASCADE'
|
105898
|
+
WHEN 'd' THEN 'SET DEFAULT'
|
105899
|
+
END AS delete_rule
|
105900
|
+
FROM
|
105901
|
+
pg_catalog.pg_constraint con
|
105902
|
+
JOIN pg_catalog.pg_class rel ON rel.oid = con.conrelid
|
105903
|
+
JOIN pg_catalog.pg_namespace nsp ON nsp.oid = con.connamespace
|
105904
|
+
LEFT JOIN pg_catalog.pg_attribute att ON att.attnum = ANY (con.conkey)
|
105905
|
+
AND att.attrelid = con.conrelid
|
105906
|
+
LEFT JOIN pg_catalog.pg_class frel ON frel.oid = con.confrelid
|
105907
|
+
LEFT JOIN pg_catalog.pg_namespace fnsp ON fnsp.oid = frel.relnamespace
|
105908
|
+
LEFT JOIN pg_catalog.pg_attribute fatt ON fatt.attnum = ANY (con.confkey)
|
105909
|
+
AND fatt.attrelid = con.confrelid
|
105910
|
+
WHERE
|
105911
|
+
nsp.nspname = '${tableSchema}'
|
105912
|
+
AND rel.relname = '${tableName}'
|
105913
|
+
AND con.contype IN ('f');`
|
106271
105914
|
);
|
106272
105915
|
foreignKeysCount += tableForeignKeys.length;
|
106273
105916
|
if (progressCallback) {
|
@@ -106309,29 +105952,16 @@ ${withStyle.errorWarning(
|
|
106309
105952
|
for (const unqs of uniqueConstrainsRows) {
|
106310
105953
|
const columnName = unqs.column_name;
|
106311
105954
|
const constraintName = unqs.constraint_name;
|
106312
|
-
if (typeof
|
106313
|
-
|
105955
|
+
if (typeof uniqueConstrains[constraintName] !== "undefined") {
|
105956
|
+
uniqueConstrains[constraintName].columns.push(columnName);
|
106314
105957
|
} else {
|
106315
|
-
|
105958
|
+
uniqueConstrains[constraintName] = {
|
106316
105959
|
columns: [columnName],
|
106317
105960
|
nullsNotDistinct: false,
|
106318
105961
|
name: constraintName
|
106319
105962
|
};
|
106320
105963
|
}
|
106321
105964
|
}
|
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
105965
|
for (const columnResponse of tableResponse) {
|
106336
105966
|
const columnName = columnResponse.attname;
|
106337
105967
|
const columnAdditionalDT = columnResponse.additional_dt;
|
@@ -106575,8 +106205,7 @@ ${withStyle.errorWarning(
|
|
106575
106205
|
indexes: indexToReturn,
|
106576
106206
|
foreignKeys: foreignKeysToReturn,
|
106577
106207
|
compositePrimaryKeys: primaryKeys,
|
106578
|
-
uniqueConstraints
|
106579
|
-
checkConstraints
|
106208
|
+
uniqueConstraints: uniqueConstrains
|
106580
106209
|
};
|
106581
106210
|
} catch (e5) {
|
106582
106211
|
rej(e5);
|
@@ -106594,7 +106223,6 @@ ${withStyle.errorWarning(
|
|
106594
106223
|
progressCallback("columns", columnsCount, "done");
|
106595
106224
|
progressCallback("indexes", indexesCount, "done");
|
106596
106225
|
progressCallback("fks", foreignKeysCount, "done");
|
106597
|
-
progressCallback("checks", checksCount, "done");
|
106598
106226
|
}
|
106599
106227
|
const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
|
106600
106228
|
return {
|
@@ -106799,13 +106427,10 @@ var init_sqliteSerializer = __esm({
|
|
106799
106427
|
const foreignKeysObject = {};
|
106800
106428
|
const primaryKeysObject = {};
|
106801
106429
|
const uniqueConstraintObject = {};
|
106802
|
-
const checkConstraintObject = {};
|
106803
|
-
const checksInTable = {};
|
106804
106430
|
const {
|
106805
106431
|
name: tableName,
|
106806
106432
|
columns,
|
106807
106433
|
indexes,
|
106808
|
-
checks,
|
106809
106434
|
foreignKeys: tableForeignKeys,
|
106810
106435
|
primaryKeys,
|
106811
106436
|
uniqueConstraints
|
@@ -106962,39 +106587,13 @@ The unique constraint ${source_default.underline.blue(
|
|
106962
106587
|
columnsObject[it.columns[0].name].primaryKey = true;
|
106963
106588
|
}
|
106964
106589
|
});
|
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
106590
|
result[tableName] = {
|
106991
106591
|
name: tableName,
|
106992
106592
|
columns: columnsObject,
|
106993
106593
|
indexes: indexesObject,
|
106994
106594
|
foreignKeys: foreignKeysObject,
|
106995
106595
|
compositePrimaryKeys: primaryKeysObject,
|
106996
|
-
uniqueConstraints: uniqueConstraintObject
|
106997
|
-
checkConstraints: checkConstraintObject
|
106596
|
+
uniqueConstraints: uniqueConstraintObject
|
106998
106597
|
};
|
106999
106598
|
}
|
107000
106599
|
return {
|
@@ -107041,7 +106640,6 @@ ${withStyle.errorWarning(
|
|
107041
106640
|
let tablesCount = /* @__PURE__ */ new Set();
|
107042
106641
|
let indexesCount = 0;
|
107043
106642
|
let foreignKeysCount = 0;
|
107044
|
-
let checksCount = 0;
|
107045
106643
|
const tableToPk = {};
|
107046
106644
|
let tableToGeneratedColumnsInfo = {};
|
107047
106645
|
for (const column4 of columns) {
|
@@ -107099,8 +106697,7 @@ ${withStyle.errorWarning(
|
|
107099
106697
|
compositePrimaryKeys: {},
|
107100
106698
|
indexes: {},
|
107101
106699
|
foreignKeys: {},
|
107102
|
-
uniqueConstraints: {}
|
107103
|
-
checkConstraints: {}
|
106700
|
+
uniqueConstraints: {}
|
107104
106701
|
};
|
107105
106702
|
} else {
|
107106
106703
|
result[tableName].columns[columnName] = newColumn;
|
@@ -107214,56 +106811,6 @@ WHERE
|
|
107214
106811
|
progressCallback("indexes", indexesCount, "done");
|
107215
106812
|
progressCallback("enums", 0, "done");
|
107216
106813
|
}
|
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
106814
|
return {
|
107268
106815
|
version: "6",
|
107269
106816
|
dialect: "sqlite",
|
@@ -108705,7 +108252,6 @@ var init_mysqlSerializer = __esm({
|
|
108705
108252
|
indexes,
|
108706
108253
|
foreignKeys,
|
108707
108254
|
schema: schema4,
|
108708
|
-
checks,
|
108709
108255
|
primaryKeys,
|
108710
108256
|
uniqueConstraints
|
108711
108257
|
} = getTableConfig3(table4);
|
@@ -108714,8 +108260,6 @@ var init_mysqlSerializer = __esm({
|
|
108714
108260
|
const foreignKeysObject = {};
|
108715
108261
|
const primaryKeysObject = {};
|
108716
108262
|
const uniqueConstraintObject = {};
|
108717
|
-
const checkConstraintObject = {};
|
108718
|
-
let checksInTable = {};
|
108719
108263
|
columns.forEach((column4) => {
|
108720
108264
|
const notNull = column4.notNull;
|
108721
108265
|
const sqlTypeLowered = column4.getSQLType().toLowerCase();
|
@@ -108928,32 +108472,6 @@ We have encountered a collision between the index name on columns ${source_defau
|
|
108928
108472
|
lock: value.config.lock
|
108929
108473
|
};
|
108930
108474
|
});
|
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
108475
|
if (!schema4) {
|
108958
108476
|
result[tableName] = {
|
108959
108477
|
name: tableName,
|
@@ -108961,8 +108479,7 @@ ${withStyle.errorWarning(
|
|
108961
108479
|
indexes: indexesObject,
|
108962
108480
|
foreignKeys: foreignKeysObject,
|
108963
108481
|
compositePrimaryKeys: primaryKeysObject,
|
108964
|
-
uniqueConstraints: uniqueConstraintObject
|
108965
|
-
checkConstraint: checkConstraintObject
|
108482
|
+
uniqueConstraints: uniqueConstraintObject
|
108966
108483
|
};
|
108967
108484
|
}
|
108968
108485
|
}
|
@@ -108989,7 +108506,6 @@ ${withStyle.errorWarning(
|
|
108989
108506
|
let tablesCount = /* @__PURE__ */ new Set();
|
108990
108507
|
let indexesCount = 0;
|
108991
108508
|
let foreignKeysCount = 0;
|
108992
|
-
let checksCount = 0;
|
108993
108509
|
const idxs = await db2.query(
|
108994
108510
|
`select * from INFORMATION_SCHEMA.STATISTICS
|
108995
108511
|
WHERE INFORMATION_SCHEMA.STATISTICS.TABLE_SCHEMA = '${inputSchema}' and INFORMATION_SCHEMA.STATISTICS.INDEX_NAME != 'PRIMARY';`
|
@@ -109084,8 +108600,7 @@ ${withStyle.errorWarning(
|
|
109084
108600
|
compositePrimaryKeys: {},
|
109085
108601
|
indexes: {},
|
109086
108602
|
foreignKeys: {},
|
109087
|
-
uniqueConstraints: {}
|
109088
|
-
checkConstraint: {}
|
108603
|
+
uniqueConstraints: {}
|
109089
108604
|
};
|
109090
108605
|
} else {
|
109091
108606
|
result[tableName].columns[columnName] = newColumn;
|
@@ -109234,38 +108749,6 @@ ${withStyle.errorWarning(
|
|
109234
108749
|
progressCallback("indexes", indexesCount, "done");
|
109235
108750
|
progressCallback("enums", 0, "done");
|
109236
108751
|
}
|
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
108752
|
return {
|
109270
108753
|
version: "5",
|
109271
108754
|
dialect: "mysql",
|