drizzle-kit 0.20.14-a183d8b → 0.20.14-c82ab68

Sign up to get free protection for your applications and to get access to all the features.
package/utils.mjs CHANGED
@@ -1080,6 +1080,7 @@ var require_hanji = __commonJS({
1080
1080
  var import_hanji, info;
1081
1081
  var init_views = __esm({
1082
1082
  "src/cli/views.ts"() {
1083
+ "use strict";
1083
1084
  init_source();
1084
1085
  import_hanji = __toESM(require_hanji());
1085
1086
  info = (msg, greyMsg = "") => {
@@ -1089,11 +1090,15 @@ var init_views = __esm({
1089
1090
  });
1090
1091
 
1091
1092
  // src/global.ts
1093
+ function assertUnreachable(x) {
1094
+ throw new Error("Didn't expect to get here");
1095
+ }
1092
1096
  var originUUID, snapshotVersion, mapValues;
1093
1097
  var init_global = __esm({
1094
1098
  "src/global.ts"() {
1099
+ "use strict";
1095
1100
  originUUID = "00000000-0000-0000-0000-000000000000";
1096
- snapshotVersion = "5";
1101
+ snapshotVersion = "6";
1097
1102
  mapValues = (obj, map) => {
1098
1103
  const result = Object.keys(obj).reduce(function(result2, key) {
1099
1104
  result2[key] = map(obj[key]);
@@ -4244,9 +4249,10 @@ var init_lib = __esm({
4244
4249
  });
4245
4250
 
4246
4251
  // src/serializer/mysqlSchema.ts
4247
- var index, fk, column, tableV3, compositePK, uniqueConstraint, tableV4, table, dialect, schemaHash, schemaInternalV3, schemaInternalV4, kitInternals, schemaInternal, schemaV3, schemaV4, schema, tableSquashedV4, tableSquashed, schemaSquashed, schemaSquashedV4, MySqlSquasher, mysqlSchema, backwardCompatibleMysqlSchema, dryMySql;
4252
+ var index, fk, column, tableV3, compositePK, uniqueConstraint, tableV4, table, kitInternals, dialect, schemaHash, schemaInternalV3, schemaInternalV4, schemaInternalV5, schemaInternalV6, schemaInternal, schemaV3, schemaV4, schemaV5, schema, tableSquashedV4, tableSquashed, schemaSquashed, schemaSquashedV4, MySqlSquasher, mysqlSchema, mysqlSchemaV5, backwardCompatibleMysqlSchema, dryMySql;
4248
4253
  var init_mysqlSchema = __esm({
4249
4254
  "src/serializer/mysqlSchema.ts"() {
4255
+ "use strict";
4250
4256
  init_global();
4251
4257
  init_lib();
4252
4258
  index = objectType({
@@ -4305,6 +4311,17 @@ var init_mysqlSchema = __esm({
4305
4311
  compositePrimaryKeys: recordType(stringType(), compositePK),
4306
4312
  uniqueConstraints: recordType(stringType(), uniqueConstraint).default({})
4307
4313
  }).strict();
4314
+ kitInternals = objectType({
4315
+ tables: recordType(
4316
+ stringType(),
4317
+ objectType({
4318
+ columns: recordType(
4319
+ stringType(),
4320
+ objectType({ isDefaultAnExpression: booleanType().optional() }).optional()
4321
+ )
4322
+ }).optional()
4323
+ )
4324
+ }).optional();
4308
4325
  dialect = literalType("mysql");
4309
4326
  schemaHash = objectType({
4310
4327
  id: stringType(),
@@ -4321,18 +4338,7 @@ var init_mysqlSchema = __esm({
4321
4338
  tables: recordType(stringType(), tableV4),
4322
4339
  schemas: recordType(stringType(), stringType())
4323
4340
  }).strict();
4324
- kitInternals = objectType({
4325
- tables: recordType(
4326
- stringType(),
4327
- objectType({
4328
- columns: recordType(
4329
- stringType(),
4330
- objectType({ isDefaultAnExpression: booleanType().optional() }).optional()
4331
- )
4332
- }).optional()
4333
- )
4334
- }).optional();
4335
- schemaInternal = objectType({
4341
+ schemaInternalV5 = objectType({
4336
4342
  version: literalType("5"),
4337
4343
  dialect,
4338
4344
  tables: recordType(stringType(), table),
@@ -4344,8 +4350,33 @@ var init_mysqlSchema = __esm({
4344
4350
  }),
4345
4351
  internal: kitInternals
4346
4352
  }).strict();
4353
+ schemaInternalV6 = objectType({
4354
+ version: literalType("6"),
4355
+ dialect,
4356
+ tables: recordType(stringType(), table),
4357
+ schemas: recordType(stringType(), stringType()),
4358
+ _meta: objectType({
4359
+ schemas: recordType(stringType(), stringType()),
4360
+ tables: recordType(stringType(), stringType()),
4361
+ columns: recordType(stringType(), stringType())
4362
+ }),
4363
+ internal: kitInternals
4364
+ }).strict();
4365
+ schemaInternal = objectType({
4366
+ version: literalType("6"),
4367
+ dialect,
4368
+ tables: recordType(stringType(), table),
4369
+ schemas: recordType(stringType(), stringType()),
4370
+ _meta: objectType({
4371
+ schemas: recordType(stringType(), stringType()),
4372
+ tables: recordType(stringType(), stringType()),
4373
+ columns: recordType(stringType(), stringType())
4374
+ }),
4375
+ internal: kitInternals
4376
+ }).strict();
4347
4377
  schemaV3 = schemaInternalV3.merge(schemaHash);
4348
4378
  schemaV4 = schemaInternalV4.merge(schemaHash);
4379
+ schemaV5 = schemaInternalV5.merge(schemaHash);
4349
4380
  schema = schemaInternal.merge(schemaHash);
4350
4381
  tableSquashedV4 = objectType({
4351
4382
  name: stringType(),
@@ -4432,11 +4463,8 @@ var init_mysqlSchema = __esm({
4432
4463
  }
4433
4464
  };
4434
4465
  mysqlSchema = schema;
4435
- backwardCompatibleMysqlSchema = unionType([
4436
- schemaV3,
4437
- schemaV4,
4438
- schema
4439
- ]);
4466
+ mysqlSchemaV5 = schemaV5;
4467
+ backwardCompatibleMysqlSchema = unionType([mysqlSchemaV5, schema]);
4440
4468
  dryMySql = mysqlSchema.parse({
4441
4469
  version: snapshotVersion,
4442
4470
  dialect: "mysql",
@@ -4454,9 +4482,10 @@ var init_mysqlSchema = __esm({
4454
4482
  });
4455
4483
 
4456
4484
  // src/serializer/pgSchema.ts
4457
- var indexV2, columnV2, tableV2, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, index2, fk2, column2, tableV32, compositePK2, uniqueConstraint2, tableV42, table2, schemaHash2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaExternal, kitInternals2, pgSchemaInternal, tableSquashed2, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchema, backwardCompatiblePgSchema, PgSquasher, squashPgScheme, dryPg;
4485
+ var indexV2, columnV2, tableV2, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, index2, fk2, column2, tableV32, compositePK2, uniqueConstraint2, tableV42, table2, schemaHash2, kitInternals2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternalV5, pgSchemaExternal, pgSchemaInternal, tableSquashed2, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchemaV5, pgSchema, backwardCompatiblePgSchema, PgSquasher, squashPgScheme, dryPg;
4458
4486
  var init_pgSchema = __esm({
4459
4487
  "src/serializer/pgSchema.ts"() {
4488
+ "use strict";
4460
4489
  init_global();
4461
4490
  init_lib();
4462
4491
  indexV2 = objectType({
@@ -4576,6 +4605,21 @@ var init_pgSchema = __esm({
4576
4605
  id: stringType(),
4577
4606
  prevId: stringType()
4578
4607
  });
4608
+ kitInternals2 = objectType({
4609
+ tables: recordType(
4610
+ stringType(),
4611
+ objectType({
4612
+ columns: recordType(
4613
+ stringType(),
4614
+ objectType({
4615
+ isArray: booleanType().optional(),
4616
+ dimensions: numberType().optional(),
4617
+ rawType: stringType().optional()
4618
+ }).optional()
4619
+ )
4620
+ }).optional()
4621
+ )
4622
+ }).optional();
4579
4623
  pgSchemaInternalV3 = objectType({
4580
4624
  version: literalType("3"),
4581
4625
  dialect: literalType("pg"),
@@ -4589,6 +4633,19 @@ var init_pgSchema = __esm({
4589
4633
  enums: recordType(stringType(), enumSchema),
4590
4634
  schemas: recordType(stringType(), stringType())
4591
4635
  }).strict();
4636
+ pgSchemaInternalV5 = objectType({
4637
+ version: literalType("5"),
4638
+ dialect: literalType("pg"),
4639
+ tables: recordType(stringType(), table2),
4640
+ enums: recordType(stringType(), enumSchema),
4641
+ schemas: recordType(stringType(), stringType()),
4642
+ _meta: objectType({
4643
+ schemas: recordType(stringType(), stringType()),
4644
+ tables: recordType(stringType(), stringType()),
4645
+ columns: recordType(stringType(), stringType())
4646
+ }),
4647
+ internal: kitInternals2
4648
+ }).strict();
4592
4649
  pgSchemaExternal = objectType({
4593
4650
  version: literalType("5"),
4594
4651
  dialect: literalType("pg"),
@@ -4601,23 +4658,8 @@ var init_pgSchema = __esm({
4601
4658
  columns: recordType(stringType(), stringType())
4602
4659
  })
4603
4660
  }).strict();
4604
- kitInternals2 = objectType({
4605
- tables: recordType(
4606
- stringType(),
4607
- objectType({
4608
- columns: recordType(
4609
- stringType(),
4610
- objectType({
4611
- isArray: booleanType().optional(),
4612
- dimensions: numberType().optional(),
4613
- rawType: stringType().optional()
4614
- }).optional()
4615
- )
4616
- }).optional()
4617
- )
4618
- }).optional();
4619
4661
  pgSchemaInternal = objectType({
4620
- version: literalType("5"),
4662
+ version: literalType("6"),
4621
4663
  dialect: literalType("pg"),
4622
4664
  tables: recordType(stringType(), table2),
4623
4665
  enums: recordType(stringType(), enumSchema),
@@ -4653,7 +4695,7 @@ var init_pgSchema = __esm({
4653
4695
  schemas: recordType(stringType(), stringType())
4654
4696
  }).strict();
4655
4697
  pgSchemaSquashed = objectType({
4656
- version: literalType("5"),
4698
+ version: literalType("6"),
4657
4699
  dialect: enumType(["pg"]),
4658
4700
  tables: recordType(stringType(), tableSquashed2),
4659
4701
  enums: recordType(stringType(), enumSchema),
@@ -4661,14 +4703,9 @@ var init_pgSchema = __esm({
4661
4703
  }).strict();
4662
4704
  pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash2);
4663
4705
  pgSchemaV4 = pgSchemaInternalV4.merge(schemaHash2);
4706
+ pgSchemaV5 = pgSchemaInternalV5.merge(schemaHash2);
4664
4707
  pgSchema = pgSchemaInternal.merge(schemaHash2);
4665
- backwardCompatiblePgSchema = unionType([
4666
- pgSchemaV1,
4667
- pgSchemaV2,
4668
- pgSchemaV3,
4669
- pgSchemaV4,
4670
- pgSchema
4671
- ]);
4708
+ backwardCompatiblePgSchema = unionType([pgSchemaV5, pgSchema]);
4672
4709
  PgSquasher = {
4673
4710
  squashIdx: (idx) => {
4674
4711
  index2.parse(idx);
@@ -4684,7 +4721,7 @@ var init_pgSchema = __esm({
4684
4721
  return result;
4685
4722
  },
4686
4723
  squashFK: (fk4) => {
4687
- return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""};${fk4.schemaTo ?? ""}`;
4724
+ return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""};${fk4.schemaTo || "public"}`;
4688
4725
  },
4689
4726
  squashPK: (pk) => {
4690
4727
  return `${pk.columns.join(",")};${pk.name}`;
@@ -4761,7 +4798,7 @@ var init_pgSchema = __esm({
4761
4798
  })
4762
4799
  );
4763
4800
  return {
4764
- version: "5",
4801
+ version: "6",
4765
4802
  dialect: json.dialect,
4766
4803
  tables: mappedTables,
4767
4804
  enums: json.enums,
@@ -4789,6 +4826,7 @@ var init_pgSchema = __esm({
4789
4826
  var index3, fk3, compositePK3, column3, tableV33, uniqueConstraint3, table3, dialect2, schemaHash3, schemaInternalV32, schemaInternalV42, latestVersion, schemaInternal2, schemaV32, schemaV42, schema2, tableSquashed3, schemaSquashed2, SQLiteSquasher, drySQLite, backwardCompatibleSqliteSchema;
4790
4827
  var init_sqliteSchema = __esm({
4791
4828
  "src/serializer/sqliteSchema.ts"() {
4829
+ "use strict";
4792
4830
  init_global();
4793
4831
  init_lib();
4794
4832
  index3 = objectType({
@@ -4935,7 +4973,7 @@ var init_sqliteSchema = __esm({
4935
4973
  }
4936
4974
  };
4937
4975
  drySQLite = schema2.parse({
4938
- version: snapshotVersion,
4976
+ version: "5",
4939
4977
  dialect: "sqlite",
4940
4978
  id: originUUID,
4941
4979
  prevId: "",
@@ -4946,11 +4984,7 @@ var init_sqliteSchema = __esm({
4946
4984
  columns: {}
4947
4985
  }
4948
4986
  });
4949
- backwardCompatibleSqliteSchema = unionType([
4950
- schemaV32,
4951
- schemaV42,
4952
- schema2
4953
- ]);
4987
+ backwardCompatibleSqliteSchema = schema2;
4954
4988
  }
4955
4989
  });
4956
4990
 
@@ -4958,6 +4992,7 @@ var init_sqliteSchema = __esm({
4958
4992
  import * as glob from "glob";
4959
4993
  var init_serializer = __esm({
4960
4994
  "src/serializer/index.ts"() {
4995
+ "use strict";
4961
4996
  init_source();
4962
4997
  init_views();
4963
4998
  }
@@ -4966,6 +5001,7 @@ var init_serializer = __esm({
4966
5001
  // src/cli/validations/outputs.ts
4967
5002
  var init_outputs = __esm({
4968
5003
  "src/cli/validations/outputs.ts"() {
5004
+ "use strict";
4969
5005
  init_source();
4970
5006
  }
4971
5007
  });
@@ -6566,15 +6602,15 @@ init_pgSchema();
6566
6602
  init_sqliteSchema();
6567
6603
  var preparePgCreateTableJson = (table4, json2) => {
6568
6604
  const { name, schema: schema4, columns, compositePrimaryKeys, uniqueConstraints } = table4;
6605
+ const tableKey = `${schema4 || "public"}.${name}`;
6606
+ const compositePkName = Object.values(compositePrimaryKeys).length > 0 ? json2.tables[tableKey].compositePrimaryKeys[`${PgSquasher.unsquashPK(Object.values(compositePrimaryKeys)[0]).name}`].name : "";
6569
6607
  return {
6570
6608
  type: "create_table",
6571
6609
  tableName: name,
6572
6610
  schema: schema4,
6573
6611
  columns: Object.values(columns),
6574
6612
  compositePKs: Object.values(compositePrimaryKeys),
6575
- compositePkName: Object.values(compositePrimaryKeys).length > 0 ? json2.tables[name].compositePrimaryKeys[`${PgSquasher.unsquashPK(
6576
- Object.values(compositePrimaryKeys)[0]
6577
- ).name}`].name : "",
6613
+ compositePkName,
6578
6614
  uniqueConstraints: Object.values(uniqueConstraints)
6579
6615
  };
6580
6616
  };
@@ -6676,7 +6712,8 @@ var prepareRenameColumns = (tableName, schema4, pairs) => {
6676
6712
  var prepareAlterTableColumnsJson = (tableName, schema4, deleted, added, altered, addedFk, json2, dialect3) => {
6677
6713
  const addColumns = [];
6678
6714
  const dropColumns = _prepareDropColumns(tableName, schema4, deleted);
6679
- const alterColumns = _prepareAlterColumns(tableName, schema4, altered, json2);
6715
+ const tableKey = `${schema4 || "public"}.${tableName}`;
6716
+ const alterColumns = _prepareAlterColumns(tableKey, schema4, altered, json2);
6680
6717
  if (dialect3 === "sqlite") {
6681
6718
  let jsonCreateFKStatements = Object.values(addedFk);
6682
6719
  const sqliteAddColumns = _prepareSQLiteAddColumns(
@@ -6726,19 +6763,22 @@ var _prepareSQLiteAddColumns = (tableName, columns, referenceData) => {
6726
6763
  };
6727
6764
  });
6728
6765
  };
6729
- var _prepareAlterColumns = (tableName, schema4, columns, json2) => {
6766
+ var _prepareAlterColumns = (tableKey, schema4, columns, json2) => {
6730
6767
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
6731
6768
  let statements = [];
6732
6769
  let dropPkStatements = [];
6733
6770
  let setPkStatements = [];
6734
6771
  for (const column4 of columns) {
6735
6772
  const columnName = typeof column4.name !== "string" ? column4.name.new : column4.name;
6736
- const columnType = json2.tables[tableName].columns[columnName].type;
6737
- const columnDefault = json2.tables[tableName].columns[columnName].default;
6738
- const columnOnUpdate = json2.tables[tableName].columns[columnName].onUpdate;
6739
- const columnNotNull = json2.tables[tableName].columns[columnName].notNull;
6740
- const columnAutoIncrement = json2.tables[tableName].columns[columnName].autoincrement;
6741
- const columnPk = json2.tables[tableName].columns[columnName].primaryKey;
6773
+ const table4 = json2.tables[tableKey];
6774
+ const tableName = table4.name;
6775
+ const snapshotColumn = table4.columns[columnName];
6776
+ const columnType = snapshotColumn.type;
6777
+ const columnDefault = snapshotColumn.default;
6778
+ const columnOnUpdate = "onUpdate" in snapshotColumn ? snapshotColumn.onUpdate : void 0;
6779
+ const columnNotNull = table4.columns[columnName].notNull;
6780
+ const columnAutoIncrement = "autoincrement" in snapshotColumn ? snapshotColumn.autoincrement ?? false : false;
6781
+ const columnPk = table4.columns[columnName].primaryKey;
6742
6782
  if (((_a = column4.autoincrement) == null ? void 0 : _a.type) === "added") {
6743
6783
  statements.push({
6744
6784
  type: "alter_table_alter_column_set_autoincrement",
@@ -6785,13 +6825,14 @@ var _prepareAlterColumns = (tableName, schema4, columns, json2) => {
6785
6825
  }
6786
6826
  for (const column4 of columns) {
6787
6827
  const columnName = typeof column4.name !== "string" ? column4.name.new : column4.name;
6788
- const columnType = json2.tables[tableName].columns[columnName].type;
6789
- const columnDefault = json2.tables[tableName].columns[columnName].default;
6790
- const columnOnUpdate = json2.tables[tableName].columns[columnName].onUpdate;
6791
- const columnNotNull = json2.tables[tableName].columns[columnName].notNull;
6792
- const columnAutoIncrement = json2.tables[tableName].columns[columnName].autoincrement;
6793
- const columnPk = json2.tables[tableName].columns[columnName].primaryKey;
6794
- const compositePk = json2.tables[tableName].compositePrimaryKeys[`${tableName}_${columnName}`];
6828
+ const tableName = json2.tables[tableKey].name;
6829
+ const columnType = json2.tables[tableKey].columns[columnName].type;
6830
+ const columnDefault = json2.tables[tableKey].columns[columnName].default;
6831
+ const columnOnUpdate = json2.tables[tableKey].columns[columnName].onUpdate;
6832
+ const columnNotNull = json2.tables[tableKey].columns[columnName].notNull;
6833
+ const columnAutoIncrement = json2.tables[tableKey].columns[columnName].autoincrement;
6834
+ const columnPk = json2.tables[tableKey].columns[columnName].primaryKey;
6835
+ const compositePk = json2.tables[tableKey].compositePrimaryKeys[`${tableName}_${columnName}`];
6795
6836
  if (typeof column4.name !== "string") {
6796
6837
  statements.push({
6797
6838
  type: "alter_table_rename_column",
@@ -7139,6 +7180,7 @@ var prepareAlterCompositePrimaryKeyMySql = (tableName, pks, json1, json2) => {
7139
7180
  // src/snapshotsDiffer.ts
7140
7181
  init_sqliteSchema();
7141
7182
  init_mysqlSchema();
7183
+ init_global();
7142
7184
  var makeChanged = (schema4) => {
7143
7185
  return objectType({
7144
7186
  type: enumType(["changed"]),
@@ -7177,7 +7219,7 @@ var makeSelfOrPatched = (schema4) => {
7177
7219
  return unionType([
7178
7220
  objectType({
7179
7221
  type: literalType("none"),
7180
- value: schema4.optional()
7222
+ value: schema4
7181
7223
  }),
7182
7224
  objectType({
7183
7225
  type: literalType("added"),
@@ -7301,7 +7343,6 @@ var diffResultScheme = objectType({
7301
7343
  }).strict();
7302
7344
  var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesResolver, columnsResolver, prevFull, curFull) => {
7303
7345
  var _a, _b;
7304
- let diffResult;
7305
7346
  if (dialect3 === "mysql") {
7306
7347
  for (const tableName in json1.tables) {
7307
7348
  const table4 = json1.tables[tableName];
@@ -7329,13 +7370,26 @@ var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesR
7329
7370
  }
7330
7371
  }
7331
7372
  }
7332
- diffResult = applyJsonDiff(json1, json2);
7333
7373
  }
7334
- diffResult = applyJsonDiff(json1, json2);
7374
+ const diffResult = applyJsonDiff(json1, json2);
7335
7375
  if (Object.keys(diffResult).length === 0) {
7336
7376
  return { statements: [], sqlStatements: [], _meta: void 0 };
7337
7377
  }
7338
7378
  const typedResult = diffResultScheme.parse(diffResult);
7379
+ typedResult.alteredTablesWithColumns = typedResult.alteredTablesWithColumns.map((it) => {
7380
+ let schemaToTrim;
7381
+ if (it.schema.type === "none") {
7382
+ schemaToTrim = it.schema.value || "public";
7383
+ } else if (it.schema.type === "deleted") {
7384
+ schemaToTrim = it.schema.value;
7385
+ } else if (it.schema.type === "added") {
7386
+ schemaToTrim = "public";
7387
+ } else {
7388
+ schemaToTrim = it.schema.old;
7389
+ }
7390
+ it.name = it.name.substring(schemaToTrim.length + 1);
7391
+ return it;
7392
+ });
7339
7393
  const {
7340
7394
  created: createdSchemas,
7341
7395
  deleted: deletedSchemas,
@@ -7487,7 +7541,7 @@ var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesR
7487
7541
  prevFull,
7488
7542
  curFull
7489
7543
  );
7490
- } else {
7544
+ } else if (dialect3 === "mysql") {
7491
7545
  addedCompositePKs = prepareAddCompositePrimaryKeyMySql(
7492
7546
  it.name,
7493
7547
  it.addedCompositePKs,
@@ -7505,6 +7559,8 @@ var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesR
7505
7559
  prevFull,
7506
7560
  curFull
7507
7561
  );
7562
+ } else {
7563
+ assertUnreachable(dialect3);
7508
7564
  }
7509
7565
  let addedUniqueConstraints = [];
7510
7566
  let deletedUniqueConstraints = [];
@@ -7695,11 +7751,13 @@ var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesR
7695
7751
  return preparePgCreateTableJson(it, curFull);
7696
7752
  });
7697
7753
  jsonStatements.push(...jsonPgCreateTables);
7698
- } else {
7754
+ } else if (dialect3 === "mysql") {
7699
7755
  const jsonMySqlCreateTables = created.map((it) => {
7700
7756
  return prepareMySqlCreateTableJson(it, curFull);
7701
7757
  });
7702
7758
  jsonStatements.push(...jsonMySqlCreateTables);
7759
+ } else {
7760
+ assertUnreachable(dialect3);
7703
7761
  }
7704
7762
  jsonStatements.push(...jsonDropTables);
7705
7763
  jsonStatements.push(...jsonRenameTables);
@@ -7858,7 +7916,7 @@ var resolveColumns = (missingColumns, newColumns, predicate) => {
7858
7916
  };
7859
7917
 
7860
7918
  // src/utils.ts
7861
- var assertV1OutFolder = (out, dialect3) => {
7919
+ var assertV1OutFolder = (out) => {
7862
7920
  if (!existsSync(out))
7863
7921
  return;
7864
7922
  const oldMigrationFolders = readdirSync(out).filter(
@@ -7867,7 +7925,7 @@ var assertV1OutFolder = (out, dialect3) => {
7867
7925
  if (oldMigrationFolders.length > 0) {
7868
7926
  console.log(
7869
7927
  `Your migrations folder format is outdated, please run ${source_default.green.bold(
7870
- `drizzle-kit up:${dialect3}`
7928
+ `drizzle-kit up`
7871
7929
  )}`
7872
7930
  );
7873
7931
  process.exit(1);
@@ -7891,7 +7949,7 @@ var snapshotsPriorV4 = (out) => {
7891
7949
  return pathJson;
7892
7950
  });
7893
7951
  };
7894
- var prepareOutFolder2 = (out, dialect3) => {
7952
+ var prepareOutFolder = (out, dialect3) => {
7895
7953
  const meta = join(out, "meta");
7896
7954
  const journalPath = join(meta, "_journal.json");
7897
7955
  if (!existsSync(join(out, "meta"))) {
@@ -7906,9 +7964,9 @@ var prepareOutFolder2 = (out, dialect3) => {
7906
7964
  var validatorForDialect = (dialect3) => {
7907
7965
  switch (dialect3) {
7908
7966
  case "pg":
7909
- return { validator: backwardCompatiblePgSchema, version: 5 };
7967
+ return { validator: backwardCompatiblePgSchema, version: 6 };
7910
7968
  case "sqlite":
7911
- return { validator: backwardCompatibleSqliteSchema, version: 5 };
7969
+ return { validator: backwardCompatibleSqliteSchema, version: 6 };
7912
7970
  case "mysql":
7913
7971
  return { validator: backwardCompatibleMysqlSchema, version: 5 };
7914
7972
  }
@@ -7956,13 +8014,13 @@ var validateWithReport = (snapshots, dialect3) => {
7956
8014
  return result;
7957
8015
  };
7958
8016
  var prepareMigrationFolder = (outFolder = "drizzle", dialect3) => {
7959
- const { snapshots, journal } = prepareOutFolder2(outFolder, dialect3);
8017
+ const { snapshots, journal } = prepareOutFolder(outFolder, dialect3);
7960
8018
  const report = validateWithReport(snapshots, dialect3);
7961
8019
  if (report.nonLatest.length > 0) {
7962
8020
  console.log(
7963
8021
  report.nonLatest.map((it) => {
7964
8022
  return `${it}/snapshot.json is not of the latest version`;
7965
- }).concat(`Run ${source_default.green.bold(`drizzle-kit up:${dialect3}`)}`).join("\n")
8023
+ }).concat(`Run ${source_default.green.bold(`drizzle-kit up`)}`).join("\n")
7966
8024
  );
7967
8025
  process.exit(0);
7968
8026
  }
@@ -8095,7 +8153,9 @@ var statementsForDiffs = async (in1, in2) => {
8095
8153
  "pg",
8096
8154
  schemasResolver,
8097
8155
  tablesResolver,
8098
- columnsResolver
8156
+ columnsResolver,
8157
+ left,
8158
+ right
8099
8159
  );
8100
8160
  return { ...result, left, right };
8101
8161
  };
@@ -8106,7 +8166,7 @@ export {
8106
8166
  kloudMeta,
8107
8167
  prepareMigrationFolder,
8108
8168
  prepareMigrationMeta,
8109
- prepareOutFolder2 as prepareOutFolder,
8169
+ prepareOutFolder,
8110
8170
  schemaRenameKey,
8111
8171
  snapshotsPriorV4,
8112
8172
  statementsForDiffs,
@@ -1,2 +0,0 @@
1
- import { Dialect } from "../../schemaValidator";
2
- export declare const checkHandler: (out: string, dialect: Dialect) => void;
@@ -1,4 +0,0 @@
1
- export declare const dropMigration: ({ out, bundle, }: {
2
- out: string;
3
- bundle?: boolean | undefined;
4
- }) => Promise<void>;
@@ -1,6 +0,0 @@
1
- import { MySQLPushConfig } from "../validations/mysql";
2
- import { PgPushConfig } from "../validations/pg";
3
- import { SQLitePushConfig } from "../validations/sqlite";
4
- export declare const mysqlPush: (drizzleConfig: MySQLPushConfig, tablesFilter: string[]) => Promise<void>;
5
- export declare const pgPush: (drizzleConfig: PgPushConfig, tablesFilter: string[]) => Promise<void>;
6
- export declare const sqlitePush: (drizzleConfig: SQLitePushConfig, tablesFilter: string[]) => Promise<void>;
@@ -1,2 +0,0 @@
1
- export declare const upSqliteHandler: (out: string) => void;
2
- export declare const upSqliteHandlerV4: (out: string) => void;
package/cli/utils.d.ts DELETED
@@ -1,12 +0,0 @@
1
- export declare const assertExists: (it?: any) => void;
2
- export declare const assertStudioNodeVersion: () => void;
3
- export declare const assertPackages: (...pkgs: string[]) => Promise<void>;
4
- export declare const assertEitherPackage: (...pkgs: string[]) => Promise<string[]>;
5
- export declare const assertOrmCoreVersion: () => Promise<void>;
6
- export declare const ormCoreVersions: () => Promise<{
7
- compatibilityVersion: number;
8
- npmVersion: string;
9
- } | {
10
- compatibilityVersion?: undefined;
11
- npmVersion?: undefined;
12
- }>;