drizzle-kit 0.20.7-05d4dfb → 0.20.7-0650f86
Sign up to get free protection for your applications and to get access to all the features.
- package/bin.cjs +118 -71
- package/cli/commands/migrate.d.ts +10 -1
- package/cli/commands/utils.d.ts +9 -0
- package/cli/validations/mysql.d.ts +6 -6
- package/cli/validations/pg.d.ts +12 -12
- package/index.d.mts +2 -0
- package/index.d.ts +2 -0
- package/package.json +1 -1
- package/utils.js +95 -49
package/bin.cjs
CHANGED
@@ -11261,7 +11261,7 @@ var require_node2 = __commonJS({
|
|
11261
11261
|
});
|
11262
11262
|
|
11263
11263
|
// src/cli/commands/utils.ts
|
11264
|
-
var import_path, import_fs, import_hanji2, assertES5, safeRegister, prepareGenerateConfig, assertOutFolder, configCommonSchema, introspectCasing, configIntrospectSchema, configIntrospectCliSchema, configGenerateSchema, configPushSchema, mysqlConnectionSchema, mySqlCliConfigSchema, mySqlIntrospectConfigSchema, drizzleConfigFromFile, readDrizzleConfig;
|
11264
|
+
var import_path, import_fs, import_hanji2, assertES5, safeRegister, prepareGenerateConfig, assertOutFolder, driver, configCommonSchema, introspectCasing, configIntrospectSchema, configIntrospectCliSchema, configGenerateSchema, configPushSchema, mysqlConnectionSchema, mySqlCliConfigSchema, mySqlIntrospectConfigSchema, drizzleConfigFromFile, readDrizzleConfig;
|
11265
11265
|
var init_utils = __esm({
|
11266
11266
|
"src/cli/commands/utils.ts"() {
|
11267
11267
|
init_serializer();
|
@@ -11324,7 +11324,8 @@ var init_utils = __esm({
|
|
11324
11324
|
custom,
|
11325
11325
|
breakpoints: drizzleConfig.breakpoints ?? false,
|
11326
11326
|
schema: drizzleConfig.schema,
|
11327
|
-
out: drizzleConfig.out
|
11327
|
+
out: drizzleConfig.out,
|
11328
|
+
bundle: drizzleConfig.driver === "expo"
|
11328
11329
|
};
|
11329
11330
|
}
|
11330
11331
|
if (!schema4) {
|
@@ -11340,7 +11341,7 @@ var init_utils = __esm({
|
|
11340
11341
|
console.error(`'out' param must be set`);
|
11341
11342
|
process.exit(1);
|
11342
11343
|
}
|
11343
|
-
return { schema: schema4, out, breakpoints, custom };
|
11344
|
+
return { schema: schema4, out, breakpoints, custom, bundle: false };
|
11344
11345
|
};
|
11345
11346
|
assertOutFolder = async (it) => {
|
11346
11347
|
if ("out" in it)
|
@@ -11356,10 +11357,20 @@ var init_utils = __esm({
|
|
11356
11357
|
}
|
11357
11358
|
return cliConfig.out;
|
11358
11359
|
};
|
11360
|
+
driver = unionType([
|
11361
|
+
literalType("better-sqlite"),
|
11362
|
+
literalType("turso"),
|
11363
|
+
literalType("libsql"),
|
11364
|
+
literalType("d1"),
|
11365
|
+
literalType("expo"),
|
11366
|
+
literalType("pg"),
|
11367
|
+
literalType("mysql2")
|
11368
|
+
]);
|
11359
11369
|
configCommonSchema = objectType({
|
11360
11370
|
schema: unionType([stringType(), stringType().array()]),
|
11361
11371
|
out: stringType().optional(),
|
11362
11372
|
breakpoints: booleanType().default(true),
|
11373
|
+
driver: driver.optional(),
|
11363
11374
|
tablesFilter: unionType([stringType(), stringType().array()]).optional(),
|
11364
11375
|
schemaFilter: unionType([stringType(), stringType().array()]).default(["public"])
|
11365
11376
|
});
|
@@ -11566,9 +11577,9 @@ var init_outputs = __esm({
|
|
11566
11577
|
driver: () => withStyle.error(
|
11567
11578
|
`Either "turso", "libsql", "better-sqlite" are available options for "--driver"`
|
11568
11579
|
),
|
11569
|
-
url: (
|
11570
|
-
authToken: (
|
11571
|
-
`"authToken" is a required option for driver "${
|
11580
|
+
url: (driver2) => withStyle.error(`"url" is a required option for driver "${driver2}". You can read more about drizzle.config: https://orm.drizzle.team/kit-docs/config-reference`),
|
11581
|
+
authToken: (driver2) => withStyle.error(
|
11582
|
+
`"authToken" is a required option for driver "${driver2}". You can read more about drizzle.config: https://orm.drizzle.team/kit-docs/config-reference`
|
11572
11583
|
)
|
11573
11584
|
},
|
11574
11585
|
introspect: {},
|
@@ -12180,6 +12191,7 @@ var init_pgSerializer = __esm({
|
|
12180
12191
|
};
|
12181
12192
|
generatePgSnapshot = (tables, enums, schemas, schemaFilter) => {
|
12182
12193
|
const result = {};
|
12194
|
+
const indexesInSchema = {};
|
12183
12195
|
for (const table4 of tables) {
|
12184
12196
|
const {
|
12185
12197
|
name: tableName,
|
@@ -12331,6 +12343,24 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
12331
12343
|
return it.name;
|
12332
12344
|
}
|
12333
12345
|
});
|
12346
|
+
if (typeof indexesInSchema[schema4 ?? "public"] !== "undefined") {
|
12347
|
+
if (indexesInSchema[schema4 ?? "public"].includes(name)) {
|
12348
|
+
console.log(
|
12349
|
+
`
|
12350
|
+
${withStyle.errorWarning(
|
12351
|
+
`We've found duplicated index name across ${source_default.underline.blue(
|
12352
|
+
schema4 ?? "public"
|
12353
|
+
)} schema. Please rename your index in either the ${source_default.underline.blue(
|
12354
|
+
tableName
|
12355
|
+
)} table or the table with the duplicated index name`
|
12356
|
+
)}`
|
12357
|
+
);
|
12358
|
+
process.exit(1);
|
12359
|
+
}
|
12360
|
+
indexesInSchema[schema4 ?? "public"].push(name);
|
12361
|
+
} else {
|
12362
|
+
indexesInSchema[schema4 ?? "public"] = [name];
|
12363
|
+
}
|
12334
12364
|
indexesObject[name] = {
|
12335
12365
|
name,
|
12336
12366
|
columns: indexColumns,
|
@@ -14895,7 +14925,7 @@ __export(migrate_exports, {
|
|
14895
14925
|
prepareSnapshotFolderName: () => prepareSnapshotFolderName,
|
14896
14926
|
writeResult: () => writeResult
|
14897
14927
|
});
|
14898
|
-
var import_fs4, import_path3, import_hanji3, prepareAndMigratePg, prepareMySQLPush, prepareSQLitePush, preparePgPush, prepareAndMigrateMySql, prepareAndMigrateSqlite, prepareSQL, promptColumnsConflicts, promptTablesConflict, promptSchemasConflict, BREAKPOINT, writeResult, prepareSnapshotFolderName, two;
|
14928
|
+
var import_fs4, import_path3, import_hanji3, prepareAndMigratePg, prepareMySQLPush, prepareSQLitePush, preparePgPush, prepareAndMigrateMySql, prepareAndMigrateSqlite, prepareSQL, promptColumnsConflicts, promptTablesConflict, promptSchemasConflict, BREAKPOINT, writeResult, embeddedMigrations, prepareSnapshotFolderName, two;
|
14899
14929
|
var init_migrate = __esm({
|
14900
14930
|
"src/cli/commands/migrate.ts"() {
|
14901
14931
|
import_fs4 = __toESM(require("fs"));
|
@@ -14924,19 +14954,14 @@ var init_migrate = __esm({
|
|
14924
14954
|
const validatedPrev = pgSchema.parse(prev);
|
14925
14955
|
const validatedCur = pgSchema.parse(cur);
|
14926
14956
|
if (config.custom) {
|
14927
|
-
writeResult(
|
14928
|
-
custom,
|
14929
|
-
[],
|
14957
|
+
writeResult({
|
14958
|
+
cur: custom,
|
14959
|
+
sqlStatements: [],
|
14930
14960
|
journal,
|
14931
|
-
{
|
14932
|
-
columns: {},
|
14933
|
-
schemas: {},
|
14934
|
-
tables: {}
|
14935
|
-
},
|
14936
14961
|
outFolder,
|
14937
|
-
config.breakpoints,
|
14938
|
-
"custom"
|
14939
|
-
);
|
14962
|
+
breakpoints: config.breakpoints,
|
14963
|
+
type: "custom"
|
14964
|
+
});
|
14940
14965
|
return;
|
14941
14966
|
}
|
14942
14967
|
const squashedPrev = squashPgScheme(validatedPrev);
|
@@ -14948,14 +14973,13 @@ var init_migrate = __esm({
|
|
14948
14973
|
validatedPrev,
|
14949
14974
|
validatedCur
|
14950
14975
|
);
|
14951
|
-
writeResult(
|
14976
|
+
writeResult({
|
14952
14977
|
cur,
|
14953
14978
|
sqlStatements,
|
14954
14979
|
journal,
|
14955
|
-
_meta,
|
14956
14980
|
outFolder,
|
14957
|
-
config.breakpoints
|
14958
|
-
);
|
14981
|
+
breakpoints: config.breakpoints
|
14982
|
+
});
|
14959
14983
|
} catch (e) {
|
14960
14984
|
console.error(e);
|
14961
14985
|
}
|
@@ -15049,19 +15073,14 @@ var init_migrate = __esm({
|
|
15049
15073
|
const validatedPrev = mysqlSchema.parse(prev);
|
15050
15074
|
const validatedCur = mysqlSchema.parse(cur);
|
15051
15075
|
if (config.custom) {
|
15052
|
-
writeResult(
|
15053
|
-
custom,
|
15054
|
-
[],
|
15076
|
+
writeResult({
|
15077
|
+
cur: custom,
|
15078
|
+
sqlStatements: [],
|
15055
15079
|
journal,
|
15056
|
-
{
|
15057
|
-
columns: {},
|
15058
|
-
schemas: {},
|
15059
|
-
tables: {}
|
15060
|
-
},
|
15061
15080
|
outFolder,
|
15062
|
-
config.breakpoints,
|
15063
|
-
"custom"
|
15064
|
-
);
|
15081
|
+
breakpoints: config.breakpoints,
|
15082
|
+
type: "custom"
|
15083
|
+
});
|
15065
15084
|
return;
|
15066
15085
|
}
|
15067
15086
|
const squashedPrev = squashMysqlScheme(validatedPrev);
|
@@ -15073,14 +15092,14 @@ var init_migrate = __esm({
|
|
15073
15092
|
validatedPrev,
|
15074
15093
|
validatedCur
|
15075
15094
|
);
|
15076
|
-
writeResult(
|
15095
|
+
writeResult({
|
15077
15096
|
cur,
|
15078
15097
|
sqlStatements,
|
15079
15098
|
journal,
|
15080
15099
|
_meta,
|
15081
15100
|
outFolder,
|
15082
|
-
config.breakpoints
|
15083
|
-
);
|
15101
|
+
breakpoints: config.breakpoints
|
15102
|
+
});
|
15084
15103
|
} catch (e) {
|
15085
15104
|
console.error(e);
|
15086
15105
|
}
|
@@ -15098,19 +15117,14 @@ var init_migrate = __esm({
|
|
15098
15117
|
const validatedPrev = sqliteSchema.parse(prev);
|
15099
15118
|
const validatedCur = sqliteSchema.parse(cur);
|
15100
15119
|
if (config.custom) {
|
15101
|
-
writeResult(
|
15102
|
-
custom,
|
15103
|
-
[],
|
15120
|
+
writeResult({
|
15121
|
+
cur: custom,
|
15122
|
+
sqlStatements: [],
|
15104
15123
|
journal,
|
15105
|
-
{
|
15106
|
-
columns: {},
|
15107
|
-
schemas: {},
|
15108
|
-
tables: {}
|
15109
|
-
},
|
15110
15124
|
outFolder,
|
15111
|
-
config.breakpoints,
|
15112
|
-
"custom"
|
15113
|
-
);
|
15125
|
+
breakpoints: config.breakpoints,
|
15126
|
+
type: "custom"
|
15127
|
+
});
|
15114
15128
|
return;
|
15115
15129
|
}
|
15116
15130
|
const squashedPrev = squashSqliteScheme(validatedPrev);
|
@@ -15120,14 +15134,14 @@ var init_migrate = __esm({
|
|
15120
15134
|
squashedCur,
|
15121
15135
|
"sqlite"
|
15122
15136
|
);
|
15123
|
-
writeResult(
|
15137
|
+
writeResult({
|
15124
15138
|
cur,
|
15125
15139
|
sqlStatements,
|
15126
15140
|
journal,
|
15127
15141
|
_meta,
|
15128
15142
|
outFolder,
|
15129
|
-
config.breakpoints
|
15130
|
-
);
|
15143
|
+
breakpoints: config.breakpoints
|
15144
|
+
});
|
15131
15145
|
} catch (e) {
|
15132
15146
|
console.error(e);
|
15133
15147
|
}
|
@@ -15315,7 +15329,20 @@ var init_migrate = __esm({
|
|
15315
15329
|
return result;
|
15316
15330
|
};
|
15317
15331
|
BREAKPOINT = "--> statement-breakpoint\n";
|
15318
|
-
writeResult = (
|
15332
|
+
writeResult = ({
|
15333
|
+
cur,
|
15334
|
+
sqlStatements,
|
15335
|
+
journal,
|
15336
|
+
_meta = {
|
15337
|
+
columns: {},
|
15338
|
+
schemas: {},
|
15339
|
+
tables: {}
|
15340
|
+
},
|
15341
|
+
outFolder,
|
15342
|
+
breakpoints,
|
15343
|
+
bundle = false,
|
15344
|
+
type = "none"
|
15345
|
+
}) => {
|
15319
15346
|
if (type === "none") {
|
15320
15347
|
console.log(schema(cur));
|
15321
15348
|
if (sqlStatements.length === 0) {
|
@@ -15356,6 +15383,10 @@ ${sql2}
|
|
15356
15383
|
});
|
15357
15384
|
import_fs4.default.writeFileSync(metaJournal, JSON.stringify(journal, null, 2));
|
15358
15385
|
import_fs4.default.writeFileSync(`${outFolder}/${tag}.sql`, sql2);
|
15386
|
+
if (bundle) {
|
15387
|
+
const js = embeddedMigrations(journal);
|
15388
|
+
import_fs4.default.writeFileSync(`${outFolder}/migrations.js`, js);
|
15389
|
+
}
|
15359
15390
|
(0, import_hanji3.render)(
|
15360
15391
|
`[${source_default.green(
|
15361
15392
|
"\u2713"
|
@@ -15364,6 +15395,22 @@ ${sql2}
|
|
15364
15395
|
)} \u{1F680}`
|
15365
15396
|
);
|
15366
15397
|
};
|
15398
|
+
embeddedMigrations = (journal) => {
|
15399
|
+
let content = "import journal from './meta/_journal.json';\n";
|
15400
|
+
journal.entries.forEach((entry) => {
|
15401
|
+
content += `import m${entry.idx.toString().padStart(4, "0")} from './${entry.tag}.sql';
|
15402
|
+
`;
|
15403
|
+
});
|
15404
|
+
content += `
|
15405
|
+
export default {
|
15406
|
+
journal,
|
15407
|
+
migrations: {
|
15408
|
+
${journal.entries.map((it) => `m${it.idx.toString().padStart(4, "0")}`).join(",\n")}
|
15409
|
+
}
|
15410
|
+
}
|
15411
|
+
`;
|
15412
|
+
return content;
|
15413
|
+
};
|
15367
15414
|
prepareSnapshotFolderName = () => {
|
15368
15415
|
const now = /* @__PURE__ */ new Date();
|
15369
15416
|
return `${now.getFullYear()}${two(now.getUTCMonth() + 1)}${two(
|
@@ -15458,7 +15505,7 @@ var init_sqlgenerator = __esm({
|
|
15458
15505
|
if (typeof compositePKs !== "undefined" && compositePKs.length > 0) {
|
15459
15506
|
statement += ",\n";
|
15460
15507
|
const compositePK4 = PgSquasher.unsquashPK(compositePKs[0]);
|
15461
|
-
statement += ` CONSTRAINT ${st.compositePkName} PRIMARY KEY("${compositePK4.columns.join(`","`)}")`;
|
15508
|
+
statement += ` CONSTRAINT "${st.compositePkName}" PRIMARY KEY("${compositePK4.columns.join(`","`)}")`;
|
15462
15509
|
}
|
15463
15510
|
if (typeof uniqueConstraints !== "undefined" && uniqueConstraints.length > 0) {
|
15464
15511
|
for (const uniqueConstraint4 of uniqueConstraints) {
|
@@ -17855,9 +17902,9 @@ var init_snapshotsDiffer = __esm({
|
|
17855
17902
|
}
|
17856
17903
|
jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
|
17857
17904
|
jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
|
17858
|
-
jsonStatements.push(...jsonAddedCompositePKs);
|
17859
|
-
jsonStatements.push(...jsonTableAlternations.alterColumns);
|
17860
17905
|
jsonStatements.push(...jsonDeletedCompositePKs);
|
17906
|
+
jsonStatements.push(...jsonTableAlternations.alterColumns);
|
17907
|
+
jsonStatements.push(...jsonAddedCompositePKs);
|
17861
17908
|
if (dialect6 === "mysql") {
|
17862
17909
|
jsonStatements.push(...jsonAddedUniqueConstraints);
|
17863
17910
|
jsonStatements.push(...jsonDeletedUniqueConstraints);
|
@@ -60321,8 +60368,8 @@ var init_studioUtils = __esm({
|
|
60321
60368
|
};
|
60322
60369
|
};
|
60323
60370
|
drizzleForSQLite = async (config, sqliteSchema2, relations4, ts, verbose) => {
|
60324
|
-
const { driver, dbCredentials: creds } = config;
|
60325
|
-
if (
|
60371
|
+
const { driver: driver2, dbCredentials: creds } = config;
|
60372
|
+
if (driver2 === "d1") {
|
60326
60373
|
const { drizzle: drizzle2 } = await Promise.resolve().then(() => (init_driver(), driver_exports));
|
60327
60374
|
const { execute: execute2 } = await Promise.resolve().then(() => (init_wrangler_client(), wrangler_client_exports));
|
60328
60375
|
const db = drizzle2(execute2, creds.wranglerConfigPath, creds.dbName, {
|
@@ -60340,7 +60387,7 @@ var init_studioUtils = __esm({
|
|
60340
60387
|
ts
|
60341
60388
|
};
|
60342
60389
|
}
|
60343
|
-
if (
|
60390
|
+
if (driver2 === "better-sqlite") {
|
60344
60391
|
assertPackages("better-sqlite3");
|
60345
60392
|
const { drizzle: drizzle2 } = await import("drizzle-orm/better-sqlite3");
|
60346
60393
|
const Database = await import("better-sqlite3");
|
@@ -60359,7 +60406,7 @@ var init_studioUtils = __esm({
|
|
60359
60406
|
ts
|
60360
60407
|
};
|
60361
60408
|
}
|
60362
|
-
if (
|
60409
|
+
if (driver2 === "libsql" || driver2 === "turso") {
|
60363
60410
|
assertPackages("@libsql/client");
|
60364
60411
|
const { drizzle: drizzle2 } = await import("drizzle-orm/libsql");
|
60365
60412
|
const { createClient } = await import("@libsql/client");
|
@@ -60383,7 +60430,7 @@ var init_studioUtils = __esm({
|
|
60383
60430
|
ts
|
60384
60431
|
};
|
60385
60432
|
}
|
60386
|
-
assertUnreachable(
|
60433
|
+
assertUnreachable(driver2);
|
60387
60434
|
};
|
60388
60435
|
drizzleDb = async (drizzleConfig, models, logger) => {
|
60389
60436
|
if (drizzleConfig.driver === "pg") {
|
@@ -61097,8 +61144,8 @@ var init_mysql = __esm({
|
|
61097
61144
|
mysqlConnectionConfig
|
61098
61145
|
);
|
61099
61146
|
printCliConnectionIssues3 = (options) => {
|
61100
|
-
const { driver, uri, host, database } = options || {};
|
61101
|
-
if (
|
61147
|
+
const { driver: driver2, uri, host, database } = options || {};
|
61148
|
+
if (driver2 !== "mysql2") {
|
61102
61149
|
console.log(outputs.mysql.connection.driver());
|
61103
61150
|
}
|
61104
61151
|
if (!uri && (!host || !database)) {
|
@@ -61137,7 +61184,7 @@ var init_mysql = __esm({
|
|
61137
61184
|
const {
|
61138
61185
|
out,
|
61139
61186
|
schema: schema4,
|
61140
|
-
driver,
|
61187
|
+
driver: driver2,
|
61141
61188
|
schemaFilter,
|
61142
61189
|
tablesFilter,
|
61143
61190
|
breakpoints,
|
@@ -61147,7 +61194,7 @@ var init_mysql = __esm({
|
|
61147
61194
|
return {
|
61148
61195
|
out,
|
61149
61196
|
schema: schema4,
|
61150
|
-
driver,
|
61197
|
+
driver: driver2,
|
61151
61198
|
schemaFilter,
|
61152
61199
|
tablesFilter,
|
61153
61200
|
breakpoints,
|
@@ -61183,13 +61230,13 @@ var init_mysql = __esm({
|
|
61183
61230
|
strict,
|
61184
61231
|
verbose,
|
61185
61232
|
schema: schema4,
|
61186
|
-
driver,
|
61233
|
+
driver: driver2,
|
61187
61234
|
schemaFilter,
|
61188
61235
|
tablesFilter,
|
61189
61236
|
...rest
|
61190
61237
|
} = cliRes.data;
|
61191
61238
|
return {
|
61192
|
-
driver,
|
61239
|
+
driver: driver2,
|
61193
61240
|
schema: schema4,
|
61194
61241
|
strict,
|
61195
61242
|
verbose,
|
@@ -63632,9 +63679,9 @@ var studioCommand = new import_commander.Command("studio").option("--port <port>
|
|
63632
63679
|
prepareSQLiteSchema: prepareSQLiteSchema2,
|
63633
63680
|
drizzleForSQLite: drizzleForSQLite2
|
63634
63681
|
} = await Promise.resolve().then(() => (init_studioUtils(), studioUtils_exports));
|
63635
|
-
const { driver, schema: schemaPath } = drizzleConfig;
|
63682
|
+
const { driver: driver2, schema: schemaPath } = drizzleConfig;
|
63636
63683
|
let setup;
|
63637
|
-
if (
|
63684
|
+
if (driver2 === "pg") {
|
63638
63685
|
const { schemaToTypeScript: schemaToTypeScript4, relationsToTypeScript: relationsToTypeScript2 } = await Promise.resolve().then(() => (init_introspect_pg(), introspect_pg_exports));
|
63639
63686
|
const { serializePg: serializePg2 } = await Promise.resolve().then(() => (init_serializer(), serializer_exports));
|
63640
63687
|
const { schema: schema4, relations: relations4 } = await preparePgSchema2(schemaPath);
|
@@ -63652,7 +63699,7 @@ var studioCommand = new import_commander.Command("studio").option("--port <port>
|
|
63652
63699
|
},
|
63653
63700
|
Boolean(options.verbose)
|
63654
63701
|
);
|
63655
|
-
} else if (
|
63702
|
+
} else if (driver2 === "mysql2") {
|
63656
63703
|
const { schemaToTypeScript: schemaToTypeScript4 } = await Promise.resolve().then(() => (init_introspect_mysql(), introspect_mysql_exports));
|
63657
63704
|
const { schema: schema4, relations: relations4 } = await prepareMySqlSchema2(schemaPath);
|
63658
63705
|
const { serializeMySql: serializeMySql2 } = await Promise.resolve().then(() => (init_serializer(), serializer_exports));
|
@@ -63669,7 +63716,7 @@ var studioCommand = new import_commander.Command("studio").option("--port <port>
|
|
63669
63716
|
},
|
63670
63717
|
Boolean(options.verbose)
|
63671
63718
|
);
|
63672
|
-
} else if (
|
63719
|
+
} else if (driver2 === "better-sqlite" || driver2 === "d1" || driver2 === "libsql" || driver2 === "turso") {
|
63673
63720
|
const { schemaToTypeScript: schemaToTypeScript4 } = await Promise.resolve().then(() => (init_introspect_sqlite(), introspect_sqlite_exports));
|
63674
63721
|
const { schema: schema4, relations: relations4 } = await prepareSQLiteSchema2(schemaPath);
|
63675
63722
|
const { serializeSQLite: serializeSQLite2 } = await Promise.resolve().then(() => (init_serializer(), serializer_exports));
|
@@ -63687,7 +63734,7 @@ var studioCommand = new import_commander.Command("studio").option("--port <port>
|
|
63687
63734
|
Boolean(options.verbose)
|
63688
63735
|
);
|
63689
63736
|
} else {
|
63690
|
-
assertUnreachable(
|
63737
|
+
assertUnreachable(driver2);
|
63691
63738
|
}
|
63692
63739
|
const qeueryEngine = (0, import_studio.queryEngineForSetup)(setup);
|
63693
63740
|
const server = await (0, import_server.prepareServer)((_2) => {
|
@@ -63701,7 +63748,7 @@ var studioCommand = new import_commander.Command("studio").option("--port <port>
|
|
63701
63748
|
"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"
|
63702
63749
|
)
|
63703
63750
|
);
|
63704
|
-
if (
|
63751
|
+
if (driver2 === "d1") {
|
63705
63752
|
console.log(
|
63706
63753
|
withStyle.fullWarning(
|
63707
63754
|
"It seems like you are trying to access your D1 Database. Please make sure to run 'wrangler login' before using Drizzle Studio to ensure it has your token for making requests to the D1 Database. If you encounter an error related to CLOUDFLARE_TOKEN, please run 'wrangler login' and restart the studio"
|
@@ -256,5 +256,14 @@ export declare const prepareSQL: (prev: CommonSquashedSchema, cur: CommonSquashe
|
|
256
256
|
} | undefined;
|
257
257
|
}>;
|
258
258
|
export declare const BREAKPOINT = "--> statement-breakpoint\n";
|
259
|
-
export declare const writeResult: (cur
|
259
|
+
export declare const writeResult: ({ cur, sqlStatements, journal, _meta, outFolder, breakpoints, bundle, type, }: {
|
260
|
+
cur: CommonSchema;
|
261
|
+
sqlStatements: string[];
|
262
|
+
journal: Journal;
|
263
|
+
_meta?: any;
|
264
|
+
outFolder: string;
|
265
|
+
breakpoints: boolean;
|
266
|
+
bundle?: boolean | undefined;
|
267
|
+
type?: "none" | "custom" | "introspect" | undefined;
|
268
|
+
}) => void;
|
260
269
|
export declare const prepareSnapshotFolderName: () => string;
|
package/cli/commands/utils.d.ts
CHANGED
@@ -7,6 +7,7 @@ export type GenerateConfig = {
|
|
7
7
|
out: string;
|
8
8
|
breakpoints: boolean;
|
9
9
|
custom: boolean;
|
10
|
+
bundle: boolean;
|
10
11
|
};
|
11
12
|
export declare const prepareGenerateConfig: (options: {
|
12
13
|
schema?: string | string[];
|
@@ -20,14 +21,17 @@ export declare const assertOutFolder: (it: {
|
|
20
21
|
} | {
|
21
22
|
out: string;
|
22
23
|
}) => Promise<string>;
|
24
|
+
export declare const driver: import("zod").ZodUnion<[import("zod").ZodLiteral<"better-sqlite">, import("zod").ZodLiteral<"turso">, import("zod").ZodLiteral<"libsql">, import("zod").ZodLiteral<"d1">, import("zod").ZodLiteral<"expo">, import("zod").ZodLiteral<"pg">, import("zod").ZodLiteral<"mysql2">]>;
|
23
25
|
export declare const configCommonSchema: import("zod").ZodObject<{
|
24
26
|
schema: import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString, "many">]>;
|
25
27
|
out: import("zod").ZodOptional<import("zod").ZodString>;
|
26
28
|
breakpoints: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
29
|
+
driver: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodLiteral<"better-sqlite">, import("zod").ZodLiteral<"turso">, import("zod").ZodLiteral<"libsql">, import("zod").ZodLiteral<"d1">, import("zod").ZodLiteral<"expo">, import("zod").ZodLiteral<"pg">, import("zod").ZodLiteral<"mysql2">]>>;
|
27
30
|
tablesFilter: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString, "many">]>>;
|
28
31
|
schemaFilter: import("zod").ZodDefault<import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString, "many">]>>;
|
29
32
|
}, "strip", import("zod").ZodTypeAny, {
|
30
33
|
out?: string | undefined;
|
34
|
+
driver?: "turso" | "better-sqlite" | "libsql" | "d1" | "pg" | "mysql2" | "expo" | undefined;
|
31
35
|
tablesFilter?: string | string[] | undefined;
|
32
36
|
schema: string | string[];
|
33
37
|
breakpoints: boolean;
|
@@ -35,6 +39,7 @@ export declare const configCommonSchema: import("zod").ZodObject<{
|
|
35
39
|
}, {
|
36
40
|
out?: string | undefined;
|
37
41
|
breakpoints?: boolean | undefined;
|
42
|
+
driver?: "turso" | "better-sqlite" | "libsql" | "d1" | "pg" | "mysql2" | "expo" | undefined;
|
38
43
|
tablesFilter?: string | string[] | undefined;
|
39
44
|
schemaFilter?: string | string[] | undefined;
|
40
45
|
schema: string | string[];
|
@@ -164,10 +169,12 @@ export declare const mySqlCliConfigSchema: import("zod").ZodIntersection<import(
|
|
164
169
|
schema: import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString, "many">]>;
|
165
170
|
out: import("zod").ZodOptional<import("zod").ZodString>;
|
166
171
|
breakpoints: import("zod").ZodDefault<import("zod").ZodBoolean>;
|
172
|
+
driver: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodLiteral<"better-sqlite">, import("zod").ZodLiteral<"turso">, import("zod").ZodLiteral<"libsql">, import("zod").ZodLiteral<"d1">, import("zod").ZodLiteral<"expo">, import("zod").ZodLiteral<"pg">, import("zod").ZodLiteral<"mysql2">]>>;
|
167
173
|
tablesFilter: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString, "many">]>>;
|
168
174
|
schemaFilter: import("zod").ZodDefault<import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString, "many">]>>;
|
169
175
|
}, "strip", import("zod").ZodTypeAny, {
|
170
176
|
out?: string | undefined;
|
177
|
+
driver?: "turso" | "better-sqlite" | "libsql" | "d1" | "pg" | "mysql2" | "expo" | undefined;
|
171
178
|
tablesFilter?: string | string[] | undefined;
|
172
179
|
schema: string | string[];
|
173
180
|
breakpoints: boolean;
|
@@ -175,6 +182,7 @@ export declare const mySqlCliConfigSchema: import("zod").ZodIntersection<import(
|
|
175
182
|
}, {
|
176
183
|
out?: string | undefined;
|
177
184
|
breakpoints?: boolean | undefined;
|
185
|
+
driver?: "turso" | "better-sqlite" | "libsql" | "d1" | "pg" | "mysql2" | "expo" | undefined;
|
178
186
|
tablesFilter?: string | string[] | undefined;
|
179
187
|
schemaFilter?: string | string[] | undefined;
|
180
188
|
schema: string | string[];
|
@@ -261,5 +269,6 @@ export declare const mySqlIntrospectConfigSchema: import("zod").ZodIntersection<
|
|
261
269
|
}>, import("zod").ZodObject<{}, "strip", import("zod").ZodTypeAny, {}, {}>]>>;
|
262
270
|
export type MySqlCliConfig = TypeOf<typeof mySqlCliConfigSchema>;
|
263
271
|
export type CliConfig = MySqlCliConfig;
|
272
|
+
export type Driver = TypeOf<typeof driver>;
|
264
273
|
export declare const drizzleConfigFromFile: (configPath?: string) => Promise<CliConfig>;
|
265
274
|
export declare const readDrizzleConfig: (configPath?: string) => Promise<any>;
|
@@ -9,17 +9,17 @@ export declare const mysqlConnectionCli: import("zod").ZodUnion<[import("zod").Z
|
|
9
9
|
}, "strip", import("zod").ZodTypeAny, {
|
10
10
|
port?: number | undefined;
|
11
11
|
password?: string | undefined;
|
12
|
+
driver: "mysql2";
|
12
13
|
host: string;
|
13
14
|
user: string;
|
14
15
|
database: string;
|
15
|
-
driver: "mysql2";
|
16
16
|
}, {
|
17
17
|
port?: number | undefined;
|
18
18
|
user?: string | undefined;
|
19
19
|
password?: string | undefined;
|
20
|
+
driver: "mysql2";
|
20
21
|
host: string;
|
21
22
|
database: string;
|
22
|
-
driver: "mysql2";
|
23
23
|
}>, import("zod").ZodObject<{
|
24
24
|
driver: import("zod").ZodLiteral<"mysql2">;
|
25
25
|
uri: import("zod").ZodString;
|
@@ -217,17 +217,17 @@ export declare const mysqlCliIntrospectParams: import("zod").ZodIntersection<imp
|
|
217
217
|
}, "strip", import("zod").ZodTypeAny, {
|
218
218
|
port?: number | undefined;
|
219
219
|
password?: string | undefined;
|
220
|
+
driver: "mysql2";
|
220
221
|
host: string;
|
221
222
|
user: string;
|
222
223
|
database: string;
|
223
|
-
driver: "mysql2";
|
224
224
|
}, {
|
225
225
|
port?: number | undefined;
|
226
226
|
user?: string | undefined;
|
227
227
|
password?: string | undefined;
|
228
|
+
driver: "mysql2";
|
228
229
|
host: string;
|
229
230
|
database: string;
|
230
|
-
driver: "mysql2";
|
231
231
|
}>, import("zod").ZodObject<{
|
232
232
|
driver: import("zod").ZodLiteral<"mysql2">;
|
233
233
|
uri: import("zod").ZodString;
|
@@ -266,17 +266,17 @@ export declare const mysqlCliPushParams: import("zod").ZodIntersection<import("z
|
|
266
266
|
}, "strip", import("zod").ZodTypeAny, {
|
267
267
|
port?: number | undefined;
|
268
268
|
password?: string | undefined;
|
269
|
+
driver: "mysql2";
|
269
270
|
host: string;
|
270
271
|
user: string;
|
271
272
|
database: string;
|
272
|
-
driver: "mysql2";
|
273
273
|
}, {
|
274
274
|
port?: number | undefined;
|
275
275
|
user?: string | undefined;
|
276
276
|
password?: string | undefined;
|
277
|
+
driver: "mysql2";
|
277
278
|
host: string;
|
278
279
|
database: string;
|
279
|
-
driver: "mysql2";
|
280
280
|
}>, import("zod").ZodObject<{
|
281
281
|
driver: import("zod").ZodLiteral<"mysql2">;
|
282
282
|
uri: import("zod").ZodString;
|
package/cli/validations/pg.d.ts
CHANGED
@@ -13,31 +13,31 @@ export declare const pgConnectionCli: import("zod").ZodUnion<[import("zod").ZodO
|
|
13
13
|
password?: string | undefined;
|
14
14
|
ssl?: boolean | undefined;
|
15
15
|
type: "params";
|
16
|
+
driver: "pg";
|
16
17
|
host: string;
|
17
18
|
user: string;
|
18
19
|
database: string;
|
19
|
-
driver: "pg";
|
20
20
|
}, {
|
21
21
|
type?: "params" | undefined;
|
22
22
|
port?: number | undefined;
|
23
23
|
user?: string | undefined;
|
24
24
|
password?: string | undefined;
|
25
25
|
ssl?: boolean | undefined;
|
26
|
+
driver: "pg";
|
26
27
|
host: string;
|
27
28
|
database: string;
|
28
|
-
driver: "pg";
|
29
29
|
}>, import("zod").ZodObject<{
|
30
30
|
driver: import("zod").ZodLiteral<"pg">;
|
31
31
|
connectionString: import("zod").ZodString;
|
32
32
|
type: import("zod").ZodDefault<import("zod").ZodLiteral<"url">>;
|
33
33
|
}, "strip", import("zod").ZodTypeAny, {
|
34
34
|
type: "url";
|
35
|
-
connectionString: string;
|
36
35
|
driver: "pg";
|
36
|
+
connectionString: string;
|
37
37
|
}, {
|
38
38
|
type?: "url" | undefined;
|
39
|
-
connectionString: string;
|
40
39
|
driver: "pg";
|
40
|
+
connectionString: string;
|
41
41
|
}>]>;
|
42
42
|
export declare const pgConnectionConfig: import("zod").ZodUnion<[import("zod").ZodObject<{
|
43
43
|
driver: import("zod").ZodLiteral<"pg">;
|
@@ -253,31 +253,31 @@ export declare const pgCliIntrospectParams: import("zod").ZodIntersection<import
|
|
253
253
|
password?: string | undefined;
|
254
254
|
ssl?: boolean | undefined;
|
255
255
|
type: "params";
|
256
|
+
driver: "pg";
|
256
257
|
host: string;
|
257
258
|
user: string;
|
258
259
|
database: string;
|
259
|
-
driver: "pg";
|
260
260
|
}, {
|
261
261
|
type?: "params" | undefined;
|
262
262
|
port?: number | undefined;
|
263
263
|
user?: string | undefined;
|
264
264
|
password?: string | undefined;
|
265
265
|
ssl?: boolean | undefined;
|
266
|
+
driver: "pg";
|
266
267
|
host: string;
|
267
268
|
database: string;
|
268
|
-
driver: "pg";
|
269
269
|
}>, import("zod").ZodObject<{
|
270
270
|
driver: import("zod").ZodLiteral<"pg">;
|
271
271
|
connectionString: import("zod").ZodString;
|
272
272
|
type: import("zod").ZodDefault<import("zod").ZodLiteral<"url">>;
|
273
273
|
}, "strip", import("zod").ZodTypeAny, {
|
274
274
|
type: "url";
|
275
|
-
connectionString: string;
|
276
275
|
driver: "pg";
|
276
|
+
connectionString: string;
|
277
277
|
}, {
|
278
278
|
type?: "url" | undefined;
|
279
|
-
connectionString: string;
|
280
279
|
driver: "pg";
|
280
|
+
connectionString: string;
|
281
281
|
}>]>>;
|
282
282
|
export declare const pgCliPushParams: import("zod").ZodIntersection<import("zod").ZodObject<{
|
283
283
|
schema: import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString, "many">]>;
|
@@ -311,31 +311,31 @@ export declare const pgCliPushParams: import("zod").ZodIntersection<import("zod"
|
|
311
311
|
password?: string | undefined;
|
312
312
|
ssl?: boolean | undefined;
|
313
313
|
type: "params";
|
314
|
+
driver: "pg";
|
314
315
|
host: string;
|
315
316
|
user: string;
|
316
317
|
database: string;
|
317
|
-
driver: "pg";
|
318
318
|
}, {
|
319
319
|
type?: "params" | undefined;
|
320
320
|
port?: number | undefined;
|
321
321
|
user?: string | undefined;
|
322
322
|
password?: string | undefined;
|
323
323
|
ssl?: boolean | undefined;
|
324
|
+
driver: "pg";
|
324
325
|
host: string;
|
325
326
|
database: string;
|
326
|
-
driver: "pg";
|
327
327
|
}>, import("zod").ZodObject<{
|
328
328
|
driver: import("zod").ZodLiteral<"pg">;
|
329
329
|
connectionString: import("zod").ZodString;
|
330
330
|
type: import("zod").ZodDefault<import("zod").ZodLiteral<"url">>;
|
331
331
|
}, "strip", import("zod").ZodTypeAny, {
|
332
332
|
type: "url";
|
333
|
-
connectionString: string;
|
334
333
|
driver: "pg";
|
334
|
+
connectionString: string;
|
335
335
|
}, {
|
336
336
|
type?: "url" | undefined;
|
337
|
-
connectionString: string;
|
338
337
|
driver: "pg";
|
338
|
+
connectionString: string;
|
339
339
|
}>]>>;
|
340
340
|
export declare const pgConfigPushParams: import("zod").ZodIntersection<import("zod").ZodObject<{
|
341
341
|
schema: import("zod").ZodUnion<[import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString, "many">]>;
|
package/index.d.mts
CHANGED
package/index.d.ts
CHANGED
package/package.json
CHANGED
package/utils.js
CHANGED
@@ -11140,7 +11140,7 @@ var require_node2 = __commonJS({
|
|
11140
11140
|
});
|
11141
11141
|
|
11142
11142
|
// src/cli/commands/utils.ts
|
11143
|
-
var import_hanji2, assertES5, safeRegister, configCommonSchema, introspectCasing, configIntrospectSchema, configIntrospectCliSchema, configGenerateSchema, configPushSchema, mysqlConnectionSchema, mySqlCliConfigSchema, mySqlIntrospectConfigSchema;
|
11143
|
+
var import_hanji2, assertES5, safeRegister, driver, configCommonSchema, introspectCasing, configIntrospectSchema, configIntrospectCliSchema, configGenerateSchema, configPushSchema, mysqlConnectionSchema, mySqlCliConfigSchema, mySqlIntrospectConfigSchema;
|
11144
11144
|
var init_utils = __esm({
|
11145
11145
|
"src/cli/commands/utils.ts"() {
|
11146
11146
|
init_serializer();
|
@@ -11189,10 +11189,20 @@ var init_utils = __esm({
|
|
11189
11189
|
await assertES5(res.unregister);
|
11190
11190
|
return res;
|
11191
11191
|
};
|
11192
|
+
driver = unionType([
|
11193
|
+
literalType("better-sqlite"),
|
11194
|
+
literalType("turso"),
|
11195
|
+
literalType("libsql"),
|
11196
|
+
literalType("d1"),
|
11197
|
+
literalType("expo"),
|
11198
|
+
literalType("pg"),
|
11199
|
+
literalType("mysql2")
|
11200
|
+
]);
|
11192
11201
|
configCommonSchema = objectType({
|
11193
11202
|
schema: unionType([stringType(), stringType().array()]),
|
11194
11203
|
out: stringType().optional(),
|
11195
11204
|
breakpoints: booleanType().default(true),
|
11205
|
+
driver: driver.optional(),
|
11196
11206
|
tablesFilter: unionType([stringType(), stringType().array()]).optional(),
|
11197
11207
|
schemaFilter: unionType([stringType(), stringType().array()]).default(["public"])
|
11198
11208
|
});
|
@@ -11906,6 +11916,7 @@ var init_pgSerializer = __esm({
|
|
11906
11916
|
};
|
11907
11917
|
generatePgSnapshot = (tables, enums, schemas, schemaFilter) => {
|
11908
11918
|
const result = {};
|
11919
|
+
const indexesInSchema = {};
|
11909
11920
|
for (const table4 of tables) {
|
11910
11921
|
const {
|
11911
11922
|
name: tableName,
|
@@ -12057,6 +12068,24 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
12057
12068
|
return it.name;
|
12058
12069
|
}
|
12059
12070
|
});
|
12071
|
+
if (typeof indexesInSchema[schema4 ?? "public"] !== "undefined") {
|
12072
|
+
if (indexesInSchema[schema4 ?? "public"].includes(name)) {
|
12073
|
+
console.log(
|
12074
|
+
`
|
12075
|
+
${withStyle.errorWarning(
|
12076
|
+
`We've found duplicated index name across ${source_default.underline.blue(
|
12077
|
+
schema4 ?? "public"
|
12078
|
+
)} schema. Please rename your index in either the ${source_default.underline.blue(
|
12079
|
+
tableName
|
12080
|
+
)} table or the table with the duplicated index name`
|
12081
|
+
)}`
|
12082
|
+
);
|
12083
|
+
process.exit(1);
|
12084
|
+
}
|
12085
|
+
indexesInSchema[schema4 ?? "public"].push(name);
|
12086
|
+
} else {
|
12087
|
+
indexesInSchema[schema4 ?? "public"] = [name];
|
12088
|
+
}
|
12060
12089
|
indexesObject[name] = {
|
12061
12090
|
name,
|
12062
12091
|
columns: indexColumns,
|
@@ -14613,7 +14642,7 @@ __export(migrate_exports, {
|
|
14613
14642
|
prepareSnapshotFolderName: () => prepareSnapshotFolderName,
|
14614
14643
|
writeResult: () => writeResult
|
14615
14644
|
});
|
14616
|
-
var import_fs3, import_path2, import_hanji3, prepareAndMigratePg, prepareMySQLPush, prepareSQLitePush, preparePgPush, prepareAndMigrateMySql, prepareAndMigrateSqlite, prepareSQL, promptColumnsConflicts, promptTablesConflict, promptSchemasConflict, BREAKPOINT, writeResult, prepareSnapshotFolderName, two;
|
14645
|
+
var import_fs3, import_path2, import_hanji3, prepareAndMigratePg, prepareMySQLPush, prepareSQLitePush, preparePgPush, prepareAndMigrateMySql, prepareAndMigrateSqlite, prepareSQL, promptColumnsConflicts, promptTablesConflict, promptSchemasConflict, BREAKPOINT, writeResult, embeddedMigrations, prepareSnapshotFolderName, two;
|
14617
14646
|
var init_migrate = __esm({
|
14618
14647
|
"src/cli/commands/migrate.ts"() {
|
14619
14648
|
import_fs3 = __toESM(require("fs"));
|
@@ -14642,19 +14671,14 @@ var init_migrate = __esm({
|
|
14642
14671
|
const validatedPrev = pgSchema.parse(prev);
|
14643
14672
|
const validatedCur = pgSchema.parse(cur);
|
14644
14673
|
if (config.custom) {
|
14645
|
-
writeResult(
|
14646
|
-
custom,
|
14647
|
-
[],
|
14674
|
+
writeResult({
|
14675
|
+
cur: custom,
|
14676
|
+
sqlStatements: [],
|
14648
14677
|
journal,
|
14649
|
-
{
|
14650
|
-
columns: {},
|
14651
|
-
schemas: {},
|
14652
|
-
tables: {}
|
14653
|
-
},
|
14654
14678
|
outFolder,
|
14655
|
-
config.breakpoints,
|
14656
|
-
"custom"
|
14657
|
-
);
|
14679
|
+
breakpoints: config.breakpoints,
|
14680
|
+
type: "custom"
|
14681
|
+
});
|
14658
14682
|
return;
|
14659
14683
|
}
|
14660
14684
|
const squashedPrev = squashPgScheme(validatedPrev);
|
@@ -14666,14 +14690,13 @@ var init_migrate = __esm({
|
|
14666
14690
|
validatedPrev,
|
14667
14691
|
validatedCur
|
14668
14692
|
);
|
14669
|
-
writeResult(
|
14693
|
+
writeResult({
|
14670
14694
|
cur,
|
14671
14695
|
sqlStatements,
|
14672
14696
|
journal,
|
14673
|
-
_meta,
|
14674
14697
|
outFolder,
|
14675
|
-
config.breakpoints
|
14676
|
-
);
|
14698
|
+
breakpoints: config.breakpoints
|
14699
|
+
});
|
14677
14700
|
} catch (e) {
|
14678
14701
|
console.error(e);
|
14679
14702
|
}
|
@@ -14767,19 +14790,14 @@ var init_migrate = __esm({
|
|
14767
14790
|
const validatedPrev = mysqlSchema.parse(prev);
|
14768
14791
|
const validatedCur = mysqlSchema.parse(cur);
|
14769
14792
|
if (config.custom) {
|
14770
|
-
writeResult(
|
14771
|
-
custom,
|
14772
|
-
[],
|
14793
|
+
writeResult({
|
14794
|
+
cur: custom,
|
14795
|
+
sqlStatements: [],
|
14773
14796
|
journal,
|
14774
|
-
{
|
14775
|
-
columns: {},
|
14776
|
-
schemas: {},
|
14777
|
-
tables: {}
|
14778
|
-
},
|
14779
14797
|
outFolder,
|
14780
|
-
config.breakpoints,
|
14781
|
-
"custom"
|
14782
|
-
);
|
14798
|
+
breakpoints: config.breakpoints,
|
14799
|
+
type: "custom"
|
14800
|
+
});
|
14783
14801
|
return;
|
14784
14802
|
}
|
14785
14803
|
const squashedPrev = squashMysqlScheme(validatedPrev);
|
@@ -14791,14 +14809,14 @@ var init_migrate = __esm({
|
|
14791
14809
|
validatedPrev,
|
14792
14810
|
validatedCur
|
14793
14811
|
);
|
14794
|
-
writeResult(
|
14812
|
+
writeResult({
|
14795
14813
|
cur,
|
14796
14814
|
sqlStatements,
|
14797
14815
|
journal,
|
14798
14816
|
_meta,
|
14799
14817
|
outFolder,
|
14800
|
-
config.breakpoints
|
14801
|
-
);
|
14818
|
+
breakpoints: config.breakpoints
|
14819
|
+
});
|
14802
14820
|
} catch (e) {
|
14803
14821
|
console.error(e);
|
14804
14822
|
}
|
@@ -14816,19 +14834,14 @@ var init_migrate = __esm({
|
|
14816
14834
|
const validatedPrev = sqliteSchema.parse(prev);
|
14817
14835
|
const validatedCur = sqliteSchema.parse(cur);
|
14818
14836
|
if (config.custom) {
|
14819
|
-
writeResult(
|
14820
|
-
custom,
|
14821
|
-
[],
|
14837
|
+
writeResult({
|
14838
|
+
cur: custom,
|
14839
|
+
sqlStatements: [],
|
14822
14840
|
journal,
|
14823
|
-
{
|
14824
|
-
columns: {},
|
14825
|
-
schemas: {},
|
14826
|
-
tables: {}
|
14827
|
-
},
|
14828
14841
|
outFolder,
|
14829
|
-
config.breakpoints,
|
14830
|
-
"custom"
|
14831
|
-
);
|
14842
|
+
breakpoints: config.breakpoints,
|
14843
|
+
type: "custom"
|
14844
|
+
});
|
14832
14845
|
return;
|
14833
14846
|
}
|
14834
14847
|
const squashedPrev = squashSqliteScheme(validatedPrev);
|
@@ -14838,14 +14851,14 @@ var init_migrate = __esm({
|
|
14838
14851
|
squashedCur,
|
14839
14852
|
"sqlite"
|
14840
14853
|
);
|
14841
|
-
writeResult(
|
14854
|
+
writeResult({
|
14842
14855
|
cur,
|
14843
14856
|
sqlStatements,
|
14844
14857
|
journal,
|
14845
14858
|
_meta,
|
14846
14859
|
outFolder,
|
14847
|
-
config.breakpoints
|
14848
|
-
);
|
14860
|
+
breakpoints: config.breakpoints
|
14861
|
+
});
|
14849
14862
|
} catch (e) {
|
14850
14863
|
console.error(e);
|
14851
14864
|
}
|
@@ -15033,7 +15046,20 @@ var init_migrate = __esm({
|
|
15033
15046
|
return result;
|
15034
15047
|
};
|
15035
15048
|
BREAKPOINT = "--> statement-breakpoint\n";
|
15036
|
-
writeResult = (
|
15049
|
+
writeResult = ({
|
15050
|
+
cur,
|
15051
|
+
sqlStatements,
|
15052
|
+
journal,
|
15053
|
+
_meta = {
|
15054
|
+
columns: {},
|
15055
|
+
schemas: {},
|
15056
|
+
tables: {}
|
15057
|
+
},
|
15058
|
+
outFolder,
|
15059
|
+
breakpoints,
|
15060
|
+
bundle = false,
|
15061
|
+
type = "none"
|
15062
|
+
}) => {
|
15037
15063
|
if (type === "none") {
|
15038
15064
|
console.log(schema(cur));
|
15039
15065
|
if (sqlStatements.length === 0) {
|
@@ -15074,6 +15100,10 @@ ${sql2}
|
|
15074
15100
|
});
|
15075
15101
|
import_fs3.default.writeFileSync(metaJournal, JSON.stringify(journal, null, 2));
|
15076
15102
|
import_fs3.default.writeFileSync(`${outFolder}/${tag}.sql`, sql2);
|
15103
|
+
if (bundle) {
|
15104
|
+
const js = embeddedMigrations(journal);
|
15105
|
+
import_fs3.default.writeFileSync(`${outFolder}/migrations.js`, js);
|
15106
|
+
}
|
15077
15107
|
(0, import_hanji3.render)(
|
15078
15108
|
`[${source_default.green(
|
15079
15109
|
"\u2713"
|
@@ -15082,6 +15112,22 @@ ${sql2}
|
|
15082
15112
|
)} \u{1F680}`
|
15083
15113
|
);
|
15084
15114
|
};
|
15115
|
+
embeddedMigrations = (journal) => {
|
15116
|
+
let content = "import journal from './meta/_journal.json';\n";
|
15117
|
+
journal.entries.forEach((entry) => {
|
15118
|
+
content += `import m${entry.idx.toString().padStart(4, "0")} from './${entry.tag}.sql';
|
15119
|
+
`;
|
15120
|
+
});
|
15121
|
+
content += `
|
15122
|
+
export default {
|
15123
|
+
journal,
|
15124
|
+
migrations: {
|
15125
|
+
${journal.entries.map((it) => `m${it.idx.toString().padStart(4, "0")}`).join(",\n")}
|
15126
|
+
}
|
15127
|
+
}
|
15128
|
+
`;
|
15129
|
+
return content;
|
15130
|
+
};
|
15085
15131
|
prepareSnapshotFolderName = () => {
|
15086
15132
|
const now = /* @__PURE__ */ new Date();
|
15087
15133
|
return `${now.getFullYear()}${two(now.getUTCMonth() + 1)}${two(
|
@@ -15176,7 +15222,7 @@ var init_sqlgenerator = __esm({
|
|
15176
15222
|
if (typeof compositePKs !== "undefined" && compositePKs.length > 0) {
|
15177
15223
|
statement += ",\n";
|
15178
15224
|
const compositePK4 = PgSquasher.unsquashPK(compositePKs[0]);
|
15179
|
-
statement += ` CONSTRAINT ${st.compositePkName} PRIMARY KEY("${compositePK4.columns.join(`","`)}")`;
|
15225
|
+
statement += ` CONSTRAINT "${st.compositePkName}" PRIMARY KEY("${compositePK4.columns.join(`","`)}")`;
|
15180
15226
|
}
|
15181
15227
|
if (typeof uniqueConstraints !== "undefined" && uniqueConstraints.length > 0) {
|
15182
15228
|
for (const uniqueConstraint4 of uniqueConstraints) {
|
@@ -17573,9 +17619,9 @@ var init_snapshotsDiffer = __esm({
|
|
17573
17619
|
}
|
17574
17620
|
jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
|
17575
17621
|
jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
|
17576
|
-
jsonStatements.push(...jsonAddedCompositePKs);
|
17577
|
-
jsonStatements.push(...jsonTableAlternations.alterColumns);
|
17578
17622
|
jsonStatements.push(...jsonDeletedCompositePKs);
|
17623
|
+
jsonStatements.push(...jsonTableAlternations.alterColumns);
|
17624
|
+
jsonStatements.push(...jsonAddedCompositePKs);
|
17579
17625
|
if (dialect6 === "mysql") {
|
17580
17626
|
jsonStatements.push(...jsonAddedUniqueConstraints);
|
17581
17627
|
jsonStatements.push(...jsonDeletedUniqueConstraints);
|