drizzle-kit 0.19.4 → 0.19.5-0b8d69c
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/index.cjs +42 -8
- package/package.json +1 -1
- package/utils.js +37 -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,
|
@@ -15011,7 +15013,7 @@ var init_sqlgenerator = __esm({
|
|
15011
15013
|
if (typeof compositePKs !== "undefined" && compositePKs.length > 0) {
|
15012
15014
|
statement += ",\n";
|
15013
15015
|
const compositePK4 = MySqlSquasher.unsquashPK(compositePKs[0]);
|
15014
|
-
statement += ` CONSTRAINT \`${st.compositePkName}\` PRIMARY KEY(
|
15016
|
+
statement += ` CONSTRAINT \`${st.compositePkName}\` PRIMARY KEY(\`${compositePK4.columns.join(`\`,\``)}\`)`;
|
15015
15017
|
}
|
15016
15018
|
if (typeof uniqueConstraints !== "undefined" && uniqueConstraints.length > 0) {
|
15017
15019
|
for (const uniqueConstraint4 of uniqueConstraints) {
|
@@ -15054,7 +15056,7 @@ var init_sqlgenerator = __esm({
|
|
15054
15056
|
}
|
15055
15057
|
compositePKs.forEach((it) => {
|
15056
15058
|
statement += ",\n ";
|
15057
|
-
statement += `PRIMARY KEY(${it.map((it2) => `\`${it2}\``).join(", ")})
|
15059
|
+
statement += `PRIMARY KEY(${it.map((it2) => `\`${it2}\``).join(", ")})`;
|
15058
15060
|
});
|
15059
15061
|
for (let i = 0; i < referenceData.length; i++) {
|
15060
15062
|
const referenceAsString = referenceData[i];
|
@@ -16954,7 +16956,37 @@ var init_snapshotsDiffer = __esm({
|
|
16954
16956
|
}).strict();
|
16955
16957
|
applySnapshotsDiff = async (json1, json2, dialect6, schemasResolver, tablesResolver, columnsResolver, prevFull, curFull) => {
|
16956
16958
|
var _a, _b;
|
16957
|
-
|
16959
|
+
let diffResult;
|
16960
|
+
if (dialect6 === "mysql") {
|
16961
|
+
for (const tableName in json1.tables) {
|
16962
|
+
const table4 = json1.tables[tableName];
|
16963
|
+
for (const indexName4 in table4.indexes) {
|
16964
|
+
const index4 = MySqlSquasher.unsquashIdx(table4.indexes[indexName4]);
|
16965
|
+
if (index4.isUnique) {
|
16966
|
+
table4.uniqueConstraints[indexName4] = MySqlSquasher.squashUnique({
|
16967
|
+
name: index4.name,
|
16968
|
+
columns: index4.columns
|
16969
|
+
});
|
16970
|
+
delete json1.tables[tableName].indexes[index4.name];
|
16971
|
+
}
|
16972
|
+
}
|
16973
|
+
}
|
16974
|
+
for (const tableName in json2.tables) {
|
16975
|
+
const table4 = json2.tables[tableName];
|
16976
|
+
for (const indexName4 in table4.indexes) {
|
16977
|
+
const index4 = MySqlSquasher.unsquashIdx(table4.indexes[indexName4]);
|
16978
|
+
if (index4.isUnique) {
|
16979
|
+
table4.uniqueConstraints[indexName4] = MySqlSquasher.squashUnique({
|
16980
|
+
name: index4.name,
|
16981
|
+
columns: index4.columns
|
16982
|
+
});
|
16983
|
+
delete json2.tables[tableName].indexes[index4.name];
|
16984
|
+
}
|
16985
|
+
}
|
16986
|
+
}
|
16987
|
+
diffResult = applyJsonDiff(json1, json2);
|
16988
|
+
}
|
16989
|
+
diffResult = applyJsonDiff(json1, json2);
|
16958
16990
|
if (Object.keys(diffResult).length === 0) {
|
16959
16991
|
return { statements: [], sqlStatements: [], _meta: void 0 };
|
16960
16992
|
}
|
@@ -17125,7 +17157,6 @@ var init_snapshotsDiffer = __esm({
|
|
17125
17157
|
prevFull
|
17126
17158
|
);
|
17127
17159
|
}
|
17128
|
-
;
|
17129
17160
|
alteredCompositePKs = prepareAlterCompositePrimaryKeyMySql(
|
17130
17161
|
it.name,
|
17131
17162
|
it.alteredCompositePKs,
|
@@ -37657,6 +37688,9 @@ import { sql } from "drizzle-orm"
|
|
37657
37688
|
if (typeof defaultValue === "string" && defaultValue.startsWith("(") && defaultValue.endsWith(")")) {
|
37658
37689
|
return `sql\`${defaultValue}\``;
|
37659
37690
|
}
|
37691
|
+
if (defaultValue === "NULL") {
|
37692
|
+
return `sql\`NULL\``;
|
37693
|
+
}
|
37660
37694
|
return defaultValue;
|
37661
37695
|
};
|
37662
37696
|
column5 = (type, name, defaultValue, autoincrement, casing) => {
|
@@ -51858,7 +51892,7 @@ init_source();
|
|
51858
51892
|
// package.json
|
51859
51893
|
var package_default = {
|
51860
51894
|
name: "drizzle-kit",
|
51861
|
-
version: "0.19.
|
51895
|
+
version: "0.19.5",
|
51862
51896
|
repository: "https://github.com/drizzle-team/drizzle-kit-mirror",
|
51863
51897
|
author: "Drizzle Team",
|
51864
51898
|
license: "MIT",
|
@@ -52700,7 +52734,7 @@ var dbPushMysqlCommand = new import_commander.Command("push:mysql").option(
|
|
52700
52734
|
var dbPushSqliteCommand = new import_commander.Command("push:sqlite").option(
|
52701
52735
|
"--config <config>",
|
52702
52736
|
"Path to a config.ts file, drizzle.config.ts by default"
|
52703
|
-
).option("--tableFilters", `Table name filters`).option("--connectionString <connectionString>", "SQLite connection string").option("--driver <driver>", "SQLite database path").option("--url <url>", "SQLite database path").option("--auth-token <authToken>", "SQLite database path").option("--verbose", "Print all statements for each push").option("--strict", "Always ask for confirmation").action(async (options) => {
|
52737
|
+
).option("--schema <schema>", "Path to a schema file or folder").option("--tableFilters", `Table name filters`).option("--connectionString <connectionString>", "SQLite connection string").option("--driver <driver>", "SQLite database path").option("--url <url>", "SQLite database path").option("--auth-token <authToken>", "SQLite database path").option("--verbose", "Print all statements for each push").option("--strict", "Always ask for confirmation").action(async (options) => {
|
52704
52738
|
printVersions();
|
52705
52739
|
assertPackages("drizzle-orm");
|
52706
52740
|
assertOrmCoreVersion();
|
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,
|
@@ -13725,7 +13727,7 @@ var MySqlCreateTableConvertor = class extends Convertor {
|
|
13725
13727
|
if (typeof compositePKs !== "undefined" && compositePKs.length > 0) {
|
13726
13728
|
statement += ",\n";
|
13727
13729
|
const compositePK4 = MySqlSquasher.unsquashPK(compositePKs[0]);
|
13728
|
-
statement += ` CONSTRAINT \`${st.compositePkName}\` PRIMARY KEY(
|
13730
|
+
statement += ` CONSTRAINT \`${st.compositePkName}\` PRIMARY KEY(\`${compositePK4.columns.join(`\`,\``)}\`)`;
|
13729
13731
|
}
|
13730
13732
|
if (typeof uniqueConstraints !== "undefined" && uniqueConstraints.length > 0) {
|
13731
13733
|
for (const uniqueConstraint4 of uniqueConstraints) {
|
@@ -13768,7 +13770,7 @@ var SQLiteCreateTableConvertor = class extends Convertor {
|
|
13768
13770
|
}
|
13769
13771
|
compositePKs.forEach((it) => {
|
13770
13772
|
statement += ",\n ";
|
13771
|
-
statement += `PRIMARY KEY(${it.map((it2) => `\`${it2}\``).join(", ")})
|
13773
|
+
statement += `PRIMARY KEY(${it.map((it2) => `\`${it2}\``).join(", ")})`;
|
13772
13774
|
});
|
13773
13775
|
for (let i = 0; i < referenceData.length; i++) {
|
13774
13776
|
const referenceAsString = referenceData[i];
|
@@ -15651,7 +15653,37 @@ var diffResultScheme = objectType({
|
|
15651
15653
|
}).strict();
|
15652
15654
|
var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesResolver, columnsResolver, prevFull, curFull) => {
|
15653
15655
|
var _a, _b;
|
15654
|
-
|
15656
|
+
let diffResult;
|
15657
|
+
if (dialect3 === "mysql") {
|
15658
|
+
for (const tableName in json1.tables) {
|
15659
|
+
const table4 = json1.tables[tableName];
|
15660
|
+
for (const indexName in table4.indexes) {
|
15661
|
+
const index4 = MySqlSquasher.unsquashIdx(table4.indexes[indexName]);
|
15662
|
+
if (index4.isUnique) {
|
15663
|
+
table4.uniqueConstraints[indexName] = MySqlSquasher.squashUnique({
|
15664
|
+
name: index4.name,
|
15665
|
+
columns: index4.columns
|
15666
|
+
});
|
15667
|
+
delete json1.tables[tableName].indexes[index4.name];
|
15668
|
+
}
|
15669
|
+
}
|
15670
|
+
}
|
15671
|
+
for (const tableName in json2.tables) {
|
15672
|
+
const table4 = json2.tables[tableName];
|
15673
|
+
for (const indexName in table4.indexes) {
|
15674
|
+
const index4 = MySqlSquasher.unsquashIdx(table4.indexes[indexName]);
|
15675
|
+
if (index4.isUnique) {
|
15676
|
+
table4.uniqueConstraints[indexName] = MySqlSquasher.squashUnique({
|
15677
|
+
name: index4.name,
|
15678
|
+
columns: index4.columns
|
15679
|
+
});
|
15680
|
+
delete json2.tables[tableName].indexes[index4.name];
|
15681
|
+
}
|
15682
|
+
}
|
15683
|
+
}
|
15684
|
+
diffResult = applyJsonDiff(json1, json2);
|
15685
|
+
}
|
15686
|
+
diffResult = applyJsonDiff(json1, json2);
|
15655
15687
|
if (Object.keys(diffResult).length === 0) {
|
15656
15688
|
return { statements: [], sqlStatements: [], _meta: void 0 };
|
15657
15689
|
}
|
@@ -15822,7 +15854,6 @@ var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesR
|
|
15822
15854
|
prevFull
|
15823
15855
|
);
|
15824
15856
|
}
|
15825
|
-
;
|
15826
15857
|
alteredCompositePKs = prepareAlterCompositePrimaryKeyMySql(
|
15827
15858
|
it.name,
|
15828
15859
|
it.alteredCompositePKs,
|