drizzle-kit 0.19.4-2a2e18d → 0.19.4
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 +264 -113
- package/package.json +2 -2
- package/utils.js +10 -9
package/index.cjs
CHANGED
|
@@ -4189,7 +4189,7 @@ var require_hanji = __commonJS({
|
|
|
4189
4189
|
}
|
|
4190
4190
|
};
|
|
4191
4191
|
exports.TaskTerminal = TaskTerminal;
|
|
4192
|
-
function
|
|
4192
|
+
function render7(view) {
|
|
4193
4193
|
const { stdin, stdout, closable } = (0, readline_1.prepareReadLine)();
|
|
4194
4194
|
if (view instanceof Prompt3) {
|
|
4195
4195
|
const terminal = new Terminal(view, stdin, stdout, closable);
|
|
@@ -4201,7 +4201,7 @@ var require_hanji = __commonJS({
|
|
|
4201
4201
|
closable.close();
|
|
4202
4202
|
return;
|
|
4203
4203
|
}
|
|
4204
|
-
exports.render =
|
|
4204
|
+
exports.render = render7;
|
|
4205
4205
|
function renderWithTask4(view, task) {
|
|
4206
4206
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4207
4207
|
const terminal = new TaskTerminal(view, process.stdout);
|
|
@@ -11384,6 +11384,71 @@ var init_mysqlImports = __esm({
|
|
|
11384
11384
|
}
|
|
11385
11385
|
});
|
|
11386
11386
|
|
|
11387
|
+
// src/cli/validations/outputs.ts
|
|
11388
|
+
var withStyle, outputs;
|
|
11389
|
+
var init_outputs = __esm({
|
|
11390
|
+
"src/cli/validations/outputs.ts"() {
|
|
11391
|
+
init_source();
|
|
11392
|
+
withStyle = {
|
|
11393
|
+
error: (str) => `${source_default.red(`${source_default.white.bgRed(" Invalid input ")} ${str}`)}`,
|
|
11394
|
+
warning: (str) => `${source_default.white.bgGray(" Warning ")} ${str}`,
|
|
11395
|
+
errorWarning: (str) => `${source_default.red(`${source_default.white.bgRed(" Warning ")} ${str}`)}`,
|
|
11396
|
+
fullWarning: (str) => `${source_default.black.bgYellow("[Warning]")} ${source_default.bold(str)}`
|
|
11397
|
+
};
|
|
11398
|
+
outputs = {
|
|
11399
|
+
studio: {
|
|
11400
|
+
drivers: (param) => withStyle.error(
|
|
11401
|
+
`"${param}" is not a valid driver. Available drivers: "pg", "mysql2", "better-sqlite", "libsql", "turso". You can read more about drizzle.config: https://orm.drizzle.team/kit-docs/config-reference`
|
|
11402
|
+
),
|
|
11403
|
+
noCredentials: () => withStyle.error(
|
|
11404
|
+
`You need to specify a "dbCredentials" param in you config. It will help drizzle to know how to query you database. You can read more about drizzle.config: https://orm.drizzle.team/kit-docs/config-reference`
|
|
11405
|
+
),
|
|
11406
|
+
noDriver: () => withStyle.error(
|
|
11407
|
+
`You need to specify a "driver" param in you config. It will help drizzle to know how to query you database. You can read more about drizzle.config: https://orm.drizzle.team/kit-docs/config-reference`
|
|
11408
|
+
)
|
|
11409
|
+
},
|
|
11410
|
+
common: {
|
|
11411
|
+
ambiguousParams: (command) => withStyle.error(
|
|
11412
|
+
`You can't use both --config and other cli options for ${command} command`
|
|
11413
|
+
),
|
|
11414
|
+
schema: (command) => withStyle.error(`"--schema" is a required field for ${command} command`),
|
|
11415
|
+
schemaConfig: (command) => withStyle.error(
|
|
11416
|
+
`"schema" is a required field in drizzle.config for ${command} command`
|
|
11417
|
+
)
|
|
11418
|
+
},
|
|
11419
|
+
postgres: {
|
|
11420
|
+
connection: {
|
|
11421
|
+
driver: () => withStyle.error(`Only "pg" is available options for "--driver"`),
|
|
11422
|
+
required: () => withStyle.error(
|
|
11423
|
+
`Either "connectionString" or "host", "database" are required for database connection`
|
|
11424
|
+
)
|
|
11425
|
+
}
|
|
11426
|
+
},
|
|
11427
|
+
mysql: {
|
|
11428
|
+
connection: {
|
|
11429
|
+
driver: () => withStyle.error(`Only "mysql2" is available options for "--driver"`),
|
|
11430
|
+
required: () => withStyle.error(
|
|
11431
|
+
`Either "connectionString" or "host", "database" are required for database connection`
|
|
11432
|
+
)
|
|
11433
|
+
}
|
|
11434
|
+
},
|
|
11435
|
+
sqlite: {
|
|
11436
|
+
connection: {
|
|
11437
|
+
driver: () => withStyle.error(
|
|
11438
|
+
`Either "turso", "libsql", "better-sqlite" are available options for "--driver"`
|
|
11439
|
+
),
|
|
11440
|
+
url: (driver) => withStyle.error(`"url" is a required option for driver "${driver}". You can read more about drizzle.config: https://orm.drizzle.team/kit-docs/config-reference`),
|
|
11441
|
+
authToken: (driver) => withStyle.error(
|
|
11442
|
+
`"authToken" is a required option for driver "${driver}". You can read more about drizzle.config: https://orm.drizzle.team/kit-docs/config-reference`
|
|
11443
|
+
)
|
|
11444
|
+
},
|
|
11445
|
+
introspect: {},
|
|
11446
|
+
push: {}
|
|
11447
|
+
}
|
|
11448
|
+
};
|
|
11449
|
+
}
|
|
11450
|
+
});
|
|
11451
|
+
|
|
11387
11452
|
// src/serializer/mysqlSerializer.ts
|
|
11388
11453
|
var mysqlSerializer_exports = {};
|
|
11389
11454
|
__export(mysqlSerializer_exports, {
|
|
@@ -11416,6 +11481,8 @@ var init_mysqlSerializer = __esm({
|
|
|
11416
11481
|
import_mysql_core3 = require("drizzle-orm/mysql-core");
|
|
11417
11482
|
import_drizzle_orm3 = require("drizzle-orm");
|
|
11418
11483
|
init_serializer();
|
|
11484
|
+
init_outputs();
|
|
11485
|
+
init_source();
|
|
11419
11486
|
dialect3 = new import_mysql_core2.MySqlDialect();
|
|
11420
11487
|
indexName = (tableName, columns) => {
|
|
11421
11488
|
return `${tableName}_${columns.join("_")}_index`;
|
|
@@ -11458,6 +11525,24 @@ var init_mysqlSerializer = __esm({
|
|
|
11458
11525
|
// : undefined,
|
|
11459
11526
|
};
|
|
11460
11527
|
if (column7.isUnique) {
|
|
11528
|
+
const existingUnique = uniqueConstraintObject[column7.uniqueName];
|
|
11529
|
+
if (typeof existingUnique !== "undefined") {
|
|
11530
|
+
console.log(
|
|
11531
|
+
`
|
|
11532
|
+
${withStyle.errorWarning(`We've found duplicated unique constraint names in ${source_default.underline.blue(
|
|
11533
|
+
tableName
|
|
11534
|
+
)} table.
|
|
11535
|
+
The unique constraint ${source_default.underline.blue(
|
|
11536
|
+
column7.uniqueName
|
|
11537
|
+
)} on the ${source_default.underline.blue(
|
|
11538
|
+
column7.name
|
|
11539
|
+
)} column is confilcting with a unique constraint name already defined for ${source_default.underline.blue(
|
|
11540
|
+
existingUnique.columns.join(",")
|
|
11541
|
+
)} columns
|
|
11542
|
+
`)}`
|
|
11543
|
+
);
|
|
11544
|
+
process.exit(1);
|
|
11545
|
+
}
|
|
11461
11546
|
uniqueConstraintObject[column7.uniqueName] = {
|
|
11462
11547
|
name: column7.uniqueName,
|
|
11463
11548
|
columns: [columnToSet.name]
|
|
@@ -11499,9 +11584,29 @@ var init_mysqlSerializer = __esm({
|
|
|
11499
11584
|
columnsObject[column7.name].notNull = true;
|
|
11500
11585
|
}
|
|
11501
11586
|
});
|
|
11502
|
-
uniqueConstraints.map((unq) => {
|
|
11587
|
+
uniqueConstraints == null ? void 0 : uniqueConstraints.map((unq) => {
|
|
11503
11588
|
const columnNames = unq.columns.map((c) => c.name);
|
|
11504
11589
|
const name = unq.name ?? (0, import_mysql_core2.uniqueKeyName)(table4, columnNames);
|
|
11590
|
+
const existingUnique = uniqueConstraintObject[name];
|
|
11591
|
+
if (typeof existingUnique !== "undefined") {
|
|
11592
|
+
console.log(
|
|
11593
|
+
`
|
|
11594
|
+
${withStyle.errorWarning(
|
|
11595
|
+
`We've found duplicated unique constraint names in ${source_default.underline.blue(
|
|
11596
|
+
tableName
|
|
11597
|
+
)} table.
|
|
11598
|
+
The unique constraint ${source_default.underline.blue(
|
|
11599
|
+
name
|
|
11600
|
+
)} on the ${source_default.underline.blue(
|
|
11601
|
+
columnNames.join(",")
|
|
11602
|
+
)} columns is confilcting with a unique constraint name already defined for ${source_default.underline.blue(
|
|
11603
|
+
existingUnique.columns.join(",")
|
|
11604
|
+
)} columns
|
|
11605
|
+
`
|
|
11606
|
+
)}`
|
|
11607
|
+
);
|
|
11608
|
+
process.exit(1);
|
|
11609
|
+
}
|
|
11505
11610
|
uniqueConstraintObject[name] = {
|
|
11506
11611
|
name: unq.name,
|
|
11507
11612
|
columns: columnNames
|
|
@@ -11753,7 +11858,9 @@ var init_mysqlSerializer = __esm({
|
|
|
11753
11858
|
}
|
|
11754
11859
|
if (isUnique) {
|
|
11755
11860
|
if (typeof tableInResult.uniqueConstraints[constraintName] !== "undefined") {
|
|
11756
|
-
tableInResult.uniqueConstraints[constraintName].columns.push(
|
|
11861
|
+
tableInResult.uniqueConstraints[constraintName].columns.push(
|
|
11862
|
+
columnName
|
|
11863
|
+
);
|
|
11757
11864
|
} else {
|
|
11758
11865
|
tableInResult.uniqueConstraints[constraintName] = {
|
|
11759
11866
|
name: constraintName,
|
|
@@ -11846,6 +11953,8 @@ var init_pgSerializer = __esm({
|
|
|
11846
11953
|
import_drizzle_orm5 = require("drizzle-orm");
|
|
11847
11954
|
import_drizzle_orm6 = require("drizzle-orm");
|
|
11848
11955
|
init_serializer();
|
|
11956
|
+
init_source();
|
|
11957
|
+
init_outputs();
|
|
11849
11958
|
dialect4 = new import_pg_core2.PgDialect();
|
|
11850
11959
|
indexName2 = (tableName, columns) => {
|
|
11851
11960
|
return `${tableName}_${columns.join("_")}_index`;
|
|
@@ -11879,6 +11988,24 @@ var init_pgSerializer = __esm({
|
|
|
11879
11988
|
notNull
|
|
11880
11989
|
};
|
|
11881
11990
|
if (column7.isUnique) {
|
|
11991
|
+
const existingUnique = uniqueConstraintObject[column7.uniqueName];
|
|
11992
|
+
if (typeof existingUnique !== "undefined") {
|
|
11993
|
+
console.log(
|
|
11994
|
+
`
|
|
11995
|
+
${withStyle.errorWarning(`We've found duplicated unique constraint names in ${source_default.underline.blue(
|
|
11996
|
+
tableName
|
|
11997
|
+
)} table.
|
|
11998
|
+
The unique constraint ${source_default.underline.blue(
|
|
11999
|
+
column7.uniqueName
|
|
12000
|
+
)} on the ${source_default.underline.blue(
|
|
12001
|
+
column7.name
|
|
12002
|
+
)} column is confilcting with a unique constraint name already defined for ${source_default.underline.blue(
|
|
12003
|
+
existingUnique.columns.join(",")
|
|
12004
|
+
)} columns
|
|
12005
|
+
`)}`
|
|
12006
|
+
);
|
|
12007
|
+
process.exit(1);
|
|
12008
|
+
}
|
|
11882
12009
|
uniqueConstraintObject[column7.uniqueName] = {
|
|
11883
12010
|
name: column7.uniqueName,
|
|
11884
12011
|
nullsNotDistinct: column7.uniqueType === "not distinct",
|
|
@@ -11919,9 +12046,27 @@ var init_pgSerializer = __esm({
|
|
|
11919
12046
|
columns: columnNames
|
|
11920
12047
|
};
|
|
11921
12048
|
});
|
|
11922
|
-
uniqueConstraints.map((unq) => {
|
|
12049
|
+
uniqueConstraints == null ? void 0 : uniqueConstraints.map((unq) => {
|
|
11923
12050
|
const columnNames = unq.columns.map((c) => c.name);
|
|
11924
12051
|
const name = unq.name ?? (0, import_pg_core2.uniqueKeyName)(table4, columnNames);
|
|
12052
|
+
const existingUnique = uniqueConstraintObject[name];
|
|
12053
|
+
if (typeof existingUnique !== "undefined") {
|
|
12054
|
+
console.log(
|
|
12055
|
+
`
|
|
12056
|
+
${withStyle.errorWarning(`We've found duplicated unique constraint names in ${source_default.underline.blue(
|
|
12057
|
+
tableName
|
|
12058
|
+
)} table.
|
|
12059
|
+
The unique constraint ${source_default.underline.blue(
|
|
12060
|
+
name
|
|
12061
|
+
)} on the ${source_default.underline.blue(
|
|
12062
|
+
columnNames.join(",")
|
|
12063
|
+
)} columns is confilcting with a unique constraint name already defined for ${source_default.underline.blue(
|
|
12064
|
+
existingUnique.columns.join(",")
|
|
12065
|
+
)} columns
|
|
12066
|
+
`)}`
|
|
12067
|
+
);
|
|
12068
|
+
process.exit(1);
|
|
12069
|
+
}
|
|
11925
12070
|
uniqueConstraintObject[name] = {
|
|
11926
12071
|
name: unq.name,
|
|
11927
12072
|
nullsNotDistinct: unq.nullsNotDistinct,
|
|
@@ -12454,6 +12599,8 @@ var init_sqliteSerializer = __esm({
|
|
|
12454
12599
|
import_drizzle_orm9 = require("drizzle-orm");
|
|
12455
12600
|
import_sqlite_core2 = require("drizzle-orm/sqlite-core");
|
|
12456
12601
|
init_serializer();
|
|
12602
|
+
init_outputs();
|
|
12603
|
+
init_source();
|
|
12457
12604
|
dialect5 = new import_sqlite_core2.SQLiteSyncDialect();
|
|
12458
12605
|
generateSqliteSnapshot = (tables, enums) => {
|
|
12459
12606
|
const result = {};
|
|
@@ -12490,6 +12637,24 @@ var init_sqliteSerializer = __esm({
|
|
|
12490
12637
|
}
|
|
12491
12638
|
columnsObject[column7.name] = columnToSet;
|
|
12492
12639
|
if (column7.isUnique) {
|
|
12640
|
+
const existingUnique = indexesObject[column7.uniqueName];
|
|
12641
|
+
if (typeof existingUnique !== "undefined") {
|
|
12642
|
+
console.log(
|
|
12643
|
+
`
|
|
12644
|
+
${withStyle.errorWarning(`We've found duplicated unique constraint names in ${source_default.underline.blue(
|
|
12645
|
+
tableName
|
|
12646
|
+
)} table.
|
|
12647
|
+
The unique constraint ${source_default.underline.blue(
|
|
12648
|
+
column7.uniqueName
|
|
12649
|
+
)} on the ${source_default.underline.blue(
|
|
12650
|
+
column7.name
|
|
12651
|
+
)} column is confilcting with a unique constraint name already defined for ${source_default.underline.blue(
|
|
12652
|
+
existingUnique.columns.join(",")
|
|
12653
|
+
)} columns
|
|
12654
|
+
`)}`
|
|
12655
|
+
);
|
|
12656
|
+
process.exit(1);
|
|
12657
|
+
}
|
|
12493
12658
|
indexesObject[column7.uniqueName] = {
|
|
12494
12659
|
name: column7.uniqueName,
|
|
12495
12660
|
columns: [columnToSet.name],
|
|
@@ -12543,9 +12708,29 @@ var init_sqliteSerializer = __esm({
|
|
|
12543
12708
|
where
|
|
12544
12709
|
};
|
|
12545
12710
|
});
|
|
12546
|
-
uniqueConstraints.map((unq) => {
|
|
12711
|
+
uniqueConstraints == null ? void 0 : uniqueConstraints.map((unq) => {
|
|
12547
12712
|
const columnNames = unq.columns.map((c) => c.name);
|
|
12548
12713
|
const name = unq.name ?? (0, import_sqlite_core2.uniqueKeyName)(table4, columnNames);
|
|
12714
|
+
const existingUnique = indexesObject[name];
|
|
12715
|
+
if (typeof existingUnique !== "undefined") {
|
|
12716
|
+
console.log(
|
|
12717
|
+
`
|
|
12718
|
+
${withStyle.errorWarning(
|
|
12719
|
+
`We've found duplicated unique constraint names in ${source_default.underline.blue(
|
|
12720
|
+
tableName
|
|
12721
|
+
)} table.
|
|
12722
|
+
The unique constraint ${source_default.underline.blue(
|
|
12723
|
+
name
|
|
12724
|
+
)} on the ${source_default.underline.blue(
|
|
12725
|
+
columnNames.join(",")
|
|
12726
|
+
)} columns is confilcting with a unique constraint name already defined for ${source_default.underline.blue(
|
|
12727
|
+
existingUnique.columns.join(",")
|
|
12728
|
+
)} columns
|
|
12729
|
+
`
|
|
12730
|
+
)}`
|
|
12731
|
+
);
|
|
12732
|
+
process.exit(1);
|
|
12733
|
+
}
|
|
12549
12734
|
indexesObject[name] = {
|
|
12550
12735
|
name: unq.name,
|
|
12551
12736
|
columns: columnNames,
|
|
@@ -14779,7 +14964,7 @@ var init_sqlgenerator = __esm({
|
|
|
14779
14964
|
const primaryKeyStatement = column7.primaryKey ? " PRIMARY KEY" : "";
|
|
14780
14965
|
const notNullStatement = column7.notNull ? " NOT NULL" : "";
|
|
14781
14966
|
const defaultStatement = column7.default !== void 0 ? ` DEFAULT ${column7.default}` : "";
|
|
14782
|
-
const uniqueConstraint4 = column7.isUnique ? ` CONSTRAINT ${column7.uniqueName} UNIQUE${column7.nullsNotDistinct ? " NULLS NOT DISTINCT" : ""}` : "";
|
|
14967
|
+
const uniqueConstraint4 = column7.isUnique ? ` CONSTRAINT "${column7.uniqueName}" UNIQUE${column7.nullsNotDistinct ? " NULLS NOT DISTINCT" : ""}` : "";
|
|
14783
14968
|
const type = isPgNativeType(column7.type) ? column7.type : `"${column7.type}"`;
|
|
14784
14969
|
statement += ` "${column7.name}" ${type}${primaryKeyStatement}${defaultStatement}${notNullStatement}${uniqueConstraint4}`;
|
|
14785
14970
|
statement += i === columns.length - 1 ? "" : ",\n";
|
|
@@ -14793,7 +14978,7 @@ var init_sqlgenerator = __esm({
|
|
|
14793
14978
|
for (const uniqueConstraint4 of uniqueConstraints) {
|
|
14794
14979
|
statement += ",\n";
|
|
14795
14980
|
const unsquashedUnique = PgSquasher.unsquashUnique(uniqueConstraint4);
|
|
14796
|
-
statement += ` CONSTRAINT ${unsquashedUnique.name} UNIQUE("${unsquashedUnique.columns.join(`","`)}")`;
|
|
14981
|
+
statement += ` CONSTRAINT "${unsquashedUnique.name}" UNIQUE${unsquashedUnique.nullsNotDistinct ? " NULLS NOT DISTINCT" : ""}("${unsquashedUnique.columns.join(`","`)}")`;
|
|
14797
14982
|
}
|
|
14798
14983
|
}
|
|
14799
14984
|
statement += `
|
|
@@ -14826,13 +15011,13 @@ var init_sqlgenerator = __esm({
|
|
|
14826
15011
|
if (typeof compositePKs !== "undefined" && compositePKs.length > 0) {
|
|
14827
15012
|
statement += ",\n";
|
|
14828
15013
|
const compositePK4 = MySqlSquasher.unsquashPK(compositePKs[0]);
|
|
14829
|
-
statement += ` CONSTRAINT
|
|
15014
|
+
statement += ` CONSTRAINT \`${st.compositePkName}\` PRIMARY KEY("${compositePK4.columns.join(`","`)}")`;
|
|
14830
15015
|
}
|
|
14831
15016
|
if (typeof uniqueConstraints !== "undefined" && uniqueConstraints.length > 0) {
|
|
14832
15017
|
for (const uniqueConstraint4 of uniqueConstraints) {
|
|
14833
15018
|
statement += ",\n";
|
|
14834
15019
|
const unsquashedUnique = MySqlSquasher.unsquashUnique(uniqueConstraint4);
|
|
14835
|
-
statement += ` CONSTRAINT
|
|
15020
|
+
statement += ` CONSTRAINT \`${unsquashedUnique.name}\` UNIQUE(\`${unsquashedUnique.columns.join(`\`,\``)}\`)`;
|
|
14836
15021
|
}
|
|
14837
15022
|
}
|
|
14838
15023
|
statement += `
|
|
@@ -14855,19 +15040,20 @@ var init_sqlgenerator = __esm({
|
|
|
14855
15040
|
uniqueConstraints
|
|
14856
15041
|
} = st;
|
|
14857
15042
|
let statement = "";
|
|
14858
|
-
statement += `CREATE TABLE \`${tableName}\` (
|
|
15043
|
+
statement += `CREATE TABLE \`${tableName}\` (
|
|
15044
|
+
`;
|
|
14859
15045
|
for (let i = 0; i < columns.length; i++) {
|
|
14860
15046
|
const column7 = columns[i];
|
|
14861
15047
|
const primaryKeyStatement = column7.primaryKey ? " PRIMARY KEY" : "";
|
|
14862
15048
|
const notNullStatement = column7.notNull ? " NOT NULL" : "";
|
|
14863
15049
|
const defaultStatement = column7.default !== void 0 ? ` DEFAULT ${column7.default}` : "";
|
|
14864
15050
|
const autoincrementStatement = column7.autoincrement ? " AUTOINCREMENT" : "";
|
|
14865
|
-
statement += "
|
|
15051
|
+
statement += " ";
|
|
14866
15052
|
statement += `\`${column7.name}\` ${column7.type}${primaryKeyStatement}${autoincrementStatement}${defaultStatement}${notNullStatement}`;
|
|
14867
|
-
statement += "
|
|
15053
|
+
statement += i === columns.length - 1 ? "" : ",\n";
|
|
14868
15054
|
}
|
|
14869
15055
|
compositePKs.forEach((it) => {
|
|
14870
|
-
statement += "
|
|
15056
|
+
statement += ",\n ";
|
|
14871
15057
|
statement += `PRIMARY KEY(${it.map((it2) => `\`${it2}\``).join(", ")}),`;
|
|
14872
15058
|
});
|
|
14873
15059
|
for (let i = 0; i < referenceData.length; i++) {
|
|
@@ -14911,7 +15097,7 @@ var init_sqlgenerator = __esm({
|
|
|
14911
15097
|
convert(statement) {
|
|
14912
15098
|
const unsquashed = PgSquasher.unsquashUnique(statement.data);
|
|
14913
15099
|
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
|
14914
|
-
return `ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${unsquashed.name}" UNIQUE("${unsquashed.columns.join('","')}");`;
|
|
15100
|
+
return `ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${unsquashed.name}" UNIQUE${unsquashed.nullsNotDistinct ? " NULLS NOT DISTINCT" : ""}("${unsquashed.columns.join('","')}");`;
|
|
14915
15101
|
}
|
|
14916
15102
|
};
|
|
14917
15103
|
PgAlterTableDropUniqueConstraintConvertor = class extends Convertor {
|
|
@@ -18390,70 +18576,6 @@ var init_sqliteUtils = __esm({
|
|
|
18390
18576
|
}
|
|
18391
18577
|
});
|
|
18392
18578
|
|
|
18393
|
-
// src/cli/validations/outputs.ts
|
|
18394
|
-
var withStyle, outputs;
|
|
18395
|
-
var init_outputs = __esm({
|
|
18396
|
-
"src/cli/validations/outputs.ts"() {
|
|
18397
|
-
init_source();
|
|
18398
|
-
withStyle = {
|
|
18399
|
-
error: (str) => `${source_default.red(`${source_default.white.bgRed(" Invalid input ")} ${str}`)}`,
|
|
18400
|
-
warning: (str) => `${source_default.white.bgGray(" Warning ")} ${str}`,
|
|
18401
|
-
fullWarning: (str) => `${source_default.black.bgYellow("[Warning]")} ${source_default.bold(str)}`
|
|
18402
|
-
};
|
|
18403
|
-
outputs = {
|
|
18404
|
-
studio: {
|
|
18405
|
-
drivers: (param) => withStyle.error(
|
|
18406
|
-
`"${param}" is not a valid driver. Available drivers: "pg", "mysql2", "better-sqlite", "libsql", "turso". You can read more about drizzle.config: https://orm.drizzle.team/kit-docs/config-reference`
|
|
18407
|
-
),
|
|
18408
|
-
noCredentials: () => withStyle.error(
|
|
18409
|
-
`You need to specify a "dbCredentials" param in you config. It will help drizzle to know how to query you database. You can read more about drizzle.config: https://orm.drizzle.team/kit-docs/config-reference`
|
|
18410
|
-
),
|
|
18411
|
-
noDriver: () => withStyle.error(
|
|
18412
|
-
`You need to specify a "driver" param in you config. It will help drizzle to know how to query you database. You can read more about drizzle.config: https://orm.drizzle.team/kit-docs/config-reference`
|
|
18413
|
-
)
|
|
18414
|
-
},
|
|
18415
|
-
common: {
|
|
18416
|
-
ambiguousParams: (command) => withStyle.error(
|
|
18417
|
-
`You can't use both --config and other cli options for ${command} command`
|
|
18418
|
-
),
|
|
18419
|
-
schema: (command) => withStyle.error(`"--schema" is a required field for ${command} command`),
|
|
18420
|
-
schemaConfig: (command) => withStyle.error(
|
|
18421
|
-
`"schema" is a required field in drizzle.config for ${command} command`
|
|
18422
|
-
)
|
|
18423
|
-
},
|
|
18424
|
-
postgres: {
|
|
18425
|
-
connection: {
|
|
18426
|
-
driver: () => withStyle.error(`Only "pg" is available options for "--driver"`),
|
|
18427
|
-
required: () => withStyle.error(
|
|
18428
|
-
`Either "connectionString" or "host", "database" are required for database connection`
|
|
18429
|
-
)
|
|
18430
|
-
}
|
|
18431
|
-
},
|
|
18432
|
-
mysql: {
|
|
18433
|
-
connection: {
|
|
18434
|
-
driver: () => withStyle.error(`Only "mysql2" is available options for "--driver"`),
|
|
18435
|
-
required: () => withStyle.error(
|
|
18436
|
-
`Either "connectionString" or "host", "database" are required for database connection`
|
|
18437
|
-
)
|
|
18438
|
-
}
|
|
18439
|
-
},
|
|
18440
|
-
sqlite: {
|
|
18441
|
-
connection: {
|
|
18442
|
-
driver: () => withStyle.error(
|
|
18443
|
-
`Either "turso", "libsql", "better-sqlite" are available options for "--driver"`
|
|
18444
|
-
),
|
|
18445
|
-
url: (driver) => withStyle.error(`"url" is a required option for driver "${driver}". You can read more about drizzle.config: https://orm.drizzle.team/kit-docs/config-reference`),
|
|
18446
|
-
authToken: (driver) => withStyle.error(
|
|
18447
|
-
`"authToken" is a required option for driver "${driver}". You can read more about drizzle.config: https://orm.drizzle.team/kit-docs/config-reference`
|
|
18448
|
-
)
|
|
18449
|
-
},
|
|
18450
|
-
introspect: {},
|
|
18451
|
-
push: {}
|
|
18452
|
-
}
|
|
18453
|
-
};
|
|
18454
|
-
}
|
|
18455
|
-
});
|
|
18456
|
-
|
|
18457
18579
|
// src/cli/validations/common.ts
|
|
18458
18580
|
var checkCollisions;
|
|
18459
18581
|
var init_common = __esm({
|
|
@@ -37304,10 +37426,10 @@ __export(mysqlIntrospect_exports, {
|
|
|
37304
37426
|
mysqlIntrospect: () => mysqlIntrospect,
|
|
37305
37427
|
mysqlPushIntrospect: () => mysqlPushIntrospect
|
|
37306
37428
|
});
|
|
37307
|
-
var
|
|
37429
|
+
var import_hanji6, import_promise, connectToMySQL, mysqlIntrospect, mysqlPushIntrospect;
|
|
37308
37430
|
var init_mysqlIntrospect = __esm({
|
|
37309
37431
|
"src/cli/commands/mysqlIntrospect.ts"() {
|
|
37310
|
-
|
|
37432
|
+
import_hanji6 = __toESM(require_hanji());
|
|
37311
37433
|
init_views();
|
|
37312
37434
|
import_promise = __toESM(require_promise());
|
|
37313
37435
|
init_mysqlSerializer();
|
|
@@ -37356,7 +37478,7 @@ var init_mysqlIntrospect = __esm({
|
|
|
37356
37478
|
return false;
|
|
37357
37479
|
};
|
|
37358
37480
|
const progress = new IntrospectProgress();
|
|
37359
|
-
const res = await (0,
|
|
37481
|
+
const res = await (0, import_hanji6.renderWithTask)(
|
|
37360
37482
|
progress,
|
|
37361
37483
|
fromDatabase(
|
|
37362
37484
|
client,
|
|
@@ -46223,7 +46345,7 @@ __export(sqliteIntrospect_exports, {
|
|
|
46223
46345
|
sqliteIntrospect: () => sqliteIntrospect,
|
|
46224
46346
|
sqlitePushIntrospect: () => sqlitePushIntrospect
|
|
46225
46347
|
});
|
|
46226
|
-
var
|
|
46348
|
+
var import_hanji7, SqliteClient, BetterSqlite, TursoSqlite, connectToSQLite, sqliteIntrospect, sqlitePushIntrospect;
|
|
46227
46349
|
var init_sqliteIntrospect = __esm({
|
|
46228
46350
|
"src/cli/commands/sqliteIntrospect.ts"() {
|
|
46229
46351
|
init_views();
|
|
@@ -46232,7 +46354,7 @@ var init_sqliteIntrospect = __esm({
|
|
|
46232
46354
|
init_sqlite_introspect();
|
|
46233
46355
|
init_mjs();
|
|
46234
46356
|
init_lib_esm2();
|
|
46235
|
-
|
|
46357
|
+
import_hanji7 = __toESM(require_hanji());
|
|
46236
46358
|
SqliteClient = class {
|
|
46237
46359
|
constructor(db) {
|
|
46238
46360
|
this.db = db;
|
|
@@ -46298,7 +46420,7 @@ var init_sqliteIntrospect = __esm({
|
|
|
46298
46420
|
return false;
|
|
46299
46421
|
};
|
|
46300
46422
|
const progress = new IntrospectProgress();
|
|
46301
|
-
const res = await (0,
|
|
46423
|
+
const res = await (0, import_hanji7.renderWithTask)(
|
|
46302
46424
|
progress,
|
|
46303
46425
|
fromDatabase3(
|
|
46304
46426
|
client,
|
|
@@ -51435,10 +51557,10 @@ var pgIntrospect_exports = {};
|
|
|
51435
51557
|
__export(pgIntrospect_exports, {
|
|
51436
51558
|
pgIntrospect: () => pgIntrospect
|
|
51437
51559
|
});
|
|
51438
|
-
var
|
|
51560
|
+
var import_hanji8, import_pg, pgIntrospect;
|
|
51439
51561
|
var init_pgIntrospect = __esm({
|
|
51440
51562
|
"src/cli/commands/pgIntrospect.ts"() {
|
|
51441
|
-
|
|
51563
|
+
import_hanji8 = __toESM(require_hanji());
|
|
51442
51564
|
init_views();
|
|
51443
51565
|
import_pg = __toESM(require_lib5());
|
|
51444
51566
|
init_pgSerializer();
|
|
@@ -51461,7 +51583,7 @@ var init_pgIntrospect = __esm({
|
|
|
51461
51583
|
return false;
|
|
51462
51584
|
};
|
|
51463
51585
|
const progress = new IntrospectProgress();
|
|
51464
|
-
const res = await (0,
|
|
51586
|
+
const res = await (0, import_hanji8.renderWithTask)(
|
|
51465
51587
|
progress,
|
|
51466
51588
|
fromDatabase2(pool, filter2, (stage, count, status) => {
|
|
51467
51589
|
progress.update(stage, count, status);
|
|
@@ -51681,7 +51803,7 @@ var checkHandler = (out, dialect6) => {
|
|
|
51681
51803
|
};
|
|
51682
51804
|
|
|
51683
51805
|
// src/cli/index.ts
|
|
51684
|
-
var
|
|
51806
|
+
var import_hanji9 = __toESM(require_hanji());
|
|
51685
51807
|
var import_path7 = __toESM(require("path"));
|
|
51686
51808
|
|
|
51687
51809
|
// src/cli/utils.ts
|
|
@@ -51815,7 +51937,7 @@ var package_default = {
|
|
|
51815
51937
|
"better-sqlite3": "^8.4.0",
|
|
51816
51938
|
dockerode: "^3.3.4",
|
|
51817
51939
|
dotenv: "^16.0.3",
|
|
51818
|
-
"drizzle-orm": "0.27.
|
|
51940
|
+
"drizzle-orm": "0.27.1-8a21e7b",
|
|
51819
51941
|
eslint: "^8.29.0",
|
|
51820
51942
|
"eslint-config-prettier": "^8.5.0",
|
|
51821
51943
|
"eslint-plugin-prettier": "^4.2.1",
|
|
@@ -51923,6 +52045,8 @@ init_utils();
|
|
|
51923
52045
|
|
|
51924
52046
|
// src/cli/commands/mysqlPushUtils.ts
|
|
51925
52047
|
init_source();
|
|
52048
|
+
var import_hanji5 = __toESM(require_hanji());
|
|
52049
|
+
init_mysqlSchema();
|
|
51926
52050
|
var filterStatements = (statements) => {
|
|
51927
52051
|
return statements.filter((statement) => {
|
|
51928
52052
|
if (statement.type === "alter_table_alter_column_set_type") {
|
|
@@ -52077,6 +52201,33 @@ var logSuggestionsAndReturn = async ({
|
|
|
52077
52201
|
shouldAskForApprove = true;
|
|
52078
52202
|
}
|
|
52079
52203
|
}
|
|
52204
|
+
} else if (statement.type === "create_unique_constraint") {
|
|
52205
|
+
const res = await connection.query(
|
|
52206
|
+
`select count(*) as count from \`${statement.tableName}\``
|
|
52207
|
+
);
|
|
52208
|
+
const count = Number(res[0][0].count);
|
|
52209
|
+
if (count > 0) {
|
|
52210
|
+
const unsquashedUnique = MySqlSquasher.unsquashUnique(statement.data);
|
|
52211
|
+
console.log(
|
|
52212
|
+
`\xB7 You're about to add ${source_default.underline(
|
|
52213
|
+
unsquashedUnique.name
|
|
52214
|
+
)} unique constraint to the table, which contains ${count} items. If this statement fails, you will receive an error from the database. Do you want to truncate ${source_default.underline(
|
|
52215
|
+
statement.tableName
|
|
52216
|
+
)} table?
|
|
52217
|
+
`
|
|
52218
|
+
);
|
|
52219
|
+
const { status, data } = await (0, import_hanji5.render)(
|
|
52220
|
+
new Select([
|
|
52221
|
+
"No, add the constraint without truncating the table",
|
|
52222
|
+
`Yes, truncate the table`
|
|
52223
|
+
])
|
|
52224
|
+
);
|
|
52225
|
+
if ((data == null ? void 0 : data.index) === 1) {
|
|
52226
|
+
tablesToTruncate.push(statement.tableName);
|
|
52227
|
+
statementsToExecute.push(`truncate table ${statement.tableName};`);
|
|
52228
|
+
shouldAskForApprove = true;
|
|
52229
|
+
}
|
|
52230
|
+
}
|
|
52080
52231
|
}
|
|
52081
52232
|
}
|
|
52082
52233
|
return {
|
|
@@ -52411,14 +52562,14 @@ var generateMysqlCommand = new import_commander.Command("generate:mysql").option
|
|
|
52411
52562
|
const { prepareAndMigrateMySql: prepareAndMigrateMySql2 } = await Promise.resolve().then(() => (init_migrate(), migrate_exports));
|
|
52412
52563
|
await prepareAndMigrateMySql2(result);
|
|
52413
52564
|
});
|
|
52414
|
-
var Select = class extends
|
|
52565
|
+
var Select = class extends import_hanji9.Prompt {
|
|
52415
52566
|
// private readonly spinner: () => string;
|
|
52416
52567
|
// private timeout: NodeJS.Timer | undefined;
|
|
52417
52568
|
constructor(items) {
|
|
52418
52569
|
super();
|
|
52419
52570
|
this.on("attach", (terminal) => terminal.toggleCursor("hide"));
|
|
52420
52571
|
this.on("detach", (terminal) => terminal.toggleCursor("show"));
|
|
52421
|
-
this.data = new
|
|
52572
|
+
this.data = new import_hanji9.SelectState(
|
|
52422
52573
|
items.map((it) => ({ label: it, value: `${it}-value` }))
|
|
52423
52574
|
);
|
|
52424
52575
|
this.data.bind(this);
|
|
@@ -52453,7 +52604,7 @@ var dbPushMysqlCommand = new import_commander.Command("push:mysql").option(
|
|
|
52453
52604
|
);
|
|
52454
52605
|
const fileNames = prepareFilenames(drizzleConfig.schema);
|
|
52455
52606
|
if (fileNames.length === 0) {
|
|
52456
|
-
(0,
|
|
52607
|
+
(0, import_hanji9.render)(
|
|
52457
52608
|
`[${source_default.blue("i")}] No schema file in ${drizzleConfig.schema} was found`
|
|
52458
52609
|
);
|
|
52459
52610
|
process.exit(0);
|
|
@@ -52470,7 +52621,7 @@ var dbPushMysqlCommand = new import_commander.Command("push:mysql").option(
|
|
|
52470
52621
|
try {
|
|
52471
52622
|
if (typeof statements === "undefined") {
|
|
52472
52623
|
} else if (statements.sqlStatements.length === 0) {
|
|
52473
|
-
(0,
|
|
52624
|
+
(0, import_hanji9.render)(`[${source_default.blue("i")}] No changes detected`);
|
|
52474
52625
|
} else {
|
|
52475
52626
|
const filteredStatements = filterStatements(statements.statements);
|
|
52476
52627
|
const {
|
|
@@ -52498,11 +52649,11 @@ var dbPushMysqlCommand = new import_commander.Command("push:mysql").option(
|
|
|
52498
52649
|
}
|
|
52499
52650
|
if (drizzleConfig.strict) {
|
|
52500
52651
|
if (!shouldAskForApprove) {
|
|
52501
|
-
const { status, data } = await (0,
|
|
52652
|
+
const { status, data } = await (0, import_hanji9.render)(
|
|
52502
52653
|
new Select(["No, abort", `Yes, I want to execute all statements`])
|
|
52503
52654
|
);
|
|
52504
52655
|
if ((data == null ? void 0 : data.index) === 0) {
|
|
52505
|
-
(0,
|
|
52656
|
+
(0, import_hanji9.render)(`[${source_default.red("x")}] All changes were aborted`);
|
|
52506
52657
|
process.exit(0);
|
|
52507
52658
|
}
|
|
52508
52659
|
}
|
|
@@ -52517,14 +52668,14 @@ var dbPushMysqlCommand = new import_commander.Command("push:mysql").option(
|
|
|
52517
52668
|
)
|
|
52518
52669
|
);
|
|
52519
52670
|
console.log(source_default.white("Do you still want to push changes?"));
|
|
52520
|
-
const { status, data } = await (0,
|
|
52671
|
+
const { status, data } = await (0, import_hanji9.render)(
|
|
52521
52672
|
new Select([
|
|
52522
52673
|
"No, abort",
|
|
52523
52674
|
`Yes, I want to${tablesToRemove.length > 0 ? ` remove ${tablesToRemove.length} ${tablesToRemove.length > 1 ? "tables" : "table"},` : " "}${columnsToRemove.length > 0 ? ` remove ${columnsToRemove.length} ${columnsToRemove.length > 1 ? "columns" : "column"},` : " "}${tablesToTruncate.length > 0 ? ` truncate ${tablesToTruncate.length} ${tablesToTruncate.length > 1 ? "tables" : "table"}` : ""}`.replace(/(^,)|(,$)/g, "").replace(/ +(?= )/g, "")
|
|
52524
52675
|
])
|
|
52525
52676
|
);
|
|
52526
52677
|
if ((data == null ? void 0 : data.index) === 0) {
|
|
52527
|
-
(0,
|
|
52678
|
+
(0, import_hanji9.render)(`[${source_default.red("x")}] All changes were aborted`);
|
|
52528
52679
|
process.exit(0);
|
|
52529
52680
|
}
|
|
52530
52681
|
}
|
|
@@ -52535,9 +52686,9 @@ var dbPushMysqlCommand = new import_commander.Command("push:mysql").option(
|
|
|
52535
52686
|
await connection.client.query(statement);
|
|
52536
52687
|
}
|
|
52537
52688
|
if (filteredStatements.length > 0) {
|
|
52538
|
-
(0,
|
|
52689
|
+
(0, import_hanji9.render)(`[${source_default.green("\u2713")}] Changes applied`);
|
|
52539
52690
|
} else {
|
|
52540
|
-
(0,
|
|
52691
|
+
(0, import_hanji9.render)(`[${source_default.blue("i")}] No changes detected`);
|
|
52541
52692
|
}
|
|
52542
52693
|
}
|
|
52543
52694
|
} catch (e) {
|
|
@@ -52557,7 +52708,7 @@ var dbPushSqliteCommand = new import_commander.Command("push:sqlite").option(
|
|
|
52557
52708
|
const res = await validatePush(options);
|
|
52558
52709
|
const fileNames = prepareFilenames(res.schema);
|
|
52559
52710
|
if (fileNames.length === 0) {
|
|
52560
|
-
(0,
|
|
52711
|
+
(0, import_hanji9.render)(`[${source_default.blue("i")}] No schema file in ${res.schema} was found`);
|
|
52561
52712
|
process.exit(0);
|
|
52562
52713
|
}
|
|
52563
52714
|
const connection = await connectToSQLite2(res);
|
|
@@ -52572,7 +52723,7 @@ var dbPushSqliteCommand = new import_commander.Command("push:sqlite").option(
|
|
|
52572
52723
|
try {
|
|
52573
52724
|
if (typeof statements === "undefined") {
|
|
52574
52725
|
} else if (statements.sqlStatements.length === 0) {
|
|
52575
|
-
(0,
|
|
52726
|
+
(0, import_hanji9.render)(`
|
|
52576
52727
|
[${source_default.blue("i")}] No changes detected`);
|
|
52577
52728
|
} else {
|
|
52578
52729
|
const {
|
|
@@ -52600,11 +52751,11 @@ var dbPushSqliteCommand = new import_commander.Command("push:sqlite").option(
|
|
|
52600
52751
|
}
|
|
52601
52752
|
if (res.strict) {
|
|
52602
52753
|
if (!shouldAskForApprove) {
|
|
52603
|
-
const { status, data } = await (0,
|
|
52754
|
+
const { status, data } = await (0, import_hanji9.render)(
|
|
52604
52755
|
new Select(["No, abort", `Yes, I want to execute all statements`])
|
|
52605
52756
|
);
|
|
52606
52757
|
if ((data == null ? void 0 : data.index) === 0) {
|
|
52607
|
-
(0,
|
|
52758
|
+
(0, import_hanji9.render)(`[${source_default.red("x")}] All changes were aborted`);
|
|
52608
52759
|
process.exit(0);
|
|
52609
52760
|
}
|
|
52610
52761
|
}
|
|
@@ -52619,21 +52770,21 @@ var dbPushSqliteCommand = new import_commander.Command("push:sqlite").option(
|
|
|
52619
52770
|
)
|
|
52620
52771
|
);
|
|
52621
52772
|
console.log(source_default.white("Do you still want to push changes?"));
|
|
52622
|
-
const { status, data } = await (0,
|
|
52773
|
+
const { status, data } = await (0, import_hanji9.render)(
|
|
52623
52774
|
new Select([
|
|
52624
52775
|
"No, abort",
|
|
52625
52776
|
`Yes, I want to${tablesToRemove.length > 0 ? ` remove ${tablesToRemove.length} ${tablesToRemove.length > 1 ? "tables" : "table"},` : " "}${columnsToRemove.length > 0 ? ` remove ${columnsToRemove.length} ${columnsToRemove.length > 1 ? "columns" : "column"},` : " "}${tablesToTruncate.length > 0 ? ` truncate ${tablesToTruncate.length} ${tablesToTruncate.length > 1 ? "tables" : "table"}` : ""}`.trimEnd().replace(/(^,)|(,$)/g, "").replace(/ +(?= )/g, "")
|
|
52626
52777
|
])
|
|
52627
52778
|
);
|
|
52628
52779
|
if ((data == null ? void 0 : data.index) === 0) {
|
|
52629
|
-
(0,
|
|
52780
|
+
(0, import_hanji9.render)(`[${source_default.red("x")}] All changes were aborted`);
|
|
52630
52781
|
process.exit(0);
|
|
52631
52782
|
}
|
|
52632
52783
|
}
|
|
52633
52784
|
for (const dStmnt of statementsToExecute) {
|
|
52634
52785
|
await connection.client.run(dStmnt);
|
|
52635
52786
|
}
|
|
52636
|
-
(0,
|
|
52787
|
+
(0, import_hanji9.render)(`[${source_default.green("\u2713")}] Changes applied`);
|
|
52637
52788
|
}
|
|
52638
52789
|
} catch (e) {
|
|
52639
52790
|
console.log(e);
|
|
@@ -52802,13 +52953,13 @@ var introspectPgCommand = new import_commander.Command("introspect:pg").option("
|
|
|
52802
52953
|
"introspect"
|
|
52803
52954
|
);
|
|
52804
52955
|
} else {
|
|
52805
|
-
(0,
|
|
52956
|
+
(0, import_hanji9.render)(
|
|
52806
52957
|
`[${source_default.blue(
|
|
52807
52958
|
"i"
|
|
52808
52959
|
)}] No SQL generated, you already have migrations in project`
|
|
52809
52960
|
);
|
|
52810
52961
|
}
|
|
52811
|
-
(0,
|
|
52962
|
+
(0, import_hanji9.render)(
|
|
52812
52963
|
`[${source_default.green(
|
|
52813
52964
|
"\u2713"
|
|
52814
52965
|
)}] You schema file is ready \u279C ${source_default.bold.underline.blue(
|
|
@@ -52855,13 +53006,13 @@ var introspectMySqlCommand = new import_commander.Command("introspect:mysql").op
|
|
|
52855
53006
|
"introspect"
|
|
52856
53007
|
);
|
|
52857
53008
|
} else {
|
|
52858
|
-
(0,
|
|
53009
|
+
(0, import_hanji9.render)(
|
|
52859
53010
|
`[${source_default.blue(
|
|
52860
53011
|
"i"
|
|
52861
53012
|
)}] No SQL generated, you already have migrations in project`
|
|
52862
53013
|
);
|
|
52863
53014
|
}
|
|
52864
|
-
(0,
|
|
53015
|
+
(0, import_hanji9.render)(
|
|
52865
53016
|
`[${source_default.green(
|
|
52866
53017
|
"\u2713"
|
|
52867
53018
|
)}] You schema file is ready \u279C ${source_default.bold.underline.blue(
|
|
@@ -52908,13 +53059,13 @@ var introspectSQLiteCommand = new import_commander.Command("introspect:sqlite").
|
|
|
52908
53059
|
"introspect"
|
|
52909
53060
|
);
|
|
52910
53061
|
} else {
|
|
52911
|
-
(0,
|
|
53062
|
+
(0, import_hanji9.render)(
|
|
52912
53063
|
`[${source_default.blue(
|
|
52913
53064
|
"i"
|
|
52914
53065
|
)}] No SQL generated, you already have migrations in project`
|
|
52915
53066
|
);
|
|
52916
53067
|
}
|
|
52917
|
-
(0,
|
|
53068
|
+
(0, import_hanji9.render)(
|
|
52918
53069
|
`[${source_default.green(
|
|
52919
53070
|
"\u2713"
|
|
52920
53071
|
)}] You schema file is ready \u279C ${source_default.bold.underline.blue(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drizzle-kit",
|
|
3
|
-
"version": "0.19.4
|
|
3
|
+
"version": "0.19.4",
|
|
4
4
|
"repository": "https://github.com/drizzle-team/drizzle-kit-mirror",
|
|
5
5
|
"author": "Drizzle Team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"better-sqlite3": "^8.4.0",
|
|
80
80
|
"dockerode": "^3.3.4",
|
|
81
81
|
"dotenv": "^16.0.3",
|
|
82
|
-
"drizzle-orm": "0.27.
|
|
82
|
+
"drizzle-orm": "0.27.1-8a21e7b",
|
|
83
83
|
"eslint": "^8.29.0",
|
|
84
84
|
"eslint-config-prettier": "^8.5.0",
|
|
85
85
|
"eslint-plugin-prettier": "^4.2.1",
|
package/utils.js
CHANGED
|
@@ -13678,7 +13678,7 @@ var PgCreateTableConvertor = class extends Convertor {
|
|
|
13678
13678
|
const primaryKeyStatement = column4.primaryKey ? " PRIMARY KEY" : "";
|
|
13679
13679
|
const notNullStatement = column4.notNull ? " NOT NULL" : "";
|
|
13680
13680
|
const defaultStatement = column4.default !== void 0 ? ` DEFAULT ${column4.default}` : "";
|
|
13681
|
-
const uniqueConstraint4 = column4.isUnique ? ` CONSTRAINT ${column4.uniqueName} UNIQUE${column4.nullsNotDistinct ? " NULLS NOT DISTINCT" : ""}` : "";
|
|
13681
|
+
const uniqueConstraint4 = column4.isUnique ? ` CONSTRAINT "${column4.uniqueName}" UNIQUE${column4.nullsNotDistinct ? " NULLS NOT DISTINCT" : ""}` : "";
|
|
13682
13682
|
const type = isPgNativeType(column4.type) ? column4.type : `"${column4.type}"`;
|
|
13683
13683
|
statement += ` "${column4.name}" ${type}${primaryKeyStatement}${defaultStatement}${notNullStatement}${uniqueConstraint4}`;
|
|
13684
13684
|
statement += i === columns.length - 1 ? "" : ",\n";
|
|
@@ -13692,7 +13692,7 @@ var PgCreateTableConvertor = class extends Convertor {
|
|
|
13692
13692
|
for (const uniqueConstraint4 of uniqueConstraints) {
|
|
13693
13693
|
statement += ",\n";
|
|
13694
13694
|
const unsquashedUnique = PgSquasher.unsquashUnique(uniqueConstraint4);
|
|
13695
|
-
statement += ` CONSTRAINT ${unsquashedUnique.name} UNIQUE("${unsquashedUnique.columns.join(`","`)}")`;
|
|
13695
|
+
statement += ` CONSTRAINT "${unsquashedUnique.name}" UNIQUE${unsquashedUnique.nullsNotDistinct ? " NULLS NOT DISTINCT" : ""}("${unsquashedUnique.columns.join(`","`)}")`;
|
|
13696
13696
|
}
|
|
13697
13697
|
}
|
|
13698
13698
|
statement += `
|
|
@@ -13725,13 +13725,13 @@ var MySqlCreateTableConvertor = class extends Convertor {
|
|
|
13725
13725
|
if (typeof compositePKs !== "undefined" && compositePKs.length > 0) {
|
|
13726
13726
|
statement += ",\n";
|
|
13727
13727
|
const compositePK4 = MySqlSquasher.unsquashPK(compositePKs[0]);
|
|
13728
|
-
statement += ` CONSTRAINT
|
|
13728
|
+
statement += ` CONSTRAINT \`${st.compositePkName}\` PRIMARY KEY("${compositePK4.columns.join(`","`)}")`;
|
|
13729
13729
|
}
|
|
13730
13730
|
if (typeof uniqueConstraints !== "undefined" && uniqueConstraints.length > 0) {
|
|
13731
13731
|
for (const uniqueConstraint4 of uniqueConstraints) {
|
|
13732
13732
|
statement += ",\n";
|
|
13733
13733
|
const unsquashedUnique = MySqlSquasher.unsquashUnique(uniqueConstraint4);
|
|
13734
|
-
statement += ` CONSTRAINT
|
|
13734
|
+
statement += ` CONSTRAINT \`${unsquashedUnique.name}\` UNIQUE(\`${unsquashedUnique.columns.join(`\`,\``)}\`)`;
|
|
13735
13735
|
}
|
|
13736
13736
|
}
|
|
13737
13737
|
statement += `
|
|
@@ -13754,19 +13754,20 @@ var SQLiteCreateTableConvertor = class extends Convertor {
|
|
|
13754
13754
|
uniqueConstraints
|
|
13755
13755
|
} = st;
|
|
13756
13756
|
let statement = "";
|
|
13757
|
-
statement += `CREATE TABLE \`${tableName}\` (
|
|
13757
|
+
statement += `CREATE TABLE \`${tableName}\` (
|
|
13758
|
+
`;
|
|
13758
13759
|
for (let i = 0; i < columns.length; i++) {
|
|
13759
13760
|
const column4 = columns[i];
|
|
13760
13761
|
const primaryKeyStatement = column4.primaryKey ? " PRIMARY KEY" : "";
|
|
13761
13762
|
const notNullStatement = column4.notNull ? " NOT NULL" : "";
|
|
13762
13763
|
const defaultStatement = column4.default !== void 0 ? ` DEFAULT ${column4.default}` : "";
|
|
13763
13764
|
const autoincrementStatement = column4.autoincrement ? " AUTOINCREMENT" : "";
|
|
13764
|
-
statement += "
|
|
13765
|
+
statement += " ";
|
|
13765
13766
|
statement += `\`${column4.name}\` ${column4.type}${primaryKeyStatement}${autoincrementStatement}${defaultStatement}${notNullStatement}`;
|
|
13766
|
-
statement += "
|
|
13767
|
+
statement += i === columns.length - 1 ? "" : ",\n";
|
|
13767
13768
|
}
|
|
13768
13769
|
compositePKs.forEach((it) => {
|
|
13769
|
-
statement += "
|
|
13770
|
+
statement += ",\n ";
|
|
13770
13771
|
statement += `PRIMARY KEY(${it.map((it2) => `\`${it2}\``).join(", ")}),`;
|
|
13771
13772
|
});
|
|
13772
13773
|
for (let i = 0; i < referenceData.length; i++) {
|
|
@@ -13810,7 +13811,7 @@ var PgAlterTableAddUniqueConstraintConvertor = class extends Convertor {
|
|
|
13810
13811
|
convert(statement) {
|
|
13811
13812
|
const unsquashed = PgSquasher.unsquashUnique(statement.data);
|
|
13812
13813
|
const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
|
|
13813
|
-
return `ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${unsquashed.name}" UNIQUE("${unsquashed.columns.join('","')}");`;
|
|
13814
|
+
return `ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${unsquashed.name}" UNIQUE${unsquashed.nullsNotDistinct ? " NULLS NOT DISTINCT" : ""}("${unsquashed.columns.join('","')}");`;
|
|
13814
13815
|
}
|
|
13815
13816
|
};
|
|
13816
13817
|
var PgAlterTableDropUniqueConstraintConvertor = class extends Convertor {
|