drizzle-kit 0.19.5 → 0.19.6-8f467f3
Sign up to get free protection for your applications and to get access to all the features.
- package/index.cjs +56 -15
- package/package.json +1 -1
- package/utils.js +35 -6
package/index.cjs
CHANGED
@@ -4656,7 +4656,8 @@ var init_mysqlSchema = __esm({
|
|
4656
4656
|
columns: recordType(stringType(), column),
|
4657
4657
|
indexes: recordType(stringType(), stringType()),
|
4658
4658
|
foreignKeys: recordType(stringType(), stringType()),
|
4659
|
-
compositePrimaryKeys: recordType(stringType(), stringType())
|
4659
|
+
compositePrimaryKeys: recordType(stringType(), stringType()),
|
4660
|
+
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
4660
4661
|
}).strict();
|
4661
4662
|
schemaSquashed = objectType({
|
4662
4663
|
version: literalType("5"),
|
@@ -5228,7 +5229,8 @@ var init_sqliteSchema = __esm({
|
|
5228
5229
|
columns: recordType(stringType(), column3),
|
5229
5230
|
indexes: recordType(stringType(), stringType()),
|
5230
5231
|
foreignKeys: recordType(stringType(), stringType()),
|
5231
|
-
compositePrimaryKeys: recordType(stringType(), stringType())
|
5232
|
+
compositePrimaryKeys: recordType(stringType(), stringType()),
|
5233
|
+
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
5232
5234
|
}).strict();
|
5233
5235
|
schemaSquashed2 = objectType({
|
5234
5236
|
version: latestVersion,
|
@@ -11690,7 +11692,6 @@ The unique constraint ${source_default.underline.blue(
|
|
11690
11692
|
let tablesCount = /* @__PURE__ */ new Set();
|
11691
11693
|
let indexesCount = 0;
|
11692
11694
|
let foreignKeysCount = 0;
|
11693
|
-
const tableToPk = {};
|
11694
11695
|
for (const column7 of response) {
|
11695
11696
|
if (!tablesFilter(column7["TABLE_NAME"]))
|
11696
11697
|
continue;
|
@@ -11719,13 +11720,6 @@ The unique constraint ${source_default.underline.blue(
|
|
11719
11720
|
isAutoincrement = column7["EXTRA"] === "auto_increment";
|
11720
11721
|
isDefaultAnExpression = column7["EXTRA"].includes("DEFAULT_GENERATED");
|
11721
11722
|
}
|
11722
|
-
if (isPrimary) {
|
11723
|
-
if (typeof tableToPk[tableName] === "undefined") {
|
11724
|
-
tableToPk[tableName] = [columnName];
|
11725
|
-
} else {
|
11726
|
-
tableToPk[tableName].push(columnName);
|
11727
|
-
}
|
11728
|
-
}
|
11729
11723
|
if (schema4 !== inputSchema) {
|
11730
11724
|
schemas.push(schema4);
|
11731
11725
|
}
|
@@ -11763,6 +11757,26 @@ The unique constraint ${source_default.underline.blue(
|
|
11763
11757
|
result[tableName].columns[columnName] = newColumn;
|
11764
11758
|
}
|
11765
11759
|
}
|
11760
|
+
const tablePks = await db.execute(
|
11761
|
+
`SELECT table_name, column_name
|
11762
|
+
FROM information_schema.table_constraints t
|
11763
|
+
LEFT JOIN information_schema.key_column_usage k
|
11764
|
+
USING(constraint_name,table_schema,table_name)
|
11765
|
+
WHERE t.constraint_type='PRIMARY KEY'
|
11766
|
+
AND t.table_schema='${inputSchema}'`,
|
11767
|
+
[]
|
11768
|
+
);
|
11769
|
+
const tableToPk = {};
|
11770
|
+
const tableToPkRows = tablePks[0];
|
11771
|
+
for (const tableToPkRow of tableToPkRows) {
|
11772
|
+
const tableName = tableToPkRow["TABLE_NAME"];
|
11773
|
+
const columnName = tableToPkRow["COLUMN_NAME"];
|
11774
|
+
if (typeof tableToPk[tableName] === "undefined") {
|
11775
|
+
tableToPk[tableName] = [columnName];
|
11776
|
+
} else {
|
11777
|
+
tableToPk[tableName].push(columnName);
|
11778
|
+
}
|
11779
|
+
}
|
11766
11780
|
for (const [key, value] of Object.entries(tableToPk)) {
|
11767
11781
|
if (value.length > 1) {
|
11768
11782
|
result[key].compositePrimaryKeys = {
|
@@ -15657,7 +15671,6 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
|
|
15657
15671
|
}
|
15658
15672
|
convert(statement) {
|
15659
15673
|
const { tableName, columnName } = statement;
|
15660
|
-
console.log(statement);
|
15661
15674
|
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
15662
15675
|
return `ALTER TABLE ${tableNameWithSchema} ADD PRIMARY KEY ("${columnName}");`;
|
15663
15676
|
}
|
@@ -16954,7 +16967,37 @@ var init_snapshotsDiffer = __esm({
|
|
16954
16967
|
}).strict();
|
16955
16968
|
applySnapshotsDiff = async (json1, json2, dialect6, schemasResolver, tablesResolver, columnsResolver, prevFull, curFull) => {
|
16956
16969
|
var _a, _b;
|
16957
|
-
|
16970
|
+
let diffResult;
|
16971
|
+
if (dialect6 === "mysql") {
|
16972
|
+
for (const tableName in json1.tables) {
|
16973
|
+
const table4 = json1.tables[tableName];
|
16974
|
+
for (const indexName4 in table4.indexes) {
|
16975
|
+
const index4 = MySqlSquasher.unsquashIdx(table4.indexes[indexName4]);
|
16976
|
+
if (index4.isUnique) {
|
16977
|
+
table4.uniqueConstraints[indexName4] = MySqlSquasher.squashUnique({
|
16978
|
+
name: index4.name,
|
16979
|
+
columns: index4.columns
|
16980
|
+
});
|
16981
|
+
delete json1.tables[tableName].indexes[index4.name];
|
16982
|
+
}
|
16983
|
+
}
|
16984
|
+
}
|
16985
|
+
for (const tableName in json2.tables) {
|
16986
|
+
const table4 = json2.tables[tableName];
|
16987
|
+
for (const indexName4 in table4.indexes) {
|
16988
|
+
const index4 = MySqlSquasher.unsquashIdx(table4.indexes[indexName4]);
|
16989
|
+
if (index4.isUnique) {
|
16990
|
+
table4.uniqueConstraints[indexName4] = MySqlSquasher.squashUnique({
|
16991
|
+
name: index4.name,
|
16992
|
+
columns: index4.columns
|
16993
|
+
});
|
16994
|
+
delete json2.tables[tableName].indexes[index4.name];
|
16995
|
+
}
|
16996
|
+
}
|
16997
|
+
}
|
16998
|
+
diffResult = applyJsonDiff(json1, json2);
|
16999
|
+
}
|
17000
|
+
diffResult = applyJsonDiff(json1, json2);
|
16958
17001
|
if (Object.keys(diffResult).length === 0) {
|
16959
17002
|
return { statements: [], sqlStatements: [], _meta: void 0 };
|
16960
17003
|
}
|
@@ -17125,7 +17168,6 @@ var init_snapshotsDiffer = __esm({
|
|
17125
17168
|
prevFull
|
17126
17169
|
);
|
17127
17170
|
}
|
17128
|
-
;
|
17129
17171
|
alteredCompositePKs = prepareAlterCompositePrimaryKeyMySql(
|
17130
17172
|
it.name,
|
17131
17173
|
it.alteredCompositePKs,
|
@@ -17319,7 +17361,6 @@ var init_snapshotsDiffer = __esm({
|
|
17319
17361
|
jsonStatements.push(...jsonSQLiteCreateTables);
|
17320
17362
|
} else if (dialect6 === "pg") {
|
17321
17363
|
const jsonPgCreateTables = created.map((it) => {
|
17322
|
-
console.log(it);
|
17323
17364
|
return preparePgCreateTableJson(it, curFull);
|
17324
17365
|
});
|
17325
17366
|
jsonStatements.push(...jsonPgCreateTables);
|
@@ -51861,7 +51902,7 @@ init_source();
|
|
51861
51902
|
// package.json
|
51862
51903
|
var package_default = {
|
51863
51904
|
name: "drizzle-kit",
|
51864
|
-
version: "0.19.
|
51905
|
+
version: "0.19.6",
|
51865
51906
|
repository: "https://github.com/drizzle-team/drizzle-kit-mirror",
|
51866
51907
|
author: "Drizzle Team",
|
51867
51908
|
license: "MIT",
|
package/package.json
CHANGED
package/utils.js
CHANGED
@@ -12822,7 +12822,8 @@ var tableSquashed = objectType({
|
|
12822
12822
|
columns: recordType(stringType(), column),
|
12823
12823
|
indexes: recordType(stringType(), stringType()),
|
12824
12824
|
foreignKeys: recordType(stringType(), stringType()),
|
12825
|
-
compositePrimaryKeys: recordType(stringType(), stringType())
|
12825
|
+
compositePrimaryKeys: recordType(stringType(), stringType()),
|
12826
|
+
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
12826
12827
|
}).strict();
|
12827
12828
|
var schemaSquashed = objectType({
|
12828
12829
|
version: literalType("5"),
|
@@ -13285,7 +13286,8 @@ var tableSquashed3 = objectType({
|
|
13285
13286
|
columns: recordType(stringType(), column3),
|
13286
13287
|
indexes: recordType(stringType(), stringType()),
|
13287
13288
|
foreignKeys: recordType(stringType(), stringType()),
|
13288
|
-
compositePrimaryKeys: recordType(stringType(), stringType())
|
13289
|
+
compositePrimaryKeys: recordType(stringType(), stringType()),
|
13290
|
+
uniqueConstraints: recordType(stringType(), stringType()).default({})
|
13289
13291
|
}).strict();
|
13290
13292
|
var schemaSquashed2 = objectType({
|
13291
13293
|
version: latestVersion,
|
@@ -14371,7 +14373,6 @@ var PgAlterTableAlterColumnSetPrimaryKeyConvertor = class extends Convertor {
|
|
14371
14373
|
}
|
14372
14374
|
convert(statement) {
|
14373
14375
|
const { tableName, columnName } = statement;
|
14374
|
-
console.log(statement);
|
14375
14376
|
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
14376
14377
|
return `ALTER TABLE ${tableNameWithSchema} ADD PRIMARY KEY ("${columnName}");`;
|
14377
14378
|
}
|
@@ -15651,7 +15652,37 @@ var diffResultScheme = objectType({
|
|
15651
15652
|
}).strict();
|
15652
15653
|
var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesResolver, columnsResolver, prevFull, curFull) => {
|
15653
15654
|
var _a, _b;
|
15654
|
-
|
15655
|
+
let diffResult;
|
15656
|
+
if (dialect3 === "mysql") {
|
15657
|
+
for (const tableName in json1.tables) {
|
15658
|
+
const table4 = json1.tables[tableName];
|
15659
|
+
for (const indexName in table4.indexes) {
|
15660
|
+
const index4 = MySqlSquasher.unsquashIdx(table4.indexes[indexName]);
|
15661
|
+
if (index4.isUnique) {
|
15662
|
+
table4.uniqueConstraints[indexName] = MySqlSquasher.squashUnique({
|
15663
|
+
name: index4.name,
|
15664
|
+
columns: index4.columns
|
15665
|
+
});
|
15666
|
+
delete json1.tables[tableName].indexes[index4.name];
|
15667
|
+
}
|
15668
|
+
}
|
15669
|
+
}
|
15670
|
+
for (const tableName in json2.tables) {
|
15671
|
+
const table4 = json2.tables[tableName];
|
15672
|
+
for (const indexName in table4.indexes) {
|
15673
|
+
const index4 = MySqlSquasher.unsquashIdx(table4.indexes[indexName]);
|
15674
|
+
if (index4.isUnique) {
|
15675
|
+
table4.uniqueConstraints[indexName] = MySqlSquasher.squashUnique({
|
15676
|
+
name: index4.name,
|
15677
|
+
columns: index4.columns
|
15678
|
+
});
|
15679
|
+
delete json2.tables[tableName].indexes[index4.name];
|
15680
|
+
}
|
15681
|
+
}
|
15682
|
+
}
|
15683
|
+
diffResult = applyJsonDiff(json1, json2);
|
15684
|
+
}
|
15685
|
+
diffResult = applyJsonDiff(json1, json2);
|
15655
15686
|
if (Object.keys(diffResult).length === 0) {
|
15656
15687
|
return { statements: [], sqlStatements: [], _meta: void 0 };
|
15657
15688
|
}
|
@@ -15822,7 +15853,6 @@ var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesR
|
|
15822
15853
|
prevFull
|
15823
15854
|
);
|
15824
15855
|
}
|
15825
|
-
;
|
15826
15856
|
alteredCompositePKs = prepareAlterCompositePrimaryKeyMySql(
|
15827
15857
|
it.name,
|
15828
15858
|
it.alteredCompositePKs,
|
@@ -16016,7 +16046,6 @@ var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesR
|
|
16016
16046
|
jsonStatements.push(...jsonSQLiteCreateTables);
|
16017
16047
|
} else if (dialect3 === "pg") {
|
16018
16048
|
const jsonPgCreateTables = created.map((it) => {
|
16019
|
-
console.log(it);
|
16020
16049
|
return preparePgCreateTableJson(it, curFull);
|
16021
16050
|
});
|
16022
16051
|
jsonStatements.push(...jsonPgCreateTables);
|