drizzle-kit 0.25.0-20acc2f → 0.25.0-22c3e40
Sign up to get free protection for your applications and to get access to all the features.
- package/api.d.mts +0 -82
- package/api.d.ts +0 -82
- package/api.js +95 -676
- package/api.mjs +95 -676
- package/bin.cjs +103 -759
- package/package.json +1 -1
- package/utils.js +6 -24
- package/utils.mjs +6 -24
package/bin.cjs
CHANGED
@@ -1315,11 +1315,6 @@ Is ${source_default.bold.blue(
|
|
1315
1315
|
count: 0,
|
1316
1316
|
name: "foreign keys",
|
1317
1317
|
status: "fetching"
|
1318
|
-
},
|
1319
|
-
checks: {
|
1320
|
-
count: 0,
|
1321
|
-
name: "check constraints",
|
1322
|
-
status: "fetching"
|
1323
1318
|
}
|
1324
1319
|
};
|
1325
1320
|
this.formatCount = (count) => {
|
@@ -1357,7 +1352,6 @@ Is ${source_default.bold.blue(
|
|
1357
1352
|
info2 += this.hasEnums ? this.statusText(spin, this.state.enums) : "";
|
1358
1353
|
info2 += this.statusText(spin, this.state.indexes);
|
1359
1354
|
info2 += this.statusText(spin, this.state.fks);
|
1360
|
-
info2 += this.statusText(spin, this.state.checks);
|
1361
1355
|
return info2;
|
1362
1356
|
}
|
1363
1357
|
};
|
@@ -5427,7 +5421,7 @@ var init_lib = __esm({
|
|
5427
5421
|
});
|
5428
5422
|
|
5429
5423
|
// src/serializer/mysqlSchema.ts
|
5430
|
-
var index, fk, column, tableV3, compositePK, uniqueConstraint,
|
5424
|
+
var index, fk, column, tableV3, compositePK, uniqueConstraint, tableV4, table, kitInternals, dialect, schemaHash, schemaInternalV3, schemaInternalV4, schemaInternalV5, schemaInternal, schemaV3, schemaV4, schemaV5, schema2, tableSquashedV4, tableSquashed, schemaSquashed, schemaSquashedV4, MySqlSquasher, squashMysqlScheme, mysqlSchema, mysqlSchemaV5, mysqlSchemaSquashed, backwardCompatibleMysqlSchema, dryMySql;
|
5431
5425
|
var init_mysqlSchema = __esm({
|
5432
5426
|
"src/serializer/mysqlSchema.ts"() {
|
5433
5427
|
"use strict";
|
@@ -5477,10 +5471,6 @@ var init_mysqlSchema = __esm({
|
|
5477
5471
|
name: stringType(),
|
5478
5472
|
columns: stringType().array()
|
5479
5473
|
}).strict();
|
5480
|
-
checkConstraint = objectType({
|
5481
|
-
name: stringType(),
|
5482
|
-
value: stringType()
|
5483
|
-
}).strict();
|
5484
5474
|
tableV4 = objectType({
|
5485
5475
|
name: stringType(),
|
5486
5476
|
schema: stringType().optional(),
|
@@ -5494,8 +5484,7 @@ var init_mysqlSchema = __esm({
|
|
5494
5484
|
indexes: recordType(stringType(), index),
|
5495
5485
|
foreignKeys: recordType(stringType(), fk),
|
5496
5486
|
compositePrimaryKeys: recordType(stringType(), compositePK),
|
5497
|
-
uniqueConstraints: recordType(stringType(), uniqueConstraint).default({})
|
5498
|
-
checkConstraint: recordType(stringType(), checkConstraint).default({})
|
5487
|
+
uniqueConstraints: recordType(stringType(), uniqueConstraint).default({})
|
5499
5488
|
}).strict();
|
5500
5489
|
kitInternals = objectType({
|
5501
5490
|
tables: recordType(
|
@@ -5572,8 +5561,7 @@ var init_mysqlSchema = __esm({
|
|
5572
5561
|
indexes: recordType(stringType(), stringType()),
|
5573
5562
|
foreignKeys: recordType(stringType(), stringType()),
|
5574
5563
|
compositePrimaryKeys: recordType(stringType(), stringType()),
|
5575
|
-
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
5576
|
-
checkConstraints: recordType(stringType(), stringType()).default({})
|
5564
|
+
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
5577
5565
|
}).strict();
|
5578
5566
|
schemaSquashed = objectType({
|
5579
5567
|
version: literalType("5"),
|
@@ -5640,13 +5628,6 @@ var init_mysqlSchema = __esm({
|
|
5640
5628
|
onDelete
|
5641
5629
|
});
|
5642
5630
|
return result;
|
5643
|
-
},
|
5644
|
-
squashCheck: (input) => {
|
5645
|
-
return `${input.name};${input.value}`;
|
5646
|
-
},
|
5647
|
-
unsquashCheck: (input) => {
|
5648
|
-
const [name, value] = input.split(";");
|
5649
|
-
return { name, value };
|
5650
5631
|
}
|
5651
5632
|
};
|
5652
5633
|
squashMysqlScheme = (json) => {
|
@@ -5667,9 +5648,6 @@ var init_mysqlSchema = __esm({
|
|
5667
5648
|
return MySqlSquasher.squashUnique(unq);
|
5668
5649
|
}
|
5669
5650
|
);
|
5670
|
-
const squashedCheckConstraints = mapValues(it[1].checkConstraint, (check2) => {
|
5671
|
-
return MySqlSquasher.squashCheck(check2);
|
5672
|
-
});
|
5673
5651
|
return [
|
5674
5652
|
it[0],
|
5675
5653
|
{
|
@@ -5678,8 +5656,7 @@ var init_mysqlSchema = __esm({
|
|
5678
5656
|
indexes: squashedIndexes,
|
5679
5657
|
foreignKeys: squashedFKs,
|
5680
5658
|
compositePrimaryKeys: squashedPKs,
|
5681
|
-
uniqueConstraints: squashedUniqueConstraints
|
5682
|
-
checkConstraints: squashedCheckConstraints
|
5659
|
+
uniqueConstraints: squashedUniqueConstraints
|
5683
5660
|
}
|
5684
5661
|
];
|
5685
5662
|
})
|
@@ -5729,7 +5706,7 @@ var init_vector = __esm({
|
|
5729
5706
|
});
|
5730
5707
|
|
5731
5708
|
// src/serializer/pgSchema.ts
|
5732
|
-
var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, indexColumn, index2, indexV4, indexV5, indexV6, fk2, sequenceSchema, sequenceSquashed, columnV7, column2,
|
5709
|
+
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;
|
5733
5710
|
var init_pgSchema = __esm({
|
5734
5711
|
"src/serializer/pgSchema.ts"() {
|
5735
5712
|
"use strict";
|
@@ -5893,10 +5870,6 @@ var init_pgSchema = __esm({
|
|
5893
5870
|
}).optional(),
|
5894
5871
|
identity: sequenceSchema.merge(objectType({ type: enumType(["always", "byDefault"]) })).optional()
|
5895
5872
|
}).strict();
|
5896
|
-
checkConstraint2 = objectType({
|
5897
|
-
name: stringType(),
|
5898
|
-
value: stringType()
|
5899
|
-
}).strict();
|
5900
5873
|
columnSquashed = objectType({
|
5901
5874
|
name: stringType(),
|
5902
5875
|
type: stringType(),
|
@@ -5969,8 +5942,7 @@ var init_pgSchema = __esm({
|
|
5969
5942
|
indexes: recordType(stringType(), index2),
|
5970
5943
|
foreignKeys: recordType(stringType(), fk2),
|
5971
5944
|
compositePrimaryKeys: recordType(stringType(), compositePK2),
|
5972
|
-
uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
|
5973
|
-
checkConstraints: recordType(stringType(), checkConstraint2).default({})
|
5945
|
+
uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
|
5974
5946
|
}).strict();
|
5975
5947
|
schemaHash2 = objectType({
|
5976
5948
|
id: stringType(),
|
@@ -6078,8 +6050,7 @@ var init_pgSchema = __esm({
|
|
6078
6050
|
indexes: recordType(stringType(), stringType()),
|
6079
6051
|
foreignKeys: recordType(stringType(), stringType()),
|
6080
6052
|
compositePrimaryKeys: recordType(stringType(), stringType()),
|
6081
|
-
uniqueConstraints: recordType(stringType(), stringType())
|
6082
|
-
checkConstraints: recordType(stringType(), stringType())
|
6053
|
+
uniqueConstraints: recordType(stringType(), stringType())
|
6083
6054
|
}).strict();
|
6084
6055
|
tableSquashedV42 = objectType({
|
6085
6056
|
name: stringType(),
|
@@ -6261,16 +6232,6 @@ var init_pgSchema = __esm({
|
|
6261
6232
|
cache: splitted[6] !== "undefined" ? splitted[6] : void 0,
|
6262
6233
|
cycle: splitted[7] === "true"
|
6263
6234
|
};
|
6264
|
-
},
|
6265
|
-
squashCheck: (check2) => {
|
6266
|
-
return `${check2.name};${check2.value}`;
|
6267
|
-
},
|
6268
|
-
unsquashCheck: (input) => {
|
6269
|
-
const [
|
6270
|
-
name,
|
6271
|
-
value
|
6272
|
-
] = input.split(";");
|
6273
|
-
return { name, value };
|
6274
6235
|
}
|
6275
6236
|
};
|
6276
6237
|
squashPgScheme = (json, action) => {
|
@@ -6303,12 +6264,6 @@ var init_pgSchema = __esm({
|
|
6303
6264
|
return PgSquasher.squashUnique(unq);
|
6304
6265
|
}
|
6305
6266
|
);
|
6306
|
-
const squashedChecksContraints = mapValues(
|
6307
|
-
it[1].checkConstraints,
|
6308
|
-
(check2) => {
|
6309
|
-
return PgSquasher.squashCheck(check2);
|
6310
|
-
}
|
6311
|
-
);
|
6312
6267
|
return [
|
6313
6268
|
it[0],
|
6314
6269
|
{
|
@@ -6318,8 +6273,7 @@ var init_pgSchema = __esm({
|
|
6318
6273
|
indexes: squashedIndexes,
|
6319
6274
|
foreignKeys: squashedFKs,
|
6320
6275
|
compositePrimaryKeys: squashedPKs,
|
6321
|
-
uniqueConstraints: squashedUniqueConstraints
|
6322
|
-
checkConstraints: squashedChecksContraints
|
6276
|
+
uniqueConstraints: squashedUniqueConstraints
|
6323
6277
|
}
|
6324
6278
|
];
|
6325
6279
|
})
|
@@ -6364,7 +6318,7 @@ var init_pgSchema = __esm({
|
|
6364
6318
|
});
|
6365
6319
|
|
6366
6320
|
// src/serializer/sqliteSchema.ts
|
6367
|
-
var index3, fk3, compositePK3, column3, tableV33, uniqueConstraint3,
|
6321
|
+
var index3, fk3, compositePK3, column3, tableV33, uniqueConstraint3, table3, dialect2, schemaHash3, schemaInternalV32, schemaInternalV42, schemaInternalV52, kitInternals3, latestVersion, schemaInternal2, schemaV32, schemaV42, schemaV52, schema3, tableSquashed3, schemaSquashed2, SQLiteSquasher, squashSqliteScheme, drySQLite, sqliteSchemaV5, sqliteSchema, SQLiteSchemaSquashed, backwardCompatibleSqliteSchema;
|
6368
6322
|
var init_sqliteSchema = __esm({
|
6369
6323
|
"src/serializer/sqliteSchema.ts"() {
|
6370
6324
|
"use strict";
|
@@ -6411,18 +6365,13 @@ var init_sqliteSchema = __esm({
|
|
6411
6365
|
name: stringType(),
|
6412
6366
|
columns: stringType().array()
|
6413
6367
|
}).strict();
|
6414
|
-
checkConstraint3 = objectType({
|
6415
|
-
name: stringType(),
|
6416
|
-
value: stringType()
|
6417
|
-
}).strict();
|
6418
6368
|
table3 = objectType({
|
6419
6369
|
name: stringType(),
|
6420
6370
|
columns: recordType(stringType(), column3),
|
6421
6371
|
indexes: recordType(stringType(), index3),
|
6422
6372
|
foreignKeys: recordType(stringType(), fk3),
|
6423
6373
|
compositePrimaryKeys: recordType(stringType(), compositePK3),
|
6424
|
-
uniqueConstraints: recordType(stringType(), uniqueConstraint3).default({})
|
6425
|
-
checkConstraints: recordType(stringType(), checkConstraint3).default({})
|
6374
|
+
uniqueConstraints: recordType(stringType(), uniqueConstraint3).default({})
|
6426
6375
|
}).strict();
|
6427
6376
|
dialect2 = enumType(["sqlite"]);
|
6428
6377
|
schemaHash3 = objectType({
|
@@ -6484,8 +6433,7 @@ var init_sqliteSchema = __esm({
|
|
6484
6433
|
indexes: recordType(stringType(), stringType()),
|
6485
6434
|
foreignKeys: recordType(stringType(), stringType()),
|
6486
6435
|
compositePrimaryKeys: recordType(stringType(), stringType()),
|
6487
|
-
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
6488
|
-
checkConstraints: recordType(stringType(), stringType()).default({})
|
6436
|
+
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
6489
6437
|
}).strict();
|
6490
6438
|
schemaSquashed2 = objectType({
|
6491
6439
|
version: latestVersion,
|
@@ -6567,16 +6515,6 @@ var init_sqliteSchema = __esm({
|
|
6567
6515
|
},
|
6568
6516
|
unsquashPK: (pk) => {
|
6569
6517
|
return pk.split(",");
|
6570
|
-
},
|
6571
|
-
squashCheck: (check2) => {
|
6572
|
-
return `${check2.name};${check2.value}`;
|
6573
|
-
},
|
6574
|
-
unsquashCheck: (input) => {
|
6575
|
-
const [
|
6576
|
-
name,
|
6577
|
-
value
|
6578
|
-
] = input.split(";");
|
6579
|
-
return { name, value };
|
6580
6518
|
}
|
6581
6519
|
};
|
6582
6520
|
squashSqliteScheme = (json, action) => {
|
@@ -6603,12 +6541,6 @@ var init_sqliteSchema = __esm({
|
|
6603
6541
|
return SQLiteSquasher.squashUnique(unq);
|
6604
6542
|
}
|
6605
6543
|
);
|
6606
|
-
const squashedCheckConstraints = mapValues(
|
6607
|
-
it[1].checkConstraints,
|
6608
|
-
(check2) => {
|
6609
|
-
return SQLiteSquasher.squashCheck(check2);
|
6610
|
-
}
|
6611
|
-
);
|
6612
6544
|
return [
|
6613
6545
|
it[0],
|
6614
6546
|
{
|
@@ -6617,8 +6549,7 @@ var init_sqliteSchema = __esm({
|
|
6617
6549
|
indexes: squashedIndexes,
|
6618
6550
|
foreignKeys: squashedFKs,
|
6619
6551
|
compositePrimaryKeys: squashedPKs,
|
6620
|
-
uniqueConstraints: squashedUniqueConstraints
|
6621
|
-
checkConstraints: squashedCheckConstraints
|
6552
|
+
uniqueConstraints: squashedUniqueConstraints
|
6622
6553
|
}
|
6623
6554
|
];
|
6624
6555
|
})
|
@@ -18017,7 +17948,6 @@ var init_mysqlSerializer = __esm({
|
|
18017
17948
|
indexes,
|
18018
17949
|
foreignKeys,
|
18019
17950
|
schema: schema5,
|
18020
|
-
checks,
|
18021
17951
|
primaryKeys,
|
18022
17952
|
uniqueConstraints
|
18023
17953
|
} = (0, import_mysql_core3.getTableConfig)(table4);
|
@@ -18026,8 +17956,6 @@ var init_mysqlSerializer = __esm({
|
|
18026
17956
|
const foreignKeysObject = {};
|
18027
17957
|
const primaryKeysObject = {};
|
18028
17958
|
const uniqueConstraintObject = {};
|
18029
|
-
const checkConstraintObject = {};
|
18030
|
-
let checksInTable = {};
|
18031
17959
|
columns.forEach((column7) => {
|
18032
17960
|
const name = getColumnCasing(column7, casing2);
|
18033
17961
|
const notNull = column7.notNull;
|
@@ -18259,32 +18187,6 @@ We have encountered a collision between the index name on columns ${source_defau
|
|
18259
18187
|
lock: value.config.lock
|
18260
18188
|
};
|
18261
18189
|
});
|
18262
|
-
checks.forEach((check2) => {
|
18263
|
-
check2;
|
18264
|
-
const checkName = check2.name;
|
18265
|
-
if (typeof checksInTable[tableName] !== "undefined") {
|
18266
|
-
if (checksInTable[tableName].includes(check2.name)) {
|
18267
|
-
console.log(
|
18268
|
-
`
|
18269
|
-
${withStyle.errorWarning(
|
18270
|
-
`We've found duplicated check constraint name in ${source_default.underline.blue(
|
18271
|
-
tableName
|
18272
|
-
)}. Please rename your check constraint in the ${source_default.underline.blue(
|
18273
|
-
tableName
|
18274
|
-
)} table`
|
18275
|
-
)}`
|
18276
|
-
);
|
18277
|
-
process.exit(1);
|
18278
|
-
}
|
18279
|
-
checksInTable[tableName].push(checkName);
|
18280
|
-
} else {
|
18281
|
-
checksInTable[tableName] = [check2.name];
|
18282
|
-
}
|
18283
|
-
checkConstraintObject[checkName] = {
|
18284
|
-
name: checkName,
|
18285
|
-
value: dialect4.sqlToQuery(check2.value).sql
|
18286
|
-
};
|
18287
|
-
});
|
18288
18190
|
if (!schema5) {
|
18289
18191
|
result[tableName] = {
|
18290
18192
|
name: tableName,
|
@@ -18292,8 +18194,7 @@ ${withStyle.errorWarning(
|
|
18292
18194
|
indexes: indexesObject,
|
18293
18195
|
foreignKeys: foreignKeysObject,
|
18294
18196
|
compositePrimaryKeys: primaryKeysObject,
|
18295
|
-
uniqueConstraints: uniqueConstraintObject
|
18296
|
-
checkConstraint: checkConstraintObject
|
18197
|
+
uniqueConstraints: uniqueConstraintObject
|
18297
18198
|
};
|
18298
18199
|
}
|
18299
18200
|
}
|
@@ -18320,7 +18221,6 @@ ${withStyle.errorWarning(
|
|
18320
18221
|
let tablesCount = /* @__PURE__ */ new Set();
|
18321
18222
|
let indexesCount = 0;
|
18322
18223
|
let foreignKeysCount = 0;
|
18323
|
-
let checksCount = 0;
|
18324
18224
|
const idxs = await db.query(
|
18325
18225
|
`select * from INFORMATION_SCHEMA.STATISTICS
|
18326
18226
|
WHERE INFORMATION_SCHEMA.STATISTICS.TABLE_SCHEMA = '${inputSchema}' and INFORMATION_SCHEMA.STATISTICS.INDEX_NAME != 'PRIMARY';`
|
@@ -18416,8 +18316,7 @@ ${withStyle.errorWarning(
|
|
18416
18316
|
compositePrimaryKeys: {},
|
18417
18317
|
indexes: {},
|
18418
18318
|
foreignKeys: {},
|
18419
|
-
uniqueConstraints: {}
|
18420
|
-
checkConstraint: {}
|
18319
|
+
uniqueConstraints: {}
|
18421
18320
|
};
|
18422
18321
|
} else {
|
18423
18322
|
result[tableName].columns[columnName] = newColumn;
|
@@ -18568,38 +18467,6 @@ ${withStyle.errorWarning(
|
|
18568
18467
|
progressCallback("indexes", indexesCount, "done");
|
18569
18468
|
progressCallback("enums", 0, "done");
|
18570
18469
|
}
|
18571
|
-
const checkConstraints = await db.query(
|
18572
|
-
`SELECT
|
18573
|
-
tc.table_name,
|
18574
|
-
tc.constraint_name,
|
18575
|
-
cc.check_clause
|
18576
|
-
FROM
|
18577
|
-
information_schema.table_constraints tc
|
18578
|
-
JOIN
|
18579
|
-
information_schema.check_constraints cc
|
18580
|
-
ON tc.constraint_name = cc.constraint_name
|
18581
|
-
WHERE
|
18582
|
-
tc.constraint_schema = '${inputSchema}'
|
18583
|
-
AND
|
18584
|
-
tc.constraint_type = 'CHECK';`
|
18585
|
-
);
|
18586
|
-
checksCount += checkConstraints.length;
|
18587
|
-
if (progressCallback) {
|
18588
|
-
progressCallback("checks", checksCount, "fetching");
|
18589
|
-
}
|
18590
|
-
for (const checkConstraintRow of checkConstraints) {
|
18591
|
-
const constraintName = checkConstraintRow["CONSTRAINT_NAME"];
|
18592
|
-
const constraintValue = checkConstraintRow["CHECK_CLAUSE"];
|
18593
|
-
const tableName = checkConstraintRow["TABLE_NAME"];
|
18594
|
-
const tableInResult = result[tableName];
|
18595
|
-
tableInResult.checkConstraint[constraintName] = {
|
18596
|
-
name: constraintName,
|
18597
|
-
value: constraintValue
|
18598
|
-
};
|
18599
|
-
}
|
18600
|
-
if (progressCallback) {
|
18601
|
-
progressCallback("checks", checksCount, "done");
|
18602
|
-
}
|
18603
18470
|
return {
|
18604
18471
|
version: "5",
|
18605
18472
|
dialect: "mysql",
|
@@ -18736,7 +18603,6 @@ var init_pgSerializer = __esm({
|
|
18736
18603
|
const sequencesToReturn = {};
|
18737
18604
|
const indexesInSchema = {};
|
18738
18605
|
for (const table4 of tables) {
|
18739
|
-
const checksInTable = {};
|
18740
18606
|
const {
|
18741
18607
|
name: tableName,
|
18742
18608
|
columns,
|
@@ -18752,7 +18618,6 @@ var init_pgSerializer = __esm({
|
|
18752
18618
|
}
|
18753
18619
|
const columnsObject = {};
|
18754
18620
|
const indexesObject = {};
|
18755
|
-
const checksObject = {};
|
18756
18621
|
const foreignKeysObject = {};
|
18757
18622
|
const primaryKeysObject = {};
|
18758
18623
|
const uniqueConstraintObject = {};
|
@@ -19020,33 +18885,6 @@ ${withStyle.errorWarning(
|
|
19020
18885
|
with: value.config.with ?? {}
|
19021
18886
|
};
|
19022
18887
|
});
|
19023
|
-
checks.forEach((check2) => {
|
19024
|
-
const checkName = check2.name;
|
19025
|
-
if (typeof checksInTable[`"${schema5 ?? "public"}"."${tableName}"`] !== "undefined") {
|
19026
|
-
if (checksInTable[`"${schema5 ?? "public"}"."${tableName}"`].includes(check2.name)) {
|
19027
|
-
console.log(
|
19028
|
-
`
|
19029
|
-
${withStyle.errorWarning(
|
19030
|
-
`We've found duplicated check constraint name across ${source_default.underline.blue(
|
19031
|
-
schema5 ?? "public"
|
19032
|
-
)} schema in ${source_default.underline.blue(
|
19033
|
-
tableName
|
19034
|
-
)}. Please rename your check constraint in either the ${source_default.underline.blue(
|
19035
|
-
tableName
|
19036
|
-
)} table or the table with the duplicated check contraint name`
|
19037
|
-
)}`
|
19038
|
-
);
|
19039
|
-
process.exit(1);
|
19040
|
-
}
|
19041
|
-
checksInTable[`"${schema5 ?? "public"}"."${tableName}"`].push(checkName);
|
19042
|
-
} else {
|
19043
|
-
checksInTable[`"${schema5 ?? "public"}"."${tableName}"`] = [check2.name];
|
19044
|
-
}
|
19045
|
-
checksObject[checkName] = {
|
19046
|
-
name: checkName,
|
19047
|
-
value: dialect4.sqlToQuery(check2.value).sql
|
19048
|
-
};
|
19049
|
-
});
|
19050
18888
|
const tableKey2 = `${schema5 ?? "public"}.${tableName}`;
|
19051
18889
|
result[tableKey2] = {
|
19052
18890
|
name: tableName,
|
@@ -19055,8 +18893,7 @@ ${withStyle.errorWarning(
|
|
19055
18893
|
indexes: indexesObject,
|
19056
18894
|
foreignKeys: foreignKeysObject,
|
19057
18895
|
compositePrimaryKeys: primaryKeysObject,
|
19058
|
-
uniqueConstraints: uniqueConstraintObject
|
19059
|
-
checkConstraints: checksObject
|
18896
|
+
uniqueConstraints: uniqueConstraintObject
|
19060
18897
|
};
|
19061
18898
|
}
|
19062
18899
|
for (const sequence of sequences) {
|
@@ -19147,7 +18984,6 @@ ${withStyle.errorWarning(
|
|
19147
18984
|
let indexesCount = 0;
|
19148
18985
|
let foreignKeysCount = 0;
|
19149
18986
|
let tableCount = 0;
|
19150
|
-
let checksCount = 0;
|
19151
18987
|
const sequencesToReturn = {};
|
19152
18988
|
const seqWhere = schemaFilters.map((t2) => `schemaname = '${t2}'`).join(" or ");
|
19153
18989
|
const allSequences = await db.query(
|
@@ -19219,8 +19055,7 @@ ${withStyle.errorWarning(
|
|
19219
19055
|
const indexToReturn = {};
|
19220
19056
|
const foreignKeysToReturn = {};
|
19221
19057
|
const primaryKeys = {};
|
19222
|
-
const
|
19223
|
-
const checkConstraints = {};
|
19058
|
+
const uniqueConstrains = {};
|
19224
19059
|
const tableResponse = await db.query(
|
19225
19060
|
`SELECT a.attrelid::regclass::text, a.attname, is_nullable, a.attndims as array_dimensions
|
19226
19061
|
, CASE WHEN a.atttypid = ANY ('{int,int8,int2}'::regtype[])
|
@@ -19258,97 +19093,55 @@ ${withStyle.errorWarning(
|
|
19258
19093
|
ORDER BY a.attnum;`
|
19259
19094
|
);
|
19260
19095
|
const tableConstraints = await db.query(
|
19261
|
-
`SELECT c.column_name,
|
19262
|
-
|
19263
|
-
|
19264
|
-
|
19265
|
-
|
19266
|
-
|
19267
|
-
FROM information_schema.table_constraints tc
|
19268
|
-
JOIN information_schema.constraint_column_usage AS ccu
|
19269
|
-
USING (constraint_schema, constraint_name)
|
19270
|
-
JOIN information_schema.columns AS c
|
19271
|
-
ON c.table_schema = tc.constraint_schema
|
19272
|
-
AND tc.table_name = c.table_name
|
19273
|
-
AND ccu.column_name = c.column_name
|
19274
|
-
JOIN pg_constraint con
|
19275
|
-
ON con.conname = tc.constraint_name
|
19276
|
-
AND con.conrelid = (
|
19277
|
-
SELECT oid
|
19278
|
-
FROM pg_class
|
19279
|
-
WHERE relname = tc.table_name
|
19280
|
-
AND relnamespace = (
|
19281
|
-
SELECT oid
|
19282
|
-
FROM pg_namespace
|
19283
|
-
WHERE nspname = tc.constraint_schema
|
19284
|
-
)
|
19285
|
-
)
|
19286
|
-
WHERE tc.table_name = '${tableName}' AND tc.constraint_schema = '${tableSchema}';`
|
19096
|
+
`SELECT c.column_name, c.data_type, constraint_type, constraint_name, constraint_schema
|
19097
|
+
FROM information_schema.table_constraints tc
|
19098
|
+
JOIN information_schema.constraint_column_usage AS ccu USING (constraint_schema, constraint_name)
|
19099
|
+
JOIN information_schema.columns AS c ON c.table_schema = tc.constraint_schema
|
19100
|
+
AND tc.table_name = c.table_name AND ccu.column_name = c.column_name
|
19101
|
+
WHERE tc.table_name = '${tableName}' and constraint_schema = '${tableSchema}';`
|
19287
19102
|
);
|
19288
|
-
const tableChecks = await db.query(`SELECT
|
19289
|
-
tc.constraint_name,
|
19290
|
-
tc.constraint_type,
|
19291
|
-
pg_get_constraintdef(con.oid) AS constraint_definition
|
19292
|
-
FROM
|
19293
|
-
information_schema.table_constraints AS tc
|
19294
|
-
JOIN pg_constraint AS con
|
19295
|
-
ON tc.constraint_name = con.conname
|
19296
|
-
AND con.conrelid = (
|
19297
|
-
SELECT oid
|
19298
|
-
FROM pg_class
|
19299
|
-
WHERE relname = tc.table_name
|
19300
|
-
AND relnamespace = (
|
19301
|
-
SELECT oid
|
19302
|
-
FROM pg_namespace
|
19303
|
-
WHERE nspname = tc.constraint_schema
|
19304
|
-
)
|
19305
|
-
)
|
19306
|
-
WHERE
|
19307
|
-
tc.table_name = '${tableName}'
|
19308
|
-
AND tc.constraint_schema = '${tableSchema}'
|
19309
|
-
AND tc.constraint_type = 'CHECK';`);
|
19310
19103
|
columnsCount += tableResponse.length;
|
19311
19104
|
if (progressCallback) {
|
19312
19105
|
progressCallback("columns", columnsCount, "fetching");
|
19313
19106
|
}
|
19314
19107
|
const tableForeignKeys = await db.query(
|
19315
19108
|
`SELECT
|
19316
|
-
|
19317
|
-
|
19318
|
-
|
19319
|
-
|
19320
|
-
|
19321
|
-
|
19322
|
-
|
19323
|
-
|
19324
|
-
|
19325
|
-
|
19326
|
-
|
19327
|
-
|
19328
|
-
|
19329
|
-
|
19330
|
-
|
19331
|
-
|
19332
|
-
|
19333
|
-
|
19334
|
-
|
19335
|
-
|
19336
|
-
|
19337
|
-
|
19338
|
-
|
19339
|
-
|
19340
|
-
|
19341
|
-
|
19342
|
-
|
19343
|
-
|
19344
|
-
|
19345
|
-
|
19346
|
-
|
19347
|
-
|
19348
|
-
|
19349
|
-
|
19350
|
-
|
19351
|
-
|
19109
|
+
con.contype AS constraint_type,
|
19110
|
+
nsp.nspname AS constraint_schema,
|
19111
|
+
con.conname AS constraint_name,
|
19112
|
+
rel.relname AS table_name,
|
19113
|
+
att.attname AS column_name,
|
19114
|
+
fnsp.nspname AS foreign_table_schema,
|
19115
|
+
frel.relname AS foreign_table_name,
|
19116
|
+
fatt.attname AS foreign_column_name,
|
19117
|
+
CASE con.confupdtype
|
19118
|
+
WHEN 'a' THEN 'NO ACTION'
|
19119
|
+
WHEN 'r' THEN 'RESTRICT'
|
19120
|
+
WHEN 'n' THEN 'SET NULL'
|
19121
|
+
WHEN 'c' THEN 'CASCADE'
|
19122
|
+
WHEN 'd' THEN 'SET DEFAULT'
|
19123
|
+
END AS update_rule,
|
19124
|
+
CASE con.confdeltype
|
19125
|
+
WHEN 'a' THEN 'NO ACTION'
|
19126
|
+
WHEN 'r' THEN 'RESTRICT'
|
19127
|
+
WHEN 'n' THEN 'SET NULL'
|
19128
|
+
WHEN 'c' THEN 'CASCADE'
|
19129
|
+
WHEN 'd' THEN 'SET DEFAULT'
|
19130
|
+
END AS delete_rule
|
19131
|
+
FROM
|
19132
|
+
pg_catalog.pg_constraint con
|
19133
|
+
JOIN pg_catalog.pg_class rel ON rel.oid = con.conrelid
|
19134
|
+
JOIN pg_catalog.pg_namespace nsp ON nsp.oid = con.connamespace
|
19135
|
+
LEFT JOIN pg_catalog.pg_attribute att ON att.attnum = ANY (con.conkey)
|
19136
|
+
AND att.attrelid = con.conrelid
|
19137
|
+
LEFT JOIN pg_catalog.pg_class frel ON frel.oid = con.confrelid
|
19138
|
+
LEFT JOIN pg_catalog.pg_namespace fnsp ON fnsp.oid = frel.relnamespace
|
19139
|
+
LEFT JOIN pg_catalog.pg_attribute fatt ON fatt.attnum = ANY (con.confkey)
|
19140
|
+
AND fatt.attrelid = con.confrelid
|
19141
|
+
WHERE
|
19142
|
+
nsp.nspname = '${tableSchema}'
|
19143
|
+
AND rel.relname = '${tableName}'
|
19144
|
+
AND con.contype IN ('f');`
|
19352
19145
|
);
|
19353
19146
|
foreignKeysCount += tableForeignKeys.length;
|
19354
19147
|
if (progressCallback) {
|
@@ -19390,29 +19183,16 @@ ${withStyle.errorWarning(
|
|
19390
19183
|
for (const unqs of uniqueConstrainsRows) {
|
19391
19184
|
const columnName = unqs.column_name;
|
19392
19185
|
const constraintName = unqs.constraint_name;
|
19393
|
-
if (typeof
|
19394
|
-
|
19186
|
+
if (typeof uniqueConstrains[constraintName] !== "undefined") {
|
19187
|
+
uniqueConstrains[constraintName].columns.push(columnName);
|
19395
19188
|
} else {
|
19396
|
-
|
19189
|
+
uniqueConstrains[constraintName] = {
|
19397
19190
|
columns: [columnName],
|
19398
19191
|
nullsNotDistinct: false,
|
19399
19192
|
name: constraintName
|
19400
19193
|
};
|
19401
19194
|
}
|
19402
19195
|
}
|
19403
|
-
checksCount += tableChecks.length;
|
19404
|
-
if (progressCallback) {
|
19405
|
-
progressCallback("checks", checksCount, "fetching");
|
19406
|
-
}
|
19407
|
-
for (const checks of tableChecks) {
|
19408
|
-
let checkValue = checks.constraint_definition;
|
19409
|
-
const constraintName = checks.constraint_name;
|
19410
|
-
checkValue = checkValue.replace(/^CHECK\s*\(\(/, "").replace(/\)\)\s*$/, "");
|
19411
|
-
checkConstraints[constraintName] = {
|
19412
|
-
name: constraintName,
|
19413
|
-
value: checkValue
|
19414
|
-
};
|
19415
|
-
}
|
19416
19196
|
for (const columnResponse of tableResponse) {
|
19417
19197
|
const columnName = columnResponse.attname;
|
19418
19198
|
const columnAdditionalDT = columnResponse.additional_dt;
|
@@ -19657,8 +19437,7 @@ ${withStyle.errorWarning(
|
|
19657
19437
|
indexes: indexToReturn,
|
19658
19438
|
foreignKeys: foreignKeysToReturn,
|
19659
19439
|
compositePrimaryKeys: primaryKeys,
|
19660
|
-
uniqueConstraints
|
19661
|
-
checkConstraints
|
19440
|
+
uniqueConstraints: uniqueConstrains
|
19662
19441
|
};
|
19663
19442
|
} catch (e2) {
|
19664
19443
|
rej(e2);
|
@@ -19676,7 +19455,6 @@ ${withStyle.errorWarning(
|
|
19676
19455
|
progressCallback("columns", columnsCount, "done");
|
19677
19456
|
progressCallback("indexes", indexesCount, "done");
|
19678
19457
|
progressCallback("fks", foreignKeysCount, "done");
|
19679
|
-
progressCallback("checks", checksCount, "done");
|
19680
19458
|
}
|
19681
19459
|
const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
|
19682
19460
|
return {
|
@@ -19749,8 +19527,6 @@ ${withStyle.errorWarning(
|
|
19749
19527
|
}
|
19750
19528
|
return columnDefaultAsString;
|
19751
19529
|
}
|
19752
|
-
} else if (column7.data_type.includes("numeric")) {
|
19753
|
-
return columnDefaultAsString.includes("'") ? columnDefaultAsString : `'${columnDefaultAsString}'`;
|
19754
19530
|
} else if (column7.data_type === "json" || column7.data_type === "jsonb") {
|
19755
19531
|
const jsonWithoutSpaces = JSON.stringify(JSON.parse(columnDefaultAsString.slice(1, -1)));
|
19756
19532
|
return `'${jsonWithoutSpaces}'::${column7.data_type}`;
|
@@ -19892,13 +19668,10 @@ var init_sqliteSerializer = __esm({
|
|
19892
19668
|
const foreignKeysObject = {};
|
19893
19669
|
const primaryKeysObject = {};
|
19894
19670
|
const uniqueConstraintObject = {};
|
19895
|
-
const checkConstraintObject = {};
|
19896
|
-
const checksInTable = {};
|
19897
19671
|
const {
|
19898
19672
|
name: tableName,
|
19899
19673
|
columns,
|
19900
19674
|
indexes,
|
19901
|
-
checks,
|
19902
19675
|
foreignKeys: tableForeignKeys,
|
19903
19676
|
primaryKeys,
|
19904
19677
|
uniqueConstraints
|
@@ -20075,39 +19848,13 @@ The unique constraint ${source_default.underline.blue(
|
|
20075
19848
|
columnsObject[getColumnCasing(it.columns[0], casing2)].primaryKey = true;
|
20076
19849
|
}
|
20077
19850
|
});
|
20078
|
-
checks.forEach((check2) => {
|
20079
|
-
const checkName = check2.name;
|
20080
|
-
if (typeof checksInTable[tableName] !== "undefined") {
|
20081
|
-
if (checksInTable[tableName].includes(check2.name)) {
|
20082
|
-
console.log(
|
20083
|
-
`
|
20084
|
-
${withStyle.errorWarning(
|
20085
|
-
`We've found duplicated check constraint name in ${source_default.underline.blue(
|
20086
|
-
tableName
|
20087
|
-
)}. Please rename your check constraint in the ${source_default.underline.blue(
|
20088
|
-
tableName
|
20089
|
-
)} table`
|
20090
|
-
)}`
|
20091
|
-
);
|
20092
|
-
process.exit(1);
|
20093
|
-
}
|
20094
|
-
checksInTable[tableName].push(checkName);
|
20095
|
-
} else {
|
20096
|
-
checksInTable[tableName] = [check2.name];
|
20097
|
-
}
|
20098
|
-
checkConstraintObject[checkName] = {
|
20099
|
-
name: checkName,
|
20100
|
-
value: dialect4.sqlToQuery(check2.value).sql
|
20101
|
-
};
|
20102
|
-
});
|
20103
19851
|
result[tableName] = {
|
20104
19852
|
name: tableName,
|
20105
19853
|
columns: columnsObject,
|
20106
19854
|
indexes: indexesObject,
|
20107
19855
|
foreignKeys: foreignKeysObject,
|
20108
19856
|
compositePrimaryKeys: primaryKeysObject,
|
20109
|
-
uniqueConstraints: uniqueConstraintObject
|
20110
|
-
checkConstraints: checkConstraintObject
|
19857
|
+
uniqueConstraints: uniqueConstraintObject
|
20111
19858
|
};
|
20112
19859
|
}
|
20113
19860
|
return {
|
@@ -20154,7 +19901,6 @@ ${withStyle.errorWarning(
|
|
20154
19901
|
let tablesCount = /* @__PURE__ */ new Set();
|
20155
19902
|
let indexesCount = 0;
|
20156
19903
|
let foreignKeysCount = 0;
|
20157
|
-
let checksCount = 0;
|
20158
19904
|
const tableToPk = {};
|
20159
19905
|
let tableToGeneratedColumnsInfo = {};
|
20160
19906
|
for (const column7 of columns) {
|
@@ -20213,8 +19959,7 @@ ${withStyle.errorWarning(
|
|
20213
19959
|
compositePrimaryKeys: {},
|
20214
19960
|
indexes: {},
|
20215
19961
|
foreignKeys: {},
|
20216
|
-
uniqueConstraints: {}
|
20217
|
-
checkConstraints: {}
|
19962
|
+
uniqueConstraints: {}
|
20218
19963
|
};
|
20219
19964
|
} else {
|
20220
19965
|
result[tableName].columns[columnName] = newColumn;
|
@@ -20330,57 +20075,6 @@ WHERE
|
|
20330
20075
|
progressCallback("indexes", indexesCount, "done");
|
20331
20076
|
progressCallback("enums", 0, "done");
|
20332
20077
|
}
|
20333
|
-
const namedCheckPattern = /CONSTRAINT\s*["']?(\w+)["']?\s*CHECK\s*\((.*?)\)/gi;
|
20334
|
-
const unnamedCheckPattern = /CHECK\s*\((.*?)\)/gi;
|
20335
|
-
let checkCounter = 0;
|
20336
|
-
const checkConstraints = {};
|
20337
|
-
const checks = await db.query(`SELECT name as "tableName", sql as "sql"
|
20338
|
-
FROM sqlite_master
|
20339
|
-
WHERE type = 'table' AND name != 'sqlite_sequence';`);
|
20340
|
-
for (const check2 of checks) {
|
20341
|
-
if (!tablesFilter(check2.tableName))
|
20342
|
-
continue;
|
20343
|
-
const { tableName, sql } = check2;
|
20344
|
-
let namedChecks = [...sql.matchAll(namedCheckPattern)];
|
20345
|
-
if (namedChecks.length > 0) {
|
20346
|
-
namedChecks.forEach(([_2, checkName, checkValue]) => {
|
20347
|
-
checkConstraints[checkName] = {
|
20348
|
-
name: checkName,
|
20349
|
-
value: checkValue.trim()
|
20350
|
-
};
|
20351
|
-
});
|
20352
|
-
} else {
|
20353
|
-
let unnamedChecks = [...sql.matchAll(unnamedCheckPattern)];
|
20354
|
-
unnamedChecks.forEach(([_2, checkValue]) => {
|
20355
|
-
let checkName = `${tableName}_check_${++checkCounter}`;
|
20356
|
-
checkConstraints[checkName] = {
|
20357
|
-
name: checkName,
|
20358
|
-
value: checkValue.trim()
|
20359
|
-
};
|
20360
|
-
});
|
20361
|
-
}
|
20362
|
-
checksCount += Object.values(checkConstraints).length;
|
20363
|
-
if (progressCallback) {
|
20364
|
-
progressCallback("checks", checksCount, "fetching");
|
20365
|
-
}
|
20366
|
-
const table4 = result[tableName];
|
20367
|
-
if (!table4) {
|
20368
|
-
result[tableName] = {
|
20369
|
-
name: tableName,
|
20370
|
-
columns: {},
|
20371
|
-
compositePrimaryKeys: {},
|
20372
|
-
indexes: {},
|
20373
|
-
foreignKeys: {},
|
20374
|
-
uniqueConstraints: {},
|
20375
|
-
checkConstraints
|
20376
|
-
};
|
20377
|
-
} else {
|
20378
|
-
result[tableName].checkConstraints = checkConstraints;
|
20379
|
-
}
|
20380
|
-
}
|
20381
|
-
if (progressCallback) {
|
20382
|
-
progressCallback("checks", checksCount, "done");
|
20383
|
-
}
|
20384
20078
|
return {
|
20385
20079
|
version: "6",
|
20386
20080
|
dialect: "sqlite",
|
@@ -23121,21 +22815,6 @@ var init_jsonDiffer = __esm({
|
|
23121
22815
|
return !it[0].endsWith("__deleted") && !it[0].endsWith("__added");
|
23122
22816
|
})
|
23123
22817
|
);
|
23124
|
-
const addedCheckConstraints = Object.fromEntries(
|
23125
|
-
Object.entries(table4.checkConstraints || {}).filter((it) => {
|
23126
|
-
return it[0].endsWith("__added");
|
23127
|
-
})
|
23128
|
-
);
|
23129
|
-
const deletedCheckConstraints = Object.fromEntries(
|
23130
|
-
Object.entries(table4.checkConstraints || {}).filter((it) => {
|
23131
|
-
return it[0].endsWith("__deleted");
|
23132
|
-
})
|
23133
|
-
);
|
23134
|
-
const alteredCheckConstraints = Object.fromEntries(
|
23135
|
-
Object.entries(table4.checkConstraints || {}).filter((it) => {
|
23136
|
-
return !it[0].endsWith("__deleted") && !it[0].endsWith("__added");
|
23137
|
-
})
|
23138
|
-
);
|
23139
22818
|
const mappedAltered = altered.map((it) => alternationsInColumn(it)).filter(Boolean);
|
23140
22819
|
return {
|
23141
22820
|
name: table4.name,
|
@@ -23152,10 +22831,7 @@ var init_jsonDiffer = __esm({
|
|
23152
22831
|
alteredCompositePKs,
|
23153
22832
|
addedUniqueConstraints,
|
23154
22833
|
deletedUniqueConstraints,
|
23155
|
-
alteredUniqueConstraints
|
23156
|
-
addedCheckConstraints,
|
23157
|
-
deletedCheckConstraints,
|
23158
|
-
alteredCheckConstraints
|
22834
|
+
alteredUniqueConstraints
|
23159
22835
|
};
|
23160
22836
|
};
|
23161
22837
|
alternationsInColumn = (column7) => {
|
@@ -23409,32 +23085,6 @@ var init_jsonDiffer = __esm({
|
|
23409
23085
|
};
|
23410
23086
|
}
|
23411
23087
|
return it;
|
23412
|
-
}).map((it) => {
|
23413
|
-
if ("" in it) {
|
23414
|
-
return {
|
23415
|
-
...it,
|
23416
|
-
autoincrement: {
|
23417
|
-
type: "changed",
|
23418
|
-
old: it.autoincrement.__old,
|
23419
|
-
new: it.autoincrement.__new
|
23420
|
-
}
|
23421
|
-
};
|
23422
|
-
}
|
23423
|
-
if ("autoincrement__added" in it) {
|
23424
|
-
const { autoincrement__added, ...others } = it;
|
23425
|
-
return {
|
23426
|
-
...others,
|
23427
|
-
autoincrement: { type: "added", value: it.autoincrement__added }
|
23428
|
-
};
|
23429
|
-
}
|
23430
|
-
if ("autoincrement__deleted" in it) {
|
23431
|
-
const { autoincrement__deleted, ...others } = it;
|
23432
|
-
return {
|
23433
|
-
...others,
|
23434
|
-
autoincrement: { type: "deleted", value: it.autoincrement__deleted }
|
23435
|
-
};
|
23436
|
-
}
|
23437
|
-
return it;
|
23438
23088
|
}).filter(Boolean);
|
23439
23089
|
return result[0];
|
23440
23090
|
};
|
@@ -23455,7 +23105,7 @@ function fromJson(statements, dialect4, action, json2) {
|
|
23455
23105
|
}).filter((it) => it !== "");
|
23456
23106
|
return result;
|
23457
23107
|
}
|
23458
|
-
var pgNativeTypes, isPgNativeType, Convertor, PgCreateTableConvertor, MySqlCreateTableConvertor, SQLiteCreateTableConvertor, PgAlterTableAlterColumnSetGenerated, PgAlterTableAlterColumnDropGenerated, PgAlterTableAlterColumnAlterGenerated, PgAlterTableAddUniqueConstraintConvertor, PgAlterTableDropUniqueConstraintConvertor,
|
23108
|
+
var pgNativeTypes, isPgNativeType, Convertor, PgCreateTableConvertor, MySqlCreateTableConvertor, SQLiteCreateTableConvertor, PgAlterTableAlterColumnSetGenerated, PgAlterTableAlterColumnDropGenerated, PgAlterTableAlterColumnAlterGenerated, PgAlterTableAddUniqueConstraintConvertor, PgAlterTableDropUniqueConstraintConvertor, MySQLAlterTableAddUniqueConstraintConvertor, MySQLAlterTableDropUniqueConstraintConvertor, CreatePgSequenceConvertor, DropPgSequenceConvertor, RenamePgSequenceConvertor, MovePgSequenceConvertor, AlterPgSequenceConvertor, CreateTypeEnumConvertor, DropTypeEnumConvertor, AlterTypeAddValueConvertor, AlterTypeSetSchemaConvertor, AlterRenameTypeConvertor, AlterTypeDropValueConvertor, PgDropTableConvertor, MySQLDropTableConvertor, SQLiteDropTableConvertor, PgRenameTableConvertor, SqliteRenameTableConvertor, MySqlRenameTableConvertor, PgAlterTableRenameColumnConvertor, MySqlAlterTableRenameColumnConvertor, SQLiteAlterTableRenameColumnConvertor, PgAlterTableDropColumnConvertor, MySqlAlterTableDropColumnConvertor, SQLiteAlterTableDropColumnConvertor, PgAlterTableAddColumnConvertor, MySqlAlterTableAddColumnConvertor, SQLiteAlterTableAddColumnConvertor, PgAlterTableAlterColumnSetTypeConvertor, PgAlterTableAlterColumnSetDefaultConvertor, PgAlterTableAlterColumnDropDefaultConvertor, PgAlterTableAlterColumnDropGeneratedConvertor, PgAlterTableAlterColumnSetExpressionConvertor, PgAlterTableAlterColumnAlterrGeneratedConvertor, SqliteAlterTableAlterColumnDropGeneratedConvertor, SqliteAlterTableAlterColumnSetExpressionConvertor, SqliteAlterTableAlterColumnAlterGeneratedConvertor, MySqlAlterTableAlterColumnAlterrGeneratedConvertor, MySqlAlterTableAddPk, MySqlAlterTableDropPk, LibSQLModifyColumn, MySqlModifyColumn, PgAlterTableCreateCompositePrimaryKeyConvertor, PgAlterTableDeleteCompositePrimaryKeyConvertor, PgAlterTableAlterCompositePrimaryKeyConvertor, MySqlAlterTableCreateCompositePrimaryKeyConvertor, MySqlAlterTableDeleteCompositePrimaryKeyConvertor, MySqlAlterTableAlterCompositePrimaryKeyConvertor, PgAlterTableAlterColumnSetPrimaryKeyConvertor, PgAlterTableAlterColumnDropPrimaryKeyConvertor, PgAlterTableAlterColumnSetNotNullConvertor, PgAlterTableAlterColumnDropNotNullConvertor, PgCreateForeignKeyConvertor, LibSQLCreateForeignKeyConvertor, MySqlCreateForeignKeyConvertor, PgAlterForeignKeyConvertor, PgDeleteForeignKeyConvertor, MySqlDeleteForeignKeyConvertor, CreatePgIndexConvertor, CreateMySqlIndexConvertor, CreateSqliteIndexConvertor, PgDropIndexConvertor, PgCreateSchemaConvertor, PgRenameSchemaConvertor, PgDropSchemaConvertor, PgAlterTableSetSchemaConvertor, PgAlterTableSetNewSchemaConvertor, PgAlterTableRemoveFromSchemaConvertor, SqliteDropIndexConvertor, MySqlDropIndexConvertor, SQLiteRecreateTableConvertor, LibSQLRecreateTableConvertor, convertors;
|
23459
23109
|
var init_sqlgenerator = __esm({
|
23460
23110
|
"src/sqlgenerator.ts"() {
|
23461
23111
|
"use strict";
|
@@ -23517,7 +23167,7 @@ var init_sqlgenerator = __esm({
|
|
23517
23167
|
return statement.type === "create_table" && dialect4 === "postgresql";
|
23518
23168
|
}
|
23519
23169
|
convert(st) {
|
23520
|
-
const { tableName, schema: schema5, columns, compositePKs, uniqueConstraints
|
23170
|
+
const { tableName, schema: schema5, columns, compositePKs, uniqueConstraints } = st;
|
23521
23171
|
let statement = "";
|
23522
23172
|
const name = schema5 ? `"${schema5}"."${tableName}"` : `"${tableName}"`;
|
23523
23173
|
statement += `CREATE TABLE IF NOT EXISTS ${name} (
|
@@ -23550,13 +23200,6 @@ var init_sqlgenerator = __esm({
|
|
23550
23200
|
statement += ` CONSTRAINT "${unsquashedUnique.name}" UNIQUE${unsquashedUnique.nullsNotDistinct ? " NULLS NOT DISTINCT" : ""}("${unsquashedUnique.columns.join(`","`)}")`;
|
23551
23201
|
}
|
23552
23202
|
}
|
23553
|
-
if (typeof checkConstraints !== "undefined" && checkConstraints.length > 0) {
|
23554
|
-
for (const checkConstraint4 of checkConstraints) {
|
23555
|
-
statement += ",\n";
|
23556
|
-
const unsquashedCheck = PgSquasher.unsquashCheck(checkConstraint4);
|
23557
|
-
statement += ` CONSTRAINT "${unsquashedCheck.name}" CHECK (${unsquashedCheck.value})`;
|
23558
|
-
}
|
23559
|
-
}
|
23560
23203
|
statement += `
|
23561
23204
|
);`;
|
23562
23205
|
statement += `
|
@@ -23574,7 +23217,6 @@ var init_sqlgenerator = __esm({
|
|
23574
23217
|
tableName,
|
23575
23218
|
columns,
|
23576
23219
|
schema: schema5,
|
23577
|
-
checkConstraints,
|
23578
23220
|
compositePKs,
|
23579
23221
|
uniqueConstraints,
|
23580
23222
|
internals
|
@@ -23609,13 +23251,6 @@ var init_sqlgenerator = __esm({
|
|
23609
23251
|
statement += ` CONSTRAINT \`${unsquashedUnique.name}\` UNIQUE(${uniqueString})`;
|
23610
23252
|
}
|
23611
23253
|
}
|
23612
|
-
if (typeof checkConstraints !== "undefined" && checkConstraints.length > 0) {
|
23613
|
-
for (const checkConstraint4 of checkConstraints) {
|
23614
|
-
statement += ",\n";
|
23615
|
-
const unsquashedCheck = MySqlSquasher.unsquashCheck(checkConstraint4);
|
23616
|
-
statement += ` CONSTRAINT \`${unsquashedCheck.name}\` CHECK(${unsquashedCheck.value})`;
|
23617
|
-
}
|
23618
|
-
}
|
23619
23254
|
statement += `
|
23620
23255
|
);`;
|
23621
23256
|
statement += `
|
@@ -23633,8 +23268,7 @@ var init_sqlgenerator = __esm({
|
|
23633
23268
|
columns,
|
23634
23269
|
referenceData,
|
23635
23270
|
compositePKs,
|
23636
|
-
uniqueConstraints
|
23637
|
-
checkConstraints
|
23271
|
+
uniqueConstraints
|
23638
23272
|
} = st;
|
23639
23273
|
let statement = "";
|
23640
23274
|
statement += `CREATE TABLE \`${tableName}\` (
|
@@ -23675,17 +23309,10 @@ var init_sqlgenerator = __esm({
|
|
23675
23309
|
if (typeof uniqueConstraints !== "undefined" && uniqueConstraints.length > 0) {
|
23676
23310
|
for (const uniqueConstraint4 of uniqueConstraints) {
|
23677
23311
|
statement += ",\n";
|
23678
|
-
const unsquashedUnique =
|
23312
|
+
const unsquashedUnique = MySqlSquasher.unsquashUnique(uniqueConstraint4);
|
23679
23313
|
statement += ` CONSTRAINT ${unsquashedUnique.name} UNIQUE(\`${unsquashedUnique.columns.join(`\`,\``)}\`)`;
|
23680
23314
|
}
|
23681
23315
|
}
|
23682
|
-
if (typeof checkConstraints !== "undefined" && checkConstraints.length > 0) {
|
23683
|
-
for (const check2 of checkConstraints) {
|
23684
|
-
statement += ",\n";
|
23685
|
-
const { value, name } = SQLiteSquasher.unsquashCheck(check2);
|
23686
|
-
statement += ` CONSTRAINT "${name}" CHECK(${value})`;
|
23687
|
-
}
|
23688
|
-
}
|
23689
23316
|
statement += `
|
23690
23317
|
`;
|
23691
23318
|
statement += `);`;
|
@@ -23785,25 +23412,6 @@ var init_sqlgenerator = __esm({
|
|
23785
23412
|
return `ALTER TABLE ${tableNameWithSchema} DROP CONSTRAINT "${unsquashed.name}";`;
|
23786
23413
|
}
|
23787
23414
|
};
|
23788
|
-
PgAlterTableAddCheckConstraintConvertor = class extends Convertor {
|
23789
|
-
can(statement, dialect4) {
|
23790
|
-
return statement.type === "create_check_constraint" && dialect4 === "postgresql";
|
23791
|
-
}
|
23792
|
-
convert(statement) {
|
23793
|
-
const unsquashed = PgSquasher.unsquashCheck(statement.data);
|
23794
|
-
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
23795
|
-
return `ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${unsquashed.name}" CHECK (${unsquashed.value});`;
|
23796
|
-
}
|
23797
|
-
};
|
23798
|
-
PgAlterTableDeleteCheckConstraintConvertor = class extends Convertor {
|
23799
|
-
can(statement, dialect4) {
|
23800
|
-
return statement.type === "delete_check_constraint" && dialect4 === "postgresql";
|
23801
|
-
}
|
23802
|
-
convert(statement) {
|
23803
|
-
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
23804
|
-
return `ALTER TABLE ${tableNameWithSchema} DROP CONSTRAINT "${statement.constraintName}";`;
|
23805
|
-
}
|
23806
|
-
};
|
23807
23415
|
MySQLAlterTableAddUniqueConstraintConvertor = class extends Convertor {
|
23808
23416
|
can(statement, dialect4) {
|
23809
23417
|
return statement.type === "create_unique_constraint" && dialect4 === "mysql";
|
@@ -23822,25 +23430,6 @@ var init_sqlgenerator = __esm({
|
|
23822
23430
|
return `ALTER TABLE \`${statement.tableName}\` DROP INDEX \`${unsquashed.name}\`;`;
|
23823
23431
|
}
|
23824
23432
|
};
|
23825
|
-
MySqlAlterTableAddCheckConstraintConvertor = class extends Convertor {
|
23826
|
-
can(statement, dialect4) {
|
23827
|
-
return statement.type === "create_check_constraint" && dialect4 === "mysql";
|
23828
|
-
}
|
23829
|
-
convert(statement) {
|
23830
|
-
const unsquashed = MySqlSquasher.unsquashCheck(statement.data);
|
23831
|
-
const { tableName } = statement;
|
23832
|
-
return `ALTER TABLE \`${tableName}\` ADD CONSTRAINT \`${unsquashed.name}\` CHECK (${unsquashed.value});`;
|
23833
|
-
}
|
23834
|
-
};
|
23835
|
-
MySqlAlterTableDeleteCheckConstraintConvertor = class extends Convertor {
|
23836
|
-
can(statement, dialect4) {
|
23837
|
-
return statement.type === "delete_check_constraint" && dialect4 === "mysql";
|
23838
|
-
}
|
23839
|
-
convert(statement) {
|
23840
|
-
const { tableName } = statement;
|
23841
|
-
return `ALTER TABLE \`${tableName}\` DROP CONSTRAINT \`${statement.constraintName}\`;`;
|
23842
|
-
}
|
23843
|
-
};
|
23844
23433
|
CreatePgSequenceConvertor = class extends Convertor {
|
23845
23434
|
can(statement, dialect4) {
|
23846
23435
|
return statement.type === "create_sequence" && dialect4 === "postgresql";
|
@@ -24444,7 +24033,7 @@ var init_sqlgenerator = __esm({
|
|
24444
24033
|
};
|
24445
24034
|
LibSQLModifyColumn = class extends Convertor {
|
24446
24035
|
can(statement, dialect4) {
|
24447
|
-
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"
|
24036
|
+
return (statement.type === "alter_table_alter_column_set_type" || statement.type === "alter_table_alter_column_drop_notnull" || statement.type === "alter_table_alter_column_set_notnull" || statement.type === "alter_table_alter_column_set_default" || statement.type === "alter_table_alter_column_drop_default") && dialect4 === "turso";
|
24448
24037
|
}
|
24449
24038
|
convert(statement, json2) {
|
24450
24039
|
const { tableName, columnName } = statement;
|
@@ -25034,22 +24623,18 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
25034
24623
|
return statement.type === "recreate_table" && dialect4 === "sqlite";
|
25035
24624
|
}
|
25036
24625
|
convert(statement) {
|
25037
|
-
const { tableName, columns, compositePKs, referenceData
|
24626
|
+
const { tableName, columns, compositePKs, referenceData } = statement;
|
25038
24627
|
const columnNames = columns.map((it) => `"${it.name}"`).join(", ");
|
25039
24628
|
const newTableName = `__new_${tableName}`;
|
25040
24629
|
const sqlStatements = [];
|
25041
24630
|
sqlStatements.push(`PRAGMA foreign_keys=OFF;`);
|
25042
|
-
const mappedCheckConstraints = checkConstraints.map(
|
25043
|
-
(it) => it.replaceAll(`"${tableName}".`, `"${newTableName}".`).replaceAll(`\`${tableName}\`.`, `\`${newTableName}\`.`).replaceAll(`${tableName}.`, `${newTableName}.`).replaceAll(`'${tableName}'.`, `'${newTableName}'.`)
|
25044
|
-
);
|
25045
24631
|
sqlStatements.push(
|
25046
24632
|
new SQLiteCreateTableConvertor().convert({
|
25047
24633
|
type: "sqlite_create_table",
|
25048
24634
|
tableName: newTableName,
|
25049
24635
|
columns,
|
25050
24636
|
referenceData,
|
25051
|
-
compositePKs
|
25052
|
-
checkConstraints: mappedCheckConstraints
|
24637
|
+
compositePKs
|
25053
24638
|
})
|
25054
24639
|
);
|
25055
24640
|
sqlStatements.push(
|
@@ -25080,13 +24665,10 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
25080
24665
|
return statement.type === "recreate_table" && dialect4 === "turso";
|
25081
24666
|
}
|
25082
24667
|
convert(statement) {
|
25083
|
-
const { tableName, columns, compositePKs, referenceData
|
24668
|
+
const { tableName, columns, compositePKs, referenceData } = statement;
|
25084
24669
|
const columnNames = columns.map((it) => `"${it.name}"`).join(", ");
|
25085
24670
|
const newTableName = `__new_${tableName}`;
|
25086
24671
|
const sqlStatements = [];
|
25087
|
-
const mappedCheckConstraints = checkConstraints.map(
|
25088
|
-
(it) => it.replaceAll(`"${tableName}".`, `"${newTableName}".`).replaceAll(`\`${tableName}\`.`, `\`${newTableName}\`.`).replaceAll(`${tableName}.`, `${newTableName}.`).replaceAll(`'${tableName}'.`, `\`${newTableName}\`.`)
|
25089
|
-
);
|
25090
24672
|
sqlStatements.push(`PRAGMA foreign_keys=OFF;`);
|
25091
24673
|
sqlStatements.push(
|
25092
24674
|
new SQLiteCreateTableConvertor().convert({
|
@@ -25094,8 +24676,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
25094
24676
|
tableName: newTableName,
|
25095
24677
|
columns,
|
25096
24678
|
referenceData,
|
25097
|
-
compositePKs
|
25098
|
-
checkConstraints: mappedCheckConstraints
|
24679
|
+
compositePKs
|
25099
24680
|
})
|
25100
24681
|
);
|
25101
24682
|
sqlStatements.push(
|
@@ -25156,10 +24737,6 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
25156
24737
|
convertors.push(new PgAlterTableAlterColumnSetTypeConvertor());
|
25157
24738
|
convertors.push(new PgAlterTableAddUniqueConstraintConvertor());
|
25158
24739
|
convertors.push(new PgAlterTableDropUniqueConstraintConvertor());
|
25159
|
-
convertors.push(new PgAlterTableAddCheckConstraintConvertor());
|
25160
|
-
convertors.push(new PgAlterTableDeleteCheckConstraintConvertor());
|
25161
|
-
convertors.push(new MySqlAlterTableAddCheckConstraintConvertor());
|
25162
|
-
convertors.push(new MySqlAlterTableDeleteCheckConstraintConvertor());
|
25163
24740
|
convertors.push(new MySQLAlterTableAddUniqueConstraintConvertor());
|
25164
24741
|
convertors.push(new MySQLAlterTableDropUniqueConstraintConvertor());
|
25165
24742
|
convertors.push(new CreatePgIndexConvertor());
|
@@ -25250,10 +24827,6 @@ var init_sqlitePushUtils = __esm({
|
|
25250
24827
|
const compositePKs = Object.values(
|
25251
24828
|
json.tables[tableName].compositePrimaryKeys
|
25252
24829
|
).map((it) => SQLiteSquasher.unsquashPK(it));
|
25253
|
-
const checkConstraints = Object.values(json.tables[tableName].checkConstraints);
|
25254
|
-
const mappedCheckConstraints = checkConstraints.map(
|
25255
|
-
(it) => it.replaceAll(`"${tableName}".`, `"${newTableName}".`).replaceAll(`\`${tableName}\`.`, `\`${newTableName}\`.`).replaceAll(`${tableName}.`, `${newTableName}.`).replaceAll(`'${tableName}'.`, `\`${newTableName}\`.`)
|
25256
|
-
);
|
25257
24830
|
const fks = referenceData.map((it) => SQLiteSquasher.unsquashPushFK(it));
|
25258
24831
|
statements.push(
|
25259
24832
|
new SQLiteCreateTableConvertor().convert({
|
@@ -25261,8 +24834,7 @@ var init_sqlitePushUtils = __esm({
|
|
25261
24834
|
tableName: newTableName,
|
25262
24835
|
columns: tableColumns,
|
25263
24836
|
referenceData: fks,
|
25264
|
-
compositePKs
|
25265
|
-
checkConstraints: mappedCheckConstraints
|
24837
|
+
compositePKs
|
25266
24838
|
})
|
25267
24839
|
);
|
25268
24840
|
if (!dataLoss) {
|
@@ -25474,7 +25046,7 @@ var init_sqlitePushUtils = __esm({
|
|
25474
25046
|
});
|
25475
25047
|
|
25476
25048
|
// src/jsonStatements.ts
|
25477
|
-
var preparePgCreateTableJson, prepareMySqlCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareDropEnumValues, prepareDropEnumJson, prepareMoveEnumJson, prepareRenameEnumJson, prepareCreateSequenceJson, prepareAlterSequenceJson, prepareDropSequenceJson, prepareMoveSequenceJson, prepareRenameSequenceJson, prepareCreateSchemasJson, prepareRenameSchemasJson, prepareDeleteSchemasJson, prepareRenameColumns, _prepareDropColumns, _prepareAddColumns, _prepareSqliteAddColumns, prepareAlterColumnsMysql, preparePgAlterColumns, prepareSqliteAlterColumns, preparePgCreateIndexesJson, prepareCreateIndexesJson, prepareCreateReferencesJson, prepareLibSQLCreateReferencesJson, prepareDropReferencesJson, prepareLibSQLDropReferencesJson, prepareAlterReferencesJson, prepareDropIndexesJson, prepareAddCompositePrimaryKeySqlite, prepareDeleteCompositePrimaryKeySqlite, prepareAlterCompositePrimaryKeySqlite, prepareAddCompositePrimaryKeyPg, prepareDeleteCompositePrimaryKeyPg, prepareAlterCompositePrimaryKeyPg, prepareAddUniqueConstraintPg, prepareDeleteUniqueConstraintPg,
|
25049
|
+
var preparePgCreateTableJson, prepareMySqlCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareDropEnumValues, prepareDropEnumJson, prepareMoveEnumJson, prepareRenameEnumJson, prepareCreateSequenceJson, prepareAlterSequenceJson, prepareDropSequenceJson, prepareMoveSequenceJson, prepareRenameSequenceJson, prepareCreateSchemasJson, prepareRenameSchemasJson, prepareDeleteSchemasJson, prepareRenameColumns, _prepareDropColumns, _prepareAddColumns, _prepareSqliteAddColumns, prepareAlterColumnsMysql, preparePgAlterColumns, prepareSqliteAlterColumns, preparePgCreateIndexesJson, prepareCreateIndexesJson, prepareCreateReferencesJson, prepareLibSQLCreateReferencesJson, prepareDropReferencesJson, prepareLibSQLDropReferencesJson, prepareAlterReferencesJson, prepareDropIndexesJson, prepareAddCompositePrimaryKeySqlite, prepareDeleteCompositePrimaryKeySqlite, prepareAlterCompositePrimaryKeySqlite, prepareAddCompositePrimaryKeyPg, prepareDeleteCompositePrimaryKeyPg, prepareAlterCompositePrimaryKeyPg, prepareAddUniqueConstraintPg, prepareDeleteUniqueConstraintPg, prepareAddCompositePrimaryKeyMySql, prepareDeleteCompositePrimaryKeyMySql, prepareAlterCompositePrimaryKeyMySql;
|
25478
25050
|
var init_jsonStatements = __esm({
|
25479
25051
|
"src/jsonStatements.ts"() {
|
25480
25052
|
"use strict";
|
@@ -25485,7 +25057,7 @@ var init_jsonStatements = __esm({
|
|
25485
25057
|
init_pgSchema();
|
25486
25058
|
init_sqliteSchema();
|
25487
25059
|
preparePgCreateTableJson = (table4, json2) => {
|
25488
|
-
const { name, schema: schema5, columns, compositePrimaryKeys, uniqueConstraints
|
25060
|
+
const { name, schema: schema5, columns, compositePrimaryKeys, uniqueConstraints } = table4;
|
25489
25061
|
const tableKey2 = `${schema5 || "public"}.${name}`;
|
25490
25062
|
const compositePkName = Object.values(compositePrimaryKeys).length > 0 ? json2.tables[tableKey2].compositePrimaryKeys[`${PgSquasher.unsquashPK(Object.values(compositePrimaryKeys)[0]).name}`].name : "";
|
25491
25063
|
return {
|
@@ -25495,12 +25067,11 @@ var init_jsonStatements = __esm({
|
|
25495
25067
|
columns: Object.values(columns),
|
25496
25068
|
compositePKs: Object.values(compositePrimaryKeys),
|
25497
25069
|
compositePkName,
|
25498
|
-
uniqueConstraints: Object.values(uniqueConstraints)
|
25499
|
-
checkConstraints: Object.values(checkConstraints)
|
25070
|
+
uniqueConstraints: Object.values(uniqueConstraints)
|
25500
25071
|
};
|
25501
25072
|
};
|
25502
25073
|
prepareMySqlCreateTableJson = (table4, json2, internals) => {
|
25503
|
-
const { name, schema: schema5, columns, compositePrimaryKeys, uniqueConstraints
|
25074
|
+
const { name, schema: schema5, columns, compositePrimaryKeys, uniqueConstraints } = table4;
|
25504
25075
|
return {
|
25505
25076
|
type: "create_table",
|
25506
25077
|
tableName: name,
|
@@ -25509,12 +25080,11 @@ var init_jsonStatements = __esm({
|
|
25509
25080
|
compositePKs: Object.values(compositePrimaryKeys),
|
25510
25081
|
compositePkName: Object.values(compositePrimaryKeys).length > 0 ? json2.tables[name].compositePrimaryKeys[MySqlSquasher.unsquashPK(Object.values(compositePrimaryKeys)[0]).name].name : "",
|
25511
25082
|
uniqueConstraints: Object.values(uniqueConstraints),
|
25512
|
-
internals
|
25513
|
-
checkConstraints: Object.values(checkConstraints)
|
25083
|
+
internals
|
25514
25084
|
};
|
25515
25085
|
};
|
25516
25086
|
prepareSQLiteCreateTable = (table4, action) => {
|
25517
|
-
const { name, columns, uniqueConstraints
|
25087
|
+
const { name, columns, uniqueConstraints } = table4;
|
25518
25088
|
const references2 = Object.values(table4.foreignKeys);
|
25519
25089
|
const composites = Object.values(table4.compositePrimaryKeys).map(
|
25520
25090
|
(it) => SQLiteSquasher.unsquashPK(it)
|
@@ -25528,8 +25098,7 @@ var init_jsonStatements = __esm({
|
|
25528
25098
|
columns: Object.values(columns),
|
25529
25099
|
referenceData: fks,
|
25530
25100
|
compositePKs: composites,
|
25531
|
-
uniqueConstraints: Object.values(uniqueConstraints)
|
25532
|
-
checkConstraints: Object.values(checkConstraints)
|
25101
|
+
uniqueConstraints: Object.values(uniqueConstraints)
|
25533
25102
|
};
|
25534
25103
|
};
|
25535
25104
|
prepareDropTableJson = (table4) => {
|
@@ -26799,26 +26368,6 @@ var init_jsonStatements = __esm({
|
|
26799
26368
|
};
|
26800
26369
|
});
|
26801
26370
|
};
|
26802
|
-
prepareAddCheckConstraint = (tableName, schema5, check2) => {
|
26803
|
-
return Object.values(check2).map((it) => {
|
26804
|
-
return {
|
26805
|
-
type: "create_check_constraint",
|
26806
|
-
tableName,
|
26807
|
-
data: it,
|
26808
|
-
schema: schema5
|
26809
|
-
};
|
26810
|
-
});
|
26811
|
-
};
|
26812
|
-
prepareDeleteCheckConstraint = (tableName, schema5, check2) => {
|
26813
|
-
return Object.values(check2).map((it) => {
|
26814
|
-
return {
|
26815
|
-
type: "delete_check_constraint",
|
26816
|
-
tableName,
|
26817
|
-
constraintName: PgSquasher.unsquashCheck(it).name,
|
26818
|
-
schema: schema5
|
26819
|
-
};
|
26820
|
-
});
|
26821
|
-
};
|
26822
26371
|
prepareAddCompositePrimaryKeyMySql = (tableName, pks, json1, json2) => {
|
26823
26372
|
var _a, _b;
|
26824
26373
|
const res = [];
|
@@ -26869,7 +26418,7 @@ var init_statementCombiner = __esm({
|
|
26869
26418
|
init_jsonStatements();
|
26870
26419
|
init_sqliteSchema();
|
26871
26420
|
prepareLibSQLRecreateTable = (table4, action) => {
|
26872
|
-
const { name, columns, uniqueConstraints, indexes
|
26421
|
+
const { name, columns, uniqueConstraints, indexes } = table4;
|
26873
26422
|
const composites = Object.values(table4.compositePrimaryKeys).map(
|
26874
26423
|
(it) => SQLiteSquasher.unsquashPK(it)
|
26875
26424
|
);
|
@@ -26884,8 +26433,7 @@ var init_statementCombiner = __esm({
|
|
26884
26433
|
columns: Object.values(columns),
|
26885
26434
|
compositePKs: composites,
|
26886
26435
|
referenceData: fks,
|
26887
|
-
uniqueConstraints: Object.values(uniqueConstraints)
|
26888
|
-
checkConstraints: Object.values(checkConstraints)
|
26436
|
+
uniqueConstraints: Object.values(uniqueConstraints)
|
26889
26437
|
}
|
26890
26438
|
];
|
26891
26439
|
if (Object.keys(indexes).length) {
|
@@ -26894,7 +26442,7 @@ var init_statementCombiner = __esm({
|
|
26894
26442
|
return statements;
|
26895
26443
|
};
|
26896
26444
|
prepareSQLiteRecreateTable = (table4, action) => {
|
26897
|
-
const { name, columns, uniqueConstraints, indexes
|
26445
|
+
const { name, columns, uniqueConstraints, indexes } = table4;
|
26898
26446
|
const composites = Object.values(table4.compositePrimaryKeys).map(
|
26899
26447
|
(it) => SQLiteSquasher.unsquashPK(it)
|
26900
26448
|
);
|
@@ -26909,8 +26457,7 @@ var init_statementCombiner = __esm({
|
|
26909
26457
|
columns: Object.values(columns),
|
26910
26458
|
compositePKs: composites,
|
26911
26459
|
referenceData: fks,
|
26912
|
-
uniqueConstraints: Object.values(uniqueConstraints)
|
26913
|
-
checkConstraints: Object.values(checkConstraints)
|
26460
|
+
uniqueConstraints: Object.values(uniqueConstraints)
|
26914
26461
|
}
|
26915
26462
|
];
|
26916
26463
|
if (Object.keys(indexes).length) {
|
@@ -26921,7 +26468,7 @@ var init_statementCombiner = __esm({
|
|
26921
26468
|
libSQLCombineStatements = (statements, json2, action) => {
|
26922
26469
|
const newStatements = {};
|
26923
26470
|
for (const statement of statements) {
|
26924
|
-
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"
|
26471
|
+
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") {
|
26925
26472
|
const tableName2 = statement.tableName;
|
26926
26473
|
const statementsForTable2 = newStatements[tableName2];
|
26927
26474
|
if (!statementsForTable2) {
|
@@ -27062,16 +26609,16 @@ var init_statementCombiner = __esm({
|
|
27062
26609
|
sqliteCombineStatements = (statements, json2, action) => {
|
27063
26610
|
const newStatements = {};
|
27064
26611
|
for (const statement of statements) {
|
27065
|
-
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"
|
26612
|
+
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") {
|
27066
26613
|
const tableName2 = statement.tableName;
|
27067
26614
|
const statementsForTable2 = newStatements[tableName2];
|
27068
26615
|
if (!statementsForTable2) {
|
27069
|
-
newStatements[tableName2] =
|
26616
|
+
newStatements[tableName2] = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
|
27070
26617
|
continue;
|
27071
26618
|
}
|
27072
26619
|
if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
|
27073
26620
|
const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
|
27074
|
-
const preparedStatements =
|
26621
|
+
const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
|
27075
26622
|
if (wasRename) {
|
27076
26623
|
newStatements[tableName2].push(...preparedStatements);
|
27077
26624
|
} else {
|
@@ -27085,12 +26632,12 @@ var init_statementCombiner = __esm({
|
|
27085
26632
|
const tableName2 = statement.tableName;
|
27086
26633
|
const statementsForTable2 = newStatements[tableName2];
|
27087
26634
|
if (!statementsForTable2) {
|
27088
|
-
newStatements[tableName2] =
|
26635
|
+
newStatements[tableName2] = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
|
27089
26636
|
continue;
|
27090
26637
|
}
|
27091
26638
|
if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
|
27092
26639
|
const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
|
27093
|
-
const preparedStatements =
|
26640
|
+
const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
|
27094
26641
|
if (wasRename) {
|
27095
26642
|
newStatements[tableName2].push(...preparedStatements);
|
27096
26643
|
} else {
|
@@ -27115,7 +26662,7 @@ var init_statementCombiner = __esm({
|
|
27115
26662
|
}
|
27116
26663
|
if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
|
27117
26664
|
const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
|
27118
|
-
const preparedStatements =
|
26665
|
+
const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
|
27119
26666
|
if (wasRename) {
|
27120
26667
|
newStatements[tableName2].push(...preparedStatements);
|
27121
26668
|
} else {
|
@@ -27250,8 +26797,7 @@ var init_snapshotsDiffer = __esm({
|
|
27250
26797
|
indexes: recordType(stringType(), stringType()),
|
27251
26798
|
foreignKeys: recordType(stringType(), stringType()),
|
27252
26799
|
compositePrimaryKeys: recordType(stringType(), stringType()).default({}),
|
27253
|
-
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
27254
|
-
checkConstraints: recordType(stringType(), stringType()).default({})
|
26800
|
+
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
27255
26801
|
}).strict();
|
27256
26802
|
alteredTableScheme = objectType({
|
27257
26803
|
name: stringType(),
|
@@ -27292,21 +26838,6 @@ var init_snapshotsDiffer = __esm({
|
|
27292
26838
|
__new: stringType(),
|
27293
26839
|
__old: stringType()
|
27294
26840
|
})
|
27295
|
-
),
|
27296
|
-
addedCheckConstraints: recordType(
|
27297
|
-
stringType(),
|
27298
|
-
stringType()
|
27299
|
-
),
|
27300
|
-
deletedCheckConstraints: recordType(
|
27301
|
-
stringType(),
|
27302
|
-
stringType()
|
27303
|
-
),
|
27304
|
-
alteredCheckConstraints: recordType(
|
27305
|
-
stringType(),
|
27306
|
-
objectType({
|
27307
|
-
__new: stringType(),
|
27308
|
-
__old: stringType()
|
27309
|
-
})
|
27310
26841
|
)
|
27311
26842
|
}).strict();
|
27312
26843
|
diffResultScheme = objectType({
|
@@ -27647,8 +27178,6 @@ var init_snapshotsDiffer = __esm({
|
|
27647
27178
|
schemaTo: it.schemaTo || "public"
|
27648
27179
|
});
|
27649
27180
|
}
|
27650
|
-
const jsonDeletedCheckConstraints = [];
|
27651
|
-
const jsonCreatedCheckConstraints = [];
|
27652
27181
|
for (let it of alteredTables) {
|
27653
27182
|
let addedColumns = [];
|
27654
27183
|
for (const addedPkName of Object.keys(it.addedCompositePKs)) {
|
@@ -27688,8 +27217,6 @@ var init_snapshotsDiffer = __esm({
|
|
27688
27217
|
let addedUniqueConstraints = [];
|
27689
27218
|
let deletedUniqueConstraints = [];
|
27690
27219
|
let alteredUniqueConstraints = [];
|
27691
|
-
let createCheckConstraints = [];
|
27692
|
-
let deleteCheckConstraints = [];
|
27693
27220
|
addedUniqueConstraints = prepareAddUniqueConstraintPg(
|
27694
27221
|
it.name,
|
27695
27222
|
it.schema,
|
@@ -27714,24 +27241,6 @@ var init_snapshotsDiffer = __esm({
|
|
27714
27241
|
...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
|
27715
27242
|
);
|
27716
27243
|
}
|
27717
|
-
createCheckConstraints = prepareAddCheckConstraint(it.name, it.schema, it.addedCheckConstraints);
|
27718
|
-
deleteCheckConstraints = prepareDeleteCheckConstraint(
|
27719
|
-
it.name,
|
27720
|
-
it.schema,
|
27721
|
-
it.deletedCheckConstraints
|
27722
|
-
);
|
27723
|
-
if (it.alteredCheckConstraints && action !== "push") {
|
27724
|
-
const added = {};
|
27725
|
-
const deleted = {};
|
27726
|
-
for (const k of Object.keys(it.alteredCheckConstraints)) {
|
27727
|
-
added[k] = it.alteredCheckConstraints[k].__new;
|
27728
|
-
deleted[k] = it.alteredCheckConstraints[k].__old;
|
27729
|
-
}
|
27730
|
-
createCheckConstraints.push(...prepareAddCheckConstraint(it.name, it.schema, added));
|
27731
|
-
deleteCheckConstraints.push(...prepareDeleteCheckConstraint(it.name, it.schema, deleted));
|
27732
|
-
}
|
27733
|
-
jsonCreatedCheckConstraints.push(...createCheckConstraints);
|
27734
|
-
jsonDeletedCheckConstraints.push(...deleteCheckConstraints);
|
27735
27244
|
jsonAddedCompositePKs.push(...addedCompositePKs);
|
27736
27245
|
jsonDeletedCompositePKs.push(...deletedCompositePKs);
|
27737
27246
|
jsonAlteredCompositePKs.push(...alteredCompositePKs);
|
@@ -27888,7 +27397,6 @@ var init_snapshotsDiffer = __esm({
|
|
27888
27397
|
jsonStatements.push(...jsonRenameTables);
|
27889
27398
|
jsonStatements.push(...jsonRenameColumnsStatements);
|
27890
27399
|
jsonStatements.push(...jsonDeletedUniqueConstraints);
|
27891
|
-
jsonStatements.push(...jsonDeletedCheckConstraints);
|
27892
27400
|
jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
|
27893
27401
|
jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
|
27894
27402
|
jsonStatements.push(...jsonDeletedCompositePKs);
|
@@ -27902,7 +27410,6 @@ var init_snapshotsDiffer = __esm({
|
|
27902
27410
|
jsonStatements.push(...jsonDropColumnsStatemets);
|
27903
27411
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
27904
27412
|
jsonStatements.push(...jsonAddedUniqueConstraints);
|
27905
|
-
jsonStatements.push(...jsonCreatedCheckConstraints);
|
27906
27413
|
jsonStatements.push(...jsonAlteredUniqueConstraints);
|
27907
27414
|
jsonStatements.push(...jsonAlterEnumsWithDroppedValues);
|
27908
27415
|
jsonStatements.push(...dropEnums);
|
@@ -28077,8 +27584,6 @@ var init_snapshotsDiffer = __esm({
|
|
28077
27584
|
const jsonAddedUniqueConstraints = [];
|
28078
27585
|
const jsonDeletedUniqueConstraints = [];
|
28079
27586
|
const jsonAlteredUniqueConstraints = [];
|
28080
|
-
const jsonCreatedCheckConstraints = [];
|
28081
|
-
const jsonDeletedCheckConstraints = [];
|
28082
27587
|
const jsonRenameColumnsStatements = columnRenames.map((it) => prepareRenameColumns(it.table, "", it.renames)).flat();
|
28083
27588
|
const jsonAddColumnsStatemets = columnCreates.map((it) => _prepareAddColumns(it.table, "", it.columns)).flat();
|
28084
27589
|
const jsonDropColumnsStatemets = columnDeletes.map((it) => _prepareDropColumns(it.table, "", it.columns)).flat();
|
@@ -28117,8 +27622,6 @@ var init_snapshotsDiffer = __esm({
|
|
28117
27622
|
let addedUniqueConstraints = [];
|
28118
27623
|
let deletedUniqueConstraints = [];
|
28119
27624
|
let alteredUniqueConstraints = [];
|
28120
|
-
let createdCheckConstraints = [];
|
28121
|
-
let deletedCheckConstraints = [];
|
28122
27625
|
addedUniqueConstraints = prepareAddUniqueConstraintPg(
|
28123
27626
|
it.name,
|
28124
27627
|
it.schema,
|
@@ -28143,30 +27646,12 @@ var init_snapshotsDiffer = __esm({
|
|
28143
27646
|
...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
|
28144
27647
|
);
|
28145
27648
|
}
|
28146
|
-
createdCheckConstraints = prepareAddCheckConstraint(it.name, it.schema, it.addedCheckConstraints);
|
28147
|
-
deletedCheckConstraints = prepareDeleteCheckConstraint(
|
28148
|
-
it.name,
|
28149
|
-
it.schema,
|
28150
|
-
it.deletedCheckConstraints
|
28151
|
-
);
|
28152
|
-
if (it.alteredCheckConstraints && action !== "push") {
|
28153
|
-
const added = {};
|
28154
|
-
const deleted = {};
|
28155
|
-
for (const k of Object.keys(it.alteredCheckConstraints)) {
|
28156
|
-
added[k] = it.alteredCheckConstraints[k].__new;
|
28157
|
-
deleted[k] = it.alteredCheckConstraints[k].__old;
|
28158
|
-
}
|
28159
|
-
createdCheckConstraints.push(...prepareAddCheckConstraint(it.name, it.schema, added));
|
28160
|
-
deletedCheckConstraints.push(...prepareDeleteCheckConstraint(it.name, it.schema, deleted));
|
28161
|
-
}
|
28162
27649
|
jsonAddedCompositePKs.push(...addedCompositePKs);
|
28163
27650
|
jsonDeletedCompositePKs.push(...deletedCompositePKs);
|
28164
27651
|
jsonAlteredCompositePKs.push(...alteredCompositePKs);
|
28165
27652
|
jsonAddedUniqueConstraints.push(...addedUniqueConstraints);
|
28166
27653
|
jsonDeletedUniqueConstraints.push(...deletedUniqueConstraints);
|
28167
27654
|
jsonAlteredUniqueConstraints.push(...alteredUniqueConstraints);
|
28168
|
-
jsonCreatedCheckConstraints.push(...createdCheckConstraints);
|
28169
|
-
jsonDeletedCheckConstraints.push(...deletedCheckConstraints);
|
28170
27655
|
});
|
28171
27656
|
const rColumns = jsonRenameColumnsStatements.map((it) => {
|
28172
27657
|
const tableName = it.tableName;
|
@@ -28262,7 +27747,6 @@ var init_snapshotsDiffer = __esm({
|
|
28262
27747
|
jsonStatements.push(...jsonRenameTables);
|
28263
27748
|
jsonStatements.push(...jsonRenameColumnsStatements);
|
28264
27749
|
jsonStatements.push(...jsonDeletedUniqueConstraints);
|
28265
|
-
jsonStatements.push(...jsonDeletedCheckConstraints);
|
28266
27750
|
jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
|
28267
27751
|
jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
|
28268
27752
|
jsonStatements.push(...jsonDeletedCompositePKs);
|
@@ -28273,11 +27757,11 @@ var init_snapshotsDiffer = __esm({
|
|
28273
27757
|
jsonStatements.push(...jsonAddColumnsStatemets);
|
28274
27758
|
jsonStatements.push(...jsonCreateReferencesForCreatedTables);
|
28275
27759
|
jsonStatements.push(...jsonCreateIndexesForCreatedTables);
|
28276
|
-
jsonStatements.push(...jsonCreatedCheckConstraints);
|
28277
27760
|
jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
|
28278
27761
|
jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
|
28279
27762
|
jsonStatements.push(...jsonDropColumnsStatemets);
|
28280
27763
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
27764
|
+
jsonStatements.push(...jsonAddedUniqueConstraints);
|
28281
27765
|
jsonStatements.push(...jsonAlteredUniqueConstraints);
|
28282
27766
|
const sqlStatements = fromJson(jsonStatements, "mysql");
|
28283
27767
|
const uniqueSqlStatements = [];
|
@@ -28405,8 +27889,6 @@ var init_snapshotsDiffer = __esm({
|
|
28405
27889
|
const jsonAddedUniqueConstraints = [];
|
28406
27890
|
const jsonDeletedUniqueConstraints = [];
|
28407
27891
|
const jsonAlteredUniqueConstraints = [];
|
28408
|
-
const jsonDeletedCheckConstraints = [];
|
28409
|
-
const jsonCreatedCheckConstraints = [];
|
28410
27892
|
allAltered.forEach((it) => {
|
28411
27893
|
let addedColumns = [];
|
28412
27894
|
for (const addedPkName of Object.keys(it.addedCompositePKs)) {
|
@@ -28463,56 +27945,12 @@ var init_snapshotsDiffer = __esm({
|
|
28463
27945
|
...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
|
28464
27946
|
);
|
28465
27947
|
}
|
28466
|
-
let createdCheckConstraints = [];
|
28467
|
-
let deletedCheckConstraints = [];
|
28468
|
-
addedUniqueConstraints = prepareAddUniqueConstraintPg(
|
28469
|
-
it.name,
|
28470
|
-
it.schema,
|
28471
|
-
it.addedUniqueConstraints
|
28472
|
-
);
|
28473
|
-
deletedUniqueConstraints = prepareDeleteUniqueConstraintPg(
|
28474
|
-
it.name,
|
28475
|
-
it.schema,
|
28476
|
-
it.deletedUniqueConstraints
|
28477
|
-
);
|
28478
|
-
if (it.alteredUniqueConstraints) {
|
28479
|
-
const added = {};
|
28480
|
-
const deleted = {};
|
28481
|
-
for (const k of Object.keys(it.alteredUniqueConstraints)) {
|
28482
|
-
added[k] = it.alteredUniqueConstraints[k].__new;
|
28483
|
-
deleted[k] = it.alteredUniqueConstraints[k].__old;
|
28484
|
-
}
|
28485
|
-
addedUniqueConstraints.push(
|
28486
|
-
...prepareAddUniqueConstraintPg(it.name, it.schema, added)
|
28487
|
-
);
|
28488
|
-
deletedUniqueConstraints.push(
|
28489
|
-
...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
|
28490
|
-
);
|
28491
|
-
}
|
28492
|
-
createdCheckConstraints = prepareAddCheckConstraint(it.name, it.schema, it.addedCheckConstraints);
|
28493
|
-
deletedCheckConstraints = prepareDeleteCheckConstraint(
|
28494
|
-
it.name,
|
28495
|
-
it.schema,
|
28496
|
-
it.deletedCheckConstraints
|
28497
|
-
);
|
28498
|
-
if (it.alteredCheckConstraints && action !== "push") {
|
28499
|
-
const added = {};
|
28500
|
-
const deleted = {};
|
28501
|
-
for (const k of Object.keys(it.alteredCheckConstraints)) {
|
28502
|
-
added[k] = it.alteredCheckConstraints[k].__new;
|
28503
|
-
deleted[k] = it.alteredCheckConstraints[k].__old;
|
28504
|
-
}
|
28505
|
-
createdCheckConstraints.push(...prepareAddCheckConstraint(it.name, it.schema, added));
|
28506
|
-
deletedCheckConstraints.push(...prepareDeleteCheckConstraint(it.name, it.schema, deleted));
|
28507
|
-
}
|
28508
27948
|
jsonAddedCompositePKs.push(...addedCompositePKs);
|
28509
27949
|
jsonDeletedCompositePKs.push(...deletedCompositePKs);
|
28510
27950
|
jsonAlteredCompositePKs.push(...alteredCompositePKs);
|
28511
27951
|
jsonAddedUniqueConstraints.push(...addedUniqueConstraints);
|
28512
27952
|
jsonDeletedUniqueConstraints.push(...deletedUniqueConstraints);
|
28513
27953
|
jsonAlteredUniqueConstraints.push(...alteredUniqueConstraints);
|
28514
|
-
jsonCreatedCheckConstraints.push(...createdCheckConstraints);
|
28515
|
-
jsonDeletedCheckConstraints.push(...deletedCheckConstraints);
|
28516
27954
|
});
|
28517
27955
|
const rColumns = jsonRenameColumnsStatements.map((it) => {
|
28518
27956
|
const tableName = it.tableName;
|
@@ -28597,7 +28035,6 @@ var init_snapshotsDiffer = __esm({
|
|
28597
28035
|
jsonStatements.push(...jsonRenameTables);
|
28598
28036
|
jsonStatements.push(...jsonRenameColumnsStatements);
|
28599
28037
|
jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
|
28600
|
-
jsonStatements.push(...jsonDeletedCheckConstraints);
|
28601
28038
|
jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
|
28602
28039
|
jsonStatements.push(...jsonDeletedCompositePKs);
|
28603
28040
|
jsonStatements.push(...jsonTableAlternations);
|
@@ -28605,7 +28042,6 @@ var init_snapshotsDiffer = __esm({
|
|
28605
28042
|
jsonStatements.push(...jsonAddColumnsStatemets);
|
28606
28043
|
jsonStatements.push(...jsonCreateIndexesForCreatedTables);
|
28607
28044
|
jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
|
28608
|
-
jsonStatements.push(...jsonCreatedCheckConstraints);
|
28609
28045
|
jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
|
28610
28046
|
jsonStatements.push(...jsonDropColumnsStatemets);
|
28611
28047
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
@@ -28749,8 +28185,6 @@ var init_snapshotsDiffer = __esm({
|
|
28749
28185
|
const jsonAddedUniqueConstraints = [];
|
28750
28186
|
const jsonDeletedUniqueConstraints = [];
|
28751
28187
|
const jsonAlteredUniqueConstraints = [];
|
28752
|
-
const jsonDeletedCheckConstraints = [];
|
28753
|
-
const jsonCreatedCheckConstraints = [];
|
28754
28188
|
allAltered.forEach((it) => {
|
28755
28189
|
let addedColumns = [];
|
28756
28190
|
for (const addedPkName of Object.keys(it.addedCompositePKs)) {
|
@@ -28783,8 +28217,6 @@ var init_snapshotsDiffer = __esm({
|
|
28783
28217
|
let addedUniqueConstraints = [];
|
28784
28218
|
let deletedUniqueConstraints = [];
|
28785
28219
|
let alteredUniqueConstraints = [];
|
28786
|
-
let createdCheckConstraints = [];
|
28787
|
-
let deletedCheckConstraints = [];
|
28788
28220
|
addedUniqueConstraints = prepareAddUniqueConstraintPg(
|
28789
28221
|
it.name,
|
28790
28222
|
it.schema,
|
@@ -28809,30 +28241,12 @@ var init_snapshotsDiffer = __esm({
|
|
28809
28241
|
...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
|
28810
28242
|
);
|
28811
28243
|
}
|
28812
|
-
createdCheckConstraints = prepareAddCheckConstraint(it.name, it.schema, it.addedCheckConstraints);
|
28813
|
-
deletedCheckConstraints = prepareDeleteCheckConstraint(
|
28814
|
-
it.name,
|
28815
|
-
it.schema,
|
28816
|
-
it.deletedCheckConstraints
|
28817
|
-
);
|
28818
|
-
if (it.alteredCheckConstraints && action !== "push") {
|
28819
|
-
const added = {};
|
28820
|
-
const deleted = {};
|
28821
|
-
for (const k of Object.keys(it.alteredCheckConstraints)) {
|
28822
|
-
added[k] = it.alteredCheckConstraints[k].__new;
|
28823
|
-
deleted[k] = it.alteredCheckConstraints[k].__old;
|
28824
|
-
}
|
28825
|
-
createdCheckConstraints.push(...prepareAddCheckConstraint(it.name, it.schema, added));
|
28826
|
-
deletedCheckConstraints.push(...prepareDeleteCheckConstraint(it.name, it.schema, deleted));
|
28827
|
-
}
|
28828
28244
|
jsonAddedCompositePKs.push(...addedCompositePKs);
|
28829
28245
|
jsonDeletedCompositePKs.push(...deletedCompositePKs);
|
28830
28246
|
jsonAlteredCompositePKs.push(...alteredCompositePKs);
|
28831
28247
|
jsonAddedUniqueConstraints.push(...addedUniqueConstraints);
|
28832
28248
|
jsonDeletedUniqueConstraints.push(...deletedUniqueConstraints);
|
28833
28249
|
jsonAlteredUniqueConstraints.push(...alteredUniqueConstraints);
|
28834
|
-
jsonCreatedCheckConstraints.push(...createdCheckConstraints);
|
28835
|
-
jsonDeletedCheckConstraints.push(...deletedCheckConstraints);
|
28836
28250
|
});
|
28837
28251
|
const jsonTableAlternations = allAltered.map((it) => {
|
28838
28252
|
return prepareSqliteAlterColumns(it.name, it.schema, it.altered, json2);
|
@@ -28910,7 +28324,6 @@ var init_snapshotsDiffer = __esm({
|
|
28910
28324
|
jsonStatements.push(...jsonRenameTables);
|
28911
28325
|
jsonStatements.push(...jsonRenameColumnsStatements);
|
28912
28326
|
jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
|
28913
|
-
jsonStatements.push(...jsonDeletedCheckConstraints);
|
28914
28327
|
jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
|
28915
28328
|
jsonStatements.push(...jsonDeletedCompositePKs);
|
28916
28329
|
jsonStatements.push(...jsonTableAlternations);
|
@@ -28918,7 +28331,6 @@ var init_snapshotsDiffer = __esm({
|
|
28918
28331
|
jsonStatements.push(...jsonAddColumnsStatemets);
|
28919
28332
|
jsonStatements.push(...jsonCreateIndexesForCreatedTables);
|
28920
28333
|
jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
|
28921
|
-
jsonStatements.push(...jsonCreatedCheckConstraints);
|
28922
28334
|
jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
|
28923
28335
|
jsonStatements.push(...jsonDropColumnsStatemets);
|
28924
28336
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
@@ -77821,19 +77233,14 @@ var init_libSqlPushUtils = __esm({
|
|
77821
77233
|
const compositePKs = Object.values(
|
77822
77234
|
json.tables[tableName].compositePrimaryKeys
|
77823
77235
|
).map((it) => SQLiteSquasher.unsquashPK(it));
|
77824
|
-
const checkConstraints = Object.values(json.tables[tableName].checkConstraints);
|
77825
77236
|
const fks = referenceData.map((it) => SQLiteSquasher.unsquashPushFK(it));
|
77826
|
-
const mappedCheckConstraints = checkConstraints.map(
|
77827
|
-
(it) => it.replaceAll(`"${tableName}".`, `"${newTableName}".`).replaceAll(`\`${tableName}\`.`, `\`${newTableName}\`.`).replaceAll(`${tableName}.`, `${newTableName}.`).replaceAll(`'${tableName}'.`, `\`${newTableName}\`.`)
|
77828
|
-
);
|
77829
77237
|
statements.push(
|
77830
77238
|
new SQLiteCreateTableConvertor().convert({
|
77831
77239
|
type: "sqlite_create_table",
|
77832
77240
|
tableName: newTableName,
|
77833
77241
|
columns: tableColumns,
|
77834
77242
|
referenceData: fks,
|
77835
|
-
compositePKs
|
77836
|
-
checkConstraints: mappedCheckConstraints
|
77243
|
+
compositePKs
|
77837
77244
|
})
|
77838
77245
|
);
|
77839
77246
|
if (!dataLoss) {
|
@@ -79724,7 +79131,7 @@ var init_pgIntrospect = __esm({
|
|
79724
79131
|
});
|
79725
79132
|
|
79726
79133
|
// src/introspect-sqlite.ts
|
79727
|
-
var import_casing3, sqliteImportsList, indexName3, objToStatement2, relations, escapeColumnKey, withCasing, dbColumnName, schemaToTypeScript, isCyclic, isSelf, mapColumnDefault, column4, createTableColumns, createTableIndexes, createTableUniques,
|
79134
|
+
var import_casing3, sqliteImportsList, indexName3, objToStatement2, relations, escapeColumnKey, withCasing, dbColumnName, schemaToTypeScript, isCyclic, isSelf, mapColumnDefault, column4, createTableColumns, createTableIndexes, createTableUniques, createTablePKs, createTableFKs;
|
79728
79135
|
var init_introspect_sqlite = __esm({
|
79729
79136
|
"src/introspect-sqlite.ts"() {
|
79730
79137
|
"use strict";
|
@@ -79794,14 +79201,10 @@ var init_introspect_sqlite = __esm({
|
|
79794
79201
|
const uniqueImports = Object.values(it.uniqueConstraints).map(
|
79795
79202
|
(it2) => "unique"
|
79796
79203
|
);
|
79797
|
-
const checkImports = Object.values(it.checkConstraints).map(
|
79798
|
-
(it2) => "check"
|
79799
|
-
);
|
79800
79204
|
res.sqlite.push(...idxImports);
|
79801
79205
|
res.sqlite.push(...fkImpots);
|
79802
79206
|
res.sqlite.push(...pkImports);
|
79803
79207
|
res.sqlite.push(...uniqueImports);
|
79804
|
-
res.sqlite.push(...checkImports);
|
79805
79208
|
const columnImports = Object.values(it.columns).map((col) => {
|
79806
79209
|
return col.type;
|
79807
79210
|
}).filter((type) => {
|
@@ -79834,7 +79237,7 @@ var init_introspect_sqlite = __esm({
|
|
79834
79237
|
const filteredFKs = Object.values(table4.foreignKeys).filter((it) => {
|
79835
79238
|
return it.columnsFrom.length > 1 || isSelf(it);
|
79836
79239
|
});
|
79837
|
-
if (Object.keys(table4.indexes).length > 0 || filteredFKs.length > 0 || Object.keys(table4.compositePrimaryKeys).length > 0 || Object.keys(table4.uniqueConstraints).length > 0
|
79240
|
+
if (Object.keys(table4.indexes).length > 0 || filteredFKs.length > 0 || Object.keys(table4.compositePrimaryKeys).length > 0 || Object.keys(table4.uniqueConstraints).length > 0) {
|
79838
79241
|
statement += ",\n";
|
79839
79242
|
statement += "(table) => {\n";
|
79840
79243
|
statement += " return {\n";
|
@@ -79852,10 +79255,6 @@ var init_introspect_sqlite = __esm({
|
|
79852
79255
|
Object.values(table4.uniqueConstraints),
|
79853
79256
|
casing2
|
79854
79257
|
);
|
79855
|
-
statement += createTableChecks(
|
79856
|
-
Object.values(table4.checkConstraints),
|
79857
|
-
casing2
|
79858
|
-
);
|
79859
79258
|
statement += " }\n";
|
79860
79259
|
statement += "}";
|
79861
79260
|
}
|
@@ -80007,19 +79406,6 @@ var init_introspect_sqlite = __esm({
|
|
80007
79406
|
statement += `"${it.name}")`;
|
80008
79407
|
statement += `.on(${it.columns.map((it2) => `table.${withCasing(it2, casing2)}`).join(", ")}),`;
|
80009
79408
|
statement += `
|
80010
|
-
`;
|
80011
|
-
});
|
80012
|
-
return statement;
|
80013
|
-
};
|
80014
|
-
createTableChecks = (checks, casing2) => {
|
80015
|
-
let statement = "";
|
80016
|
-
checks.forEach((it) => {
|
80017
|
-
const checkKey = withCasing(it.name, casing2);
|
80018
|
-
statement += ` ${checkKey}: `;
|
80019
|
-
statement += "check(";
|
80020
|
-
statement += `"${it.name}", `;
|
80021
|
-
statement += `sql\`${it.value}\`)`;
|
80022
|
-
statement += `,
|
80023
79409
|
`;
|
80024
79410
|
});
|
80025
79411
|
return statement;
|
@@ -80868,7 +80254,7 @@ var require_pluralize = __commonJS({
|
|
80868
80254
|
});
|
80869
80255
|
|
80870
80256
|
// src/introspect-mysql.ts
|
80871
|
-
var import_casing4, mysqlImportsList, objToStatement22, timeConfig, binaryConfig, importsPatch, relations2, escapeColumnKey2, prepareCasing, dbColumnName2, schemaToTypeScript2, isCyclic2, isSelf2, mapColumnDefault2, mapColumnDefaultForJson, column5, createTableColumns2, createTableIndexes2, createTableUniques2,
|
80257
|
+
var import_casing4, mysqlImportsList, objToStatement22, timeConfig, binaryConfig, importsPatch, relations2, escapeColumnKey2, prepareCasing, dbColumnName2, schemaToTypeScript2, isCyclic2, isSelf2, mapColumnDefault2, mapColumnDefaultForJson, column5, createTableColumns2, createTableIndexes2, createTableUniques2, createTablePKs2, createTableFKs2;
|
80872
80258
|
var init_introspect_mysql = __esm({
|
80873
80259
|
"src/introspect-mysql.ts"() {
|
80874
80260
|
"use strict";
|
@@ -80983,14 +80369,10 @@ var init_introspect_mysql = __esm({
|
|
80983
80369
|
const uniqueImports = Object.values(it.uniqueConstraints).map(
|
80984
80370
|
(it2) => "unique"
|
80985
80371
|
);
|
80986
|
-
const checkImports = Object.values(it.checkConstraint).map(
|
80987
|
-
(it2) => "check"
|
80988
|
-
);
|
80989
80372
|
res.mysql.push(...idxImports);
|
80990
80373
|
res.mysql.push(...fkImpots);
|
80991
80374
|
res.mysql.push(...pkImports);
|
80992
80375
|
res.mysql.push(...uniqueImports);
|
80993
|
-
res.mysql.push(...checkImports);
|
80994
80376
|
const columnImports = Object.values(it.columns).map((col) => {
|
80995
80377
|
let patched = importsPatch[col.type] ?? col.type;
|
80996
80378
|
patched = patched.startsWith("varchar(") ? "varchar" : patched;
|
@@ -81036,7 +80418,7 @@ var init_introspect_mysql = __esm({
|
|
81036
80418
|
const filteredFKs = Object.values(table4.foreignKeys).filter((it) => {
|
81037
80419
|
return it.columnsFrom.length > 1 || isSelf2(it);
|
81038
80420
|
});
|
81039
|
-
if (Object.keys(table4.indexes).length > 0 || filteredFKs.length > 0 || Object.keys(table4.compositePrimaryKeys).length > 0 || Object.keys(table4.uniqueConstraints).length > 0
|
80421
|
+
if (Object.keys(table4.indexes).length > 0 || filteredFKs.length > 0 || Object.keys(table4.compositePrimaryKeys).length > 0 || Object.keys(table4.uniqueConstraints).length > 0) {
|
81040
80422
|
statement += ",\n";
|
81041
80423
|
statement += "(table) => {\n";
|
81042
80424
|
statement += " return {\n";
|
@@ -81054,10 +80436,6 @@ var init_introspect_mysql = __esm({
|
|
81054
80436
|
Object.values(table4.uniqueConstraints),
|
81055
80437
|
withCasing4
|
81056
80438
|
);
|
81057
|
-
statement += createTableChecks2(
|
81058
|
-
Object.values(table4.checkConstraint),
|
81059
|
-
withCasing4
|
81060
|
-
);
|
81061
80439
|
statement += " }\n";
|
81062
80440
|
statement += "}";
|
81063
80441
|
}
|
@@ -81397,19 +80775,6 @@ import { sql } from "drizzle-orm"
|
|
81397
80775
|
statement += `"${it.name}")`;
|
81398
80776
|
statement += `.on(${it.columns.map((it2) => `table.${casing2(it2)}`).join(", ")}),`;
|
81399
80777
|
statement += `
|
81400
|
-
`;
|
81401
|
-
});
|
81402
|
-
return statement;
|
81403
|
-
};
|
81404
|
-
createTableChecks2 = (checks, casing2) => {
|
81405
|
-
let statement = "";
|
81406
|
-
checks.forEach((it) => {
|
81407
|
-
const checkKey = casing2(it.name);
|
81408
|
-
statement += ` ${checkKey}: `;
|
81409
|
-
statement += "check(";
|
81410
|
-
statement += `"${it.name}", `;
|
81411
|
-
statement += `sql\`${it.value.replace(/`/g, "\\`")}\`)`;
|
81412
|
-
statement += `,
|
81413
80778
|
`;
|
81414
80779
|
});
|
81415
80780
|
return statement;
|
@@ -81480,7 +80845,7 @@ function generateIdentityParams(identity) {
|
|
81480
80845
|
}
|
81481
80846
|
return `.generatedByDefaultAsIdentity(${paramsObj})`;
|
81482
80847
|
}
|
81483
|
-
var import_drizzle_orm9, import_relations, import_casing5, pgImportsList, timeConfig2, possibleIntervals, intervalStrToObj, intervalConfig, mapColumnDefault3, importsPatch2, relations3, escapeColumnKey3, withCasing2, dbColumnName3, paramNameFor, schemaToTypeScript3, isCyclic3, isSelf3, buildArrayDefault, mapDefault, column6, dimensionsInArray, createTableColumns3, createTableIndexes3, createTablePKs3, createTableUniques3,
|
80848
|
+
var import_drizzle_orm9, import_relations, import_casing5, pgImportsList, timeConfig2, possibleIntervals, intervalStrToObj, intervalConfig, mapColumnDefault3, importsPatch2, relations3, escapeColumnKey3, withCasing2, dbColumnName3, paramNameFor, schemaToTypeScript3, isCyclic3, isSelf3, buildArrayDefault, mapDefault, column6, dimensionsInArray, createTableColumns3, createTableIndexes3, createTablePKs3, createTableUniques3, createTableFKs3;
|
81484
80849
|
var init_introspect_pg = __esm({
|
81485
80850
|
"src/introspect-pg.ts"() {
|
81486
80851
|
"use strict";
|
@@ -81658,9 +81023,6 @@ var init_introspect_pg = __esm({
|
|
81658
81023
|
const uniqueImports = Object.values(it.uniqueConstraints).map(
|
81659
81024
|
(it2) => "unique"
|
81660
81025
|
);
|
81661
|
-
const checkImports = Object.values(it.checkConstraints).map(
|
81662
|
-
(it2) => "check"
|
81663
|
-
);
|
81664
81026
|
if (it.schema && it.schema !== "public" && it.schema !== "") {
|
81665
81027
|
res.pg.push("pgSchema");
|
81666
81028
|
}
|
@@ -81668,7 +81030,6 @@ var init_introspect_pg = __esm({
|
|
81668
81030
|
res.pg.push(...fkImpots);
|
81669
81031
|
res.pg.push(...pkImports);
|
81670
81032
|
res.pg.push(...uniqueImports);
|
81671
|
-
res.pg.push(...checkImports);
|
81672
81033
|
const columnImports = Object.values(it.columns).map((col) => {
|
81673
81034
|
let patched = (importsPatch2[col.type] || col.type).replace("[]", "");
|
81674
81035
|
patched = patched === "double precision" ? "doublePrecision" : patched;
|
@@ -81758,7 +81119,7 @@ var init_introspect_pg = __esm({
|
|
81758
81119
|
schema5.internal
|
81759
81120
|
);
|
81760
81121
|
statement += "}";
|
81761
|
-
if (Object.keys(table4.indexes).length > 0 || Object.values(table4.foreignKeys).length > 0 || Object.keys(table4.compositePrimaryKeys).length > 0 || Object.keys(table4.uniqueConstraints).length > 0
|
81122
|
+
if (Object.keys(table4.indexes).length > 0 || Object.values(table4.foreignKeys).length > 0 || Object.keys(table4.compositePrimaryKeys).length > 0 || Object.keys(table4.uniqueConstraints).length > 0) {
|
81762
81123
|
statement += ",\n";
|
81763
81124
|
statement += "(table) => {\n";
|
81764
81125
|
statement += " return {\n";
|
@@ -81776,10 +81137,6 @@ var init_introspect_pg = __esm({
|
|
81776
81137
|
Object.values(table4.uniqueConstraints),
|
81777
81138
|
casing2
|
81778
81139
|
);
|
81779
|
-
statement += createTableChecks3(
|
81780
|
-
Object.values(table4.checkConstraints),
|
81781
|
-
casing2
|
81782
|
-
);
|
81783
81140
|
statement += " }\n";
|
81784
81141
|
statement += "}";
|
81785
81142
|
}
|
@@ -82242,19 +81599,6 @@ var init_introspect_pg = __esm({
|
|
82242
81599
|
statement += `.on(${it.columns.map((it2) => `table.${withCasing2(it2, casing2)}`).join(", ")})`;
|
82243
81600
|
statement += it.nullsNotDistinct ? `.nullsNotDistinct()` : "";
|
82244
81601
|
statement += `,
|
82245
|
-
`;
|
82246
|
-
});
|
82247
|
-
return statement;
|
82248
|
-
};
|
82249
|
-
createTableChecks3 = (checkConstraints, casing2) => {
|
82250
|
-
let statement = "";
|
82251
|
-
checkConstraints.forEach((it) => {
|
82252
|
-
const checkKey = withCasing2(it.name, casing2);
|
82253
|
-
statement += ` ${checkKey}: `;
|
82254
|
-
statement += "check(";
|
82255
|
-
statement += `"${it.name}", `;
|
82256
|
-
statement += `sql\`${it.value}\`)`;
|
82257
|
-
statement += `,
|
82258
81602
|
`;
|
82259
81603
|
});
|
82260
81604
|
return statement;
|
@@ -86099,7 +85443,7 @@ init_utils2();
|
|
86099
85443
|
var version2 = async () => {
|
86100
85444
|
const { npmVersion } = await ormCoreVersions();
|
86101
85445
|
const ormVersion = npmVersion ? `drizzle-orm: v${npmVersion}` : "";
|
86102
|
-
const envVersion = "0.25.0-
|
85446
|
+
const envVersion = "0.25.0-22c3e40";
|
86103
85447
|
const kitVersion = envVersion ? `v${envVersion}` : "--";
|
86104
85448
|
const versions = `drizzle-kit: ${kitVersion}
|
86105
85449
|
${ormVersion}`;
|