drizzle-kit 0.20.7-05d4dfb → 0.20.7-2e40056
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/bin.cjs +222 -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 +99 -49
|
@@ -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
|
});
|
|
@@ -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,
|
|
@@ -14603,6 +14632,7 @@ var init_words = __esm({
|
|
|
14603
14632
|
var migrate_exports = {};
|
|
14604
14633
|
__export(migrate_exports, {
|
|
14605
14634
|
BREAKPOINT: () => BREAKPOINT,
|
|
14635
|
+
embeddedMigrations: () => embeddedMigrations,
|
|
14606
14636
|
prepareAndMigrateMySql: () => prepareAndMigrateMySql,
|
|
14607
14637
|
prepareAndMigratePg: () => prepareAndMigratePg,
|
|
14608
14638
|
prepareAndMigrateSqlite: () => prepareAndMigrateSqlite,
|
|
@@ -14613,7 +14643,7 @@ __export(migrate_exports, {
|
|
|
14613
14643
|
prepareSnapshotFolderName: () => prepareSnapshotFolderName,
|
|
14614
14644
|
writeResult: () => writeResult
|
|
14615
14645
|
});
|
|
14616
|
-
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;
|
|
14617
14647
|
var init_migrate = __esm({
|
|
14618
14648
|
"src/cli/commands/migrate.ts"() {
|
|
14619
14649
|
import_fs3 = __toESM(require("fs"));
|
|
@@ -14642,19 +14672,14 @@ var init_migrate = __esm({
|
|
|
14642
14672
|
const validatedPrev = pgSchema.parse(prev);
|
|
14643
14673
|
const validatedCur = pgSchema.parse(cur);
|
|
14644
14674
|
if (config.custom) {
|
|
14645
|
-
writeResult(
|
|
14646
|
-
custom,
|
|
14647
|
-
[],
|
|
14675
|
+
writeResult({
|
|
14676
|
+
cur: custom,
|
|
14677
|
+
sqlStatements: [],
|
|
14648
14678
|
journal,
|
|
14649
|
-
{
|
|
14650
|
-
columns: {},
|
|
14651
|
-
schemas: {},
|
|
14652
|
-
tables: {}
|
|
14653
|
-
},
|
|
14654
14679
|
outFolder,
|
|
14655
|
-
config.breakpoints,
|
|
14656
|
-
"custom"
|
|
14657
|
-
);
|
|
14680
|
+
breakpoints: config.breakpoints,
|
|
14681
|
+
type: "custom"
|
|
14682
|
+
});
|
|
14658
14683
|
return;
|
|
14659
14684
|
}
|
|
14660
14685
|
const squashedPrev = squashPgScheme(validatedPrev);
|
|
@@ -14666,14 +14691,13 @@ var init_migrate = __esm({
|
|
|
14666
14691
|
validatedPrev,
|
|
14667
14692
|
validatedCur
|
|
14668
14693
|
);
|
|
14669
|
-
writeResult(
|
|
14694
|
+
writeResult({
|
|
14670
14695
|
cur,
|
|
14671
14696
|
sqlStatements,
|
|
14672
14697
|
journal,
|
|
14673
|
-
_meta,
|
|
14674
14698
|
outFolder,
|
|
14675
|
-
config.breakpoints
|
|
14676
|
-
);
|
|
14699
|
+
breakpoints: config.breakpoints
|
|
14700
|
+
});
|
|
14677
14701
|
} catch (e) {
|
|
14678
14702
|
console.error(e);
|
|
14679
14703
|
}
|
|
@@ -14767,19 +14791,14 @@ var init_migrate = __esm({
|
|
|
14767
14791
|
const validatedPrev = mysqlSchema.parse(prev);
|
|
14768
14792
|
const validatedCur = mysqlSchema.parse(cur);
|
|
14769
14793
|
if (config.custom) {
|
|
14770
|
-
writeResult(
|
|
14771
|
-
custom,
|
|
14772
|
-
[],
|
|
14794
|
+
writeResult({
|
|
14795
|
+
cur: custom,
|
|
14796
|
+
sqlStatements: [],
|
|
14773
14797
|
journal,
|
|
14774
|
-
{
|
|
14775
|
-
columns: {},
|
|
14776
|
-
schemas: {},
|
|
14777
|
-
tables: {}
|
|
14778
|
-
},
|
|
14779
14798
|
outFolder,
|
|
14780
|
-
config.breakpoints,
|
|
14781
|
-
"custom"
|
|
14782
|
-
);
|
|
14799
|
+
breakpoints: config.breakpoints,
|
|
14800
|
+
type: "custom"
|
|
14801
|
+
});
|
|
14783
14802
|
return;
|
|
14784
14803
|
}
|
|
14785
14804
|
const squashedPrev = squashMysqlScheme(validatedPrev);
|
|
@@ -14791,14 +14810,14 @@ var init_migrate = __esm({
|
|
|
14791
14810
|
validatedPrev,
|
|
14792
14811
|
validatedCur
|
|
14793
14812
|
);
|
|
14794
|
-
writeResult(
|
|
14813
|
+
writeResult({
|
|
14795
14814
|
cur,
|
|
14796
14815
|
sqlStatements,
|
|
14797
14816
|
journal,
|
|
14798
14817
|
_meta,
|
|
14799
14818
|
outFolder,
|
|
14800
|
-
config.breakpoints
|
|
14801
|
-
);
|
|
14819
|
+
breakpoints: config.breakpoints
|
|
14820
|
+
});
|
|
14802
14821
|
} catch (e) {
|
|
14803
14822
|
console.error(e);
|
|
14804
14823
|
}
|
|
@@ -14816,19 +14835,15 @@ var init_migrate = __esm({
|
|
|
14816
14835
|
const validatedPrev = sqliteSchema.parse(prev);
|
|
14817
14836
|
const validatedCur = sqliteSchema.parse(cur);
|
|
14818
14837
|
if (config.custom) {
|
|
14819
|
-
writeResult(
|
|
14820
|
-
custom,
|
|
14821
|
-
[],
|
|
14838
|
+
writeResult({
|
|
14839
|
+
cur: custom,
|
|
14840
|
+
sqlStatements: [],
|
|
14822
14841
|
journal,
|
|
14823
|
-
{
|
|
14824
|
-
columns: {},
|
|
14825
|
-
schemas: {},
|
|
14826
|
-
tables: {}
|
|
14827
|
-
},
|
|
14828
14842
|
outFolder,
|
|
14829
|
-
config.breakpoints,
|
|
14830
|
-
|
|
14831
|
-
|
|
14843
|
+
breakpoints: config.breakpoints,
|
|
14844
|
+
bundle: config.bundle,
|
|
14845
|
+
type: "custom"
|
|
14846
|
+
});
|
|
14832
14847
|
return;
|
|
14833
14848
|
}
|
|
14834
14849
|
const squashedPrev = squashSqliteScheme(validatedPrev);
|
|
@@ -14838,14 +14853,15 @@ var init_migrate = __esm({
|
|
|
14838
14853
|
squashedCur,
|
|
14839
14854
|
"sqlite"
|
|
14840
14855
|
);
|
|
14841
|
-
writeResult(
|
|
14856
|
+
writeResult({
|
|
14842
14857
|
cur,
|
|
14843
14858
|
sqlStatements,
|
|
14844
14859
|
journal,
|
|
14845
14860
|
_meta,
|
|
14846
14861
|
outFolder,
|
|
14847
|
-
config.breakpoints
|
|
14848
|
-
|
|
14862
|
+
breakpoints: config.breakpoints,
|
|
14863
|
+
bundle: config.bundle
|
|
14864
|
+
});
|
|
14849
14865
|
} catch (e) {
|
|
14850
14866
|
console.error(e);
|
|
14851
14867
|
}
|
|
@@ -15033,7 +15049,20 @@ var init_migrate = __esm({
|
|
|
15033
15049
|
return result;
|
|
15034
15050
|
};
|
|
15035
15051
|
BREAKPOINT = "--> statement-breakpoint\n";
|
|
15036
|
-
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
|
+
}) => {
|
|
15037
15066
|
if (type === "none") {
|
|
15038
15067
|
console.log(schema(cur));
|
|
15039
15068
|
if (sqlStatements.length === 0) {
|
|
@@ -15074,6 +15103,10 @@ ${sql2}
|
|
|
15074
15103
|
});
|
|
15075
15104
|
import_fs3.default.writeFileSync(metaJournal, JSON.stringify(journal, null, 2));
|
|
15076
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
|
+
}
|
|
15077
15110
|
(0, import_hanji3.render)(
|
|
15078
15111
|
`[${source_default.green(
|
|
15079
15112
|
"\u2713"
|
|
@@ -15082,6 +15115,23 @@ ${sql2}
|
|
|
15082
15115
|
)} \u{1F680}`
|
|
15083
15116
|
);
|
|
15084
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
|
+
};
|
|
15085
15135
|
prepareSnapshotFolderName = () => {
|
|
15086
15136
|
const now = /* @__PURE__ */ new Date();
|
|
15087
15137
|
return `${now.getFullYear()}${two(now.getUTCMonth() + 1)}${two(
|
|
@@ -15176,7 +15226,7 @@ var init_sqlgenerator = __esm({
|
|
|
15176
15226
|
if (typeof compositePKs !== "undefined" && compositePKs.length > 0) {
|
|
15177
15227
|
statement += ",\n";
|
|
15178
15228
|
const compositePK4 = PgSquasher.unsquashPK(compositePKs[0]);
|
|
15179
|
-
statement += ` CONSTRAINT ${st.compositePkName} PRIMARY KEY("${compositePK4.columns.join(`","`)}")`;
|
|
15229
|
+
statement += ` CONSTRAINT "${st.compositePkName}" PRIMARY KEY("${compositePK4.columns.join(`","`)}")`;
|
|
15180
15230
|
}
|
|
15181
15231
|
if (typeof uniqueConstraints !== "undefined" && uniqueConstraints.length > 0) {
|
|
15182
15232
|
for (const uniqueConstraint4 of uniqueConstraints) {
|
|
@@ -17573,9 +17623,9 @@ var init_snapshotsDiffer = __esm({
|
|
|
17573
17623
|
}
|
|
17574
17624
|
jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
|
|
17575
17625
|
jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
|
|
17576
|
-
jsonStatements.push(...jsonAddedCompositePKs);
|
|
17577
|
-
jsonStatements.push(...jsonTableAlternations.alterColumns);
|
|
17578
17626
|
jsonStatements.push(...jsonDeletedCompositePKs);
|
|
17627
|
+
jsonStatements.push(...jsonTableAlternations.alterColumns);
|
|
17628
|
+
jsonStatements.push(...jsonAddedCompositePKs);
|
|
17579
17629
|
if (dialect6 === "mysql") {
|
|
17580
17630
|
jsonStatements.push(...jsonAddedUniqueConstraints);
|
|
17581
17631
|
jsonStatements.push(...jsonDeletedUniqueConstraints);
|