drizzle-kit 0.20.7 → 0.20.8
Sign up to get free protection for your applications and to get access to all the features.
- package/bin.cjs +203 -144
- package/cli/commands/migrate.d.ts +11 -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 +79 -48
@@ -256,5 +256,15 @@ 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;
|
269
|
+
export declare const embeddedMigrations: (journal: Journal) => string;
|
260
270
|
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
|
});
|
@@ -11721,9 +11731,9 @@ We have encountered a collision between the index name on columns ${source_defau
|
|
11721
11731
|
}
|
11722
11732
|
try {
|
11723
11733
|
const fks = await db.execute(
|
11724
|
-
`SELECT INFORMATION_SCHEMA.KEY_COLUMN_USAGE.TABLE_SCHEMA,INFORMATION_SCHEMA.KEY_COLUMN_USAGE.TABLE_NAME,INFORMATION_SCHEMA.KEY_COLUMN_USAGE.CONSTRAINT_NAME,INFORMATION_SCHEMA.KEY_COLUMN_USAGE.COLUMN_NAME,INFORMATION_SCHEMA.KEY_COLUMN_USAGE.REFERENCED_TABLE_SCHEMA,INFORMATION_SCHEMA.KEY_COLUMN_USAGE.REFERENCED_TABLE_NAME, INFORMATION_SCHEMA.KEY_COLUMN_USAGE.REFERENCED_COLUMN_NAME,
|
11734
|
+
`SELECT INFORMATION_SCHEMA.KEY_COLUMN_USAGE.TABLE_SCHEMA,INFORMATION_SCHEMA.KEY_COLUMN_USAGE.TABLE_NAME,INFORMATION_SCHEMA.KEY_COLUMN_USAGE.CONSTRAINT_NAME,INFORMATION_SCHEMA.KEY_COLUMN_USAGE.COLUMN_NAME,INFORMATION_SCHEMA.KEY_COLUMN_USAGE.REFERENCED_TABLE_SCHEMA,INFORMATION_SCHEMA.KEY_COLUMN_USAGE.REFERENCED_TABLE_NAME, INFORMATION_SCHEMA.KEY_COLUMN_USAGE.REFERENCED_COLUMN_NAME,INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS.UPDATE_RULE, INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS.DELETE_RULE
|
11725
11735
|
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
|
11726
|
-
LEFT JOIN
|
11736
|
+
LEFT JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS on INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS.CONSTRAINT_NAME = INFORMATION_SCHEMA.KEY_COLUMN_USAGE.CONSTRAINT_NAME
|
11727
11737
|
WHERE INFORMATION_SCHEMA.KEY_COLUMN_USAGE.TABLE_SCHEMA = ? AND INFORMATION_SCHEMA.KEY_COLUMN_USAGE.CONSTRAINT_NAME != 'PRIMARY' and INFORMATION_SCHEMA.KEY_COLUMN_USAGE.REFERENCED_TABLE_NAME is not null;
|
11728
11738
|
`,
|
11729
11739
|
[inputSchema]
|
@@ -14622,6 +14632,7 @@ var init_words = __esm({
|
|
14622
14632
|
var migrate_exports = {};
|
14623
14633
|
__export(migrate_exports, {
|
14624
14634
|
BREAKPOINT: () => BREAKPOINT,
|
14635
|
+
embeddedMigrations: () => embeddedMigrations,
|
14625
14636
|
prepareAndMigrateMySql: () => prepareAndMigrateMySql,
|
14626
14637
|
prepareAndMigratePg: () => prepareAndMigratePg,
|
14627
14638
|
prepareAndMigrateSqlite: () => prepareAndMigrateSqlite,
|
@@ -14632,7 +14643,7 @@ __export(migrate_exports, {
|
|
14632
14643
|
prepareSnapshotFolderName: () => prepareSnapshotFolderName,
|
14633
14644
|
writeResult: () => writeResult
|
14634
14645
|
});
|
14635
|
-
var import_fs3, import_path2, import_hanji3, prepareAndMigratePg, prepareMySQLPush, prepareSQLitePush, preparePgPush, prepareAndMigrateMySql, prepareAndMigrateSqlite, prepareSQL, promptColumnsConflicts, promptTablesConflict, promptSchemasConflict, BREAKPOINT, writeResult, prepareSnapshotFolderName, two;
|
14646
|
+
var import_fs3, import_path2, import_hanji3, prepareAndMigratePg, prepareMySQLPush, prepareSQLitePush, preparePgPush, prepareAndMigrateMySql, prepareAndMigrateSqlite, prepareSQL, promptColumnsConflicts, promptTablesConflict, promptSchemasConflict, BREAKPOINT, writeResult, embeddedMigrations, prepareSnapshotFolderName, two;
|
14636
14647
|
var init_migrate = __esm({
|
14637
14648
|
"src/cli/commands/migrate.ts"() {
|
14638
14649
|
import_fs3 = __toESM(require("fs"));
|
@@ -14661,19 +14672,14 @@ var init_migrate = __esm({
|
|
14661
14672
|
const validatedPrev = pgSchema.parse(prev);
|
14662
14673
|
const validatedCur = pgSchema.parse(cur);
|
14663
14674
|
if (config.custom) {
|
14664
|
-
writeResult(
|
14665
|
-
custom,
|
14666
|
-
[],
|
14675
|
+
writeResult({
|
14676
|
+
cur: custom,
|
14677
|
+
sqlStatements: [],
|
14667
14678
|
journal,
|
14668
|
-
{
|
14669
|
-
columns: {},
|
14670
|
-
schemas: {},
|
14671
|
-
tables: {}
|
14672
|
-
},
|
14673
14679
|
outFolder,
|
14674
|
-
config.breakpoints,
|
14675
|
-
"custom"
|
14676
|
-
);
|
14680
|
+
breakpoints: config.breakpoints,
|
14681
|
+
type: "custom"
|
14682
|
+
});
|
14677
14683
|
return;
|
14678
14684
|
}
|
14679
14685
|
const squashedPrev = squashPgScheme(validatedPrev);
|
@@ -14685,14 +14691,13 @@ var init_migrate = __esm({
|
|
14685
14691
|
validatedPrev,
|
14686
14692
|
validatedCur
|
14687
14693
|
);
|
14688
|
-
writeResult(
|
14694
|
+
writeResult({
|
14689
14695
|
cur,
|
14690
14696
|
sqlStatements,
|
14691
14697
|
journal,
|
14692
|
-
_meta,
|
14693
14698
|
outFolder,
|
14694
|
-
config.breakpoints
|
14695
|
-
);
|
14699
|
+
breakpoints: config.breakpoints
|
14700
|
+
});
|
14696
14701
|
} catch (e) {
|
14697
14702
|
console.error(e);
|
14698
14703
|
}
|
@@ -14786,19 +14791,14 @@ var init_migrate = __esm({
|
|
14786
14791
|
const validatedPrev = mysqlSchema.parse(prev);
|
14787
14792
|
const validatedCur = mysqlSchema.parse(cur);
|
14788
14793
|
if (config.custom) {
|
14789
|
-
writeResult(
|
14790
|
-
custom,
|
14791
|
-
[],
|
14794
|
+
writeResult({
|
14795
|
+
cur: custom,
|
14796
|
+
sqlStatements: [],
|
14792
14797
|
journal,
|
14793
|
-
{
|
14794
|
-
columns: {},
|
14795
|
-
schemas: {},
|
14796
|
-
tables: {}
|
14797
|
-
},
|
14798
14798
|
outFolder,
|
14799
|
-
config.breakpoints,
|
14800
|
-
"custom"
|
14801
|
-
);
|
14799
|
+
breakpoints: config.breakpoints,
|
14800
|
+
type: "custom"
|
14801
|
+
});
|
14802
14802
|
return;
|
14803
14803
|
}
|
14804
14804
|
const squashedPrev = squashMysqlScheme(validatedPrev);
|
@@ -14810,14 +14810,14 @@ var init_migrate = __esm({
|
|
14810
14810
|
validatedPrev,
|
14811
14811
|
validatedCur
|
14812
14812
|
);
|
14813
|
-
writeResult(
|
14813
|
+
writeResult({
|
14814
14814
|
cur,
|
14815
14815
|
sqlStatements,
|
14816
14816
|
journal,
|
14817
14817
|
_meta,
|
14818
14818
|
outFolder,
|
14819
|
-
config.breakpoints
|
14820
|
-
);
|
14819
|
+
breakpoints: config.breakpoints
|
14820
|
+
});
|
14821
14821
|
} catch (e) {
|
14822
14822
|
console.error(e);
|
14823
14823
|
}
|
@@ -14835,19 +14835,15 @@ var init_migrate = __esm({
|
|
14835
14835
|
const validatedPrev = sqliteSchema.parse(prev);
|
14836
14836
|
const validatedCur = sqliteSchema.parse(cur);
|
14837
14837
|
if (config.custom) {
|
14838
|
-
writeResult(
|
14839
|
-
custom,
|
14840
|
-
[],
|
14838
|
+
writeResult({
|
14839
|
+
cur: custom,
|
14840
|
+
sqlStatements: [],
|
14841
14841
|
journal,
|
14842
|
-
{
|
14843
|
-
columns: {},
|
14844
|
-
schemas: {},
|
14845
|
-
tables: {}
|
14846
|
-
},
|
14847
14842
|
outFolder,
|
14848
|
-
config.breakpoints,
|
14849
|
-
|
14850
|
-
|
14843
|
+
breakpoints: config.breakpoints,
|
14844
|
+
bundle: config.bundle,
|
14845
|
+
type: "custom"
|
14846
|
+
});
|
14851
14847
|
return;
|
14852
14848
|
}
|
14853
14849
|
const squashedPrev = squashSqliteScheme(validatedPrev);
|
@@ -14857,14 +14853,15 @@ var init_migrate = __esm({
|
|
14857
14853
|
squashedCur,
|
14858
14854
|
"sqlite"
|
14859
14855
|
);
|
14860
|
-
writeResult(
|
14856
|
+
writeResult({
|
14861
14857
|
cur,
|
14862
14858
|
sqlStatements,
|
14863
14859
|
journal,
|
14864
14860
|
_meta,
|
14865
14861
|
outFolder,
|
14866
|
-
config.breakpoints
|
14867
|
-
|
14862
|
+
breakpoints: config.breakpoints,
|
14863
|
+
bundle: config.bundle
|
14864
|
+
});
|
14868
14865
|
} catch (e) {
|
14869
14866
|
console.error(e);
|
14870
14867
|
}
|
@@ -15052,7 +15049,20 @@ var init_migrate = __esm({
|
|
15052
15049
|
return result;
|
15053
15050
|
};
|
15054
15051
|
BREAKPOINT = "--> statement-breakpoint\n";
|
15055
|
-
writeResult = (
|
15052
|
+
writeResult = ({
|
15053
|
+
cur,
|
15054
|
+
sqlStatements,
|
15055
|
+
journal,
|
15056
|
+
_meta = {
|
15057
|
+
columns: {},
|
15058
|
+
schemas: {},
|
15059
|
+
tables: {}
|
15060
|
+
},
|
15061
|
+
outFolder,
|
15062
|
+
breakpoints,
|
15063
|
+
bundle = false,
|
15064
|
+
type = "none"
|
15065
|
+
}) => {
|
15056
15066
|
if (type === "none") {
|
15057
15067
|
console.log(schema(cur));
|
15058
15068
|
if (sqlStatements.length === 0) {
|
@@ -15093,6 +15103,10 @@ ${sql2}
|
|
15093
15103
|
});
|
15094
15104
|
import_fs3.default.writeFileSync(metaJournal, JSON.stringify(journal, null, 2));
|
15095
15105
|
import_fs3.default.writeFileSync(`${outFolder}/${tag}.sql`, sql2);
|
15106
|
+
if (bundle) {
|
15107
|
+
const js = embeddedMigrations(journal);
|
15108
|
+
import_fs3.default.writeFileSync(`${outFolder}/migrations.js`, js);
|
15109
|
+
}
|
15096
15110
|
(0, import_hanji3.render)(
|
15097
15111
|
`[${source_default.green(
|
15098
15112
|
"\u2713"
|
@@ -15101,6 +15115,23 @@ ${sql2}
|
|
15101
15115
|
)} \u{1F680}`
|
15102
15116
|
);
|
15103
15117
|
};
|
15118
|
+
embeddedMigrations = (journal) => {
|
15119
|
+
let content = "// This file is required for Expo/React Native SQLite migrations - https://orm.drizzle.team/quick-sqlite/expo\n\n";
|
15120
|
+
content += "import journal from './meta/_journal.json';\n";
|
15121
|
+
journal.entries.forEach((entry) => {
|
15122
|
+
content += `import m${entry.idx.toString().padStart(4, "0")} from './${entry.tag}.sql';
|
15123
|
+
`;
|
15124
|
+
});
|
15125
|
+
content += `
|
15126
|
+
export default {
|
15127
|
+
journal,
|
15128
|
+
migrations: {
|
15129
|
+
${journal.entries.map((it) => `m${it.idx.toString().padStart(4, "0")}`).join(",\n")}
|
15130
|
+
}
|
15131
|
+
}
|
15132
|
+
`;
|
15133
|
+
return content;
|
15134
|
+
};
|
15104
15135
|
prepareSnapshotFolderName = () => {
|
15105
15136
|
const now = /* @__PURE__ */ new Date();
|
15106
15137
|
return `${now.getFullYear()}${two(now.getUTCMonth() + 1)}${two(
|