drizzle-kit 0.20.6 → 0.20.7-02055e2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin.cjs +51 -9
- package/package.json +1 -1
- package/utils.js +24 -5
package/bin.cjs
CHANGED
@@ -11983,8 +11983,8 @@ We have encountered a collision between the index name on columns ${source_defau
|
|
11983
11983
|
}
|
11984
11984
|
for (const [key, value] of Object.entries(tableToPk)) {
|
11985
11985
|
result[key].compositePrimaryKeys = {
|
11986
|
-
[`${key}_${value.join("_")}
|
11987
|
-
name: `${key}_${value.join("_")}
|
11986
|
+
[`${key}_${value.join("_")}`]: {
|
11987
|
+
name: `${key}_${value.join("_")}`,
|
11988
11988
|
columns: value
|
11989
11989
|
}
|
11990
11990
|
};
|
@@ -12180,6 +12180,7 @@ var init_pgSerializer = __esm({
|
|
12180
12180
|
};
|
12181
12181
|
generatePgSnapshot = (tables, enums, schemas, schemaFilter) => {
|
12182
12182
|
const result = {};
|
12183
|
+
const indexesInSchema = {};
|
12183
12184
|
for (const table4 of tables) {
|
12184
12185
|
const {
|
12185
12186
|
name: tableName,
|
@@ -12331,6 +12332,24 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
12331
12332
|
return it.name;
|
12332
12333
|
}
|
12333
12334
|
});
|
12335
|
+
if (typeof indexesInSchema[schema4 ?? "public"] !== "undefined") {
|
12336
|
+
if (indexesInSchema[schema4 ?? "public"].includes(name)) {
|
12337
|
+
console.log(
|
12338
|
+
`
|
12339
|
+
${withStyle.errorWarning(
|
12340
|
+
`We've found duplicated index name across ${source_default.underline.blue(
|
12341
|
+
schema4 ?? "public"
|
12342
|
+
)} schema. Please rename your index in either the ${source_default.underline.blue(
|
12343
|
+
tableName
|
12344
|
+
)} table or the table with the duplicated index name`
|
12345
|
+
)}`
|
12346
|
+
);
|
12347
|
+
process.exit(1);
|
12348
|
+
}
|
12349
|
+
indexesInSchema[schema4 ?? "public"].push(name);
|
12350
|
+
} else {
|
12351
|
+
indexesInSchema[schema4 ?? "public"] = [name];
|
12352
|
+
}
|
12334
12353
|
indexesObject[name] = {
|
12335
12354
|
name,
|
12336
12355
|
columns: indexColumns,
|
@@ -15458,7 +15477,7 @@ var init_sqlgenerator = __esm({
|
|
15458
15477
|
if (typeof compositePKs !== "undefined" && compositePKs.length > 0) {
|
15459
15478
|
statement += ",\n";
|
15460
15479
|
const compositePK4 = PgSquasher.unsquashPK(compositePKs[0]);
|
15461
|
-
statement += ` CONSTRAINT ${st.compositePkName} PRIMARY KEY("${compositePK4.columns.join(`","`)}")`;
|
15480
|
+
statement += ` CONSTRAINT "${st.compositePkName}" PRIMARY KEY("${compositePK4.columns.join(`","`)}")`;
|
15462
15481
|
}
|
15463
15482
|
if (typeof uniqueConstraints !== "undefined" && uniqueConstraints.length > 0) {
|
15464
15483
|
for (const uniqueConstraint4 of uniqueConstraints) {
|
@@ -17850,13 +17869,14 @@ var init_snapshotsDiffer = __esm({
|
|
17850
17869
|
jsonStatements.push(...jsonDropTables);
|
17851
17870
|
jsonStatements.push(...jsonRenameTables);
|
17852
17871
|
jsonStatements.push(...jsonRenameColumnsStatements);
|
17853
|
-
jsonStatements.push(...jsonDeletedCompositePKs);
|
17854
17872
|
if (dialect6 !== "mysql") {
|
17855
17873
|
jsonStatements.push(...jsonDeletedUniqueConstraints);
|
17856
17874
|
}
|
17857
17875
|
jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
|
17858
17876
|
jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
|
17877
|
+
jsonStatements.push(...jsonDeletedCompositePKs);
|
17859
17878
|
jsonStatements.push(...jsonTableAlternations.alterColumns);
|
17879
|
+
jsonStatements.push(...jsonAddedCompositePKs);
|
17860
17880
|
if (dialect6 === "mysql") {
|
17861
17881
|
jsonStatements.push(...jsonAddedUniqueConstraints);
|
17862
17882
|
jsonStatements.push(...jsonDeletedUniqueConstraints);
|
@@ -17868,7 +17888,6 @@ var init_snapshotsDiffer = __esm({
|
|
17868
17888
|
jsonStatements.push(...jsonTableAlternations.dropColumns);
|
17869
17889
|
if (dialect6 !== "sqlite")
|
17870
17890
|
jsonStatements.push(...jsonCreateReferences);
|
17871
|
-
jsonStatements.push(...jsonAddedCompositePKs);
|
17872
17891
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
17873
17892
|
if (dialect6 !== "mysql") {
|
17874
17893
|
jsonStatements.push(...jsonAddedUniqueConstraints);
|
@@ -62158,7 +62177,7 @@ init_source();
|
|
62158
62177
|
// package.json
|
62159
62178
|
var package_default = {
|
62160
62179
|
name: "drizzle-kit",
|
62161
|
-
version: "0.20.
|
62180
|
+
version: "0.20.7",
|
62162
62181
|
repository: "https://github.com/drizzle-team/drizzle-kit-mirror",
|
62163
62182
|
author: "Drizzle Team",
|
62164
62183
|
license: "MIT",
|
@@ -62383,6 +62402,7 @@ init_source();
|
|
62383
62402
|
var import_hanji9 = __toESM(require_hanji());
|
62384
62403
|
init_mysqlSchema();
|
62385
62404
|
init_selector_ui();
|
62405
|
+
init_outputs();
|
62386
62406
|
var filterStatements = (statements, currentSchema, prevSchema) => {
|
62387
62407
|
return statements.filter((statement) => {
|
62388
62408
|
if (statement.type === "alter_table_alter_column_set_type") {
|
@@ -62426,7 +62446,8 @@ var filterStatements = (statements, currentSchema, prevSchema) => {
|
|
62426
62446
|
};
|
62427
62447
|
var logSuggestionsAndReturn = async ({
|
62428
62448
|
connection,
|
62429
|
-
statements
|
62449
|
+
statements,
|
62450
|
+
json2
|
62430
62451
|
}) => {
|
62431
62452
|
let shouldAskForApprove = false;
|
62432
62453
|
const statementsToExecute = [];
|
@@ -62512,7 +62533,6 @@ var logSuggestionsAndReturn = async ({
|
|
62512
62533
|
shouldAskForApprove = true;
|
62513
62534
|
}
|
62514
62535
|
}
|
62515
|
-
shouldAskForApprove = true;
|
62516
62536
|
} else if (statement.type === "alter_table_alter_column_set_notnull") {
|
62517
62537
|
if (typeof statement.columnDefault === "undefined") {
|
62518
62538
|
const res = await connection.query(
|
@@ -62534,6 +62554,16 @@ var logSuggestionsAndReturn = async ({
|
|
62534
62554
|
const res = await connection.query(
|
62535
62555
|
`select count(*) as count from \`${statement.tableName}\``
|
62536
62556
|
);
|
62557
|
+
if (Object.values(json2.tables[statement.tableName].columns).filter(
|
62558
|
+
(column7) => column7.autoincrement
|
62559
|
+
).length > 0) {
|
62560
|
+
console.log(
|
62561
|
+
`${withStyle.errorWarning(
|
62562
|
+
`You have removed the primary key from a ${statement.tableName} table without removing the auto-increment property from this table. As the database error states: 'there can be only one auto column, and it must be defined as a key. Make sure to remove autoincrement from ${statement.tableName} table`
|
62563
|
+
)}`
|
62564
|
+
);
|
62565
|
+
process.exit(1);
|
62566
|
+
}
|
62537
62567
|
const count = Number(res[0][0].count);
|
62538
62568
|
if (count > 0) {
|
62539
62569
|
infoToPrint.push(
|
@@ -62544,6 +62574,17 @@ var logSuggestionsAndReturn = async ({
|
|
62544
62574
|
tablesToTruncate.push(statement.tableName);
|
62545
62575
|
shouldAskForApprove = true;
|
62546
62576
|
}
|
62577
|
+
} else if (statement.type === "delete_composite_pk") {
|
62578
|
+
if (Object.values(json2.tables[statement.tableName].columns).filter(
|
62579
|
+
(column7) => column7.autoincrement
|
62580
|
+
).length > 0) {
|
62581
|
+
console.log(
|
62582
|
+
`${withStyle.errorWarning(
|
62583
|
+
`You have removed the primary key from a ${statement.tableName} table without removing the auto-increment property from this table. As the database error states: 'there can be only one auto column, and it must be defined as a key. Make sure to remove autoincrement from ${statement.tableName} table`
|
62584
|
+
)}`
|
62585
|
+
);
|
62586
|
+
process.exit(1);
|
62587
|
+
}
|
62547
62588
|
} else if (statement.type === "alter_table_add_column") {
|
62548
62589
|
if (statement.column.notNull && typeof statement.column.default === "undefined") {
|
62549
62590
|
const res = await connection.query(
|
@@ -63016,7 +63057,8 @@ var dbPushMysqlCommand = new import_commander.Command("push:mysql").option(
|
|
63016
63057
|
schemasToRemove
|
63017
63058
|
} = await logSuggestionsAndReturn({
|
63018
63059
|
connection: connection.client,
|
63019
|
-
statements: filteredStatements
|
63060
|
+
statements: filteredStatements,
|
63061
|
+
json2: statements == null ? void 0 : statements.validatedCur
|
63020
63062
|
});
|
63021
63063
|
const filteredSqlStatements = filteredStatements.map(
|
63022
63064
|
(filteredStatement) => fromJson([filteredStatement], "mysql")[0]
|
package/package.json
CHANGED
package/utils.js
CHANGED
@@ -11709,8 +11709,8 @@ We have encountered a collision between the index name on columns ${source_defau
|
|
11709
11709
|
}
|
11710
11710
|
for (const [key, value] of Object.entries(tableToPk)) {
|
11711
11711
|
result[key].compositePrimaryKeys = {
|
11712
|
-
[`${key}_${value.join("_")}
|
11713
|
-
name: `${key}_${value.join("_")}
|
11712
|
+
[`${key}_${value.join("_")}`]: {
|
11713
|
+
name: `${key}_${value.join("_")}`,
|
11714
11714
|
columns: value
|
11715
11715
|
}
|
11716
11716
|
};
|
@@ -11906,6 +11906,7 @@ var init_pgSerializer = __esm({
|
|
11906
11906
|
};
|
11907
11907
|
generatePgSnapshot = (tables, enums, schemas, schemaFilter) => {
|
11908
11908
|
const result = {};
|
11909
|
+
const indexesInSchema = {};
|
11909
11910
|
for (const table4 of tables) {
|
11910
11911
|
const {
|
11911
11912
|
name: tableName,
|
@@ -12057,6 +12058,24 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
12057
12058
|
return it.name;
|
12058
12059
|
}
|
12059
12060
|
});
|
12061
|
+
if (typeof indexesInSchema[schema4 ?? "public"] !== "undefined") {
|
12062
|
+
if (indexesInSchema[schema4 ?? "public"].includes(name)) {
|
12063
|
+
console.log(
|
12064
|
+
`
|
12065
|
+
${withStyle.errorWarning(
|
12066
|
+
`We've found duplicated index name across ${source_default.underline.blue(
|
12067
|
+
schema4 ?? "public"
|
12068
|
+
)} schema. Please rename your index in either the ${source_default.underline.blue(
|
12069
|
+
tableName
|
12070
|
+
)} table or the table with the duplicated index name`
|
12071
|
+
)}`
|
12072
|
+
);
|
12073
|
+
process.exit(1);
|
12074
|
+
}
|
12075
|
+
indexesInSchema[schema4 ?? "public"].push(name);
|
12076
|
+
} else {
|
12077
|
+
indexesInSchema[schema4 ?? "public"] = [name];
|
12078
|
+
}
|
12060
12079
|
indexesObject[name] = {
|
12061
12080
|
name,
|
12062
12081
|
columns: indexColumns,
|
@@ -15176,7 +15195,7 @@ var init_sqlgenerator = __esm({
|
|
15176
15195
|
if (typeof compositePKs !== "undefined" && compositePKs.length > 0) {
|
15177
15196
|
statement += ",\n";
|
15178
15197
|
const compositePK4 = PgSquasher.unsquashPK(compositePKs[0]);
|
15179
|
-
statement += ` CONSTRAINT ${st.compositePkName} PRIMARY KEY("${compositePK4.columns.join(`","`)}")`;
|
15198
|
+
statement += ` CONSTRAINT "${st.compositePkName}" PRIMARY KEY("${compositePK4.columns.join(`","`)}")`;
|
15180
15199
|
}
|
15181
15200
|
if (typeof uniqueConstraints !== "undefined" && uniqueConstraints.length > 0) {
|
15182
15201
|
for (const uniqueConstraint4 of uniqueConstraints) {
|
@@ -17568,13 +17587,14 @@ var init_snapshotsDiffer = __esm({
|
|
17568
17587
|
jsonStatements.push(...jsonDropTables);
|
17569
17588
|
jsonStatements.push(...jsonRenameTables);
|
17570
17589
|
jsonStatements.push(...jsonRenameColumnsStatements);
|
17571
|
-
jsonStatements.push(...jsonDeletedCompositePKs);
|
17572
17590
|
if (dialect6 !== "mysql") {
|
17573
17591
|
jsonStatements.push(...jsonDeletedUniqueConstraints);
|
17574
17592
|
}
|
17575
17593
|
jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
|
17576
17594
|
jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
|
17595
|
+
jsonStatements.push(...jsonDeletedCompositePKs);
|
17577
17596
|
jsonStatements.push(...jsonTableAlternations.alterColumns);
|
17597
|
+
jsonStatements.push(...jsonAddedCompositePKs);
|
17578
17598
|
if (dialect6 === "mysql") {
|
17579
17599
|
jsonStatements.push(...jsonAddedUniqueConstraints);
|
17580
17600
|
jsonStatements.push(...jsonDeletedUniqueConstraints);
|
@@ -17586,7 +17606,6 @@ var init_snapshotsDiffer = __esm({
|
|
17586
17606
|
jsonStatements.push(...jsonTableAlternations.dropColumns);
|
17587
17607
|
if (dialect6 !== "sqlite")
|
17588
17608
|
jsonStatements.push(...jsonCreateReferences);
|
17589
|
-
jsonStatements.push(...jsonAddedCompositePKs);
|
17590
17609
|
jsonStatements.push(...jsonAlteredCompositePKs);
|
17591
17610
|
if (dialect6 !== "mysql") {
|
17592
17611
|
jsonStatements.push(...jsonAddedUniqueConstraints);
|