drizzle-kit 0.16.9-96a79eb → 0.16.9-a7718d6

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.
Files changed (2) hide show
  1. package/index.js +178 -51
  2. package/package.json +2 -1
package/index.js CHANGED
@@ -6255,7 +6255,7 @@ var init_global = __esm({
6255
6255
  });
6256
6256
 
6257
6257
  // src/serializer/mysqlSchema.ts
6258
- var index, fk, column, tableV3, table, dialect, schemaHash, schemaInternalV3, schemaInternalV4, schemaInternal, schemaV3, schemaV4, schema2, tableSquashed, schemaSquashed, MySqlSquasher, squashMysqlScheme, mysqlSchema, mysqlSchemaV3, backwardCompatibleMysqlSchema, dryMySql;
6258
+ var index, fk, column, tableV3, table, dialect, schemaHash, schemaInternalV3, schemaInternalV4, schemaInternal, schemaV3, schemaV4, schema2, tableSquashed, schemaSquashed, MySqlSquasher, squashMysqlScheme, mysqlSchema, mysqlSchemaV4, mysqlSchemaV3, backwardCompatibleMysqlSchema, dryMySql;
6259
6259
  var init_mysqlSchema = __esm({
6260
6260
  "src/serializer/mysqlSchema.ts"() {
6261
6261
  init_global();
@@ -6408,13 +6408,14 @@ var init_mysqlSchema = __esm({
6408
6408
  })
6409
6409
  );
6410
6410
  return {
6411
- version: json.version,
6411
+ version: "5",
6412
6412
  dialect: json.dialect,
6413
6413
  tables: mappedTables,
6414
6414
  schemas: json.schemas
6415
6415
  };
6416
6416
  };
6417
6417
  mysqlSchema = schema2;
6418
+ mysqlSchemaV4 = schemaV4;
6418
6419
  mysqlSchemaV3 = schemaV3;
6419
6420
  backwardCompatibleMysqlSchema = unionType([schemaV3, schemaV4, schema2]);
6420
6421
  dryMySql = mysqlSchema.parse({
@@ -6671,7 +6672,7 @@ var init_pgSchema = __esm({
6671
6672
  });
6672
6673
 
6673
6674
  // src/serializer/sqliteSchema.ts
6674
- var index3, fk3, compositePK, column3, tableV33, table3, dialect2, schemaHash3, schemaInternalV32, schemaInternalV42, latestVersion, schemaInternal2, schemaV32, schemaV42, schema3, tableSquashed3, schemaSquashed2, SQLiteSquasher, squashSqliteScheme, drySQLite, sqliteSchemaV3, sqliteSchema, backwardCompatibleSqliteSchema;
6675
+ var index3, fk3, compositePK, column3, tableV33, table3, dialect2, schemaHash3, schemaInternalV32, schemaInternalV42, latestVersion, schemaInternal2, schemaV32, schemaV42, schema3, tableSquashed3, schemaSquashed2, SQLiteSquasher, squashSqliteScheme, drySQLite, sqliteSchemaV3, sqliteSchemaV4, sqliteSchema, backwardCompatibleSqliteSchema;
6675
6676
  var init_sqliteSchema = __esm({
6676
6677
  "src/serializer/sqliteSchema.ts"() {
6677
6678
  init_global();
@@ -6852,6 +6853,7 @@ var init_sqliteSchema = __esm({
6852
6853
  }
6853
6854
  });
6854
6855
  sqliteSchemaV3 = schemaV32;
6856
+ sqliteSchemaV4 = schemaV42;
6855
6857
  sqliteSchema = schema3;
6856
6858
  backwardCompatibleSqliteSchema = unionType([schemaV32, schemaV42, schema3]);
6857
6859
  }
@@ -6930,7 +6932,7 @@ var init_utils = __esm({
6930
6932
  case "sqlite":
6931
6933
  return { validator: backwardCompatibleSqliteSchema, version: 4 };
6932
6934
  case "mysql":
6933
- return { validator: backwardCompatibleMysqlSchema, version: 4 };
6935
+ return { validator: backwardCompatibleMysqlSchema, version: 5 };
6934
6936
  }
6935
6937
  };
6936
6938
  validateWithReport = (snapshots, dialect6) => {
@@ -12659,7 +12661,6 @@ function clearDefaults(defaultValue, collate) {
12659
12661
  if (typeof collate === "undefined" || collate === null) {
12660
12662
  collate = `utf8mb4`;
12661
12663
  }
12662
- ;
12663
12664
  let resultDefault = defaultValue;
12664
12665
  collate = `_${collate}`;
12665
12666
  if (defaultValue.startsWith(collate)) {
@@ -12779,7 +12780,17 @@ var init_mysqlSerializer = __esm({
12779
12780
  const schemas = Object.fromEntries(
12780
12781
  mysqlSchemas.map((it) => [it.schemaName, it.schemaName])
12781
12782
  );
12782
- return { version: "4", dialect: "mysql", tables: result, schemas };
12783
+ return {
12784
+ version: "5",
12785
+ dialect: "mysql",
12786
+ tables: result,
12787
+ schemas,
12788
+ _meta: {
12789
+ schemas: {},
12790
+ tables: {},
12791
+ columns: {}
12792
+ }
12793
+ };
12783
12794
  };
12784
12795
  fromDatabase = async (db, schema4, progressCallback) => {
12785
12796
  const result = {};
@@ -12913,10 +12924,15 @@ var init_mysqlSerializer = __esm({
12913
12924
  progressCallback("enums", 0, "done");
12914
12925
  const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
12915
12926
  return {
12916
- version: "4",
12927
+ version: "5",
12917
12928
  dialect: "mysql",
12918
12929
  tables: result,
12919
- schemas: schemasObject
12930
+ schemas: schemasObject,
12931
+ _meta: {
12932
+ schemas: {},
12933
+ tables: {},
12934
+ columns: {}
12935
+ }
12920
12936
  };
12921
12937
  };
12922
12938
  }
@@ -13459,7 +13475,9 @@ var init_sqliteSerializer = __esm({
13459
13475
  };
13460
13476
  });
13461
13477
  (0, import_utils7.getTableCompositePrimaryKeys)(table4).forEach((it) => {
13462
- primaryKeysObject[it.getName()] = { columns: it.columns.map((it2) => it2.name) };
13478
+ primaryKeysObject[it.getName()] = {
13479
+ columns: it.columns.map((it2) => it2.name)
13480
+ };
13463
13481
  });
13464
13482
  result[tableName] = {
13465
13483
  name: tableName,
@@ -13469,7 +13487,16 @@ var init_sqliteSerializer = __esm({
13469
13487
  compositePrimaryKeys: primaryKeysObject
13470
13488
  };
13471
13489
  }
13472
- return { version: "4", dialect: "sqlite", tables: result, enums: {} };
13490
+ return {
13491
+ version: "5",
13492
+ dialect: "sqlite",
13493
+ tables: result,
13494
+ enums: {},
13495
+ _meta: {
13496
+ tables: {},
13497
+ columns: {}
13498
+ }
13499
+ };
13473
13500
  };
13474
13501
  }
13475
13502
  });
@@ -21156,7 +21183,7 @@ var init_snapshotsDiffer = __esm({
21156
21183
  return unionType([
21157
21184
  objectType({
21158
21185
  type: literalType("none"),
21159
- value: schema4
21186
+ value: schema4.optional()
21160
21187
  }),
21161
21188
  objectType({
21162
21189
  type: literalType("added"),
@@ -22832,10 +22859,10 @@ __export(migrate_exports, {
22832
22859
  prepareAndMigratePg: () => prepareAndMigratePg,
22833
22860
  prepareAndMigrateSqlite: () => prepareAndMigrateSqlite,
22834
22861
  prepareSQL: () => prepareSQL,
22835
- prepareSnapshotFolderName: () => prepareSnapshotFolderName2,
22862
+ prepareSnapshotFolderName: () => prepareSnapshotFolderName,
22836
22863
  writeResult: () => writeResult
22837
22864
  });
22838
- var import_fs4, import_path3, import_hanji2, prepareAndMigratePg, prepareAndMigrateMySql, prepareAndMigrateSqlite, prepareSQL, promptColumnsConflicts, promptTablesConflict, promptSchemasConflict, writeResult, prepareSnapshotFolderName2, two;
22865
+ var import_fs4, import_path3, import_hanji2, prepareAndMigratePg, prepareAndMigrateMySql, prepareAndMigrateSqlite, prepareSQL, promptColumnsConflicts, promptTablesConflict, promptSchemasConflict, writeResult, prepareSnapshotFolderName, two;
22839
22866
  var init_migrate = __esm({
22840
22867
  "src/cli/commands/migrate.ts"() {
22841
22868
  import_fs4 = __toESM(require("fs"));
@@ -22885,7 +22912,7 @@ var init_migrate = __esm({
22885
22912
  const { sql, _meta } = await prepareSQL(
22886
22913
  squashedPrev,
22887
22914
  squashedCur,
22888
- "sqlite"
22915
+ "mysql"
22889
22916
  );
22890
22917
  writeResult(cur, sql, snapshots.length, journal, _meta, outFolder);
22891
22918
  } catch (e) {
@@ -23118,7 +23145,7 @@ var init_migrate = __esm({
23118
23145
  )} \u{1F680}`
23119
23146
  );
23120
23147
  };
23121
- prepareSnapshotFolderName2 = () => {
23148
+ prepareSnapshotFolderName = () => {
23122
23149
  const now = new Date();
23123
23150
  return `${now.getFullYear()}${two(now.getUTCMonth() + 1)}${two(
23124
23151
  now.getUTCDate()
@@ -44790,7 +44817,7 @@ var assertPackages = (...pkgs) => {
44790
44817
  }
44791
44818
  };
44792
44819
  var requiredApiVersion = 2;
44793
- var assertPgVersion = () => {
44820
+ var assertOrmCoreVersion = () => {
44794
44821
  const { compatibilityVersion } = require("drizzle-orm/version");
44795
44822
  if (compatibilityVersion && compatibilityVersion === requiredApiVersion)
44796
44823
  return;
@@ -44805,7 +44832,7 @@ var assertPgVersion = () => {
44805
44832
  }
44806
44833
  process.exit(1);
44807
44834
  };
44808
- var pgVersions = () => {
44835
+ var ormCoreVersions = () => {
44809
44836
  try {
44810
44837
  const { compatibilityVersion, npmVersion } = require("drizzle-orm/version");
44811
44838
  return { compatibilityVersion, npmVersion };
@@ -44876,6 +44903,7 @@ var package_default = {
44876
44903
  "@typescript-eslint/parser": "^5.46.1",
44877
44904
  ava: "^5.1.0",
44878
44905
  dockerode: "^3.3.4",
44906
+ "drizzle-kit": "^0.16.8",
44879
44907
  "drizzle-orm": "0.17.6",
44880
44908
  esbuild: "^0.15.7",
44881
44909
  "esbuild-register": "^3.3.3",
@@ -45116,7 +45144,7 @@ var updateToLatest = (json) => {
45116
45144
  const v4 = updateV3toV4(v3);
45117
45145
  return v4;
45118
45146
  }
45119
- return sqliteSchema.parse(json);
45147
+ return sqliteSchemaV4.parse(json);
45120
45148
  };
45121
45149
  var updateV3toV4 = (old) => {
45122
45150
  const mappedTables = Object.fromEntries(
@@ -45139,6 +45167,8 @@ var import_path5 = __toESM(require("path"));
45139
45167
  init_mysqlSchema();
45140
45168
  init_utils();
45141
45169
  var upMysqlHandler = (out) => {
45170
+ };
45171
+ var upMysqlHandlerV4 = (out) => {
45142
45172
  const { snapshots } = prepareOutFolder(out, "mysql");
45143
45173
  const report = validateWithReport(snapshots, "mysql");
45144
45174
  report.nonLatest.map((it) => ({
@@ -45146,7 +45176,7 @@ var upMysqlHandler = (out) => {
45146
45176
  raw: report.rawMap[it]
45147
45177
  })).forEach((it) => {
45148
45178
  const folder = it.folder;
45149
- const result = updateToLatest2(it.raw);
45179
+ const result = updateToLatestV4(it.raw);
45150
45180
  console.log(
45151
45181
  `[${source_default.green("\u2713")}] ${import_path5.default.join(out, folder, "snapshot.json")}`
45152
45182
  );
@@ -45157,14 +45187,14 @@ var upMysqlHandler = (out) => {
45157
45187
  });
45158
45188
  console.log("Everything's fine \u{1F436}\u{1F525}");
45159
45189
  };
45160
- var updateToLatest2 = (json) => {
45190
+ var updateToLatestV4 = (json) => {
45161
45191
  const version = Number(json["version"]);
45162
45192
  if (version === 3) {
45163
45193
  const v3 = mysqlSchemaV3.parse(json);
45164
45194
  const v4 = updateV3toV42(v3);
45165
45195
  return v4;
45166
45196
  }
45167
- return mysqlSchema.parse(json);
45197
+ return mysqlSchemaV4.parse(json);
45168
45198
  };
45169
45199
  var updateV3toV42 = (old) => {
45170
45200
  return {
@@ -45178,6 +45208,7 @@ var updateV3toV42 = (old) => {
45178
45208
  var import_fs8 = require("fs");
45179
45209
  var import_path6 = require("path");
45180
45210
  init_jsonDiffer();
45211
+ init_mysqlSchema();
45181
45212
  init_snapshotsDiffer();
45182
45213
  init_utils();
45183
45214
  init_words();
@@ -45232,12 +45263,16 @@ var tablesResolver = (missingTables, newTables, sql) => {
45232
45263
  const created = newTables[index4];
45233
45264
  index4 += 1;
45234
45265
  const possibleRenames = leftMissing.map((it) => {
45235
- const schemaPrefix = created.schema ? `"${created.schema}".` : "";
45236
- return {
45266
+ const pgSchemaPrefix = created.schema ? `"${created.schema}".` : "";
45267
+ const mysqlSchemaPrefix = created.schema ? `\`${created.schema}\`.` : "";
45268
+ return [{
45237
45269
  value: it,
45238
- sql: `ALTER TABLE ${schemaPrefix}"${it.name}" RENAME TO ${schemaPrefix}"${created.name}"`
45239
- };
45240
- });
45270
+ sql: `ALTER TABLE ${pgSchemaPrefix}"${it.name}" RENAME TO ${pgSchemaPrefix}"${created.name}"`
45271
+ }, {
45272
+ value: it,
45273
+ sql: `RENAME TABLE ${mysqlSchemaPrefix}\`${it.name}\` TO ${mysqlSchemaPrefix}\`${created.name}\`;`
45274
+ }];
45275
+ }).flat();
45241
45276
  const renames = possibleRenames.filter((it) => {
45242
45277
  return sql.includes(it.sql);
45243
45278
  });
@@ -45271,11 +45306,14 @@ var columnsResolver = (tableName, missingColumns, newColumns, sql) => {
45271
45306
  const created = newColumns[index4];
45272
45307
  index4 += 1;
45273
45308
  const possibleRenames = leftMissing.map((it) => {
45274
- return {
45309
+ return [{
45275
45310
  value: it,
45276
45311
  sql: `ALTER TABLE ${tableName} RENAME COLUMN "${it.name}" TO "${created.name}"`
45277
- };
45278
- });
45312
+ }, {
45313
+ value: it,
45314
+ sql: `ALTER TABLE ${tableName} RENAME COLUMN \`${it.name}\` TO \`${created.name}\``
45315
+ }];
45316
+ }).flat();
45279
45317
  const renames = possibleRenames.filter((it) => {
45280
45318
  return sql.includes(it.sql);
45281
45319
  });
@@ -45297,7 +45335,16 @@ var columnsResolver = (tableName, missingColumns, newColumns, sql) => {
45297
45335
  throw e;
45298
45336
  }
45299
45337
  };
45300
- var fullfill = (prev, cur, sql) => {
45338
+ var fullfill = (prev, cur, sql, dialect6) => {
45339
+ if (dialect6 === "pg") {
45340
+ return fullfillpg(prev, cur, sql);
45341
+ }
45342
+ if (dialect6 === "mysql") {
45343
+ return fullfillmysql(prev, cur, sql);
45344
+ }
45345
+ throw new Error("");
45346
+ };
45347
+ var fullfillpg = (prev, cur, sql) => {
45301
45348
  const b = pgSchemaV4.parse(cur);
45302
45349
  if (!prev) {
45303
45350
  return {
@@ -45343,7 +45390,10 @@ var fullfill = (prev, cur, sql) => {
45343
45390
  const allAltered = typedResult.alteredTablesWithColumns.concat(
45344
45391
  renamedWithAlternations
45345
45392
  );
45346
- const rSchemas = renamedSchemas.map((it) => ({ from: it.from.name, to: it.to.name }));
45393
+ const rSchemas = renamedSchemas.map((it) => ({
45394
+ from: it.from.name,
45395
+ to: it.to.name
45396
+ }));
45347
45397
  const rTables = renamed.map((it) => {
45348
45398
  return { from: it.from, to: it.to };
45349
45399
  });
@@ -45382,6 +45432,91 @@ var fullfill = (prev, cur, sql) => {
45382
45432
  _meta
45383
45433
  };
45384
45434
  };
45435
+ var fullfillmysql = (prev, cur, sql) => {
45436
+ const b = mysqlSchemaV4.parse(cur);
45437
+ if (!prev) {
45438
+ return {
45439
+ version: "5",
45440
+ dialect: b.dialect,
45441
+ id: b.id,
45442
+ prevId: b.prevId,
45443
+ tables: b.tables,
45444
+ schemas: b.schemas,
45445
+ _meta: {
45446
+ schemas: {},
45447
+ tables: {},
45448
+ columns: {}
45449
+ }
45450
+ };
45451
+ }
45452
+ const a = mysqlSchemaV4.parse(prev);
45453
+ const json1 = squashMysqlScheme(a);
45454
+ const json2 = squashMysqlScheme(b);
45455
+ const diffResult = applyJsonDiff(json1, json2);
45456
+ const parseResult = diffResultScheme.safeParse(diffResult);
45457
+ if (!parseResult.success) {
45458
+ parseResult.error.errors.forEach((it) => {
45459
+ console.error(it);
45460
+ });
45461
+ throw new Error();
45462
+ }
45463
+ const typedResult = parseResult.data;
45464
+ const { renamed: renamedSchemas } = schemasResolver(
45465
+ typedResult.deletedSchemas.map((it) => ({ name: it })),
45466
+ typedResult.addedSchemas.map((it) => ({ name: it })),
45467
+ sql
45468
+ );
45469
+ const { renamed } = tablesResolver(
45470
+ typedResult.deletedTables,
45471
+ typedResult.addedTables,
45472
+ sql
45473
+ );
45474
+ const renamedWithAlternations = Object.values(
45475
+ alteredTableScheme.array().parse(diffForRenamedTables(renamed))
45476
+ );
45477
+ const allAltered = typedResult.alteredTablesWithColumns.concat(
45478
+ renamedWithAlternations
45479
+ );
45480
+ const rSchemas = renamedSchemas.map((it) => ({
45481
+ from: it.from.name,
45482
+ to: it.to.name
45483
+ }));
45484
+ const rTables = renamed.map((it) => {
45485
+ return { from: it.from, to: it.to };
45486
+ });
45487
+ const rColumns = allAltered.map((table4) => {
45488
+ const name = table4.name;
45489
+ const result = columnsResolver(name, table4.deleted, table4.added, sql);
45490
+ const tableName = table4.name;
45491
+ const schema4 = typeof table4.schema === "string" ? table4.schema : "";
45492
+ return result.renamed.map((it) => {
45493
+ return {
45494
+ from: { schema: schema4, table: tableName, column: it.from.name },
45495
+ to: { schema: schema4, table: tableName, column: it.to.name }
45496
+ };
45497
+ });
45498
+ }).flat();
45499
+ const _meta = prepareMigrationMeta(rSchemas, rTables, rColumns);
45500
+ const bpatched = {
45501
+ version: "5",
45502
+ dialect: b.dialect,
45503
+ id: b.id,
45504
+ prevId: b.prevId,
45505
+ tables: b.tables,
45506
+ schemas: b.schemas,
45507
+ _meta
45508
+ };
45509
+ mysqlSchema.parse(bpatched);
45510
+ return {
45511
+ version: "5",
45512
+ dialect: b.dialect,
45513
+ id: b.id,
45514
+ prevId: b.prevId,
45515
+ tables: b.tables,
45516
+ schemas: b.schemas,
45517
+ _meta
45518
+ };
45519
+ };
45385
45520
  var upgradeFolders = (dialect6, out) => {
45386
45521
  const oldMigrationFolders = (0, import_fs8.readdirSync)(out).filter(
45387
45522
  (it) => it.length === 14 && /^\d+$/.test(it)
@@ -45391,7 +45526,7 @@ var upgradeFolders = (dialect6, out) => {
45391
45526
  (res2, it) => {
45392
45527
  const date = new Date();
45393
45528
  date.setUTCFullYear(Number(it.substring(0, 4)));
45394
- date.setUTCMonth(Number(it.substring(4, 6)));
45529
+ date.setUTCMonth(Number(it.substring(4, 6)) - 1);
45395
45530
  date.setUTCDate(Number(it.substring(6, 8)));
45396
45531
  date.setUTCHours(Number(it.substring(8, 10)));
45397
45532
  date.setUTCMinutes(Number(it.substring(10, 12)));
@@ -45429,7 +45564,7 @@ var upgradeFolders = (dialect6, out) => {
45429
45564
  when: +it.date,
45430
45565
  tag
45431
45566
  });
45432
- const patchedJSON = fullfill(prev, it.json, it.sql);
45567
+ const patchedJSON = fullfill(prev, it.json, it.sql, dialect6);
45433
45568
  (0, import_fs8.writeFileSync)(
45434
45569
  (0, import_path6.join)(`${out}`, "meta", `${prefix}_snapshot.json`),
45435
45570
  JSON.stringify(patchedJSON)
@@ -45461,7 +45596,7 @@ var assertEitherConfigOrOut = (config, out) => {
45461
45596
  return drizzleConfig.out;
45462
45597
  };
45463
45598
  var versions = () => {
45464
- const { npmVersion } = pgVersions();
45599
+ const { npmVersion } = ormCoreVersions();
45465
45600
  const ormVersion = npmVersion ? `
45466
45601
  drizzle-orm: v${npmVersion}` : "";
45467
45602
  const versions2 = `drizzle-kit: v${package_default.version}${ormVersion}`;
@@ -45594,6 +45729,9 @@ var upMysqlCommand = new Command("up:mysql").option("--out <out>", `Output folde
45594
45729
  console.log(error(`'out' folder param must be set`));
45595
45730
  process.exit(0);
45596
45731
  }
45732
+ assertPackages("drizzle-orm");
45733
+ upMysqlHandlerV4(out);
45734
+ upgradeFolders("mysql", out);
45597
45735
  upMysqlHandler(out);
45598
45736
  });
45599
45737
  var upSqliteCommand = new Command("up:sqlite").option("--out <out>", `Output folder`).option("--config <config>", `Config path [default=drizzle.config.json]`).action((options) => {
@@ -45612,7 +45750,7 @@ var pt1 = objectType({
45612
45750
  var introspectPgCommand = new Command("introspect:pg").option("--out <out>", `Migrations folder`).option("--connectionString <connectionString>", "Postgres connection string").option("--host <host>", "Postgres host").option("--port <port>", "Postgres port").option("--user <user>", "Postgres user").option("--password <password>", "Postgres password").option("--database <database>", "Postgres database name").option("--ssl <ssl>", "Postgres ssl").action(async (options) => {
45613
45751
  printVersions();
45614
45752
  assertPackages("drizzle-orm");
45615
- assertPgVersion();
45753
+ assertOrmCoreVersion();
45616
45754
  const { pgIntrospect: pgIntrospect2, PgConfig2: PgConfig22, PgConfig1: PgConfig12 } = (init_pgIntrospect(), __toCommonJS(pgIntrospect_exports));
45617
45755
  const pgIntrospectConfig = unionType([
45618
45756
  pt1.extend(PgConfig22.shape),
@@ -45654,7 +45792,7 @@ var introspectPgCommand = new Command("introspect:pg").option("--out <out>", `Mi
45654
45792
  var introspectMySqlCommand = new Command("introspect:mysql").option("--out <out>", `Migrations folder`).option("--connectionString <connectionString>", "MySQL connection string").option("--host <host>", "MySQL host").option("--port <port>", "MySQL port").option("--user <user>", "MySQL user").option("--password <password>", "MySQL password").option("--database <database>", "MySQL database name").action(async (options) => {
45655
45793
  printVersions();
45656
45794
  assertPackages("drizzle-orm");
45657
- assertPgVersion();
45795
+ assertOrmCoreVersion();
45658
45796
  const { mysqlIntrospect: mysqlIntrospect2, MySQLConfig1: MySQLConfig12, MySQLConfig2: MySQLConfig22 } = (init_mysqlIntrospect(), __toCommonJS(mysqlIntrospect_exports));
45659
45797
  const mysqlIntrospectConfig = unionType([
45660
45798
  pt1.extend(MySQLConfig22.shape),
@@ -45665,29 +45803,18 @@ var introspectMySqlCommand = new Command("introspect:mysql").option("--out <out>
45665
45803
  console.log("Missing required params");
45666
45804
  return;
45667
45805
  }
45668
- const migrationFolders = prepareOutFolders(res.data.out);
45669
- const folderName = prepareSnapshotFolderName();
45670
- const migrationFolderPath = `./${res.data.out}/${folderName}`;
45806
+ const { snapshots, journal } = prepareOutFolder(res.data.out, "mysql");
45671
45807
  const { schema: schema4, ts } = await mysqlIntrospect2(res.data);
45672
45808
  const schemaFile = import_path7.default.join(res.data.out, "schema.ts");
45673
45809
  (0, import_fs9.writeFileSync)(schemaFile, ts);
45674
45810
  console.log();
45675
- if (migrationFolders.length === 0) {
45676
- import_fs9.default.mkdirSync(migrationFolderPath);
45677
- const snapshotFile = import_path7.default.join(migrationFolderPath, "snapshot.json");
45678
- (0, import_fs9.writeFileSync)(snapshotFile, JSON.stringify(schema4));
45679
- const sql = await prepareSQL(
45811
+ if (snapshots.length === 0) {
45812
+ const { sql, _meta } = await prepareSQL(
45680
45813
  squashMysqlScheme(dryMySql),
45681
45814
  squashMysqlScheme(schema4),
45682
45815
  "mysql"
45683
45816
  );
45684
- const sqlFile = import_path7.default.join(migrationFolderPath, "migration.sql");
45685
- (0, import_fs9.writeFileSync)(sqlFile, sql.sql);
45686
- (0, import_hanji5.render)(
45687
- `[${source_default.green(
45688
- "\u2713"
45689
- )}] Your SQL migration file \u279C ${source_default.bold.underline.blue(sqlFile)} \u{1F680}`
45690
- );
45817
+ writeResult(schema4, sql, 0, journal, _meta, res.data.out);
45691
45818
  } else {
45692
45819
  (0, import_hanji5.render)(
45693
45820
  `[${source_default.blue(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drizzle-kit",
3
- "version": "0.16.9-96a79eb",
3
+ "version": "0.16.9-a7718d6",
4
4
  "repository": "https://github.com/drizzle-team/drizzle-kit-mirror",
5
5
  "author": "Alex Blokh <aleksandrblokh@gmail.com>",
6
6
  "license": "MIT",
@@ -56,6 +56,7 @@
56
56
  "@typescript-eslint/parser": "^5.46.1",
57
57
  "ava": "^5.1.0",
58
58
  "dockerode": "^3.3.4",
59
+ "drizzle-kit": "^0.16.8",
59
60
  "drizzle-orm": "0.17.6",
60
61
  "esbuild": "^0.15.7",
61
62
  "esbuild-register": "^3.3.3",