drizzle-kit 0.20.7-02055e2 → 0.20.7-0650f86

Sign up to get free protection for your applications and to get access to all the features.
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: (driver) => withStyle.error(`"url" is a required option for driver "${driver}". You can read more about drizzle.config: https://orm.drizzle.team/kit-docs/config-reference`),
11570
- authToken: (driver) => withStyle.error(
11571
- `"authToken" is a required option for driver "${driver}". You can read more about drizzle.config: https://orm.drizzle.team/kit-docs/config-reference`
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: {},
@@ -14914,7 +14925,7 @@ __export(migrate_exports, {
14914
14925
  prepareSnapshotFolderName: () => prepareSnapshotFolderName,
14915
14926
  writeResult: () => writeResult
14916
14927
  });
14917
- 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;
14918
14929
  var init_migrate = __esm({
14919
14930
  "src/cli/commands/migrate.ts"() {
14920
14931
  import_fs4 = __toESM(require("fs"));
@@ -14943,19 +14954,14 @@ var init_migrate = __esm({
14943
14954
  const validatedPrev = pgSchema.parse(prev);
14944
14955
  const validatedCur = pgSchema.parse(cur);
14945
14956
  if (config.custom) {
14946
- writeResult(
14947
- custom,
14948
- [],
14957
+ writeResult({
14958
+ cur: custom,
14959
+ sqlStatements: [],
14949
14960
  journal,
14950
- {
14951
- columns: {},
14952
- schemas: {},
14953
- tables: {}
14954
- },
14955
14961
  outFolder,
14956
- config.breakpoints,
14957
- "custom"
14958
- );
14962
+ breakpoints: config.breakpoints,
14963
+ type: "custom"
14964
+ });
14959
14965
  return;
14960
14966
  }
14961
14967
  const squashedPrev = squashPgScheme(validatedPrev);
@@ -14967,14 +14973,13 @@ var init_migrate = __esm({
14967
14973
  validatedPrev,
14968
14974
  validatedCur
14969
14975
  );
14970
- writeResult(
14976
+ writeResult({
14971
14977
  cur,
14972
14978
  sqlStatements,
14973
14979
  journal,
14974
- _meta,
14975
14980
  outFolder,
14976
- config.breakpoints
14977
- );
14981
+ breakpoints: config.breakpoints
14982
+ });
14978
14983
  } catch (e) {
14979
14984
  console.error(e);
14980
14985
  }
@@ -15068,19 +15073,14 @@ var init_migrate = __esm({
15068
15073
  const validatedPrev = mysqlSchema.parse(prev);
15069
15074
  const validatedCur = mysqlSchema.parse(cur);
15070
15075
  if (config.custom) {
15071
- writeResult(
15072
- custom,
15073
- [],
15076
+ writeResult({
15077
+ cur: custom,
15078
+ sqlStatements: [],
15074
15079
  journal,
15075
- {
15076
- columns: {},
15077
- schemas: {},
15078
- tables: {}
15079
- },
15080
15080
  outFolder,
15081
- config.breakpoints,
15082
- "custom"
15083
- );
15081
+ breakpoints: config.breakpoints,
15082
+ type: "custom"
15083
+ });
15084
15084
  return;
15085
15085
  }
15086
15086
  const squashedPrev = squashMysqlScheme(validatedPrev);
@@ -15092,14 +15092,14 @@ var init_migrate = __esm({
15092
15092
  validatedPrev,
15093
15093
  validatedCur
15094
15094
  );
15095
- writeResult(
15095
+ writeResult({
15096
15096
  cur,
15097
15097
  sqlStatements,
15098
15098
  journal,
15099
15099
  _meta,
15100
15100
  outFolder,
15101
- config.breakpoints
15102
- );
15101
+ breakpoints: config.breakpoints
15102
+ });
15103
15103
  } catch (e) {
15104
15104
  console.error(e);
15105
15105
  }
@@ -15117,19 +15117,14 @@ var init_migrate = __esm({
15117
15117
  const validatedPrev = sqliteSchema.parse(prev);
15118
15118
  const validatedCur = sqliteSchema.parse(cur);
15119
15119
  if (config.custom) {
15120
- writeResult(
15121
- custom,
15122
- [],
15120
+ writeResult({
15121
+ cur: custom,
15122
+ sqlStatements: [],
15123
15123
  journal,
15124
- {
15125
- columns: {},
15126
- schemas: {},
15127
- tables: {}
15128
- },
15129
15124
  outFolder,
15130
- config.breakpoints,
15131
- "custom"
15132
- );
15125
+ breakpoints: config.breakpoints,
15126
+ type: "custom"
15127
+ });
15133
15128
  return;
15134
15129
  }
15135
15130
  const squashedPrev = squashSqliteScheme(validatedPrev);
@@ -15139,14 +15134,14 @@ var init_migrate = __esm({
15139
15134
  squashedCur,
15140
15135
  "sqlite"
15141
15136
  );
15142
- writeResult(
15137
+ writeResult({
15143
15138
  cur,
15144
15139
  sqlStatements,
15145
15140
  journal,
15146
15141
  _meta,
15147
15142
  outFolder,
15148
- config.breakpoints
15149
- );
15143
+ breakpoints: config.breakpoints
15144
+ });
15150
15145
  } catch (e) {
15151
15146
  console.error(e);
15152
15147
  }
@@ -15334,7 +15329,20 @@ var init_migrate = __esm({
15334
15329
  return result;
15335
15330
  };
15336
15331
  BREAKPOINT = "--> statement-breakpoint\n";
15337
- writeResult = (cur, sqlStatements, journal, _meta, outFolder, breakpoints, type = "none") => {
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
+ }) => {
15338
15346
  if (type === "none") {
15339
15347
  console.log(schema(cur));
15340
15348
  if (sqlStatements.length === 0) {
@@ -15375,6 +15383,10 @@ ${sql2}
15375
15383
  });
15376
15384
  import_fs4.default.writeFileSync(metaJournal, JSON.stringify(journal, null, 2));
15377
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
+ }
15378
15390
  (0, import_hanji3.render)(
15379
15391
  `[${source_default.green(
15380
15392
  "\u2713"
@@ -15383,6 +15395,22 @@ ${sql2}
15383
15395
  )} \u{1F680}`
15384
15396
  );
15385
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
+ };
15386
15414
  prepareSnapshotFolderName = () => {
15387
15415
  const now = /* @__PURE__ */ new Date();
15388
15416
  return `${now.getFullYear()}${two(now.getUTCMonth() + 1)}${two(
@@ -60340,8 +60368,8 @@ var init_studioUtils = __esm({
60340
60368
  };
60341
60369
  };
60342
60370
  drizzleForSQLite = async (config, sqliteSchema2, relations4, ts, verbose) => {
60343
- const { driver, dbCredentials: creds } = config;
60344
- if (driver === "d1") {
60371
+ const { driver: driver2, dbCredentials: creds } = config;
60372
+ if (driver2 === "d1") {
60345
60373
  const { drizzle: drizzle2 } = await Promise.resolve().then(() => (init_driver(), driver_exports));
60346
60374
  const { execute: execute2 } = await Promise.resolve().then(() => (init_wrangler_client(), wrangler_client_exports));
60347
60375
  const db = drizzle2(execute2, creds.wranglerConfigPath, creds.dbName, {
@@ -60359,7 +60387,7 @@ var init_studioUtils = __esm({
60359
60387
  ts
60360
60388
  };
60361
60389
  }
60362
- if (driver === "better-sqlite") {
60390
+ if (driver2 === "better-sqlite") {
60363
60391
  assertPackages("better-sqlite3");
60364
60392
  const { drizzle: drizzle2 } = await import("drizzle-orm/better-sqlite3");
60365
60393
  const Database = await import("better-sqlite3");
@@ -60378,7 +60406,7 @@ var init_studioUtils = __esm({
60378
60406
  ts
60379
60407
  };
60380
60408
  }
60381
- if (driver === "libsql" || driver === "turso") {
60409
+ if (driver2 === "libsql" || driver2 === "turso") {
60382
60410
  assertPackages("@libsql/client");
60383
60411
  const { drizzle: drizzle2 } = await import("drizzle-orm/libsql");
60384
60412
  const { createClient } = await import("@libsql/client");
@@ -60402,7 +60430,7 @@ var init_studioUtils = __esm({
60402
60430
  ts
60403
60431
  };
60404
60432
  }
60405
- assertUnreachable(driver);
60433
+ assertUnreachable(driver2);
60406
60434
  };
60407
60435
  drizzleDb = async (drizzleConfig, models, logger) => {
60408
60436
  if (drizzleConfig.driver === "pg") {
@@ -61116,8 +61144,8 @@ var init_mysql = __esm({
61116
61144
  mysqlConnectionConfig
61117
61145
  );
61118
61146
  printCliConnectionIssues3 = (options) => {
61119
- const { driver, uri, host, database } = options || {};
61120
- if (driver !== "mysql2") {
61147
+ const { driver: driver2, uri, host, database } = options || {};
61148
+ if (driver2 !== "mysql2") {
61121
61149
  console.log(outputs.mysql.connection.driver());
61122
61150
  }
61123
61151
  if (!uri && (!host || !database)) {
@@ -61156,7 +61184,7 @@ var init_mysql = __esm({
61156
61184
  const {
61157
61185
  out,
61158
61186
  schema: schema4,
61159
- driver,
61187
+ driver: driver2,
61160
61188
  schemaFilter,
61161
61189
  tablesFilter,
61162
61190
  breakpoints,
@@ -61166,7 +61194,7 @@ var init_mysql = __esm({
61166
61194
  return {
61167
61195
  out,
61168
61196
  schema: schema4,
61169
- driver,
61197
+ driver: driver2,
61170
61198
  schemaFilter,
61171
61199
  tablesFilter,
61172
61200
  breakpoints,
@@ -61202,13 +61230,13 @@ var init_mysql = __esm({
61202
61230
  strict,
61203
61231
  verbose,
61204
61232
  schema: schema4,
61205
- driver,
61233
+ driver: driver2,
61206
61234
  schemaFilter,
61207
61235
  tablesFilter,
61208
61236
  ...rest
61209
61237
  } = cliRes.data;
61210
61238
  return {
61211
- driver,
61239
+ driver: driver2,
61212
61240
  schema: schema4,
61213
61241
  strict,
61214
61242
  verbose,
@@ -63651,9 +63679,9 @@ var studioCommand = new import_commander.Command("studio").option("--port <port>
63651
63679
  prepareSQLiteSchema: prepareSQLiteSchema2,
63652
63680
  drizzleForSQLite: drizzleForSQLite2
63653
63681
  } = await Promise.resolve().then(() => (init_studioUtils(), studioUtils_exports));
63654
- const { driver, schema: schemaPath } = drizzleConfig;
63682
+ const { driver: driver2, schema: schemaPath } = drizzleConfig;
63655
63683
  let setup;
63656
- if (driver === "pg") {
63684
+ if (driver2 === "pg") {
63657
63685
  const { schemaToTypeScript: schemaToTypeScript4, relationsToTypeScript: relationsToTypeScript2 } = await Promise.resolve().then(() => (init_introspect_pg(), introspect_pg_exports));
63658
63686
  const { serializePg: serializePg2 } = await Promise.resolve().then(() => (init_serializer(), serializer_exports));
63659
63687
  const { schema: schema4, relations: relations4 } = await preparePgSchema2(schemaPath);
@@ -63671,7 +63699,7 @@ var studioCommand = new import_commander.Command("studio").option("--port <port>
63671
63699
  },
63672
63700
  Boolean(options.verbose)
63673
63701
  );
63674
- } else if (driver === "mysql2") {
63702
+ } else if (driver2 === "mysql2") {
63675
63703
  const { schemaToTypeScript: schemaToTypeScript4 } = await Promise.resolve().then(() => (init_introspect_mysql(), introspect_mysql_exports));
63676
63704
  const { schema: schema4, relations: relations4 } = await prepareMySqlSchema2(schemaPath);
63677
63705
  const { serializeMySql: serializeMySql2 } = await Promise.resolve().then(() => (init_serializer(), serializer_exports));
@@ -63688,7 +63716,7 @@ var studioCommand = new import_commander.Command("studio").option("--port <port>
63688
63716
  },
63689
63717
  Boolean(options.verbose)
63690
63718
  );
63691
- } else if (driver === "better-sqlite" || driver === "d1" || driver === "libsql" || driver === "turso") {
63719
+ } else if (driver2 === "better-sqlite" || driver2 === "d1" || driver2 === "libsql" || driver2 === "turso") {
63692
63720
  const { schemaToTypeScript: schemaToTypeScript4 } = await Promise.resolve().then(() => (init_introspect_sqlite(), introspect_sqlite_exports));
63693
63721
  const { schema: schema4, relations: relations4 } = await prepareSQLiteSchema2(schemaPath);
63694
63722
  const { serializeSQLite: serializeSQLite2 } = await Promise.resolve().then(() => (init_serializer(), serializer_exports));
@@ -63706,7 +63734,7 @@ var studioCommand = new import_commander.Command("studio").option("--port <port>
63706
63734
  Boolean(options.verbose)
63707
63735
  );
63708
63736
  } else {
63709
- assertUnreachable(driver);
63737
+ assertUnreachable(driver2);
63710
63738
  }
63711
63739
  const qeueryEngine = (0, import_studio.queryEngineForSetup)(setup);
63712
63740
  const server = await (0, import_server.prepareServer)((_2) => {
@@ -63720,7 +63748,7 @@ var studioCommand = new import_commander.Command("studio").option("--port <port>
63720
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"
63721
63749
  )
63722
63750
  );
63723
- if (driver === "d1") {
63751
+ if (driver2 === "d1") {
63724
63752
  console.log(
63725
63753
  withStyle.fullWarning(
63726
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: CommonSchema, sqlStatements: string[], journal: Journal, _meta: any, outFolder: string, breakpoints: boolean, type?: "introspect" | "custom" | "none") => void;
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;
@@ -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;
@@ -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
@@ -101,5 +101,7 @@ export type Config = {
101
101
  wranglerConfigPath: string;
102
102
  dbName: string;
103
103
  };
104
+ } | {
105
+ driver: "expo";
104
106
  } | {});
105
107
  export declare function defineConfig(config: Config): Config;
package/index.d.ts CHANGED
@@ -101,5 +101,7 @@ export type Config = {
101
101
  wranglerConfigPath: string;
102
102
  dbName: string;
103
103
  };
104
+ } | {
105
+ driver: "expo";
104
106
  } | {});
105
107
  export declare function defineConfig(config: Config): Config;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drizzle-kit",
3
- "version": "0.20.7-02055e2",
3
+ "version": "0.20.7-0650f86",
4
4
  "repository": "https://github.com/drizzle-team/drizzle-kit-mirror",
5
5
  "author": "Drizzle Team",
6
6
  "license": "MIT",
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
  });
@@ -14632,7 +14642,7 @@ __export(migrate_exports, {
14632
14642
  prepareSnapshotFolderName: () => prepareSnapshotFolderName,
14633
14643
  writeResult: () => writeResult
14634
14644
  });
14635
- 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;
14636
14646
  var init_migrate = __esm({
14637
14647
  "src/cli/commands/migrate.ts"() {
14638
14648
  import_fs3 = __toESM(require("fs"));
@@ -14661,19 +14671,14 @@ var init_migrate = __esm({
14661
14671
  const validatedPrev = pgSchema.parse(prev);
14662
14672
  const validatedCur = pgSchema.parse(cur);
14663
14673
  if (config.custom) {
14664
- writeResult(
14665
- custom,
14666
- [],
14674
+ writeResult({
14675
+ cur: custom,
14676
+ sqlStatements: [],
14667
14677
  journal,
14668
- {
14669
- columns: {},
14670
- schemas: {},
14671
- tables: {}
14672
- },
14673
14678
  outFolder,
14674
- config.breakpoints,
14675
- "custom"
14676
- );
14679
+ breakpoints: config.breakpoints,
14680
+ type: "custom"
14681
+ });
14677
14682
  return;
14678
14683
  }
14679
14684
  const squashedPrev = squashPgScheme(validatedPrev);
@@ -14685,14 +14690,13 @@ var init_migrate = __esm({
14685
14690
  validatedPrev,
14686
14691
  validatedCur
14687
14692
  );
14688
- writeResult(
14693
+ writeResult({
14689
14694
  cur,
14690
14695
  sqlStatements,
14691
14696
  journal,
14692
- _meta,
14693
14697
  outFolder,
14694
- config.breakpoints
14695
- );
14698
+ breakpoints: config.breakpoints
14699
+ });
14696
14700
  } catch (e) {
14697
14701
  console.error(e);
14698
14702
  }
@@ -14786,19 +14790,14 @@ var init_migrate = __esm({
14786
14790
  const validatedPrev = mysqlSchema.parse(prev);
14787
14791
  const validatedCur = mysqlSchema.parse(cur);
14788
14792
  if (config.custom) {
14789
- writeResult(
14790
- custom,
14791
- [],
14793
+ writeResult({
14794
+ cur: custom,
14795
+ sqlStatements: [],
14792
14796
  journal,
14793
- {
14794
- columns: {},
14795
- schemas: {},
14796
- tables: {}
14797
- },
14798
14797
  outFolder,
14799
- config.breakpoints,
14800
- "custom"
14801
- );
14798
+ breakpoints: config.breakpoints,
14799
+ type: "custom"
14800
+ });
14802
14801
  return;
14803
14802
  }
14804
14803
  const squashedPrev = squashMysqlScheme(validatedPrev);
@@ -14810,14 +14809,14 @@ var init_migrate = __esm({
14810
14809
  validatedPrev,
14811
14810
  validatedCur
14812
14811
  );
14813
- writeResult(
14812
+ writeResult({
14814
14813
  cur,
14815
14814
  sqlStatements,
14816
14815
  journal,
14817
14816
  _meta,
14818
14817
  outFolder,
14819
- config.breakpoints
14820
- );
14818
+ breakpoints: config.breakpoints
14819
+ });
14821
14820
  } catch (e) {
14822
14821
  console.error(e);
14823
14822
  }
@@ -14835,19 +14834,14 @@ var init_migrate = __esm({
14835
14834
  const validatedPrev = sqliteSchema.parse(prev);
14836
14835
  const validatedCur = sqliteSchema.parse(cur);
14837
14836
  if (config.custom) {
14838
- writeResult(
14839
- custom,
14840
- [],
14837
+ writeResult({
14838
+ cur: custom,
14839
+ sqlStatements: [],
14841
14840
  journal,
14842
- {
14843
- columns: {},
14844
- schemas: {},
14845
- tables: {}
14846
- },
14847
14841
  outFolder,
14848
- config.breakpoints,
14849
- "custom"
14850
- );
14842
+ breakpoints: config.breakpoints,
14843
+ type: "custom"
14844
+ });
14851
14845
  return;
14852
14846
  }
14853
14847
  const squashedPrev = squashSqliteScheme(validatedPrev);
@@ -14857,14 +14851,14 @@ var init_migrate = __esm({
14857
14851
  squashedCur,
14858
14852
  "sqlite"
14859
14853
  );
14860
- writeResult(
14854
+ writeResult({
14861
14855
  cur,
14862
14856
  sqlStatements,
14863
14857
  journal,
14864
14858
  _meta,
14865
14859
  outFolder,
14866
- config.breakpoints
14867
- );
14860
+ breakpoints: config.breakpoints
14861
+ });
14868
14862
  } catch (e) {
14869
14863
  console.error(e);
14870
14864
  }
@@ -15052,7 +15046,20 @@ var init_migrate = __esm({
15052
15046
  return result;
15053
15047
  };
15054
15048
  BREAKPOINT = "--> statement-breakpoint\n";
15055
- writeResult = (cur, sqlStatements, journal, _meta, outFolder, breakpoints, type = "none") => {
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
+ }) => {
15056
15063
  if (type === "none") {
15057
15064
  console.log(schema(cur));
15058
15065
  if (sqlStatements.length === 0) {
@@ -15093,6 +15100,10 @@ ${sql2}
15093
15100
  });
15094
15101
  import_fs3.default.writeFileSync(metaJournal, JSON.stringify(journal, null, 2));
15095
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
+ }
15096
15107
  (0, import_hanji3.render)(
15097
15108
  `[${source_default.green(
15098
15109
  "\u2713"
@@ -15101,6 +15112,22 @@ ${sql2}
15101
15112
  )} \u{1F680}`
15102
15113
  );
15103
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
+ };
15104
15131
  prepareSnapshotFolderName = () => {
15105
15132
  const now = /* @__PURE__ */ new Date();
15106
15133
  return `${now.getFullYear()}${two(now.getUTCMonth() + 1)}${two(