drizzle-kit 0.19.2 → 0.19.3-d338b71
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 +878 -583
- package/package.json +6 -3
- package/utils.js +67 -35
package/index.cjs
CHANGED
|
@@ -12386,7 +12386,7 @@ var init_sqliteSerializer = __esm({
|
|
|
12386
12386
|
primaryKeys.forEach((it) => {
|
|
12387
12387
|
if (it.columns.length > 1) {
|
|
12388
12388
|
primaryKeysObject[it.getName()] = {
|
|
12389
|
-
columns: it.columns.map((it2) => it2.name)
|
|
12389
|
+
columns: it.columns.map((it2) => it2.name).sort()
|
|
12390
12390
|
};
|
|
12391
12391
|
} else {
|
|
12392
12392
|
columnsObject[it.columns[0].name].primaryKey = true;
|
|
@@ -12416,10 +12416,22 @@ var init_sqliteSerializer = __esm({
|
|
|
12416
12416
|
const columns = await db.query(
|
|
12417
12417
|
`SELECT
|
|
12418
12418
|
m.name as "tableName", p.name as "columnName", p.type as "columnType", p."notnull" as "notNull", p.dflt_value as "defaultValue", p.pk as pk
|
|
12419
|
-
FROM sqlite_master AS m JOIN pragma_table_info(m.name) AS p
|
|
12419
|
+
FROM sqlite_master AS m JOIN pragma_table_info(m.name) AS p
|
|
12420
12420
|
WHERE m.type = 'table' and m.tbl_name != 'sqlite_sequence' and m.tbl_name != 'sqlite_stat1' and m.tbl_name != '_litestream_seq' and m.tbl_name != '_litestream_lock';
|
|
12421
12421
|
`
|
|
12422
12422
|
);
|
|
12423
|
+
const isSeqExists = await db.query(
|
|
12424
|
+
`SELECT * FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';`
|
|
12425
|
+
);
|
|
12426
|
+
const tablesWithSeq = [];
|
|
12427
|
+
if (isSeqExists.length > 0) {
|
|
12428
|
+
const seq = await db.query(
|
|
12429
|
+
`SELECT * FROM sqlite_sequence WHERE name != 'sqlite_sequence' and name != 'sqlite_stat1' and name != '_litestream_seq' and name != '_litestream_lock';`
|
|
12430
|
+
);
|
|
12431
|
+
for (const s of seq) {
|
|
12432
|
+
tablesWithSeq.push(s.name);
|
|
12433
|
+
}
|
|
12434
|
+
}
|
|
12423
12435
|
let columnsCount = 0;
|
|
12424
12436
|
let tablesCount = /* @__PURE__ */ new Set();
|
|
12425
12437
|
let indexesCount = 0;
|
|
@@ -12442,7 +12454,7 @@ var init_sqliteSerializer = __esm({
|
|
|
12442
12454
|
const columnType = column7.columnType;
|
|
12443
12455
|
const isPrimary = column7.pk !== 0;
|
|
12444
12456
|
const columnDefault = column7.defaultValue;
|
|
12445
|
-
const isAutoincrement =
|
|
12457
|
+
const isAutoincrement = isPrimary && tablesWithSeq.includes(tableName);
|
|
12446
12458
|
if (isPrimary) {
|
|
12447
12459
|
if (typeof tableToPk[tableName] === "undefined") {
|
|
12448
12460
|
tableToPk[tableName] = [columnName];
|
|
@@ -12454,7 +12466,7 @@ var init_sqliteSerializer = __esm({
|
|
|
12454
12466
|
const newColumn = {
|
|
12455
12467
|
default: columnDefault === null ? void 0 : /^-?[\d.]+(?:e-?\d+)?$/.test(columnDefault) ? Number(columnDefault) : ["CURRENT_TIME", "CURRENT_DATE", "CURRENT_TIMESTAMP"].includes(
|
|
12456
12468
|
columnDefault
|
|
12457
|
-
) ? `(${columnDefault})` : columnDefault,
|
|
12469
|
+
) ? `(${columnDefault})` : columnDefault === "false" ? false : columnDefault === "true" ? true : columnDefault.startsWith('"') && columnDefault.endsWith('"') ? columnDefault.substring(1, columnDefault.length - 1) : columnDefault,
|
|
12458
12470
|
autoincrement: isAutoincrement,
|
|
12459
12471
|
name: columnName,
|
|
12460
12472
|
type: mapSqlToSqliteType(columnType),
|
|
@@ -12477,9 +12489,10 @@ var init_sqliteSerializer = __esm({
|
|
|
12477
12489
|
}
|
|
12478
12490
|
for (const [key, value] of Object.entries(tableToPk)) {
|
|
12479
12491
|
if (value.length > 1) {
|
|
12492
|
+
value.sort();
|
|
12480
12493
|
result[key].compositePrimaryKeys = {
|
|
12481
|
-
[`${key}_${value.
|
|
12482
|
-
columns: value
|
|
12494
|
+
[`${key}_${value.join("_")}_pk`]: {
|
|
12495
|
+
columns: value
|
|
12483
12496
|
}
|
|
12484
12497
|
};
|
|
12485
12498
|
} else if (value.length === 1) {
|
|
@@ -14658,9 +14671,9 @@ var init_sqlgenerator = __esm({
|
|
|
14658
14671
|
const primaryKeyStatement = column7.primaryKey ? " PRIMARY KEY" : "";
|
|
14659
14672
|
const notNullStatement = column7.notNull ? " NOT NULL" : "";
|
|
14660
14673
|
const defaultStatement = column7.default !== void 0 ? ` DEFAULT ${column7.default}` : "";
|
|
14661
|
-
const autoincrementStatement = column7.autoincrement ? "
|
|
14674
|
+
const autoincrementStatement = column7.autoincrement ? " AUTOINCREMENT" : "";
|
|
14662
14675
|
statement += "\n ";
|
|
14663
|
-
statement += `\`${column7.name}\` ${column7.type}${
|
|
14676
|
+
statement += `\`${column7.name}\` ${column7.type}${primaryKeyStatement}${autoincrementStatement}${defaultStatement}${notNullStatement}`;
|
|
14664
14677
|
statement += ",";
|
|
14665
14678
|
}
|
|
14666
14679
|
compositePKs.forEach((it) => {
|
|
@@ -16300,6 +16313,8 @@ var init_snapshotsDiffer = __esm({
|
|
|
16300
16313
|
init_jsonDiffer();
|
|
16301
16314
|
init_jsonStatements();
|
|
16302
16315
|
init_utils2();
|
|
16316
|
+
init_sqliteSchema();
|
|
16317
|
+
init_mysqlSchema();
|
|
16303
16318
|
makeChanged = (schema4) => {
|
|
16304
16319
|
return objectType({
|
|
16305
16320
|
type: enumType(["changed"]),
|
|
@@ -16537,35 +16552,64 @@ var init_snapshotsDiffer = __esm({
|
|
|
16537
16552
|
const jsonSetNewTableSchemas = [];
|
|
16538
16553
|
allAlteredResolved.forEach((it) => {
|
|
16539
16554
|
const schemaUnwrapped = valueFromSelfOrPatchedNew(it.schema);
|
|
16540
|
-
let
|
|
16541
|
-
|
|
16542
|
-
|
|
16555
|
+
let addedColumns = [];
|
|
16556
|
+
for (const addedPkName of Object.keys(it.addedCompositePKs)) {
|
|
16557
|
+
const addedPkColumns = it.addedCompositePKs[addedPkName];
|
|
16558
|
+
if (dialect6 === "sqlite") {
|
|
16559
|
+
addedColumns = SQLiteSquasher.unsquashPK(addedPkColumns);
|
|
16560
|
+
} else if (dialect6 === "mysql") {
|
|
16561
|
+
addedColumns = MySqlSquasher.unsquashPK(addedPkColumns).columns;
|
|
16562
|
+
} else {
|
|
16563
|
+
addedColumns = SQLiteSquasher.unsquashPK(addedPkColumns);
|
|
16564
|
+
}
|
|
16565
|
+
}
|
|
16566
|
+
let deletedColumns = [];
|
|
16567
|
+
for (const deletedPkName of Object.keys(it.deletedCompositePKs)) {
|
|
16568
|
+
const deletedPkColumns = it.deletedCompositePKs[deletedPkName];
|
|
16569
|
+
if (dialect6 === "sqlite") {
|
|
16570
|
+
deletedColumns = SQLiteSquasher.unsquashPK(deletedPkColumns);
|
|
16571
|
+
} else if (dialect6 === "mysql") {
|
|
16572
|
+
deletedColumns = MySqlSquasher.unsquashPK(deletedPkColumns).columns;
|
|
16573
|
+
} else {
|
|
16574
|
+
deletedColumns = SQLiteSquasher.unsquashPK(deletedPkColumns);
|
|
16575
|
+
}
|
|
16576
|
+
}
|
|
16577
|
+
addedColumns.sort();
|
|
16578
|
+
deletedColumns.sort();
|
|
16579
|
+
const doPerformDeleteAndCreate = JSON.stringify(addedColumns) !== JSON.stringify(deletedColumns);
|
|
16580
|
+
let addedCompositePKs = [];
|
|
16581
|
+
let deletedCompositePKs = [];
|
|
16582
|
+
let alteredCompositePKs = [];
|
|
16543
16583
|
if (dialect6 === "sqlite") {
|
|
16544
|
-
|
|
16545
|
-
|
|
16546
|
-
|
|
16547
|
-
|
|
16548
|
-
|
|
16549
|
-
|
|
16550
|
-
|
|
16551
|
-
|
|
16584
|
+
if (doPerformDeleteAndCreate) {
|
|
16585
|
+
addedCompositePKs = prepareAddCompositePrimaryKeySqlite(
|
|
16586
|
+
it.name,
|
|
16587
|
+
it.addedCompositePKs
|
|
16588
|
+
);
|
|
16589
|
+
deletedCompositePKs = prepareDeleteCompositePrimaryKeySqlite(
|
|
16590
|
+
it.name,
|
|
16591
|
+
it.deletedCompositePKs
|
|
16592
|
+
);
|
|
16593
|
+
}
|
|
16552
16594
|
alteredCompositePKs = prepareAlterCompositePrimaryKeySqlite(
|
|
16553
16595
|
it.name,
|
|
16554
16596
|
it.alteredCompositePKs
|
|
16555
16597
|
);
|
|
16556
16598
|
} else if (dialect6 === "pg") {
|
|
16557
|
-
|
|
16558
|
-
|
|
16559
|
-
|
|
16560
|
-
|
|
16561
|
-
|
|
16562
|
-
|
|
16563
|
-
|
|
16564
|
-
|
|
16565
|
-
|
|
16566
|
-
|
|
16567
|
-
|
|
16568
|
-
|
|
16599
|
+
if (doPerformDeleteAndCreate) {
|
|
16600
|
+
addedCompositePKs = prepareAddCompositePrimaryKeyPg(
|
|
16601
|
+
it.name,
|
|
16602
|
+
schemaUnwrapped,
|
|
16603
|
+
it.addedCompositePKs,
|
|
16604
|
+
curFull
|
|
16605
|
+
);
|
|
16606
|
+
deletedCompositePKs = prepareDeleteCompositePrimaryKeyPg(
|
|
16607
|
+
it.name,
|
|
16608
|
+
schemaUnwrapped,
|
|
16609
|
+
it.deletedCompositePKs,
|
|
16610
|
+
prevFull
|
|
16611
|
+
);
|
|
16612
|
+
}
|
|
16569
16613
|
alteredCompositePKs = prepareAlterCompositePrimaryKeyPg(
|
|
16570
16614
|
it.name,
|
|
16571
16615
|
schemaUnwrapped,
|
|
@@ -16574,16 +16618,19 @@ var init_snapshotsDiffer = __esm({
|
|
|
16574
16618
|
curFull
|
|
16575
16619
|
);
|
|
16576
16620
|
} else {
|
|
16577
|
-
|
|
16578
|
-
|
|
16579
|
-
|
|
16580
|
-
|
|
16581
|
-
|
|
16582
|
-
|
|
16583
|
-
|
|
16584
|
-
|
|
16585
|
-
|
|
16586
|
-
|
|
16621
|
+
if (doPerformDeleteAndCreate) {
|
|
16622
|
+
addedCompositePKs = prepareAddCompositePrimaryKeyMySql(
|
|
16623
|
+
it.name,
|
|
16624
|
+
it.addedCompositePKs,
|
|
16625
|
+
curFull
|
|
16626
|
+
);
|
|
16627
|
+
deletedCompositePKs = prepareDeleteCompositePrimaryKeyMySql(
|
|
16628
|
+
it.name,
|
|
16629
|
+
it.deletedCompositePKs,
|
|
16630
|
+
prevFull
|
|
16631
|
+
);
|
|
16632
|
+
}
|
|
16633
|
+
;
|
|
16587
16634
|
alteredCompositePKs = prepareAlterCompositePrimaryKeyMySql(
|
|
16588
16635
|
it.name,
|
|
16589
16636
|
it.alteredCompositePKs,
|
|
@@ -17966,6 +18013,577 @@ var init_utils3 = __esm({
|
|
|
17966
18013
|
}
|
|
17967
18014
|
});
|
|
17968
18015
|
|
|
18016
|
+
// src/cli/commands/sqliteUtils.ts
|
|
18017
|
+
var sqliteConnectionSchema, sqliteCliConfigSchema;
|
|
18018
|
+
var init_sqliteUtils = __esm({
|
|
18019
|
+
"src/cli/commands/sqliteUtils.ts"() {
|
|
18020
|
+
init_lib();
|
|
18021
|
+
init_utils();
|
|
18022
|
+
sqliteConnectionSchema = unionType([
|
|
18023
|
+
objectType({
|
|
18024
|
+
driver: literalType("turso"),
|
|
18025
|
+
dbCredentials: objectType({
|
|
18026
|
+
url: stringType(),
|
|
18027
|
+
authToken: stringType().optional()
|
|
18028
|
+
})
|
|
18029
|
+
}),
|
|
18030
|
+
objectType({
|
|
18031
|
+
driver: literalType("libsql"),
|
|
18032
|
+
dbCredentials: objectType({
|
|
18033
|
+
url: stringType()
|
|
18034
|
+
})
|
|
18035
|
+
}),
|
|
18036
|
+
objectType({
|
|
18037
|
+
driver: literalType("better-sqlite"),
|
|
18038
|
+
dbCredentials: objectType({
|
|
18039
|
+
url: stringType()
|
|
18040
|
+
})
|
|
18041
|
+
})
|
|
18042
|
+
]);
|
|
18043
|
+
sqliteCliConfigSchema = intersectionType(
|
|
18044
|
+
configIntrospectSchema,
|
|
18045
|
+
sqliteConnectionSchema
|
|
18046
|
+
);
|
|
18047
|
+
}
|
|
18048
|
+
});
|
|
18049
|
+
|
|
18050
|
+
// src/cli/validations/outputs.ts
|
|
18051
|
+
var withStyle, outputs;
|
|
18052
|
+
var init_outputs = __esm({
|
|
18053
|
+
"src/cli/validations/outputs.ts"() {
|
|
18054
|
+
init_source();
|
|
18055
|
+
withStyle = {
|
|
18056
|
+
error: (str) => `${source_default.red(`${source_default.white.bgRed(" Invalid input ")} ${str}`)}`,
|
|
18057
|
+
warning: (str) => `${source_default.white.bgGray(" Warning ")} ${str}`,
|
|
18058
|
+
fullWarning: (str) => `${source_default.black.bgYellow("[Warning]")} ${source_default.bold(str)}`
|
|
18059
|
+
};
|
|
18060
|
+
outputs = {
|
|
18061
|
+
studio: {
|
|
18062
|
+
drivers: (param) => withStyle.error(
|
|
18063
|
+
`"${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`
|
|
18064
|
+
),
|
|
18065
|
+
noCredentials: () => withStyle.error(
|
|
18066
|
+
`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`
|
|
18067
|
+
),
|
|
18068
|
+
noDriver: () => withStyle.error(
|
|
18069
|
+
`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`
|
|
18070
|
+
)
|
|
18071
|
+
},
|
|
18072
|
+
common: {
|
|
18073
|
+
ambiguousParams: (command) => withStyle.error(
|
|
18074
|
+
`You can't use both --config and other cli options for ${command} command`
|
|
18075
|
+
),
|
|
18076
|
+
schema: (command) => withStyle.error(`"--schema" is a required field for ${command} command`),
|
|
18077
|
+
schemaConfig: (command) => withStyle.error(
|
|
18078
|
+
`"schema" is a required field in drizzle.config for ${command} command`
|
|
18079
|
+
)
|
|
18080
|
+
},
|
|
18081
|
+
postgres: {
|
|
18082
|
+
connection: {
|
|
18083
|
+
driver: () => withStyle.error(`Only "pg" is available options for "--driver"`),
|
|
18084
|
+
required: () => withStyle.error(
|
|
18085
|
+
`Either "connectionString" or "host", "database" are required for database connection`
|
|
18086
|
+
)
|
|
18087
|
+
}
|
|
18088
|
+
},
|
|
18089
|
+
mysql: {
|
|
18090
|
+
connection: {
|
|
18091
|
+
driver: () => withStyle.error(`Only "mysql2" is available options for "--driver"`),
|
|
18092
|
+
required: () => withStyle.error(
|
|
18093
|
+
`Either "connectionString" or "host", "database" are required for database connection`
|
|
18094
|
+
)
|
|
18095
|
+
}
|
|
18096
|
+
},
|
|
18097
|
+
sqlite: {
|
|
18098
|
+
connection: {
|
|
18099
|
+
driver: () => withStyle.error(
|
|
18100
|
+
`Either "turso", "libsql", "better-sqlite" are available options for "--driver"`
|
|
18101
|
+
),
|
|
18102
|
+
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`),
|
|
18103
|
+
authToken: (driver) => withStyle.error(
|
|
18104
|
+
`"authToken" is a required option for driver "${driver}". You can read more about drizzle.config: https://orm.drizzle.team/kit-docs/config-reference`
|
|
18105
|
+
)
|
|
18106
|
+
},
|
|
18107
|
+
introspect: {},
|
|
18108
|
+
push: {}
|
|
18109
|
+
}
|
|
18110
|
+
};
|
|
18111
|
+
}
|
|
18112
|
+
});
|
|
18113
|
+
|
|
18114
|
+
// src/cli/validations/common.ts
|
|
18115
|
+
var checkCollisions;
|
|
18116
|
+
var init_common = __esm({
|
|
18117
|
+
"src/cli/validations/common.ts"() {
|
|
18118
|
+
init_outputs();
|
|
18119
|
+
checkCollisions = (options, command, inputWhitelist = []) => {
|
|
18120
|
+
const { config, ...rest } = options;
|
|
18121
|
+
let atLeastOneParam = false;
|
|
18122
|
+
for (const key of Object.keys(rest)) {
|
|
18123
|
+
if (inputWhitelist.includes(key))
|
|
18124
|
+
continue;
|
|
18125
|
+
atLeastOneParam = true;
|
|
18126
|
+
}
|
|
18127
|
+
if (!atLeastOneParam && typeof config !== "undefined") {
|
|
18128
|
+
return {
|
|
18129
|
+
success: true,
|
|
18130
|
+
action: "config"
|
|
18131
|
+
};
|
|
18132
|
+
}
|
|
18133
|
+
if (typeof config === "undefined" && atLeastOneParam) {
|
|
18134
|
+
return {
|
|
18135
|
+
success: true,
|
|
18136
|
+
action: "cli"
|
|
18137
|
+
};
|
|
18138
|
+
}
|
|
18139
|
+
if (typeof config === "undefined" && !atLeastOneParam) {
|
|
18140
|
+
return {
|
|
18141
|
+
success: true,
|
|
18142
|
+
action: "config"
|
|
18143
|
+
};
|
|
18144
|
+
}
|
|
18145
|
+
return {
|
|
18146
|
+
success: false,
|
|
18147
|
+
message: outputs.common.ambiguousParams(command),
|
|
18148
|
+
action: "error"
|
|
18149
|
+
};
|
|
18150
|
+
};
|
|
18151
|
+
}
|
|
18152
|
+
});
|
|
18153
|
+
|
|
18154
|
+
// src/cli/validations/sqlite.ts
|
|
18155
|
+
var sqliteConnectionCli, sqliteCliIntrospectParams, sqliteCliPushParams, sqliteConfigPushParams, printCliConnectionIssues, printConfigConnectionIssues, validateIntrospect, validatePush;
|
|
18156
|
+
var init_sqlite = __esm({
|
|
18157
|
+
"src/cli/validations/sqlite.ts"() {
|
|
18158
|
+
init_lib();
|
|
18159
|
+
init_sqliteUtils();
|
|
18160
|
+
init_utils();
|
|
18161
|
+
init_common();
|
|
18162
|
+
init_outputs();
|
|
18163
|
+
sqliteConnectionCli = unionType([
|
|
18164
|
+
objectType({
|
|
18165
|
+
driver: literalType("turso"),
|
|
18166
|
+
url: stringType(),
|
|
18167
|
+
authToken: stringType()
|
|
18168
|
+
}),
|
|
18169
|
+
objectType({
|
|
18170
|
+
driver: literalType("better-sqlite"),
|
|
18171
|
+
url: stringType()
|
|
18172
|
+
}),
|
|
18173
|
+
objectType({
|
|
18174
|
+
driver: literalType("libsql"),
|
|
18175
|
+
url: stringType()
|
|
18176
|
+
})
|
|
18177
|
+
]);
|
|
18178
|
+
sqliteCliIntrospectParams = intersectionType(
|
|
18179
|
+
configIntrospectCliSchema,
|
|
18180
|
+
sqliteConnectionCli
|
|
18181
|
+
);
|
|
18182
|
+
sqliteCliPushParams = intersectionType(
|
|
18183
|
+
configPushSchema,
|
|
18184
|
+
sqliteConnectionCli
|
|
18185
|
+
);
|
|
18186
|
+
sqliteConfigPushParams = intersectionType(
|
|
18187
|
+
configPushSchema,
|
|
18188
|
+
sqliteConnectionSchema
|
|
18189
|
+
);
|
|
18190
|
+
printCliConnectionIssues = (options) => {
|
|
18191
|
+
if (options.driver === "turso") {
|
|
18192
|
+
if (typeof options.url === "undefined") {
|
|
18193
|
+
console.log(outputs.sqlite.connection.url("turso"));
|
|
18194
|
+
}
|
|
18195
|
+
if (typeof options.authToken === "undefined") {
|
|
18196
|
+
console.log(outputs.sqlite.connection.authToken("turso"));
|
|
18197
|
+
}
|
|
18198
|
+
} else if (options.driver === "libsql") {
|
|
18199
|
+
if (typeof options.url === "undefined") {
|
|
18200
|
+
console.log(outputs.sqlite.connection.url("libsql"));
|
|
18201
|
+
}
|
|
18202
|
+
} else if (options.driver === "better-sqlite") {
|
|
18203
|
+
if (typeof options.url === "undefined") {
|
|
18204
|
+
console.log(outputs.sqlite.connection.url("better-sqlite"));
|
|
18205
|
+
}
|
|
18206
|
+
} else {
|
|
18207
|
+
console.log(outputs.sqlite.connection.driver());
|
|
18208
|
+
}
|
|
18209
|
+
};
|
|
18210
|
+
printConfigConnectionIssues = (options) => {
|
|
18211
|
+
var _a, _b, _c;
|
|
18212
|
+
if (options.driver === "turso") {
|
|
18213
|
+
if (typeof options.url === "undefined") {
|
|
18214
|
+
console.log(outputs.sqlite.connection.url("turso"));
|
|
18215
|
+
}
|
|
18216
|
+
if (typeof ((_a = options.dbCredentials) == null ? void 0 : _a.authToken) === "undefined") {
|
|
18217
|
+
console.log(outputs.sqlite.connection.authToken("turso"));
|
|
18218
|
+
}
|
|
18219
|
+
} else if (options.driver === "libsql") {
|
|
18220
|
+
if (typeof ((_b = options.dbCredentials) == null ? void 0 : _b.url) === "undefined") {
|
|
18221
|
+
console.log(outputs.sqlite.connection.url("libsql"));
|
|
18222
|
+
}
|
|
18223
|
+
} else if (options.driver === "better-sqlite") {
|
|
18224
|
+
if (typeof ((_c = options.dbCredentials) == null ? void 0 : _c.url) === "undefined") {
|
|
18225
|
+
console.log(outputs.sqlite.connection.url("better-sqlite"));
|
|
18226
|
+
}
|
|
18227
|
+
} else {
|
|
18228
|
+
console.log(outputs.sqlite.connection.driver());
|
|
18229
|
+
}
|
|
18230
|
+
};
|
|
18231
|
+
validateIntrospect = async (options) => {
|
|
18232
|
+
const collisionRes = checkCollisions(options, "introspect:sqlite");
|
|
18233
|
+
if (!collisionRes.success) {
|
|
18234
|
+
console.log(collisionRes.message);
|
|
18235
|
+
process.exit(1);
|
|
18236
|
+
}
|
|
18237
|
+
if (collisionRes.action === "config") {
|
|
18238
|
+
const drizzleConfig = await readDrizzleConfig(options.config);
|
|
18239
|
+
const configRes = sqliteCliConfigSchema.safeParse(drizzleConfig);
|
|
18240
|
+
if (!configRes.success) {
|
|
18241
|
+
printConfigConnectionIssues(drizzleConfig);
|
|
18242
|
+
process.exit(1);
|
|
18243
|
+
}
|
|
18244
|
+
return configRes.data;
|
|
18245
|
+
}
|
|
18246
|
+
const cliRes = sqliteCliIntrospectParams.safeParse(options);
|
|
18247
|
+
if (!cliRes.success) {
|
|
18248
|
+
printCliConnectionIssues(options);
|
|
18249
|
+
process.exit(1);
|
|
18250
|
+
}
|
|
18251
|
+
if (cliRes.data.driver === "turso") {
|
|
18252
|
+
const { authToken, url: url2, introspectCasing: introspectCasing3, ...rest2 } = cliRes.data;
|
|
18253
|
+
return {
|
|
18254
|
+
...rest2,
|
|
18255
|
+
dbCredentials: { url: url2, authToken },
|
|
18256
|
+
introspect: { casing: introspectCasing3 }
|
|
18257
|
+
};
|
|
18258
|
+
}
|
|
18259
|
+
if (cliRes.data.driver === "libsql") {
|
|
18260
|
+
const { url: url2, introspectCasing: introspectCasing3, ...rest2 } = cliRes.data;
|
|
18261
|
+
return {
|
|
18262
|
+
...rest2,
|
|
18263
|
+
dbCredentials: { url: url2 },
|
|
18264
|
+
introspect: { casing: introspectCasing3 }
|
|
18265
|
+
};
|
|
18266
|
+
}
|
|
18267
|
+
const { url, introspectCasing: introspectCasing2, ...rest } = cliRes.data;
|
|
18268
|
+
return {
|
|
18269
|
+
...rest,
|
|
18270
|
+
dbCredentials: { url },
|
|
18271
|
+
introspect: { casing: introspectCasing2 }
|
|
18272
|
+
};
|
|
18273
|
+
};
|
|
18274
|
+
validatePush = async (options) => {
|
|
18275
|
+
const collisionRes = checkCollisions(options, "push:sqlite");
|
|
18276
|
+
if (!collisionRes.success) {
|
|
18277
|
+
console.log(collisionRes.message);
|
|
18278
|
+
console.log();
|
|
18279
|
+
process.exit(1);
|
|
18280
|
+
}
|
|
18281
|
+
if (collisionRes.action === "config") {
|
|
18282
|
+
const drizzleConfig = await readDrizzleConfig(options.config);
|
|
18283
|
+
const configRes = sqliteConfigPushParams.safeParse(drizzleConfig);
|
|
18284
|
+
if (!configRes.success) {
|
|
18285
|
+
printConfigConnectionIssues(drizzleConfig);
|
|
18286
|
+
process.exit(1);
|
|
18287
|
+
}
|
|
18288
|
+
return configRes.data;
|
|
18289
|
+
}
|
|
18290
|
+
const cliRes = sqliteCliPushParams.safeParse(options);
|
|
18291
|
+
if (!cliRes.success) {
|
|
18292
|
+
if (typeof options.schema === "undefined") {
|
|
18293
|
+
console.log(outputs.common.schema("push:sqlite"));
|
|
18294
|
+
}
|
|
18295
|
+
printCliConnectionIssues(options);
|
|
18296
|
+
process.exit(1);
|
|
18297
|
+
}
|
|
18298
|
+
if (cliRes.data.driver === "turso") {
|
|
18299
|
+
const { authToken, url: url2, ...rest2 } = cliRes.data;
|
|
18300
|
+
return { ...rest2, dbCredentials: { url: url2, authToken } };
|
|
18301
|
+
}
|
|
18302
|
+
const { url, ...rest } = cliRes.data;
|
|
18303
|
+
return { ...rest, dbCredentials: { url } };
|
|
18304
|
+
};
|
|
18305
|
+
}
|
|
18306
|
+
});
|
|
18307
|
+
|
|
18308
|
+
// src/cli/validations/pg.ts
|
|
18309
|
+
var pgConnectionCli, pgConnectionConfig, pgConfigIntrospectSchema, pgCliIntrospectParams, printCliConnectionIssues2, printConfigConnectionIssues2, validatePgIntrospect;
|
|
18310
|
+
var init_pg = __esm({
|
|
18311
|
+
"src/cli/validations/pg.ts"() {
|
|
18312
|
+
init_lib();
|
|
18313
|
+
init_utils();
|
|
18314
|
+
init_common();
|
|
18315
|
+
init_outputs();
|
|
18316
|
+
pgConnectionCli = unionType([
|
|
18317
|
+
objectType({
|
|
18318
|
+
driver: literalType("pg"),
|
|
18319
|
+
host: stringType(),
|
|
18320
|
+
port: coerce.number().optional(),
|
|
18321
|
+
user: stringType().default("postgres"),
|
|
18322
|
+
password: stringType().optional(),
|
|
18323
|
+
database: stringType(),
|
|
18324
|
+
ssl: coerce.boolean().optional(),
|
|
18325
|
+
type: literalType("params").default("params")
|
|
18326
|
+
}),
|
|
18327
|
+
objectType({
|
|
18328
|
+
driver: literalType("pg"),
|
|
18329
|
+
connectionString: stringType(),
|
|
18330
|
+
type: literalType("url").default("url")
|
|
18331
|
+
})
|
|
18332
|
+
]);
|
|
18333
|
+
pgConnectionConfig = unionType([
|
|
18334
|
+
objectType({
|
|
18335
|
+
driver: literalType("pg"),
|
|
18336
|
+
dbCredentials: objectType({
|
|
18337
|
+
host: stringType(),
|
|
18338
|
+
port: coerce.number().optional(),
|
|
18339
|
+
user: stringType().default("postgres"),
|
|
18340
|
+
password: stringType().optional(),
|
|
18341
|
+
database: stringType(),
|
|
18342
|
+
ssl: coerce.boolean().optional()
|
|
18343
|
+
})
|
|
18344
|
+
}),
|
|
18345
|
+
objectType({
|
|
18346
|
+
driver: literalType("pg"),
|
|
18347
|
+
dbCredentials: objectType({
|
|
18348
|
+
connectionString: stringType()
|
|
18349
|
+
})
|
|
18350
|
+
})
|
|
18351
|
+
]);
|
|
18352
|
+
pgConfigIntrospectSchema = intersectionType(
|
|
18353
|
+
configIntrospectSchema,
|
|
18354
|
+
pgConnectionConfig
|
|
18355
|
+
);
|
|
18356
|
+
pgCliIntrospectParams = intersectionType(
|
|
18357
|
+
configIntrospectCliSchema,
|
|
18358
|
+
pgConnectionCli
|
|
18359
|
+
);
|
|
18360
|
+
printCliConnectionIssues2 = (options) => {
|
|
18361
|
+
if (options.driver === "pg") {
|
|
18362
|
+
if (typeof options.connectionString === "undefined" && (typeof options.host === "undefined" || typeof options.database === "undefined")) {
|
|
18363
|
+
console.log(outputs.postgres.connection.required());
|
|
18364
|
+
}
|
|
18365
|
+
} else {
|
|
18366
|
+
console.log(outputs.postgres.connection.driver());
|
|
18367
|
+
}
|
|
18368
|
+
};
|
|
18369
|
+
printConfigConnectionIssues2 = (options) => {
|
|
18370
|
+
if (options.driver === "pg") {
|
|
18371
|
+
if (typeof options.dbCredentials.connectionString === "undefined" && (typeof options.dbCredentials.host === "undefined" || typeof options.dbCredentials.database === "undefined")) {
|
|
18372
|
+
console.log(outputs.postgres.connection.required());
|
|
18373
|
+
}
|
|
18374
|
+
} else {
|
|
18375
|
+
console.log(outputs.postgres.connection.driver());
|
|
18376
|
+
}
|
|
18377
|
+
};
|
|
18378
|
+
validatePgIntrospect = async (options) => {
|
|
18379
|
+
const collisionRes = checkCollisions(options, "introspect:pg");
|
|
18380
|
+
if (!collisionRes.success) {
|
|
18381
|
+
console.log(collisionRes.message);
|
|
18382
|
+
process.exit(1);
|
|
18383
|
+
}
|
|
18384
|
+
if (collisionRes.action === "config") {
|
|
18385
|
+
const drizzleConfig = await readDrizzleConfig(options.config);
|
|
18386
|
+
const configRes = pgConfigIntrospectSchema.safeParse(drizzleConfig);
|
|
18387
|
+
if (!configRes.success) {
|
|
18388
|
+
printConfigConnectionIssues2(drizzleConfig);
|
|
18389
|
+
process.exit(1);
|
|
18390
|
+
}
|
|
18391
|
+
return configRes.data;
|
|
18392
|
+
}
|
|
18393
|
+
const cliRes = pgCliIntrospectParams.safeParse(options);
|
|
18394
|
+
if (!cliRes.success) {
|
|
18395
|
+
printCliConnectionIssues2(options);
|
|
18396
|
+
process.exit(1);
|
|
18397
|
+
}
|
|
18398
|
+
if (cliRes.data.type === "url") {
|
|
18399
|
+
const { connectionString, introspectCasing: introspectCasing3, ...rest2 } = cliRes.data;
|
|
18400
|
+
return {
|
|
18401
|
+
...rest2,
|
|
18402
|
+
dbCredentials: { connectionString },
|
|
18403
|
+
introspect: { casing: introspectCasing3 }
|
|
18404
|
+
};
|
|
18405
|
+
}
|
|
18406
|
+
const {
|
|
18407
|
+
host,
|
|
18408
|
+
password,
|
|
18409
|
+
port,
|
|
18410
|
+
database,
|
|
18411
|
+
ssl,
|
|
18412
|
+
user,
|
|
18413
|
+
introspectCasing: introspectCasing2,
|
|
18414
|
+
...rest
|
|
18415
|
+
} = cliRes.data;
|
|
18416
|
+
return {
|
|
18417
|
+
...rest,
|
|
18418
|
+
dbCredentials: { host, password, port, database, ssl, user },
|
|
18419
|
+
introspect: { casing: introspectCasing2 }
|
|
18420
|
+
};
|
|
18421
|
+
};
|
|
18422
|
+
}
|
|
18423
|
+
});
|
|
18424
|
+
|
|
18425
|
+
// src/cli/validations/mysql.ts
|
|
18426
|
+
var mysqlConnectionCli, mysqlConnectionConfig, mysqlConfigIntrospectSchema, mysqlCliIntrospectParams, mysqlCliPushParams, mysqlConfigPushParams, printCliConnectionIssues3, printConfigConnectionIssues3, validateMySqlIntrospect, validateMySqlPush;
|
|
18427
|
+
var init_mysql = __esm({
|
|
18428
|
+
"src/cli/validations/mysql.ts"() {
|
|
18429
|
+
init_lib();
|
|
18430
|
+
init_utils();
|
|
18431
|
+
init_common();
|
|
18432
|
+
init_outputs();
|
|
18433
|
+
mysqlConnectionCli = unionType([
|
|
18434
|
+
objectType({
|
|
18435
|
+
driver: literalType("mysql2"),
|
|
18436
|
+
host: stringType(),
|
|
18437
|
+
port: coerce.number().optional(),
|
|
18438
|
+
user: stringType().default("mysql"),
|
|
18439
|
+
password: stringType().optional(),
|
|
18440
|
+
database: stringType(),
|
|
18441
|
+
type: literalType("params").default("params")
|
|
18442
|
+
}),
|
|
18443
|
+
objectType({
|
|
18444
|
+
driver: literalType("mysql2"),
|
|
18445
|
+
connectionString: stringType(),
|
|
18446
|
+
type: literalType("url").default("url")
|
|
18447
|
+
})
|
|
18448
|
+
]);
|
|
18449
|
+
mysqlConnectionConfig = unionType([
|
|
18450
|
+
objectType({
|
|
18451
|
+
driver: literalType("mysql2"),
|
|
18452
|
+
dbCredentials: objectType({
|
|
18453
|
+
host: stringType(),
|
|
18454
|
+
port: coerce.number().optional(),
|
|
18455
|
+
user: stringType().default("mysql"),
|
|
18456
|
+
password: stringType().optional(),
|
|
18457
|
+
database: stringType(),
|
|
18458
|
+
type: literalType("params").default("params")
|
|
18459
|
+
})
|
|
18460
|
+
}),
|
|
18461
|
+
objectType({
|
|
18462
|
+
driver: literalType("mysql2"),
|
|
18463
|
+
dbCredentials: objectType({
|
|
18464
|
+
connectionString: stringType(),
|
|
18465
|
+
type: literalType("url").default("url")
|
|
18466
|
+
})
|
|
18467
|
+
})
|
|
18468
|
+
]);
|
|
18469
|
+
mysqlConfigIntrospectSchema = intersectionType(
|
|
18470
|
+
configIntrospectSchema,
|
|
18471
|
+
mysqlConnectionConfig
|
|
18472
|
+
);
|
|
18473
|
+
mysqlCliIntrospectParams = intersectionType(
|
|
18474
|
+
configIntrospectCliSchema,
|
|
18475
|
+
mysqlConnectionCli
|
|
18476
|
+
);
|
|
18477
|
+
mysqlCliPushParams = intersectionType(
|
|
18478
|
+
configPushSchema,
|
|
18479
|
+
mysqlConnectionCli
|
|
18480
|
+
);
|
|
18481
|
+
mysqlConfigPushParams = intersectionType(
|
|
18482
|
+
configPushSchema,
|
|
18483
|
+
mysqlConnectionConfig
|
|
18484
|
+
);
|
|
18485
|
+
printCliConnectionIssues3 = (options) => {
|
|
18486
|
+
if (options.driver === "mysql2") {
|
|
18487
|
+
if (typeof options.connectionString === "undefined" && (typeof options.host === "undefined" || typeof options.database === "undefined")) {
|
|
18488
|
+
console.log(outputs.mysql.connection.required());
|
|
18489
|
+
}
|
|
18490
|
+
} else {
|
|
18491
|
+
console.log(outputs.mysql.connection.driver());
|
|
18492
|
+
}
|
|
18493
|
+
};
|
|
18494
|
+
printConfigConnectionIssues3 = (options) => {
|
|
18495
|
+
if (options.driver === "mysql2") {
|
|
18496
|
+
if (typeof options.dbCredentials.connectionString === "undefined" && (typeof options.dbCredentials.host === "undefined" || typeof options.dbCredentials.database === "undefined")) {
|
|
18497
|
+
console.log(outputs.mysql.connection.required());
|
|
18498
|
+
}
|
|
18499
|
+
} else {
|
|
18500
|
+
console.log(outputs.mysql.connection.driver());
|
|
18501
|
+
}
|
|
18502
|
+
};
|
|
18503
|
+
validateMySqlIntrospect = async (options) => {
|
|
18504
|
+
const collisionRes = checkCollisions(options, "introspect:mysql");
|
|
18505
|
+
if (!collisionRes.success) {
|
|
18506
|
+
console.log(collisionRes.message);
|
|
18507
|
+
process.exit(1);
|
|
18508
|
+
}
|
|
18509
|
+
if (collisionRes.action === "config") {
|
|
18510
|
+
const drizzleConfig = await readDrizzleConfig(options.config);
|
|
18511
|
+
const configRes = mysqlConfigIntrospectSchema.safeParse(drizzleConfig);
|
|
18512
|
+
if (!configRes.success) {
|
|
18513
|
+
printConfigConnectionIssues3(drizzleConfig);
|
|
18514
|
+
process.exit(1);
|
|
18515
|
+
}
|
|
18516
|
+
return configRes.data;
|
|
18517
|
+
}
|
|
18518
|
+
const cliRes = mysqlCliIntrospectParams.safeParse(options);
|
|
18519
|
+
if (!cliRes.success) {
|
|
18520
|
+
printCliConnectionIssues3(options);
|
|
18521
|
+
process.exit(1);
|
|
18522
|
+
}
|
|
18523
|
+
if (cliRes.data.type === "url") {
|
|
18524
|
+
const { connectionString, introspectCasing: introspectCasing3, type: type2, ...rest2 } = cliRes.data;
|
|
18525
|
+
return {
|
|
18526
|
+
...rest2,
|
|
18527
|
+
dbCredentials: { connectionString, type: type2 },
|
|
18528
|
+
introspect: { casing: introspectCasing3 }
|
|
18529
|
+
};
|
|
18530
|
+
}
|
|
18531
|
+
const {
|
|
18532
|
+
host,
|
|
18533
|
+
password,
|
|
18534
|
+
port,
|
|
18535
|
+
database,
|
|
18536
|
+
user,
|
|
18537
|
+
type,
|
|
18538
|
+
introspectCasing: introspectCasing2,
|
|
18539
|
+
...rest
|
|
18540
|
+
} = cliRes.data;
|
|
18541
|
+
return {
|
|
18542
|
+
...rest,
|
|
18543
|
+
dbCredentials: { host, password, port, database, user, type },
|
|
18544
|
+
introspect: { casing: introspectCasing2 }
|
|
18545
|
+
};
|
|
18546
|
+
};
|
|
18547
|
+
validateMySqlPush = async (options) => {
|
|
18548
|
+
const collisionRes = checkCollisions(options, "push:mysql");
|
|
18549
|
+
if (!collisionRes.success) {
|
|
18550
|
+
console.log(collisionRes.message);
|
|
18551
|
+
console.log();
|
|
18552
|
+
process.exit(1);
|
|
18553
|
+
}
|
|
18554
|
+
if (collisionRes.action === "config") {
|
|
18555
|
+
const drizzleConfig = await readDrizzleConfig(options.config);
|
|
18556
|
+
const configRes = mysqlConfigPushParams.safeParse(drizzleConfig);
|
|
18557
|
+
if (!configRes.success) {
|
|
18558
|
+
printConfigConnectionIssues3(drizzleConfig);
|
|
18559
|
+
process.exit(1);
|
|
18560
|
+
}
|
|
18561
|
+
return configRes.data;
|
|
18562
|
+
}
|
|
18563
|
+
const cliRes = mysqlCliPushParams.safeParse(options);
|
|
18564
|
+
if (!cliRes.success) {
|
|
18565
|
+
if (typeof options.schema === "undefined") {
|
|
18566
|
+
console.log(outputs.common.schema("push:mysql"));
|
|
18567
|
+
}
|
|
18568
|
+
printCliConnectionIssues3(options);
|
|
18569
|
+
process.exit(1);
|
|
18570
|
+
}
|
|
18571
|
+
if (cliRes.data.type === "url") {
|
|
18572
|
+
const { connectionString, type: type2, ...rest2 } = cliRes.data;
|
|
18573
|
+
return {
|
|
18574
|
+
...rest2,
|
|
18575
|
+
dbCredentials: { connectionString, type: type2 }
|
|
18576
|
+
};
|
|
18577
|
+
}
|
|
18578
|
+
const { host, password, port, database, user, type, ...rest } = cliRes.data;
|
|
18579
|
+
return {
|
|
18580
|
+
...rest,
|
|
18581
|
+
dbCredentials: { host, password, port, database, user, type }
|
|
18582
|
+
};
|
|
18583
|
+
};
|
|
18584
|
+
}
|
|
18585
|
+
});
|
|
18586
|
+
|
|
17969
18587
|
// node_modules/.pnpm/sqlstring@2.3.3/node_modules/sqlstring/lib/SqlString.js
|
|
17970
18588
|
var require_SqlString = __commonJS({
|
|
17971
18589
|
"node_modules/.pnpm/sqlstring@2.3.3/node_modules/sqlstring/lib/SqlString.js"(exports) {
|
|
@@ -44785,12 +45403,12 @@ var require_lib3 = __commonJS({
|
|
|
44785
45403
|
const dest = new URL$1(destination).protocol;
|
|
44786
45404
|
return orig === dest;
|
|
44787
45405
|
};
|
|
44788
|
-
function
|
|
44789
|
-
if (!
|
|
45406
|
+
function fetch(url, opts) {
|
|
45407
|
+
if (!fetch.Promise) {
|
|
44790
45408
|
throw new Error("native promise missing, set fetch.Promise to your favorite alternative");
|
|
44791
45409
|
}
|
|
44792
|
-
Body.Promise =
|
|
44793
|
-
return new
|
|
45410
|
+
Body.Promise = fetch.Promise;
|
|
45411
|
+
return new fetch.Promise(function(resolve2, reject) {
|
|
44794
45412
|
const request = new Request2(url, opts);
|
|
44795
45413
|
const options = getNodeRequestOptions(request);
|
|
44796
45414
|
const send = (options.protocol === "https:" ? https : http).request;
|
|
@@ -44863,7 +45481,7 @@ var require_lib3 = __commonJS({
|
|
|
44863
45481
|
req.on("response", function(res) {
|
|
44864
45482
|
clearTimeout(reqTimeout);
|
|
44865
45483
|
const headers = createHeadersLenient(res.headers);
|
|
44866
|
-
if (
|
|
45484
|
+
if (fetch.isRedirect(res.statusCode)) {
|
|
44867
45485
|
const location = headers.get("Location");
|
|
44868
45486
|
let locationURL = null;
|
|
44869
45487
|
try {
|
|
@@ -44925,7 +45543,7 @@ var require_lib3 = __commonJS({
|
|
|
44925
45543
|
requestOpts.body = void 0;
|
|
44926
45544
|
requestOpts.headers.delete("content-length");
|
|
44927
45545
|
}
|
|
44928
|
-
resolve2(
|
|
45546
|
+
resolve2(fetch(new Request2(locationURL, requestOpts)));
|
|
44929
45547
|
finalize();
|
|
44930
45548
|
return;
|
|
44931
45549
|
}
|
|
@@ -45018,11 +45636,11 @@ var require_lib3 = __commonJS({
|
|
|
45018
45636
|
stream.end();
|
|
45019
45637
|
}
|
|
45020
45638
|
}
|
|
45021
|
-
|
|
45639
|
+
fetch.isRedirect = function(code) {
|
|
45022
45640
|
return code === 301 || code === 302 || code === 303 || code === 307 || code === 308;
|
|
45023
45641
|
};
|
|
45024
|
-
|
|
45025
|
-
module2.exports = exports =
|
|
45642
|
+
fetch.Promise = global.Promise;
|
|
45643
|
+
module2.exports = exports = fetch;
|
|
45026
45644
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45027
45645
|
exports.default = exports;
|
|
45028
45646
|
exports.Headers = Headers2;
|
|
@@ -45032,12 +45650,11 @@ var require_lib3 = __commonJS({
|
|
|
45032
45650
|
}
|
|
45033
45651
|
});
|
|
45034
45652
|
|
|
45035
|
-
// node_modules/.pnpm/@libsql+isomorphic-fetch@0.1.
|
|
45036
|
-
var import_node_fetch
|
|
45653
|
+
// node_modules/.pnpm/@libsql+isomorphic-fetch@0.1.4/node_modules/@libsql/isomorphic-fetch/node.mjs
|
|
45654
|
+
var import_node_fetch;
|
|
45037
45655
|
var init_node2 = __esm({
|
|
45038
|
-
"node_modules/.pnpm/@libsql+isomorphic-fetch@0.1.
|
|
45656
|
+
"node_modules/.pnpm/@libsql+isomorphic-fetch@0.1.4/node_modules/@libsql/isomorphic-fetch/node.mjs"() {
|
|
45039
45657
|
import_node_fetch = __toESM(require_lib3(), 1);
|
|
45040
|
-
({ Request, Response, Headers } = import_node_fetch.default);
|
|
45041
45658
|
}
|
|
45042
45659
|
});
|
|
45043
45660
|
|
|
@@ -45181,6 +45798,11 @@ var init_http = __esm({
|
|
|
45181
45798
|
});
|
|
45182
45799
|
|
|
45183
45800
|
// node_modules/.pnpm/@libsql+client@0.1.6/node_modules/@libsql/client/lib-esm/index.js
|
|
45801
|
+
var lib_esm_exports2 = {};
|
|
45802
|
+
__export(lib_esm_exports2, {
|
|
45803
|
+
LibsqlError: () => LibsqlError,
|
|
45804
|
+
createClient: () => createClient
|
|
45805
|
+
});
|
|
45184
45806
|
function createClient(config) {
|
|
45185
45807
|
return _createClient4(expandConfig(config));
|
|
45186
45808
|
}
|
|
@@ -50439,6 +51061,164 @@ var init_pgIntrospect = __esm({
|
|
|
50439
51061
|
}
|
|
50440
51062
|
});
|
|
50441
51063
|
|
|
51064
|
+
// src/cli/validations/studio.ts
|
|
51065
|
+
var studio_exports = {};
|
|
51066
|
+
__export(studio_exports, {
|
|
51067
|
+
studioConfigSchema: () => studioConfigSchema,
|
|
51068
|
+
validateStudio: () => validateStudio
|
|
51069
|
+
});
|
|
51070
|
+
var studioConfigSchema, printDriverIssues, validateStudio;
|
|
51071
|
+
var init_studio = __esm({
|
|
51072
|
+
"src/cli/validations/studio.ts"() {
|
|
51073
|
+
init_lib();
|
|
51074
|
+
init_pg();
|
|
51075
|
+
init_mysql();
|
|
51076
|
+
init_sqliteUtils();
|
|
51077
|
+
init_utils();
|
|
51078
|
+
init_outputs();
|
|
51079
|
+
init_pg();
|
|
51080
|
+
init_mysql();
|
|
51081
|
+
init_sqlite();
|
|
51082
|
+
studioConfigSchema = intersectionType(
|
|
51083
|
+
objectType({
|
|
51084
|
+
schema: unionType([stringType(), stringType().array()])
|
|
51085
|
+
}),
|
|
51086
|
+
unionType([mysqlConnectionConfig, pgConnectionConfig, sqliteConnectionSchema])
|
|
51087
|
+
);
|
|
51088
|
+
printDriverIssues = (options) => {
|
|
51089
|
+
if (options.driver === "pg") {
|
|
51090
|
+
printConfigConnectionIssues2(options);
|
|
51091
|
+
} else if (options.driver === "mysql") {
|
|
51092
|
+
printConfigConnectionIssues3(options);
|
|
51093
|
+
} else if (["libsql", "turso", "better-sqlite"].includes(options.driver)) {
|
|
51094
|
+
printConfigConnectionIssues(options);
|
|
51095
|
+
} else {
|
|
51096
|
+
if (typeof options.driver === "undefined") {
|
|
51097
|
+
console.log(outputs.studio.noDriver());
|
|
51098
|
+
} else {
|
|
51099
|
+
console.log(outputs.studio.drivers(options.driver));
|
|
51100
|
+
}
|
|
51101
|
+
if (typeof options.dbCredentials === "undefined") {
|
|
51102
|
+
console.log(outputs.studio.noCredentials());
|
|
51103
|
+
}
|
|
51104
|
+
}
|
|
51105
|
+
};
|
|
51106
|
+
validateStudio = async (options) => {
|
|
51107
|
+
const drizzleConfig = await readDrizzleConfig(
|
|
51108
|
+
options.config
|
|
51109
|
+
);
|
|
51110
|
+
const configRes = studioConfigSchema.safeParse(drizzleConfig);
|
|
51111
|
+
if (!configRes.success) {
|
|
51112
|
+
if (typeof drizzleConfig.schema === "undefined") {
|
|
51113
|
+
console.log(outputs.common.schemaConfig("studio"));
|
|
51114
|
+
process.exit(1);
|
|
51115
|
+
}
|
|
51116
|
+
printDriverIssues(drizzleConfig);
|
|
51117
|
+
process.exit(1);
|
|
51118
|
+
}
|
|
51119
|
+
return configRes.data;
|
|
51120
|
+
};
|
|
51121
|
+
}
|
|
51122
|
+
});
|
|
51123
|
+
|
|
51124
|
+
// src/serializer/studioUtils.ts
|
|
51125
|
+
var studioUtils_exports = {};
|
|
51126
|
+
__export(studioUtils_exports, {
|
|
51127
|
+
drizzleDb: () => drizzleDb,
|
|
51128
|
+
prepareModels: () => prepareModels
|
|
51129
|
+
});
|
|
51130
|
+
var import_drizzle_orm10, import_mysql_core4, import_pg_core4, import_sqlite_core3, prepareModels, drizzleDb;
|
|
51131
|
+
var init_studioUtils = __esm({
|
|
51132
|
+
"src/serializer/studioUtils.ts"() {
|
|
51133
|
+
import_drizzle_orm10 = require("drizzle-orm");
|
|
51134
|
+
import_mysql_core4 = require("drizzle-orm/mysql-core");
|
|
51135
|
+
import_pg_core4 = require("drizzle-orm/pg-core");
|
|
51136
|
+
import_sqlite_core3 = require("drizzle-orm/sqlite-core");
|
|
51137
|
+
init_utils();
|
|
51138
|
+
init_serializer();
|
|
51139
|
+
prepareModels = async (path3) => {
|
|
51140
|
+
const imports = prepareFilenames(path3);
|
|
51141
|
+
const sqliteSchema2 = {};
|
|
51142
|
+
const pgSchema3 = {};
|
|
51143
|
+
const mysqlSchema3 = {};
|
|
51144
|
+
const { unregister } = safeRegister();
|
|
51145
|
+
for (let i = 0; i < imports.length; i++) {
|
|
51146
|
+
const it = imports[i];
|
|
51147
|
+
const i0 = require(`${it}`);
|
|
51148
|
+
const i0values = Object.entries(i0);
|
|
51149
|
+
i0values.forEach(([k, t]) => {
|
|
51150
|
+
if ((0, import_drizzle_orm10.is)(t, import_pg_core4.PgTable)) {
|
|
51151
|
+
pgSchema3[k] = t;
|
|
51152
|
+
}
|
|
51153
|
+
if ((0, import_drizzle_orm10.is)(t, import_mysql_core4.MySqlTable)) {
|
|
51154
|
+
mysqlSchema3[k] = t;
|
|
51155
|
+
}
|
|
51156
|
+
if ((0, import_drizzle_orm10.is)(t, import_sqlite_core3.SQLiteTable)) {
|
|
51157
|
+
sqliteSchema2[k] = t;
|
|
51158
|
+
}
|
|
51159
|
+
if ((0, import_drizzle_orm10.is)(t, import_drizzle_orm10.Relations)) {
|
|
51160
|
+
sqliteSchema2[k] = t;
|
|
51161
|
+
pgSchema3[k] = t;
|
|
51162
|
+
mysqlSchema3[k] = t;
|
|
51163
|
+
}
|
|
51164
|
+
});
|
|
51165
|
+
}
|
|
51166
|
+
unregister();
|
|
51167
|
+
return { pgSchema: pgSchema3, mysqlSchema: mysqlSchema3, sqliteSchema: sqliteSchema2 };
|
|
51168
|
+
};
|
|
51169
|
+
drizzleDb = async (drizzleConfig, models, logger) => {
|
|
51170
|
+
if (drizzleConfig.driver === "pg") {
|
|
51171
|
+
const { drizzle } = await import("drizzle-orm/node-postgres");
|
|
51172
|
+
const { Pool: Pool2, types } = await Promise.resolve().then(() => __toESM(require_lib5()));
|
|
51173
|
+
const client = new Pool2({ ...drizzleConfig.dbCredentials, max: 1 });
|
|
51174
|
+
types.setTypeParser(types.builtins.INTERVAL, (val) => val);
|
|
51175
|
+
return {
|
|
51176
|
+
db: drizzle(client, { logger }),
|
|
51177
|
+
type: "pg",
|
|
51178
|
+
schema: models.pgSchema
|
|
51179
|
+
};
|
|
51180
|
+
} else if (drizzleConfig.driver === "mysql2") {
|
|
51181
|
+
const { drizzle } = await import("drizzle-orm/mysql2");
|
|
51182
|
+
const { createPool } = await Promise.resolve().then(() => __toESM(require_promise()));
|
|
51183
|
+
const client = createPool({
|
|
51184
|
+
uri: drizzleConfig.dbCredentials.type === "url" ? drizzleConfig.dbCredentials.connectionString : void 0,
|
|
51185
|
+
host: drizzleConfig.dbCredentials.type === "params" ? drizzleConfig.dbCredentials.host : void 0,
|
|
51186
|
+
port: drizzleConfig.dbCredentials.type === "params" ? drizzleConfig.dbCredentials.port : void 0,
|
|
51187
|
+
user: drizzleConfig.dbCredentials.type === "params" ? drizzleConfig.dbCredentials.user : void 0,
|
|
51188
|
+
database: drizzleConfig.dbCredentials.type === "params" ? drizzleConfig.dbCredentials.database : void 0,
|
|
51189
|
+
password: drizzleConfig.dbCredentials.type === "params" ? drizzleConfig.dbCredentials.password : void 0,
|
|
51190
|
+
connectionLimit: 1
|
|
51191
|
+
});
|
|
51192
|
+
return {
|
|
51193
|
+
db: drizzle(client, { logger }),
|
|
51194
|
+
type: "mysql",
|
|
51195
|
+
schema: models.mysqlSchema
|
|
51196
|
+
};
|
|
51197
|
+
} else {
|
|
51198
|
+
if (drizzleConfig.driver === "better-sqlite") {
|
|
51199
|
+
const { drizzle } = await import("drizzle-orm/better-sqlite3");
|
|
51200
|
+
const Database2 = await import("better-sqlite3");
|
|
51201
|
+
const client = new Database2.default(drizzleConfig.dbCredentials.url);
|
|
51202
|
+
return {
|
|
51203
|
+
db: drizzle(client, { logger }),
|
|
51204
|
+
type: "sqlite",
|
|
51205
|
+
schema: models.sqliteSchema
|
|
51206
|
+
};
|
|
51207
|
+
} else {
|
|
51208
|
+
const { drizzle } = await import("drizzle-orm/libsql");
|
|
51209
|
+
const { createClient: createClient2 } = await Promise.resolve().then(() => (init_lib_esm2(), lib_esm_exports2));
|
|
51210
|
+
const client = createClient2({ ...drizzleConfig.dbCredentials });
|
|
51211
|
+
return {
|
|
51212
|
+
db: drizzle(client, { logger }),
|
|
51213
|
+
type: "sqlite",
|
|
51214
|
+
schema: models.sqliteSchema
|
|
51215
|
+
};
|
|
51216
|
+
}
|
|
51217
|
+
}
|
|
51218
|
+
};
|
|
51219
|
+
}
|
|
51220
|
+
});
|
|
51221
|
+
|
|
50442
51222
|
// src/cli/index.ts
|
|
50443
51223
|
var cli_exports = {};
|
|
50444
51224
|
__export(cli_exports, {
|
|
@@ -50543,7 +51323,7 @@ init_source();
|
|
|
50543
51323
|
// package.json
|
|
50544
51324
|
var package_default = {
|
|
50545
51325
|
name: "drizzle-kit",
|
|
50546
|
-
version: "0.19.
|
|
51326
|
+
version: "0.19.3",
|
|
50547
51327
|
repository: "https://github.com/drizzle-team/drizzle-kit-mirror",
|
|
50548
51328
|
author: "Drizzle Team",
|
|
50549
51329
|
license: "MIT",
|
|
@@ -50580,7 +51360,8 @@ var package_default = {
|
|
|
50580
51360
|
"build:dev": "rm -rf ./dist && tsx build.dev.ts && tsc -p tsconfig.cli-types.json && chmod +x ./dist/index.cjs",
|
|
50581
51361
|
pack: "build && package",
|
|
50582
51362
|
tsc: "tsc -p tsconfig.build.json",
|
|
50583
|
-
pub: "cp package.json readme.md dist/ && cd dist && npm publish"
|
|
51363
|
+
pub: "cp package.json readme.md dist/ && cd dist && npm publish",
|
|
51364
|
+
studio: "./dist/index.cjs studio --verbose"
|
|
50584
51365
|
},
|
|
50585
51366
|
ava: {
|
|
50586
51367
|
files: [
|
|
@@ -50594,6 +51375,7 @@ var package_default = {
|
|
|
50594
51375
|
]
|
|
50595
51376
|
},
|
|
50596
51377
|
dependencies: {
|
|
51378
|
+
"@drizzle-team/studio": "^0.0.1",
|
|
50597
51379
|
"@esbuild-kit/esm-loader": "^2.5.5",
|
|
50598
51380
|
camelcase: "^7.0.1",
|
|
50599
51381
|
chalk: "^5.2.0",
|
|
@@ -50620,13 +51402,14 @@ var package_default = {
|
|
|
50620
51402
|
"better-sqlite3": "^8.4.0",
|
|
50621
51403
|
dockerode: "^3.3.4",
|
|
50622
51404
|
dotenv: "^16.0.3",
|
|
50623
|
-
"drizzle-orm": "0.27.0
|
|
51405
|
+
"drizzle-orm": "0.27.0",
|
|
50624
51406
|
eslint: "^8.29.0",
|
|
50625
51407
|
"eslint-config-prettier": "^8.5.0",
|
|
50626
51408
|
"eslint-plugin-prettier": "^4.2.1",
|
|
50627
51409
|
"get-port": "^6.1.2",
|
|
50628
51410
|
mysql2: "2.3.3",
|
|
50629
51411
|
pg: "^8.8.0",
|
|
51412
|
+
postgres: "^3.3.5",
|
|
50630
51413
|
prettier: "^2.8.1",
|
|
50631
51414
|
tsx: "^3.12.1",
|
|
50632
51415
|
typescript: "^4.9.4",
|
|
@@ -51148,532 +51931,12 @@ var logSuggestionsAndReturn2 = async ({
|
|
|
51148
51931
|
// src/cli/index.ts
|
|
51149
51932
|
init_serializer();
|
|
51150
51933
|
init_sqliteSchema();
|
|
51151
|
-
|
|
51152
|
-
|
|
51153
|
-
|
|
51154
|
-
|
|
51155
|
-
|
|
51156
|
-
|
|
51157
|
-
init_utils();
|
|
51158
|
-
var sqliteConnectionSchema = unionType([
|
|
51159
|
-
objectType({
|
|
51160
|
-
driver: literalType("turso"),
|
|
51161
|
-
dbCredentials: objectType({
|
|
51162
|
-
url: stringType(),
|
|
51163
|
-
authToken: stringType().optional()
|
|
51164
|
-
})
|
|
51165
|
-
}),
|
|
51166
|
-
objectType({
|
|
51167
|
-
driver: literalType("libsql"),
|
|
51168
|
-
dbCredentials: objectType({
|
|
51169
|
-
url: stringType()
|
|
51170
|
-
})
|
|
51171
|
-
}),
|
|
51172
|
-
objectType({
|
|
51173
|
-
driver: literalType("better-sqlite"),
|
|
51174
|
-
dbCredentials: objectType({
|
|
51175
|
-
url: stringType()
|
|
51176
|
-
})
|
|
51177
|
-
})
|
|
51178
|
-
]);
|
|
51179
|
-
var sqliteCliConfigSchema = intersectionType(
|
|
51180
|
-
configIntrospectSchema,
|
|
51181
|
-
sqliteConnectionSchema
|
|
51182
|
-
);
|
|
51183
|
-
|
|
51184
|
-
// src/cli/validations/sqlite.ts
|
|
51185
|
-
init_utils();
|
|
51186
|
-
|
|
51187
|
-
// src/cli/validations/outputs.ts
|
|
51188
|
-
init_source();
|
|
51189
|
-
var withStyle = {
|
|
51190
|
-
error: (str) => `${source_default.red(`${source_default.white.bgRed(" Invalid input ")} ${str}`)}`,
|
|
51191
|
-
warning: (str) => `${source_default.white.bgGray(" Warning ")} ${str}`
|
|
51192
|
-
};
|
|
51193
|
-
var outputs = {
|
|
51194
|
-
common: {
|
|
51195
|
-
ambiguousParams: (command) => withStyle.error(
|
|
51196
|
-
`You can't use both --config and other cli options for ${command} command`
|
|
51197
|
-
),
|
|
51198
|
-
schema: (command) => withStyle.error(`"--schema" is a required field for ${command} command`)
|
|
51199
|
-
},
|
|
51200
|
-
postgres: {
|
|
51201
|
-
connection: {
|
|
51202
|
-
driver: () => withStyle.error(
|
|
51203
|
-
`Only "pg" is available options for "--driver"`
|
|
51204
|
-
),
|
|
51205
|
-
required: () => withStyle.error(
|
|
51206
|
-
`Either "connectionString" or "host", "database" are required for database connection`
|
|
51207
|
-
)
|
|
51208
|
-
}
|
|
51209
|
-
},
|
|
51210
|
-
mysql: {
|
|
51211
|
-
connection: {
|
|
51212
|
-
driver: () => withStyle.error(
|
|
51213
|
-
`Only "mysql2" is available options for "--driver"`
|
|
51214
|
-
),
|
|
51215
|
-
required: () => withStyle.error(
|
|
51216
|
-
`Either "connectionString" or "host", "database" are required for database connection`
|
|
51217
|
-
)
|
|
51218
|
-
}
|
|
51219
|
-
},
|
|
51220
|
-
sqlite: {
|
|
51221
|
-
connection: {
|
|
51222
|
-
driver: () => withStyle.error(`Either "turso", "libsql", "better-sqlite" are available options for "--driver"`),
|
|
51223
|
-
url: (driver) => withStyle.error(`"--url" is a required option for driver "${driver}"`),
|
|
51224
|
-
authToken: (driver) => withStyle.error(
|
|
51225
|
-
`"--auth-token" is a required option for driver "${driver}"`
|
|
51226
|
-
)
|
|
51227
|
-
},
|
|
51228
|
-
introspect: {},
|
|
51229
|
-
push: {}
|
|
51230
|
-
}
|
|
51231
|
-
};
|
|
51232
|
-
|
|
51233
|
-
// src/cli/validations/common.ts
|
|
51234
|
-
var checkCollisions = (options, command, inputWhitelist = []) => {
|
|
51235
|
-
const { config, ...rest } = options;
|
|
51236
|
-
let atLeastOneParam = false;
|
|
51237
|
-
for (const key of Object.keys(rest)) {
|
|
51238
|
-
if (inputWhitelist.includes(key))
|
|
51239
|
-
continue;
|
|
51240
|
-
atLeastOneParam = true;
|
|
51241
|
-
}
|
|
51242
|
-
if (!atLeastOneParam && typeof config !== "undefined") {
|
|
51243
|
-
return {
|
|
51244
|
-
success: true,
|
|
51245
|
-
action: "config"
|
|
51246
|
-
};
|
|
51247
|
-
}
|
|
51248
|
-
if (typeof config === "undefined" && atLeastOneParam) {
|
|
51249
|
-
return {
|
|
51250
|
-
success: true,
|
|
51251
|
-
action: "cli"
|
|
51252
|
-
};
|
|
51253
|
-
}
|
|
51254
|
-
if (typeof config === "undefined" && !atLeastOneParam) {
|
|
51255
|
-
return {
|
|
51256
|
-
success: true,
|
|
51257
|
-
action: "config"
|
|
51258
|
-
};
|
|
51259
|
-
}
|
|
51260
|
-
return {
|
|
51261
|
-
success: false,
|
|
51262
|
-
message: outputs.common.ambiguousParams(command),
|
|
51263
|
-
action: "error"
|
|
51264
|
-
};
|
|
51265
|
-
};
|
|
51266
|
-
|
|
51267
|
-
// src/cli/validations/sqlite.ts
|
|
51268
|
-
var sqliteConnectionCli = unionType([
|
|
51269
|
-
objectType({
|
|
51270
|
-
driver: literalType("turso"),
|
|
51271
|
-
url: stringType(),
|
|
51272
|
-
authToken: stringType()
|
|
51273
|
-
}),
|
|
51274
|
-
objectType({
|
|
51275
|
-
driver: literalType("better-sqlite"),
|
|
51276
|
-
url: stringType()
|
|
51277
|
-
}),
|
|
51278
|
-
objectType({
|
|
51279
|
-
driver: literalType("libsql"),
|
|
51280
|
-
url: stringType()
|
|
51281
|
-
})
|
|
51282
|
-
]);
|
|
51283
|
-
var sqliteCliIntrospectParams = intersectionType(
|
|
51284
|
-
configIntrospectCliSchema,
|
|
51285
|
-
sqliteConnectionCli
|
|
51286
|
-
);
|
|
51287
|
-
var sqliteCliPushParams = intersectionType(
|
|
51288
|
-
configPushSchema,
|
|
51289
|
-
sqliteConnectionCli
|
|
51290
|
-
);
|
|
51291
|
-
var sqliteConfigPushParams = intersectionType(
|
|
51292
|
-
configPushSchema,
|
|
51293
|
-
sqliteConnectionSchema
|
|
51294
|
-
);
|
|
51295
|
-
var printCliConnectionIssues = (options) => {
|
|
51296
|
-
if (options.driver === "turso") {
|
|
51297
|
-
if (typeof options.url === "undefined") {
|
|
51298
|
-
console.log(outputs.sqlite.connection.url("turso"));
|
|
51299
|
-
}
|
|
51300
|
-
if (typeof options.authToken === "undefined") {
|
|
51301
|
-
console.log(outputs.sqlite.connection.authToken("turso"));
|
|
51302
|
-
}
|
|
51303
|
-
} else if (options.driver === "libsql") {
|
|
51304
|
-
if (typeof options.url === "undefined") {
|
|
51305
|
-
console.log(outputs.sqlite.connection.url("libsql"));
|
|
51306
|
-
}
|
|
51307
|
-
} else if (options.driver === "better-sqlite") {
|
|
51308
|
-
if (typeof options.url === "undefined") {
|
|
51309
|
-
console.log(outputs.sqlite.connection.url("better-sqlite"));
|
|
51310
|
-
}
|
|
51311
|
-
} else {
|
|
51312
|
-
console.log(outputs.sqlite.connection.driver());
|
|
51313
|
-
}
|
|
51314
|
-
};
|
|
51315
|
-
var printConfigConnectionIssues = (options) => {
|
|
51316
|
-
var _a, _b, _c;
|
|
51317
|
-
if (options.driver === "turso") {
|
|
51318
|
-
if (typeof options.url === "undefined") {
|
|
51319
|
-
console.log(outputs.sqlite.connection.url("turso"));
|
|
51320
|
-
}
|
|
51321
|
-
if (typeof ((_a = options.dbCredentials) == null ? void 0 : _a.authToken) === "undefined") {
|
|
51322
|
-
console.log(outputs.sqlite.connection.authToken("turso"));
|
|
51323
|
-
}
|
|
51324
|
-
} else if (options.driver === "libsql") {
|
|
51325
|
-
if (typeof ((_b = options.dbCredentials) == null ? void 0 : _b.url) === "undefined") {
|
|
51326
|
-
console.log(outputs.sqlite.connection.url("libsql"));
|
|
51327
|
-
}
|
|
51328
|
-
} else if (options.driver === "better-sqlite") {
|
|
51329
|
-
if (typeof ((_c = options.dbCredentials) == null ? void 0 : _c.url) === "undefined") {
|
|
51330
|
-
console.log(outputs.sqlite.connection.url("better-sqlite"));
|
|
51331
|
-
}
|
|
51332
|
-
} else {
|
|
51333
|
-
console.log(outputs.sqlite.connection.driver());
|
|
51334
|
-
}
|
|
51335
|
-
};
|
|
51336
|
-
var validateIntrospect = async (options) => {
|
|
51337
|
-
const collisionRes = checkCollisions(options, "introspect:sqlite");
|
|
51338
|
-
if (!collisionRes.success) {
|
|
51339
|
-
console.log(collisionRes.message);
|
|
51340
|
-
process.exit(1);
|
|
51341
|
-
}
|
|
51342
|
-
if (collisionRes.action === "config") {
|
|
51343
|
-
const drizzleConfig = await readDrizzleConfig(options.config);
|
|
51344
|
-
const configRes = sqliteCliConfigSchema.safeParse(drizzleConfig);
|
|
51345
|
-
if (!configRes.success) {
|
|
51346
|
-
printConfigConnectionIssues(drizzleConfig);
|
|
51347
|
-
process.exit(1);
|
|
51348
|
-
}
|
|
51349
|
-
return configRes.data;
|
|
51350
|
-
}
|
|
51351
|
-
const cliRes = sqliteCliIntrospectParams.safeParse(options);
|
|
51352
|
-
if (!cliRes.success) {
|
|
51353
|
-
printCliConnectionIssues(options);
|
|
51354
|
-
process.exit(1);
|
|
51355
|
-
}
|
|
51356
|
-
if (cliRes.data.driver === "turso") {
|
|
51357
|
-
const { authToken, url: url2, introspectCasing: introspectCasing3, ...rest2 } = cliRes.data;
|
|
51358
|
-
return {
|
|
51359
|
-
...rest2,
|
|
51360
|
-
dbCredentials: { url: url2, authToken },
|
|
51361
|
-
introspect: { casing: introspectCasing3 }
|
|
51362
|
-
};
|
|
51363
|
-
}
|
|
51364
|
-
if (cliRes.data.driver === "libsql") {
|
|
51365
|
-
const { url: url2, introspectCasing: introspectCasing3, ...rest2 } = cliRes.data;
|
|
51366
|
-
return {
|
|
51367
|
-
...rest2,
|
|
51368
|
-
dbCredentials: { url: url2 },
|
|
51369
|
-
introspect: { casing: introspectCasing3 }
|
|
51370
|
-
};
|
|
51371
|
-
}
|
|
51372
|
-
const { url, introspectCasing: introspectCasing2, ...rest } = cliRes.data;
|
|
51373
|
-
return {
|
|
51374
|
-
...rest,
|
|
51375
|
-
dbCredentials: { url },
|
|
51376
|
-
introspect: { casing: introspectCasing2 }
|
|
51377
|
-
};
|
|
51378
|
-
};
|
|
51379
|
-
var validatePush = async (options) => {
|
|
51380
|
-
const collisionRes = checkCollisions(options, "push:sqlite");
|
|
51381
|
-
if (!collisionRes.success) {
|
|
51382
|
-
console.log(collisionRes.message);
|
|
51383
|
-
console.log();
|
|
51384
|
-
process.exit(1);
|
|
51385
|
-
}
|
|
51386
|
-
if (collisionRes.action === "config") {
|
|
51387
|
-
const drizzleConfig = await readDrizzleConfig(options.config);
|
|
51388
|
-
const configRes = sqliteConfigPushParams.safeParse(drizzleConfig);
|
|
51389
|
-
if (!configRes.success) {
|
|
51390
|
-
printConfigConnectionIssues(drizzleConfig);
|
|
51391
|
-
process.exit(1);
|
|
51392
|
-
}
|
|
51393
|
-
return configRes.data;
|
|
51394
|
-
}
|
|
51395
|
-
const cliRes = sqliteCliPushParams.safeParse(options);
|
|
51396
|
-
if (!cliRes.success) {
|
|
51397
|
-
if (typeof options.schema === "undefined") {
|
|
51398
|
-
console.log(outputs.common.schema("push:sqlite"));
|
|
51399
|
-
}
|
|
51400
|
-
printCliConnectionIssues(options);
|
|
51401
|
-
process.exit(1);
|
|
51402
|
-
}
|
|
51403
|
-
if (cliRes.data.driver === "turso") {
|
|
51404
|
-
const { authToken, url: url2, ...rest2 } = cliRes.data;
|
|
51405
|
-
return { ...rest2, dbCredentials: { url: url2, authToken } };
|
|
51406
|
-
}
|
|
51407
|
-
const { url, ...rest } = cliRes.data;
|
|
51408
|
-
return { ...rest, dbCredentials: { url } };
|
|
51409
|
-
};
|
|
51410
|
-
|
|
51411
|
-
// src/cli/validations/pg.ts
|
|
51412
|
-
init_lib();
|
|
51413
|
-
init_utils();
|
|
51414
|
-
var pgConnectionCli = unionType([
|
|
51415
|
-
objectType({
|
|
51416
|
-
driver: literalType("pg"),
|
|
51417
|
-
host: stringType(),
|
|
51418
|
-
port: coerce.number().optional(),
|
|
51419
|
-
user: stringType().default("postgres"),
|
|
51420
|
-
password: stringType().optional(),
|
|
51421
|
-
database: stringType(),
|
|
51422
|
-
ssl: coerce.boolean().optional(),
|
|
51423
|
-
type: literalType("params").default("params")
|
|
51424
|
-
}),
|
|
51425
|
-
objectType({
|
|
51426
|
-
driver: literalType("pg"),
|
|
51427
|
-
connectionString: stringType(),
|
|
51428
|
-
type: literalType("url").default("url")
|
|
51429
|
-
})
|
|
51430
|
-
]);
|
|
51431
|
-
var pgConnectionConfig = unionType([
|
|
51432
|
-
objectType({
|
|
51433
|
-
driver: literalType("pg"),
|
|
51434
|
-
dbCredentials: objectType({
|
|
51435
|
-
host: stringType(),
|
|
51436
|
-
port: coerce.number().optional(),
|
|
51437
|
-
user: stringType().default("postgres"),
|
|
51438
|
-
password: stringType().optional(),
|
|
51439
|
-
database: stringType(),
|
|
51440
|
-
ssl: coerce.boolean().optional()
|
|
51441
|
-
})
|
|
51442
|
-
}),
|
|
51443
|
-
objectType({
|
|
51444
|
-
driver: literalType("pg"),
|
|
51445
|
-
dbCredentials: objectType({
|
|
51446
|
-
connectionString: stringType()
|
|
51447
|
-
})
|
|
51448
|
-
})
|
|
51449
|
-
]);
|
|
51450
|
-
var pgConfigIntrospectSchema = intersectionType(
|
|
51451
|
-
configIntrospectSchema,
|
|
51452
|
-
pgConnectionConfig
|
|
51453
|
-
);
|
|
51454
|
-
var pgCliIntrospectParams = intersectionType(
|
|
51455
|
-
configIntrospectCliSchema,
|
|
51456
|
-
pgConnectionCli
|
|
51457
|
-
);
|
|
51458
|
-
var printCliConnectionIssues2 = (options) => {
|
|
51459
|
-
if (options.driver === "pg") {
|
|
51460
|
-
if (typeof options.connectionString === "undefined" && (typeof options.host === "undefined" || typeof options.database === "undefined")) {
|
|
51461
|
-
console.log(outputs.postgres.connection.required());
|
|
51462
|
-
}
|
|
51463
|
-
} else {
|
|
51464
|
-
console.log(outputs.postgres.connection.driver());
|
|
51465
|
-
}
|
|
51466
|
-
};
|
|
51467
|
-
var printConfigConnectionIssues2 = (options) => {
|
|
51468
|
-
if (options.driver === "pg") {
|
|
51469
|
-
if (typeof options.dbCredentials.connectionString === "undefined" && (typeof options.dbCredentials.host === "undefined" || typeof options.dbCredentials.database === "undefined")) {
|
|
51470
|
-
console.log(outputs.postgres.connection.required());
|
|
51471
|
-
}
|
|
51472
|
-
} else {
|
|
51473
|
-
console.log(outputs.postgres.connection.driver());
|
|
51474
|
-
}
|
|
51475
|
-
};
|
|
51476
|
-
var validatePgIntrospect = async (options) => {
|
|
51477
|
-
const collisionRes = checkCollisions(options, "introspect:pg");
|
|
51478
|
-
if (!collisionRes.success) {
|
|
51479
|
-
console.log(collisionRes.message);
|
|
51480
|
-
process.exit(1);
|
|
51481
|
-
}
|
|
51482
|
-
if (collisionRes.action === "config") {
|
|
51483
|
-
const drizzleConfig = await readDrizzleConfig(options.config);
|
|
51484
|
-
const configRes = pgConfigIntrospectSchema.safeParse(drizzleConfig);
|
|
51485
|
-
if (!configRes.success) {
|
|
51486
|
-
printConfigConnectionIssues2(drizzleConfig);
|
|
51487
|
-
process.exit(1);
|
|
51488
|
-
}
|
|
51489
|
-
return configRes.data;
|
|
51490
|
-
}
|
|
51491
|
-
const cliRes = pgCliIntrospectParams.safeParse(options);
|
|
51492
|
-
if (!cliRes.success) {
|
|
51493
|
-
printCliConnectionIssues2(options);
|
|
51494
|
-
process.exit(1);
|
|
51495
|
-
}
|
|
51496
|
-
if (cliRes.data.type === "url") {
|
|
51497
|
-
const { connectionString, introspectCasing: introspectCasing3, ...rest2 } = cliRes.data;
|
|
51498
|
-
return {
|
|
51499
|
-
...rest2,
|
|
51500
|
-
dbCredentials: { connectionString },
|
|
51501
|
-
introspect: { casing: introspectCasing3 }
|
|
51502
|
-
};
|
|
51503
|
-
}
|
|
51504
|
-
const {
|
|
51505
|
-
host,
|
|
51506
|
-
password,
|
|
51507
|
-
port,
|
|
51508
|
-
database,
|
|
51509
|
-
ssl,
|
|
51510
|
-
user,
|
|
51511
|
-
introspectCasing: introspectCasing2,
|
|
51512
|
-
...rest
|
|
51513
|
-
} = cliRes.data;
|
|
51514
|
-
return {
|
|
51515
|
-
...rest,
|
|
51516
|
-
dbCredentials: { host, password, port, database, ssl, user },
|
|
51517
|
-
introspect: { casing: introspectCasing2 }
|
|
51518
|
-
};
|
|
51519
|
-
};
|
|
51520
|
-
|
|
51521
|
-
// src/cli/validations/mysql.ts
|
|
51522
|
-
init_lib();
|
|
51523
|
-
init_utils();
|
|
51524
|
-
var mysqlConnectionCli = unionType([
|
|
51525
|
-
objectType({
|
|
51526
|
-
driver: literalType("mysql2"),
|
|
51527
|
-
host: stringType(),
|
|
51528
|
-
port: coerce.number().optional(),
|
|
51529
|
-
user: stringType().default("mysql"),
|
|
51530
|
-
password: stringType().optional(),
|
|
51531
|
-
database: stringType(),
|
|
51532
|
-
type: literalType("params").default("params")
|
|
51533
|
-
}),
|
|
51534
|
-
objectType({
|
|
51535
|
-
driver: literalType("mysql2"),
|
|
51536
|
-
connectionString: stringType(),
|
|
51537
|
-
type: literalType("url").default("url")
|
|
51538
|
-
})
|
|
51539
|
-
]);
|
|
51540
|
-
var mysqlConnectionConfig = unionType([
|
|
51541
|
-
objectType({
|
|
51542
|
-
driver: literalType("mysql2"),
|
|
51543
|
-
dbCredentials: objectType({
|
|
51544
|
-
host: stringType(),
|
|
51545
|
-
port: coerce.number().optional(),
|
|
51546
|
-
user: stringType().default("mysql"),
|
|
51547
|
-
password: stringType().optional(),
|
|
51548
|
-
database: stringType(),
|
|
51549
|
-
type: literalType("params").default("params")
|
|
51550
|
-
})
|
|
51551
|
-
}),
|
|
51552
|
-
objectType({
|
|
51553
|
-
driver: literalType("mysql2"),
|
|
51554
|
-
dbCredentials: objectType({
|
|
51555
|
-
connectionString: stringType(),
|
|
51556
|
-
type: literalType("url").default("url")
|
|
51557
|
-
})
|
|
51558
|
-
})
|
|
51559
|
-
]);
|
|
51560
|
-
var mysqlConfigIntrospectSchema = intersectionType(
|
|
51561
|
-
configIntrospectSchema,
|
|
51562
|
-
mysqlConnectionConfig
|
|
51563
|
-
);
|
|
51564
|
-
var mysqlCliIntrospectParams = intersectionType(
|
|
51565
|
-
configIntrospectCliSchema,
|
|
51566
|
-
mysqlConnectionCli
|
|
51567
|
-
);
|
|
51568
|
-
var mysqlCliPushParams = intersectionType(
|
|
51569
|
-
configPushSchema,
|
|
51570
|
-
mysqlConnectionCli
|
|
51571
|
-
);
|
|
51572
|
-
var mysqlConfigPushParams = intersectionType(
|
|
51573
|
-
configPushSchema,
|
|
51574
|
-
mysqlConnectionConfig
|
|
51575
|
-
);
|
|
51576
|
-
var printCliConnectionIssues3 = (options) => {
|
|
51577
|
-
if (options.driver === "mysql2") {
|
|
51578
|
-
if (typeof options.connectionString === "undefined" && (typeof options.host === "undefined" || typeof options.database === "undefined")) {
|
|
51579
|
-
console.log(outputs.mysql.connection.required());
|
|
51580
|
-
}
|
|
51581
|
-
} else {
|
|
51582
|
-
console.log(outputs.mysql.connection.driver());
|
|
51583
|
-
}
|
|
51584
|
-
};
|
|
51585
|
-
var printConfigConnectionIssues3 = (options) => {
|
|
51586
|
-
if (options.driver === "mysql2") {
|
|
51587
|
-
if (typeof options.dbCredentials.connectionString === "undefined" && (typeof options.dbCredentials.host === "undefined" || typeof options.dbCredentials.database === "undefined")) {
|
|
51588
|
-
console.log(outputs.mysql.connection.required());
|
|
51589
|
-
}
|
|
51590
|
-
} else {
|
|
51591
|
-
console.log(outputs.mysql.connection.driver());
|
|
51592
|
-
}
|
|
51593
|
-
};
|
|
51594
|
-
var validateMySqlIntrospect = async (options) => {
|
|
51595
|
-
const collisionRes = checkCollisions(options, "introspect:mysql");
|
|
51596
|
-
if (!collisionRes.success) {
|
|
51597
|
-
console.log(collisionRes.message);
|
|
51598
|
-
process.exit(1);
|
|
51599
|
-
}
|
|
51600
|
-
if (collisionRes.action === "config") {
|
|
51601
|
-
const drizzleConfig = await readDrizzleConfig(options.config);
|
|
51602
|
-
const configRes = mysqlConfigIntrospectSchema.safeParse(drizzleConfig);
|
|
51603
|
-
if (!configRes.success) {
|
|
51604
|
-
printConfigConnectionIssues3(drizzleConfig);
|
|
51605
|
-
process.exit(1);
|
|
51606
|
-
}
|
|
51607
|
-
return configRes.data;
|
|
51608
|
-
}
|
|
51609
|
-
const cliRes = mysqlCliIntrospectParams.safeParse(options);
|
|
51610
|
-
if (!cliRes.success) {
|
|
51611
|
-
printCliConnectionIssues3(options);
|
|
51612
|
-
process.exit(1);
|
|
51613
|
-
}
|
|
51614
|
-
if (cliRes.data.type === "url") {
|
|
51615
|
-
const { connectionString, introspectCasing: introspectCasing3, type: type2, ...rest2 } = cliRes.data;
|
|
51616
|
-
return {
|
|
51617
|
-
...rest2,
|
|
51618
|
-
dbCredentials: { connectionString, type: type2 },
|
|
51619
|
-
introspect: { casing: introspectCasing3 }
|
|
51620
|
-
};
|
|
51621
|
-
}
|
|
51622
|
-
const {
|
|
51623
|
-
host,
|
|
51624
|
-
password,
|
|
51625
|
-
port,
|
|
51626
|
-
database,
|
|
51627
|
-
user,
|
|
51628
|
-
type,
|
|
51629
|
-
introspectCasing: introspectCasing2,
|
|
51630
|
-
...rest
|
|
51631
|
-
} = cliRes.data;
|
|
51632
|
-
return {
|
|
51633
|
-
...rest,
|
|
51634
|
-
dbCredentials: { host, password, port, database, user, type },
|
|
51635
|
-
introspect: { casing: introspectCasing2 }
|
|
51636
|
-
};
|
|
51637
|
-
};
|
|
51638
|
-
var validateMySqlPush = async (options) => {
|
|
51639
|
-
const collisionRes = checkCollisions(options, "push:mysql");
|
|
51640
|
-
if (!collisionRes.success) {
|
|
51641
|
-
console.log(collisionRes.message);
|
|
51642
|
-
console.log();
|
|
51643
|
-
process.exit(1);
|
|
51644
|
-
}
|
|
51645
|
-
if (collisionRes.action === "config") {
|
|
51646
|
-
const drizzleConfig = await readDrizzleConfig(options.config);
|
|
51647
|
-
const configRes = mysqlConfigPushParams.safeParse(drizzleConfig);
|
|
51648
|
-
if (!configRes.success) {
|
|
51649
|
-
printConfigConnectionIssues3(drizzleConfig);
|
|
51650
|
-
process.exit(1);
|
|
51651
|
-
}
|
|
51652
|
-
return configRes.data;
|
|
51653
|
-
}
|
|
51654
|
-
const cliRes = mysqlCliPushParams.safeParse(options);
|
|
51655
|
-
if (!cliRes.success) {
|
|
51656
|
-
if (typeof options.schema === "undefined") {
|
|
51657
|
-
console.log(outputs.common.schema("push:mysql"));
|
|
51658
|
-
}
|
|
51659
|
-
printCliConnectionIssues3(options);
|
|
51660
|
-
process.exit(1);
|
|
51661
|
-
}
|
|
51662
|
-
if (cliRes.data.type === "url") {
|
|
51663
|
-
const { connectionString, type: type2, ...rest2 } = cliRes.data;
|
|
51664
|
-
return {
|
|
51665
|
-
...rest2,
|
|
51666
|
-
dbCredentials: { connectionString, type: type2 }
|
|
51667
|
-
};
|
|
51668
|
-
}
|
|
51669
|
-
const { host, password, port, database, user, type, ...rest } = cliRes.data;
|
|
51670
|
-
return {
|
|
51671
|
-
...rest,
|
|
51672
|
-
dbCredentials: { host, password, port, database, user, type }
|
|
51673
|
-
};
|
|
51674
|
-
};
|
|
51675
|
-
|
|
51676
|
-
// src/cli/index.ts
|
|
51934
|
+
init_sqlite();
|
|
51935
|
+
init_pg();
|
|
51936
|
+
init_common();
|
|
51937
|
+
init_mysql();
|
|
51938
|
+
init_outputs();
|
|
51939
|
+
var import_studio = require("@drizzle-team/studio");
|
|
51677
51940
|
var printVersions = async () => {
|
|
51678
51941
|
const v = await versions();
|
|
51679
51942
|
console.log(`${source_default.gray(v)}
|
|
@@ -52263,6 +52526,37 @@ var dropCommand = new import_commander.Command("drop").option("--out <out>", `Ou
|
|
|
52263
52526
|
assertV1OutFolder(out, "{dialect}");
|
|
52264
52527
|
await dropMigration(out);
|
|
52265
52528
|
});
|
|
52529
|
+
var studioCommand = new import_commander.Command("studio").option("--port <port>", "Custom port for drizzle studio [default=4983]").option("--verbose", "Print all stataments that are executed by Studio").option("--config <config>", `Config path [default=drizzle.config.ts]`).action(async (options) => {
|
|
52530
|
+
const { validateStudio: validateStudio2 } = await Promise.resolve().then(() => (init_studio(), studio_exports));
|
|
52531
|
+
const drizzleConfig = await validateStudio2(options);
|
|
52532
|
+
const { prepareModels: prepareModels2, drizzleDb: drizzleDb2 } = await Promise.resolve().then(() => (init_studioUtils(), studioUtils_exports));
|
|
52533
|
+
const models = await prepareModels2(drizzleConfig.schema);
|
|
52534
|
+
const setup = await drizzleDb2(drizzleConfig, models, options.verbose);
|
|
52535
|
+
const server = await (0, import_studio.prepareServer)(setup);
|
|
52536
|
+
const port = options.port ?? 4983;
|
|
52537
|
+
console.log();
|
|
52538
|
+
console.log(
|
|
52539
|
+
withStyle.fullWarning(
|
|
52540
|
+
"Drizzle Studio is currently in Beta. If you find anything that is not working as expected or should be improved, feel free to create an issue on GitHub: https://github.com/drizzle-team/drizzle-kit-mirror/issues/new or write to us on Discord: https://discord.gg/WcRKz2FFxN"
|
|
52541
|
+
)
|
|
52542
|
+
);
|
|
52543
|
+
server.start({
|
|
52544
|
+
host: "127.0.0.1",
|
|
52545
|
+
port,
|
|
52546
|
+
cb: (err2, address) => {
|
|
52547
|
+
if (err2) {
|
|
52548
|
+
console.error(err2);
|
|
52549
|
+
} else {
|
|
52550
|
+
console.log(
|
|
52551
|
+
`
|
|
52552
|
+
Drizzle Studio is up and running on ${source_default.blue(
|
|
52553
|
+
address
|
|
52554
|
+
)}`
|
|
52555
|
+
);
|
|
52556
|
+
}
|
|
52557
|
+
}
|
|
52558
|
+
});
|
|
52559
|
+
});
|
|
52266
52560
|
var main = async () => {
|
|
52267
52561
|
const version2 = await versions();
|
|
52268
52562
|
import_commander.program.version(version2, "--version, -v");
|
|
@@ -52281,6 +52575,7 @@ var main = async () => {
|
|
|
52281
52575
|
import_commander.program.addCommand(introspectSQLiteCommand);
|
|
52282
52576
|
import_commander.program.addCommand(dbPushSqliteCommand);
|
|
52283
52577
|
import_commander.program.addCommand(checkMySqlCommand);
|
|
52578
|
+
import_commander.program.addCommand(studioCommand);
|
|
52284
52579
|
import_commander.program.parse();
|
|
52285
52580
|
};
|
|
52286
52581
|
main();
|