drizzle-kit 0.25.0-178591 → 0.25.0-1f15bfd

Sign up to get free protection for your applications and to get access to all the features.
package/bin.cjs CHANGED
@@ -1315,11 +1315,6 @@ Is ${source_default.bold.blue(
1315
1315
  count: 0,
1316
1316
  name: "foreign keys",
1317
1317
  status: "fetching"
1318
- },
1319
- checks: {
1320
- count: 0,
1321
- name: "check constraints",
1322
- status: "fetching"
1323
1318
  }
1324
1319
  };
1325
1320
  this.formatCount = (count) => {
@@ -1357,7 +1352,6 @@ Is ${source_default.bold.blue(
1357
1352
  info2 += this.hasEnums ? this.statusText(spin, this.state.enums) : "";
1358
1353
  info2 += this.statusText(spin, this.state.indexes);
1359
1354
  info2 += this.statusText(spin, this.state.fks);
1360
- info2 += this.statusText(spin, this.state.checks);
1361
1355
  return info2;
1362
1356
  }
1363
1357
  };
@@ -5427,7 +5421,7 @@ var init_lib = __esm({
5427
5421
  });
5428
5422
 
5429
5423
  // src/serializer/mysqlSchema.ts
5430
- var index, fk, column, tableV3, compositePK, uniqueConstraint, checkConstraint, tableV4, table, kitInternals, dialect, schemaHash, schemaInternalV3, schemaInternalV4, schemaInternalV5, schemaInternal, schemaV3, schemaV4, schemaV5, schema2, tableSquashedV4, tableSquashed, schemaSquashed, schemaSquashedV4, MySqlSquasher, squashMysqlScheme, mysqlSchema, mysqlSchemaV5, mysqlSchemaSquashed, backwardCompatibleMysqlSchema, dryMySql;
5424
+ var index, fk, column, tableV3, compositePK, uniqueConstraint, tableV4, table, kitInternals, dialect, schemaHash, schemaInternalV3, schemaInternalV4, schemaInternalV5, schemaInternal, schemaV3, schemaV4, schemaV5, schema2, tableSquashedV4, tableSquashed, schemaSquashed, schemaSquashedV4, MySqlSquasher, squashMysqlScheme, mysqlSchema, mysqlSchemaV5, mysqlSchemaSquashed, backwardCompatibleMysqlSchema, dryMySql;
5431
5425
  var init_mysqlSchema = __esm({
5432
5426
  "src/serializer/mysqlSchema.ts"() {
5433
5427
  "use strict";
@@ -5477,10 +5471,6 @@ var init_mysqlSchema = __esm({
5477
5471
  name: stringType(),
5478
5472
  columns: stringType().array()
5479
5473
  }).strict();
5480
- checkConstraint = objectType({
5481
- name: stringType(),
5482
- value: stringType()
5483
- }).strict();
5484
5474
  tableV4 = objectType({
5485
5475
  name: stringType(),
5486
5476
  schema: stringType().optional(),
@@ -5494,8 +5484,7 @@ var init_mysqlSchema = __esm({
5494
5484
  indexes: recordType(stringType(), index),
5495
5485
  foreignKeys: recordType(stringType(), fk),
5496
5486
  compositePrimaryKeys: recordType(stringType(), compositePK),
5497
- uniqueConstraints: recordType(stringType(), uniqueConstraint).default({}),
5498
- checkConstraint: recordType(stringType(), checkConstraint).default({})
5487
+ uniqueConstraints: recordType(stringType(), uniqueConstraint).default({})
5499
5488
  }).strict();
5500
5489
  kitInternals = objectType({
5501
5490
  tables: recordType(
@@ -5572,8 +5561,7 @@ var init_mysqlSchema = __esm({
5572
5561
  indexes: recordType(stringType(), stringType()),
5573
5562
  foreignKeys: recordType(stringType(), stringType()),
5574
5563
  compositePrimaryKeys: recordType(stringType(), stringType()),
5575
- uniqueConstraints: recordType(stringType(), stringType()).default({}),
5576
- checkConstraints: recordType(stringType(), stringType()).default({})
5564
+ uniqueConstraints: recordType(stringType(), stringType()).default({})
5577
5565
  }).strict();
5578
5566
  schemaSquashed = objectType({
5579
5567
  version: literalType("5"),
@@ -5640,13 +5628,6 @@ var init_mysqlSchema = __esm({
5640
5628
  onDelete
5641
5629
  });
5642
5630
  return result;
5643
- },
5644
- squashCheck: (input) => {
5645
- return `${input.name};${input.value}`;
5646
- },
5647
- unsquashCheck: (input) => {
5648
- const [name, value] = input.split(";");
5649
- return { name, value };
5650
5631
  }
5651
5632
  };
5652
5633
  squashMysqlScheme = (json) => {
@@ -5667,9 +5648,6 @@ var init_mysqlSchema = __esm({
5667
5648
  return MySqlSquasher.squashUnique(unq);
5668
5649
  }
5669
5650
  );
5670
- const squashedCheckConstraints = mapValues(it[1].checkConstraint, (check2) => {
5671
- return MySqlSquasher.squashCheck(check2);
5672
- });
5673
5651
  return [
5674
5652
  it[0],
5675
5653
  {
@@ -5678,8 +5656,7 @@ var init_mysqlSchema = __esm({
5678
5656
  indexes: squashedIndexes,
5679
5657
  foreignKeys: squashedFKs,
5680
5658
  compositePrimaryKeys: squashedPKs,
5681
- uniqueConstraints: squashedUniqueConstraints,
5682
- checkConstraints: squashedCheckConstraints
5659
+ uniqueConstraints: squashedUniqueConstraints
5683
5660
  }
5684
5661
  ];
5685
5662
  })
@@ -5729,7 +5706,7 @@ var init_vector = __esm({
5729
5706
  });
5730
5707
 
5731
5708
  // src/serializer/pgSchema.ts
5732
- var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, indexColumn, index2, indexV4, indexV5, indexV6, fk2, sequenceSchema, sequenceSquashed, columnV7, column2, checkConstraint2, columnSquashed, tableV32, compositePK2, uniqueConstraint2, tableV42, tableV5, tableV6, tableV7, table2, schemaHash2, kitInternals2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternalV5, pgSchemaInternalV6, pgSchemaExternal, pgSchemaInternalV7, pgSchemaInternal, tableSquashed2, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashedV6, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchemaV5, pgSchemaV6, pgSchemaV7, pgSchema, backwardCompatiblePgSchema, PgSquasher, squashPgScheme, dryPg;
5709
+ var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, indexColumn, index2, indexV4, indexV5, indexV6, fk2, sequenceSchema, sequenceSquashed, columnV7, column2, columnSquashed, tableV32, compositePK2, uniqueConstraint2, tableV42, tableV5, tableV6, tableV7, table2, schemaHash2, kitInternals2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternalV5, pgSchemaInternalV6, pgSchemaExternal, pgSchemaInternalV7, pgSchemaInternal, tableSquashed2, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashedV6, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchemaV5, pgSchemaV6, pgSchemaV7, pgSchema, backwardCompatiblePgSchema, PgSquasher, squashPgScheme, dryPg;
5733
5710
  var init_pgSchema = __esm({
5734
5711
  "src/serializer/pgSchema.ts"() {
5735
5712
  "use strict";
@@ -5893,10 +5870,6 @@ var init_pgSchema = __esm({
5893
5870
  }).optional(),
5894
5871
  identity: sequenceSchema.merge(objectType({ type: enumType(["always", "byDefault"]) })).optional()
5895
5872
  }).strict();
5896
- checkConstraint2 = objectType({
5897
- name: stringType(),
5898
- value: stringType()
5899
- }).strict();
5900
5873
  columnSquashed = objectType({
5901
5874
  name: stringType(),
5902
5875
  type: stringType(),
@@ -5969,8 +5942,7 @@ var init_pgSchema = __esm({
5969
5942
  indexes: recordType(stringType(), index2),
5970
5943
  foreignKeys: recordType(stringType(), fk2),
5971
5944
  compositePrimaryKeys: recordType(stringType(), compositePK2),
5972
- uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({}),
5973
- checkConstraints: recordType(stringType(), checkConstraint2).default({})
5945
+ uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
5974
5946
  }).strict();
5975
5947
  schemaHash2 = objectType({
5976
5948
  id: stringType(),
@@ -6078,8 +6050,7 @@ var init_pgSchema = __esm({
6078
6050
  indexes: recordType(stringType(), stringType()),
6079
6051
  foreignKeys: recordType(stringType(), stringType()),
6080
6052
  compositePrimaryKeys: recordType(stringType(), stringType()),
6081
- uniqueConstraints: recordType(stringType(), stringType()),
6082
- checkConstraints: recordType(stringType(), stringType())
6053
+ uniqueConstraints: recordType(stringType(), stringType())
6083
6054
  }).strict();
6084
6055
  tableSquashedV42 = objectType({
6085
6056
  name: stringType(),
@@ -6261,16 +6232,6 @@ var init_pgSchema = __esm({
6261
6232
  cache: splitted[6] !== "undefined" ? splitted[6] : void 0,
6262
6233
  cycle: splitted[7] === "true"
6263
6234
  };
6264
- },
6265
- squashCheck: (check2) => {
6266
- return `${check2.name};${check2.value}`;
6267
- },
6268
- unsquashCheck: (input) => {
6269
- const [
6270
- name,
6271
- value
6272
- ] = input.split(";");
6273
- return { name, value };
6274
6235
  }
6275
6236
  };
6276
6237
  squashPgScheme = (json, action) => {
@@ -6303,12 +6264,6 @@ var init_pgSchema = __esm({
6303
6264
  return PgSquasher.squashUnique(unq);
6304
6265
  }
6305
6266
  );
6306
- const squashedChecksContraints = mapValues(
6307
- it[1].checkConstraints,
6308
- (check2) => {
6309
- return PgSquasher.squashCheck(check2);
6310
- }
6311
- );
6312
6267
  return [
6313
6268
  it[0],
6314
6269
  {
@@ -6318,8 +6273,7 @@ var init_pgSchema = __esm({
6318
6273
  indexes: squashedIndexes,
6319
6274
  foreignKeys: squashedFKs,
6320
6275
  compositePrimaryKeys: squashedPKs,
6321
- uniqueConstraints: squashedUniqueConstraints,
6322
- checkConstraints: squashedChecksContraints
6276
+ uniqueConstraints: squashedUniqueConstraints
6323
6277
  }
6324
6278
  ];
6325
6279
  })
@@ -6364,7 +6318,7 @@ var init_pgSchema = __esm({
6364
6318
  });
6365
6319
 
6366
6320
  // src/serializer/sqliteSchema.ts
6367
- var index3, fk3, compositePK3, column3, tableV33, uniqueConstraint3, checkConstraint3, table3, dialect2, schemaHash3, schemaInternalV32, schemaInternalV42, schemaInternalV52, kitInternals3, latestVersion, schemaInternal2, schemaV32, schemaV42, schemaV52, schema3, tableSquashed3, schemaSquashed2, SQLiteSquasher, squashSqliteScheme, drySQLite, sqliteSchemaV5, sqliteSchema, SQLiteSchemaSquashed, backwardCompatibleSqliteSchema;
6321
+ var index3, fk3, compositePK3, column3, tableV33, uniqueConstraint3, table3, dialect2, schemaHash3, schemaInternalV32, schemaInternalV42, schemaInternalV52, kitInternals3, latestVersion, schemaInternal2, schemaV32, schemaV42, schemaV52, schema3, tableSquashed3, schemaSquashed2, SQLiteSquasher, squashSqliteScheme, drySQLite, sqliteSchemaV5, sqliteSchema, SQLiteSchemaSquashed, backwardCompatibleSqliteSchema;
6368
6322
  var init_sqliteSchema = __esm({
6369
6323
  "src/serializer/sqliteSchema.ts"() {
6370
6324
  "use strict";
@@ -6411,18 +6365,13 @@ var init_sqliteSchema = __esm({
6411
6365
  name: stringType(),
6412
6366
  columns: stringType().array()
6413
6367
  }).strict();
6414
- checkConstraint3 = objectType({
6415
- name: stringType(),
6416
- value: stringType()
6417
- }).strict();
6418
6368
  table3 = objectType({
6419
6369
  name: stringType(),
6420
6370
  columns: recordType(stringType(), column3),
6421
6371
  indexes: recordType(stringType(), index3),
6422
6372
  foreignKeys: recordType(stringType(), fk3),
6423
6373
  compositePrimaryKeys: recordType(stringType(), compositePK3),
6424
- uniqueConstraints: recordType(stringType(), uniqueConstraint3).default({}),
6425
- checkConstraints: recordType(stringType(), checkConstraint3).default({})
6374
+ uniqueConstraints: recordType(stringType(), uniqueConstraint3).default({})
6426
6375
  }).strict();
6427
6376
  dialect2 = enumType(["sqlite"]);
6428
6377
  schemaHash3 = objectType({
@@ -6484,8 +6433,7 @@ var init_sqliteSchema = __esm({
6484
6433
  indexes: recordType(stringType(), stringType()),
6485
6434
  foreignKeys: recordType(stringType(), stringType()),
6486
6435
  compositePrimaryKeys: recordType(stringType(), stringType()),
6487
- uniqueConstraints: recordType(stringType(), stringType()).default({}),
6488
- checkConstraints: recordType(stringType(), stringType()).default({})
6436
+ uniqueConstraints: recordType(stringType(), stringType()).default({})
6489
6437
  }).strict();
6490
6438
  schemaSquashed2 = objectType({
6491
6439
  version: latestVersion,
@@ -6567,16 +6515,6 @@ var init_sqliteSchema = __esm({
6567
6515
  },
6568
6516
  unsquashPK: (pk) => {
6569
6517
  return pk.split(",");
6570
- },
6571
- squashCheck: (check2) => {
6572
- return `${check2.name};${check2.value}`;
6573
- },
6574
- unsquashCheck: (input) => {
6575
- const [
6576
- name,
6577
- value
6578
- ] = input.split(";");
6579
- return { name, value };
6580
6518
  }
6581
6519
  };
6582
6520
  squashSqliteScheme = (json, action) => {
@@ -6603,12 +6541,6 @@ var init_sqliteSchema = __esm({
6603
6541
  return SQLiteSquasher.squashUnique(unq);
6604
6542
  }
6605
6543
  );
6606
- const squashedCheckConstraints = mapValues(
6607
- it[1].checkConstraints,
6608
- (check2) => {
6609
- return SQLiteSquasher.squashCheck(check2);
6610
- }
6611
- );
6612
6544
  return [
6613
6545
  it[0],
6614
6546
  {
@@ -6617,8 +6549,7 @@ var init_sqliteSchema = __esm({
6617
6549
  indexes: squashedIndexes,
6618
6550
  foreignKeys: squashedFKs,
6619
6551
  compositePrimaryKeys: squashedPKs,
6620
- uniqueConstraints: squashedUniqueConstraints,
6621
- checkConstraints: squashedCheckConstraints
6552
+ uniqueConstraints: squashedUniqueConstraints
6622
6553
  }
6623
6554
  ];
6624
6555
  })
@@ -6660,11 +6591,17 @@ function findAddedAndRemoved(columnNames1, columnNames2) {
6660
6591
  const removedColumns = columnNames1.filter((it) => !set2.has(it));
6661
6592
  return { addedColumns, removedColumns };
6662
6593
  }
6663
- var import_fs, import_path, import_url, copy, objectValues, assertV1OutFolder, dryJournal, prepareOutFolder, validatorForDialect, validateWithReport, prepareMigrationFolder, prepareMigrationMeta, schemaRenameKey, tableRenameKey, columnRenameKey, normaliseSQLiteUrl, normalisePGliteUrl;
6594
+ function getColumnCasing(column7, casing2) {
6595
+ if (!column7.name)
6596
+ return "";
6597
+ return !column7.keyAsName || casing2 === void 0 ? column7.name : casing2 === "camelCase" ? (0, import_casing.toCamelCase)(column7.name) : (0, import_casing.toSnakeCase)(column7.name);
6598
+ }
6599
+ var import_casing, import_fs, import_path, import_url, copy, objectValues, assertV1OutFolder, dryJournal, prepareOutFolder, validatorForDialect, validateWithReport, prepareMigrationFolder, prepareMigrationMeta, schemaRenameKey, tableRenameKey, columnRenameKey, normaliseSQLiteUrl, normalisePGliteUrl;
6664
6600
  var init_utils = __esm({
6665
6601
  "src/utils.ts"() {
6666
6602
  "use strict";
6667
6603
  init_source();
6604
+ import_casing = require("drizzle-orm/casing");
6668
6605
  import_fs = require("fs");
6669
6606
  import_path = require("path");
6670
6607
  import_url = require("url");
@@ -6694,27 +6631,27 @@ var init_utils = __esm({
6694
6631
  process.exit(1);
6695
6632
  }
6696
6633
  };
6697
- dryJournal = (dialect7) => {
6634
+ dryJournal = (dialect4) => {
6698
6635
  return {
6699
6636
  version: snapshotVersion,
6700
- dialect: dialect7,
6637
+ dialect: dialect4,
6701
6638
  entries: []
6702
6639
  };
6703
6640
  };
6704
- prepareOutFolder = (out, dialect7) => {
6641
+ prepareOutFolder = (out, dialect4) => {
6705
6642
  const meta = (0, import_path.join)(out, "meta");
6706
6643
  const journalPath = (0, import_path.join)(meta, "_journal.json");
6707
6644
  if (!(0, import_fs.existsSync)((0, import_path.join)(out, "meta"))) {
6708
6645
  (0, import_fs.mkdirSync)(meta, { recursive: true });
6709
- (0, import_fs.writeFileSync)(journalPath, JSON.stringify(dryJournal(dialect7)));
6646
+ (0, import_fs.writeFileSync)(journalPath, JSON.stringify(dryJournal(dialect4)));
6710
6647
  }
6711
6648
  const journal = JSON.parse((0, import_fs.readFileSync)(journalPath).toString());
6712
6649
  const snapshots = (0, import_fs.readdirSync)(meta).filter((it) => !it.startsWith("_")).map((it) => (0, import_path.join)(meta, it));
6713
6650
  snapshots.sort();
6714
6651
  return { meta, snapshots, journal };
6715
6652
  };
6716
- validatorForDialect = (dialect7) => {
6717
- switch (dialect7) {
6653
+ validatorForDialect = (dialect4) => {
6654
+ switch (dialect4) {
6718
6655
  case "postgresql":
6719
6656
  return { validator: backwardCompatiblePgSchema, version: 7 };
6720
6657
  case "sqlite":
@@ -6725,8 +6662,8 @@ var init_utils = __esm({
6725
6662
  return { validator: backwardCompatibleMysqlSchema, version: 5 };
6726
6663
  }
6727
6664
  };
6728
- validateWithReport = (snapshots, dialect7) => {
6729
- const { validator: validator2, version: version3 } = validatorForDialect(dialect7);
6665
+ validateWithReport = (snapshots, dialect4) => {
6666
+ const { validator: validator2, version: version3 } = validatorForDialect(dialect4);
6730
6667
  const result = snapshots.reduce(
6731
6668
  (accum, it) => {
6732
6669
  const raw2 = JSON.parse((0, import_fs.readFileSync)(`./${it}`).toString());
@@ -6767,9 +6704,9 @@ var init_utils = __esm({
6767
6704
  );
6768
6705
  return result;
6769
6706
  };
6770
- prepareMigrationFolder = (outFolder = "drizzle", dialect7) => {
6771
- const { snapshots, journal } = prepareOutFolder(outFolder, dialect7);
6772
- const report = validateWithReport(snapshots, dialect7);
6707
+ prepareMigrationFolder = (outFolder = "drizzle", dialect4) => {
6708
+ const { snapshots, journal } = prepareOutFolder(outFolder, dialect4);
6709
+ const report = validateWithReport(snapshots, dialect4);
6773
6710
  if (report.nonLatest.length > 0) {
6774
6711
  console.log(
6775
6712
  report.nonLatest.map((it) => {
@@ -11319,7 +11256,7 @@ var init_outputs = __esm({
11319
11256
  });
11320
11257
 
11321
11258
  // src/cli/validations/common.ts
11322
- var assertCollisions, sqliteDriversLiterals, postgresqlDriversLiterals, prefixes, prefix, sqliteDriver, postgresDriver, driver, configMigrations, configCommonSchema, casing, introspectParams, configIntrospectCliSchema, configGenerateSchema, configPushSchema, drivers, wrapParam;
11259
+ var assertCollisions, sqliteDriversLiterals, postgresqlDriversLiterals, prefixes, prefix, casingTypes, casingType, sqliteDriver, postgresDriver, driver, configMigrations, configCommonSchema, casing, introspectParams, configIntrospectCliSchema, configGenerateSchema, configPushSchema, drivers, wrapParam;
11323
11260
  var init_common = __esm({
11324
11261
  "src/cli/validations/common.ts"() {
11325
11262
  "use strict";
@@ -11363,6 +11300,8 @@ var init_common = __esm({
11363
11300
  {
11364
11301
  const _2 = "";
11365
11302
  }
11303
+ casingTypes = ["snake_case", "camelCase"];
11304
+ casingType = enumType(casingTypes);
11366
11305
  sqliteDriver = unionType(sqliteDriversLiterals);
11367
11306
  postgresDriver = unionType(postgresqlDriversLiterals);
11368
11307
  driver = unionType([sqliteDriver, postgresDriver]);
@@ -11381,7 +11320,8 @@ var init_common = __esm({
11381
11320
  tablesFilter: unionType([stringType(), stringType().array()]).optional(),
11382
11321
  schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
11383
11322
  migrations: configMigrations,
11384
- dbCredentials: anyType().optional()
11323
+ dbCredentials: anyType().optional(),
11324
+ casing: casingType.optional()
11385
11325
  }).passthrough();
11386
11326
  casing = unionType([literalType("camel"), literalType("preserve")]).default(
11387
11327
  "camel"
@@ -11463,6 +11403,7 @@ var init_cli = __esm({
11463
11403
  }).strict();
11464
11404
  pushParams = objectType({
11465
11405
  dialect: dialect3,
11406
+ casing: casingType.optional(),
11466
11407
  schema: unionType([stringType(), stringType().array()]),
11467
11408
  tablesFilter: unionType([stringType(), stringType().array()]).optional(),
11468
11409
  schemaFilter: unionType([stringType(), stringType().array()]).optional().default(["public"]),
@@ -17479,11 +17420,11 @@ var init_utils4 = __esm({
17479
17420
  prepareGenerateConfig = async (options, from) => {
17480
17421
  var _a;
17481
17422
  const config = from === "config" ? await drizzleConfigFromFile(options.config) : options;
17482
- const { schema: schema5, out, breakpoints, dialect: dialect7, driver: driver2 } = config;
17483
- if (!schema5 || !dialect7) {
17423
+ const { schema: schema5, out, breakpoints, dialect: dialect4, driver: driver2, casing: casing2 } = config;
17424
+ if (!schema5 || !dialect4) {
17484
17425
  console.log(error("Please provide required params:"));
17485
17426
  console.log(wrapParam("schema", schema5));
17486
- console.log(wrapParam("dialect", dialect7));
17427
+ console.log(wrapParam("dialect", dialect4));
17487
17428
  console.log(wrapParam("out", out, true));
17488
17429
  process.exit(1);
17489
17430
  }
@@ -17494,14 +17435,15 @@ var init_utils4 = __esm({
17494
17435
  }
17495
17436
  const prefix2 = ("migrations" in config ? (_a = config.migrations) == null ? void 0 : _a.prefix : options.prefix) || "index";
17496
17437
  return {
17497
- dialect: dialect7,
17438
+ dialect: dialect4,
17498
17439
  name: options.name,
17499
17440
  custom: options.custom || false,
17500
17441
  prefix: prefix2,
17501
17442
  breakpoints: breakpoints || true,
17502
17443
  schema: schema5,
17503
17444
  out: out || "drizzle",
17504
- bundle: driver2 === "expo"
17445
+ bundle: driver2 === "expo",
17446
+ casing: casing2
17505
17447
  };
17506
17448
  };
17507
17449
  flattenDatabaseCredentials = (config) => {
@@ -17568,6 +17510,7 @@ var init_utils4 = __esm({
17568
17510
  verbose: config.verbose ?? false,
17569
17511
  force: options.force ?? false,
17570
17512
  credentials: parsed2.data,
17513
+ casing: config.casing,
17571
17514
  tablesFilter,
17572
17515
  schemasFilter
17573
17516
  };
@@ -17585,6 +17528,7 @@ var init_utils4 = __esm({
17585
17528
  verbose: config.verbose ?? false,
17586
17529
  force: options.force ?? false,
17587
17530
  credentials: parsed2.data,
17531
+ casing: config.casing,
17588
17532
  tablesFilter,
17589
17533
  schemasFilter
17590
17534
  };
@@ -17602,6 +17546,7 @@ var init_utils4 = __esm({
17602
17546
  verbose: config.verbose ?? false,
17603
17547
  force: options.force ?? false,
17604
17548
  credentials: parsed2.data,
17549
+ casing: config.casing,
17605
17550
  tablesFilter,
17606
17551
  schemasFilter
17607
17552
  };
@@ -17619,6 +17564,7 @@ var init_utils4 = __esm({
17619
17564
  verbose: config.verbose ?? false,
17620
17565
  force: options.force ?? false,
17621
17566
  credentials: parsed2.data,
17567
+ casing: config.casing,
17622
17568
  tablesFilter,
17623
17569
  schemasFilter
17624
17570
  };
@@ -17637,11 +17583,11 @@ var init_utils4 = __esm({
17637
17583
  process.exit(1);
17638
17584
  }
17639
17585
  const config = parsed.data;
17640
- const dialect7 = config.dialect;
17586
+ const dialect4 = config.dialect;
17641
17587
  const tablesFilterConfig = config.tablesFilter;
17642
17588
  const tablesFilter = tablesFilterConfig ? typeof tablesFilterConfig === "string" ? [tablesFilterConfig] : tablesFilterConfig : [];
17643
17589
  if (config.extensionsFilters) {
17644
- if (config.extensionsFilters.includes("postgis") && dialect7 === "postgresql") {
17590
+ if (config.extensionsFilters.includes("postgis") && dialect4 === "postgresql") {
17645
17591
  tablesFilter.push(
17646
17592
  ...["!geography_columns", "!geometry_columns", "!spatial_ref_sys"]
17647
17593
  );
@@ -17649,7 +17595,7 @@ var init_utils4 = __esm({
17649
17595
  }
17650
17596
  const schemasFilterConfig = config.schemaFilter;
17651
17597
  const schemasFilter = schemasFilterConfig ? typeof schemasFilterConfig === "string" ? [schemasFilterConfig] : schemasFilterConfig : [];
17652
- if (dialect7 === "postgresql") {
17598
+ if (dialect4 === "postgresql") {
17653
17599
  const parsed2 = postgresCredentials.safeParse(config);
17654
17600
  if (!parsed2.success) {
17655
17601
  printConfigConnectionIssues3(config);
@@ -17666,7 +17612,7 @@ var init_utils4 = __esm({
17666
17612
  prefix: ((_a = config.migrations) == null ? void 0 : _a.prefix) || "index"
17667
17613
  };
17668
17614
  }
17669
- if (dialect7 === "mysql") {
17615
+ if (dialect4 === "mysql") {
17670
17616
  const parsed2 = mysqlCredentials.safeParse(config);
17671
17617
  if (!parsed2.success) {
17672
17618
  printConfigConnectionIssues2(config);
@@ -17683,7 +17629,7 @@ var init_utils4 = __esm({
17683
17629
  prefix: ((_b = config.migrations) == null ? void 0 : _b.prefix) || "index"
17684
17630
  };
17685
17631
  }
17686
- if (dialect7 === "sqlite") {
17632
+ if (dialect4 === "sqlite") {
17687
17633
  const parsed2 = sqliteCredentials.safeParse(config);
17688
17634
  if (!parsed2.success) {
17689
17635
  printConfigConnectionIssues4(config, "pull");
@@ -17700,14 +17646,14 @@ var init_utils4 = __esm({
17700
17646
  prefix: ((_c = config.migrations) == null ? void 0 : _c.prefix) || "index"
17701
17647
  };
17702
17648
  }
17703
- if (dialect7 === "turso") {
17649
+ if (dialect4 === "turso") {
17704
17650
  const parsed2 = libSQLCredentials.safeParse(config);
17705
17651
  if (!parsed2.success) {
17706
17652
  printConfigConnectionIssues(config, "pull");
17707
17653
  process.exit(1);
17708
17654
  }
17709
17655
  return {
17710
- dialect: dialect7,
17656
+ dialect: dialect4,
17711
17657
  out: config.out,
17712
17658
  breakpoints: config.breakpoints,
17713
17659
  casing: config.casing,
@@ -17717,7 +17663,7 @@ var init_utils4 = __esm({
17717
17663
  prefix: ((_d = config.migrations) == null ? void 0 : _d.prefix) || "index"
17718
17664
  };
17719
17665
  }
17720
- assertUnreachable(dialect7);
17666
+ assertUnreachable(dialect4);
17721
17667
  };
17722
17668
  prepareStudioConfig = async (options) => {
17723
17669
  const params = studioCliParams.parse(options);
@@ -17734,9 +17680,9 @@ var init_utils4 = __esm({
17734
17680
  process.exit(1);
17735
17681
  }
17736
17682
  const { host, port } = params;
17737
- const { dialect: dialect7, schema: schema5 } = result.data;
17683
+ const { dialect: dialect4, schema: schema5 } = result.data;
17738
17684
  const flattened = flattenDatabaseCredentials(config);
17739
- if (dialect7 === "postgresql") {
17685
+ if (dialect4 === "postgresql") {
17740
17686
  const parsed = postgresCredentials.safeParse(flattened);
17741
17687
  if (!parsed.success) {
17742
17688
  printConfigConnectionIssues3(flattened);
@@ -17744,14 +17690,14 @@ var init_utils4 = __esm({
17744
17690
  }
17745
17691
  const credentials2 = parsed.data;
17746
17692
  return {
17747
- dialect: dialect7,
17693
+ dialect: dialect4,
17748
17694
  schema: schema5,
17749
17695
  host,
17750
17696
  port,
17751
17697
  credentials: credentials2
17752
17698
  };
17753
17699
  }
17754
- if (dialect7 === "mysql") {
17700
+ if (dialect4 === "mysql") {
17755
17701
  const parsed = mysqlCredentials.safeParse(flattened);
17756
17702
  if (!parsed.success) {
17757
17703
  printConfigConnectionIssues2(flattened);
@@ -17759,14 +17705,14 @@ var init_utils4 = __esm({
17759
17705
  }
17760
17706
  const credentials2 = parsed.data;
17761
17707
  return {
17762
- dialect: dialect7,
17708
+ dialect: dialect4,
17763
17709
  schema: schema5,
17764
17710
  host,
17765
17711
  port,
17766
17712
  credentials: credentials2
17767
17713
  };
17768
17714
  }
17769
- if (dialect7 === "sqlite") {
17715
+ if (dialect4 === "sqlite") {
17770
17716
  const parsed = sqliteCredentials.safeParse(flattened);
17771
17717
  if (!parsed.success) {
17772
17718
  printConfigConnectionIssues4(flattened, "studio");
@@ -17774,14 +17720,14 @@ var init_utils4 = __esm({
17774
17720
  }
17775
17721
  const credentials2 = parsed.data;
17776
17722
  return {
17777
- dialect: dialect7,
17723
+ dialect: dialect4,
17778
17724
  schema: schema5,
17779
17725
  host,
17780
17726
  port,
17781
17727
  credentials: credentials2
17782
17728
  };
17783
17729
  }
17784
- if (dialect7 === "turso") {
17730
+ if (dialect4 === "turso") {
17785
17731
  const parsed = libSQLCredentials.safeParse(flattened);
17786
17732
  if (!parsed.success) {
17787
17733
  printConfigConnectionIssues(flattened, "studio");
@@ -17789,14 +17735,14 @@ var init_utils4 = __esm({
17789
17735
  }
17790
17736
  const credentials2 = parsed.data;
17791
17737
  return {
17792
- dialect: dialect7,
17738
+ dialect: dialect4,
17793
17739
  schema: schema5,
17794
17740
  host,
17795
17741
  port,
17796
17742
  credentials: credentials2
17797
17743
  };
17798
17744
  }
17799
- assertUnreachable(dialect7);
17745
+ assertUnreachable(dialect4);
17800
17746
  };
17801
17747
  migrateConfig = objectType({
17802
17748
  dialect: dialect3,
@@ -17811,10 +17757,10 @@ var init_utils4 = __esm({
17811
17757
  console.log(wrapParam("dialect", config.dialect));
17812
17758
  process.exit(1);
17813
17759
  }
17814
- const { dialect: dialect7, out } = parsed.data;
17760
+ const { dialect: dialect4, out } = parsed.data;
17815
17761
  const { schema: schema5, table: table4 } = parsed.data.migrations || {};
17816
17762
  const flattened = flattenDatabaseCredentials(config);
17817
- if (dialect7 === "postgresql") {
17763
+ if (dialect4 === "postgresql") {
17818
17764
  const parsed2 = postgresCredentials.safeParse(flattened);
17819
17765
  if (!parsed2.success) {
17820
17766
  printConfigConnectionIssues3(flattened);
@@ -17822,14 +17768,14 @@ var init_utils4 = __esm({
17822
17768
  }
17823
17769
  const credentials2 = parsed2.data;
17824
17770
  return {
17825
- dialect: dialect7,
17771
+ dialect: dialect4,
17826
17772
  out,
17827
17773
  credentials: credentials2,
17828
17774
  schema: schema5,
17829
17775
  table: table4
17830
17776
  };
17831
17777
  }
17832
- if (dialect7 === "mysql") {
17778
+ if (dialect4 === "mysql") {
17833
17779
  const parsed2 = mysqlCredentials.safeParse(flattened);
17834
17780
  if (!parsed2.success) {
17835
17781
  printConfigConnectionIssues2(flattened);
@@ -17837,14 +17783,14 @@ var init_utils4 = __esm({
17837
17783
  }
17838
17784
  const credentials2 = parsed2.data;
17839
17785
  return {
17840
- dialect: dialect7,
17786
+ dialect: dialect4,
17841
17787
  out,
17842
17788
  credentials: credentials2,
17843
17789
  schema: schema5,
17844
17790
  table: table4
17845
17791
  };
17846
17792
  }
17847
- if (dialect7 === "sqlite") {
17793
+ if (dialect4 === "sqlite") {
17848
17794
  const parsed2 = sqliteCredentials.safeParse(flattened);
17849
17795
  if (!parsed2.success) {
17850
17796
  printConfigConnectionIssues4(flattened, "migrate");
@@ -17852,14 +17798,14 @@ var init_utils4 = __esm({
17852
17798
  }
17853
17799
  const credentials2 = parsed2.data;
17854
17800
  return {
17855
- dialect: dialect7,
17801
+ dialect: dialect4,
17856
17802
  out,
17857
17803
  credentials: credentials2,
17858
17804
  schema: schema5,
17859
17805
  table: table4
17860
17806
  };
17861
17807
  }
17862
- if (dialect7 === "turso") {
17808
+ if (dialect4 === "turso") {
17863
17809
  const parsed2 = libSQLCredentials.safeParse(flattened);
17864
17810
  if (!parsed2.success) {
17865
17811
  printConfigConnectionIssues(flattened, "migrate");
@@ -17867,14 +17813,14 @@ var init_utils4 = __esm({
17867
17813
  }
17868
17814
  const credentials2 = parsed2.data;
17869
17815
  return {
17870
- dialect: dialect7,
17816
+ dialect: dialect4,
17871
17817
  out,
17872
17818
  credentials: credentials2,
17873
17819
  schema: schema5,
17874
17820
  table: table4
17875
17821
  };
17876
17822
  }
17877
- assertUnreachable(dialect7);
17823
+ assertUnreachable(dialect4);
17878
17824
  };
17879
17825
  drizzleConfigFromFile = async (configPath) => {
17880
17826
  const prefix2 = process.env.TEST_CONFIG_PATH_PREFIX || "";
@@ -17903,6 +17849,7 @@ var init_utils4 = __esm({
17903
17849
  unregister();
17904
17850
  const res = configCommonSchema.safeParse(content);
17905
17851
  if (!res.success) {
17852
+ console.log(res.error);
17906
17853
  if (!("dialect" in content)) {
17907
17854
  console.log(error("Please specify 'dialect' param in config file"));
17908
17855
  }
@@ -17975,7 +17922,7 @@ function clearDefaults(defaultValue, collate) {
17975
17922
  return `(${resultDefault})`;
17976
17923
  }
17977
17924
  }
17978
- var import_drizzle_orm2, import_drizzle_orm3, import_mysql_core2, import_mysql_core3, dialect4, indexName, generateMySqlSnapshot, fromDatabase;
17925
+ var import_drizzle_orm2, import_drizzle_orm3, import_mysql_core2, import_mysql_core3, indexName, generateMySqlSnapshot, fromDatabase;
17979
17926
  var init_mysqlSerializer = __esm({
17980
17927
  "src/serializer/mysqlSerializer.ts"() {
17981
17928
  "use strict";
@@ -17985,12 +17932,13 @@ var init_mysqlSerializer = __esm({
17985
17932
  import_mysql_core2 = require("drizzle-orm/mysql-core");
17986
17933
  import_mysql_core3 = require("drizzle-orm/mysql-core");
17987
17934
  init_outputs();
17935
+ init_utils();
17988
17936
  init_serializer();
17989
- dialect4 = new import_mysql_core2.MySqlDialect();
17990
17937
  indexName = (tableName, columns) => {
17991
17938
  return `${tableName}_${columns.join("_")}_index`;
17992
17939
  };
17993
- generateMySqlSnapshot = (tables) => {
17940
+ generateMySqlSnapshot = (tables, casing2) => {
17941
+ const dialect4 = new import_mysql_core2.MySqlDialect({ casing: casing2 });
17994
17942
  const result = {};
17995
17943
  const internal = { tables: {}, indexes: {} };
17996
17944
  for (const table4 of tables) {
@@ -18000,7 +17948,6 @@ var init_mysqlSerializer = __esm({
18000
17948
  indexes,
18001
17949
  foreignKeys,
18002
17950
  schema: schema5,
18003
- checks,
18004
17951
  primaryKeys,
18005
17952
  uniqueConstraints
18006
17953
  } = (0, import_mysql_core3.getTableConfig)(table4);
@@ -18009,15 +17956,14 @@ var init_mysqlSerializer = __esm({
18009
17956
  const foreignKeysObject = {};
18010
17957
  const primaryKeysObject = {};
18011
17958
  const uniqueConstraintObject = {};
18012
- const checkConstraintObject = {};
18013
- let checksInTable = {};
18014
17959
  columns.forEach((column7) => {
17960
+ const name = getColumnCasing(column7, casing2);
18015
17961
  const notNull = column7.notNull;
18016
17962
  const sqlTypeLowered = column7.getSQLType().toLowerCase();
18017
17963
  const autoIncrement = typeof column7.autoIncrement === "undefined" ? false : column7.autoIncrement;
18018
17964
  const generated = column7.generated;
18019
17965
  const columnToSet = {
18020
- name: column7.name,
17966
+ name,
18021
17967
  type: column7.getSQLType(),
18022
17968
  primaryKey: false,
18023
17969
  // If field is autoincrement it's notNull by default
@@ -18031,9 +17977,9 @@ var init_mysqlSerializer = __esm({
18031
17977
  } : void 0
18032
17978
  };
18033
17979
  if (column7.primary) {
18034
- primaryKeysObject[`${tableName}_${column7.name}`] = {
18035
- name: `${tableName}_${column7.name}`,
18036
- columns: [column7.name]
17980
+ primaryKeysObject[`${tableName}_${name}`] = {
17981
+ name: `${tableName}_${name}`,
17982
+ columns: [name]
18037
17983
  };
18038
17984
  }
18039
17985
  if (column7.isUnique) {
@@ -18047,7 +17993,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
18047
17993
  The unique constraint ${source_default.underline.blue(
18048
17994
  column7.uniqueName
18049
17995
  )} on the ${source_default.underline.blue(
18050
- column7.name
17996
+ name
18051
17997
  )} column is confilcting with a unique constraint name already defined for ${source_default.underline.blue(
18052
17998
  existingUnique.columns.join(",")
18053
17999
  )} columns
@@ -18062,7 +18008,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
18062
18008
  }
18063
18009
  if (column7.default !== void 0) {
18064
18010
  if ((0, import_drizzle_orm2.is)(column7.default, import_drizzle_orm3.SQL)) {
18065
- columnToSet.default = sqlToStr(column7.default);
18011
+ columnToSet.default = sqlToStr(column7.default, casing2);
18066
18012
  } else {
18067
18013
  if (typeof column7.default === "string") {
18068
18014
  columnToSet.default = `'${column7.default}'`;
@@ -18084,20 +18030,27 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
18084
18030
  }
18085
18031
  }
18086
18032
  }
18087
- columnsObject[column7.name] = columnToSet;
18033
+ columnsObject[name] = columnToSet;
18088
18034
  });
18089
18035
  primaryKeys.map((pk) => {
18090
- const columnNames = pk.columns.map((c) => c.name);
18091
- primaryKeysObject[pk.getName()] = {
18092
- name: pk.getName(),
18036
+ const originalColumnNames = pk.columns.map((c) => c.name);
18037
+ const columnNames = pk.columns.map((c) => getColumnCasing(c, casing2));
18038
+ let name = pk.getName();
18039
+ if (casing2 !== void 0) {
18040
+ for (let i2 = 0; i2 < originalColumnNames.length; i2++) {
18041
+ name = name.replace(originalColumnNames[i2], columnNames[i2]);
18042
+ }
18043
+ }
18044
+ primaryKeysObject[name] = {
18045
+ name,
18093
18046
  columns: columnNames
18094
18047
  };
18095
18048
  for (const column7 of pk.columns) {
18096
- columnsObject[column7.name].notNull = true;
18049
+ columnsObject[getColumnCasing(column7, casing2)].notNull = true;
18097
18050
  }
18098
18051
  });
18099
18052
  uniqueConstraints == null ? void 0 : uniqueConstraints.map((unq) => {
18100
- const columnNames = unq.columns.map((c) => c.name);
18053
+ const columnNames = unq.columns.map((c) => getColumnCasing(c, casing2));
18101
18054
  const name = unq.name ?? (0, import_mysql_core2.uniqueKeyName)(table4, columnNames);
18102
18055
  const existingUnique = uniqueConstraintObject[name];
18103
18056
  if (typeof existingUnique !== "undefined") {
@@ -18125,15 +18078,25 @@ The unique constraint ${source_default.underline.blue(
18125
18078
  };
18126
18079
  });
18127
18080
  const fks = foreignKeys.map((fk4) => {
18128
- const name = fk4.getName();
18129
18081
  const tableFrom = tableName;
18130
18082
  const onDelete = fk4.onDelete ?? "no action";
18131
18083
  const onUpdate = fk4.onUpdate ?? "no action";
18132
18084
  const reference = fk4.reference();
18133
18085
  const referenceFT = reference.foreignTable;
18134
18086
  const tableTo = (0, import_drizzle_orm2.getTableName)(referenceFT);
18135
- const columnsFrom = reference.columns.map((it) => it.name);
18136
- const columnsTo = reference.foreignColumns.map((it) => it.name);
18087
+ const originalColumnsFrom = reference.columns.map((it) => it.name);
18088
+ const columnsFrom = reference.columns.map((it) => getColumnCasing(it, casing2));
18089
+ const originalColumnsTo = reference.foreignColumns.map((it) => it.name);
18090
+ const columnsTo = reference.foreignColumns.map((it) => getColumnCasing(it, casing2));
18091
+ let name = fk4.getName();
18092
+ if (casing2 !== void 0) {
18093
+ for (let i2 = 0; i2 < originalColumnsFrom.length; i2++) {
18094
+ name = name.replace(originalColumnsFrom[i2], columnsFrom[i2]);
18095
+ }
18096
+ for (let i2 = 0; i2 < originalColumnsTo.length; i2++) {
18097
+ name = name.replace(originalColumnsTo[i2], columnsTo[i2]);
18098
+ }
18099
+ }
18137
18100
  return {
18138
18101
  name,
18139
18102
  tableFrom,
@@ -18173,7 +18136,7 @@ The unique constraint ${source_default.underline.blue(
18173
18136
  }
18174
18137
  return sql;
18175
18138
  } else {
18176
- return `${it.name}`;
18139
+ return `${getColumnCasing(it, casing2)}`;
18177
18140
  }
18178
18141
  });
18179
18142
  if (value.config.unique) {
@@ -18224,32 +18187,6 @@ We have encountered a collision between the index name on columns ${source_defau
18224
18187
  lock: value.config.lock
18225
18188
  };
18226
18189
  });
18227
- checks.forEach((check2) => {
18228
- check2;
18229
- const checkName = check2.name;
18230
- if (typeof checksInTable[tableName] !== "undefined") {
18231
- if (checksInTable[tableName].includes(check2.name)) {
18232
- console.log(
18233
- `
18234
- ${withStyle.errorWarning(
18235
- `We've found duplicated check constraint name in ${source_default.underline.blue(
18236
- tableName
18237
- )}. Please rename your check constraint in the ${source_default.underline.blue(
18238
- tableName
18239
- )} table`
18240
- )}`
18241
- );
18242
- process.exit(1);
18243
- }
18244
- checksInTable[tableName].push(checkName);
18245
- } else {
18246
- checksInTable[tableName] = [check2.name];
18247
- }
18248
- checkConstraintObject[checkName] = {
18249
- name: checkName,
18250
- value: dialect4.sqlToQuery(check2.value).sql
18251
- };
18252
- });
18253
18190
  if (!schema5) {
18254
18191
  result[tableName] = {
18255
18192
  name: tableName,
@@ -18257,8 +18194,7 @@ ${withStyle.errorWarning(
18257
18194
  indexes: indexesObject,
18258
18195
  foreignKeys: foreignKeysObject,
18259
18196
  compositePrimaryKeys: primaryKeysObject,
18260
- uniqueConstraints: uniqueConstraintObject,
18261
- checkConstraint: checkConstraintObject
18197
+ uniqueConstraints: uniqueConstraintObject
18262
18198
  };
18263
18199
  }
18264
18200
  }
@@ -18285,7 +18221,6 @@ ${withStyle.errorWarning(
18285
18221
  let tablesCount = /* @__PURE__ */ new Set();
18286
18222
  let indexesCount = 0;
18287
18223
  let foreignKeysCount = 0;
18288
- let checksCount = 0;
18289
18224
  const idxs = await db.query(
18290
18225
  `select * from INFORMATION_SCHEMA.STATISTICS
18291
18226
  WHERE INFORMATION_SCHEMA.STATISTICS.TABLE_SCHEMA = '${inputSchema}' and INFORMATION_SCHEMA.STATISTICS.INDEX_NAME != 'PRIMARY';`
@@ -18381,8 +18316,7 @@ ${withStyle.errorWarning(
18381
18316
  compositePrimaryKeys: {},
18382
18317
  indexes: {},
18383
18318
  foreignKeys: {},
18384
- uniqueConstraints: {},
18385
- checkConstraint: {}
18319
+ uniqueConstraints: {}
18386
18320
  };
18387
18321
  } else {
18388
18322
  result[tableName].columns[columnName] = newColumn;
@@ -18533,38 +18467,6 @@ ${withStyle.errorWarning(
18533
18467
  progressCallback("indexes", indexesCount, "done");
18534
18468
  progressCallback("enums", 0, "done");
18535
18469
  }
18536
- const checkConstraints = await db.query(
18537
- `SELECT
18538
- tc.table_name,
18539
- tc.constraint_name,
18540
- cc.check_clause
18541
- FROM
18542
- information_schema.table_constraints tc
18543
- JOIN
18544
- information_schema.check_constraints cc
18545
- ON tc.constraint_name = cc.constraint_name
18546
- WHERE
18547
- tc.constraint_schema = '${inputSchema}'
18548
- AND
18549
- tc.constraint_type = 'CHECK';`
18550
- );
18551
- checksCount += checkConstraints.length;
18552
- if (progressCallback) {
18553
- progressCallback("checks", checksCount, "fetching");
18554
- }
18555
- for (const checkConstraintRow of checkConstraints) {
18556
- const constraintName = checkConstraintRow["CONSTRAINT_NAME"];
18557
- const constraintValue = checkConstraintRow["CHECK_CLAUSE"];
18558
- const tableName = checkConstraintRow["TABLE_NAME"];
18559
- const tableInResult = result[tableName];
18560
- tableInResult.checkConstraint[constraintName] = {
18561
- name: constraintName,
18562
- value: constraintValue
18563
- };
18564
- }
18565
- if (progressCallback) {
18566
- progressCallback("checks", checksCount, "done");
18567
- }
18568
18470
  return {
18569
18471
  version: "5",
18570
18472
  dialect: "mysql",
@@ -18679,7 +18581,7 @@ function buildArrayString(array, sqlType) {
18679
18581
  }).join(",");
18680
18582
  return `{${values}}`;
18681
18583
  }
18682
- var import_drizzle_orm5, import_pg_core2, import_pg_core3, dialect5, indexName2, generatePgSnapshot, trimChar, fromDatabase2, defaultForColumn;
18584
+ var import_drizzle_orm5, import_pg_core2, import_pg_core3, indexName2, generatePgSnapshot, trimChar, fromDatabase2, defaultForColumn;
18683
18585
  var init_pgSerializer = __esm({
18684
18586
  "src/serializer/pgSerializer.ts"() {
18685
18587
  "use strict";
@@ -18691,17 +18593,16 @@ var init_pgSerializer = __esm({
18691
18593
  init_outputs();
18692
18594
  init_utils();
18693
18595
  init_serializer();
18694
- dialect5 = new import_pg_core2.PgDialect();
18695
18596
  indexName2 = (tableName, columns) => {
18696
18597
  return `${tableName}_${columns.join("_")}_index`;
18697
18598
  };
18698
- generatePgSnapshot = (tables, enums, schemas, sequences, schemaFilter) => {
18599
+ generatePgSnapshot = (tables, enums, schemas, sequences, casing2, schemaFilter) => {
18699
18600
  var _a, _b, _c, _d, _e, _f;
18601
+ const dialect4 = new import_pg_core2.PgDialect({ casing: casing2 });
18700
18602
  const result = {};
18701
18603
  const sequencesToReturn = {};
18702
18604
  const indexesInSchema = {};
18703
18605
  for (const table4 of tables) {
18704
- const checksInTable = {};
18705
18606
  const {
18706
18607
  name: tableName,
18707
18608
  columns,
@@ -18717,12 +18618,12 @@ var init_pgSerializer = __esm({
18717
18618
  }
18718
18619
  const columnsObject = {};
18719
18620
  const indexesObject = {};
18720
- const checksObject = {};
18721
18621
  const foreignKeysObject = {};
18722
18622
  const primaryKeysObject = {};
18723
18623
  const uniqueConstraintObject = {};
18724
18624
  columns.forEach((column7) => {
18725
18625
  var _a2, _b2, _c2, _d2, _e2, _f2;
18626
+ const name = getColumnCasing(column7, casing2);
18726
18627
  const notNull = column7.notNull;
18727
18628
  const primaryKey = column7.primary;
18728
18629
  const sqlTypeLowered = column7.getSQLType().toLowerCase();
@@ -18735,18 +18636,18 @@ var init_pgSerializer = __esm({
18735
18636
  const startWith = stringFromIdentityProperty((_d2 = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _d2.startWith) ?? (parseFloat(increment) < 0 ? maxValue : minValue);
18736
18637
  const cache = stringFromIdentityProperty((_e2 = identity == null ? void 0 : identity.sequenceOptions) == null ? void 0 : _e2.cache) ?? "1";
18737
18638
  const columnToSet = {
18738
- name: column7.name,
18639
+ name,
18739
18640
  type: column7.getSQLType(),
18740
18641
  typeSchema,
18741
18642
  primaryKey,
18742
18643
  notNull,
18743
18644
  generated: generated ? {
18744
- as: (0, import_drizzle_orm5.is)(generated.as, import_drizzle_orm5.SQL) ? dialect5.sqlToQuery(generated.as).sql : typeof generated.as === "function" ? dialect5.sqlToQuery(generated.as()).sql : generated.as,
18645
+ as: (0, import_drizzle_orm5.is)(generated.as, import_drizzle_orm5.SQL) ? dialect4.sqlToQuery(generated.as).sql : typeof generated.as === "function" ? dialect4.sqlToQuery(generated.as()).sql : generated.as,
18745
18646
  type: "stored"
18746
18647
  } : void 0,
18747
18648
  identity: identity ? {
18748
18649
  type: identity.type,
18749
- name: identity.sequenceName ?? `${tableName}_${column7.name}_seq`,
18650
+ name: identity.sequenceName ?? `${tableName}_${name}_seq`,
18750
18651
  schema: schema5 ?? "public",
18751
18652
  increment,
18752
18653
  startWith,
@@ -18767,7 +18668,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
18767
18668
  The unique constraint ${source_default.underline.blue(
18768
18669
  column7.uniqueName
18769
18670
  )} on the ${source_default.underline.blue(
18770
- column7.name
18671
+ name
18771
18672
  )} column is confilcting with a unique constraint name already defined for ${source_default.underline.blue(
18772
18673
  existingUnique.columns.join(",")
18773
18674
  )} columns
@@ -18783,7 +18684,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
18783
18684
  }
18784
18685
  if (column7.default !== void 0) {
18785
18686
  if ((0, import_drizzle_orm5.is)(column7.default, import_drizzle_orm5.SQL)) {
18786
- columnToSet.default = sqlToStr(column7.default);
18687
+ columnToSet.default = sqlToStr(column7.default, casing2);
18787
18688
  } else {
18788
18689
  if (typeof column7.default === "string") {
18789
18690
  columnToSet.default = `'${column7.default}'`;
@@ -18811,17 +18712,24 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
18811
18712
  }
18812
18713
  }
18813
18714
  }
18814
- columnsObject[column7.name] = columnToSet;
18715
+ columnsObject[name] = columnToSet;
18815
18716
  });
18816
18717
  primaryKeys.map((pk) => {
18817
- const columnNames = pk.columns.map((c) => c.name);
18818
- primaryKeysObject[pk.getName()] = {
18819
- name: pk.getName(),
18718
+ const originalColumnNames = pk.columns.map((c) => c.name);
18719
+ const columnNames = pk.columns.map((c) => getColumnCasing(c, casing2));
18720
+ let name = pk.getName();
18721
+ if (casing2 !== void 0) {
18722
+ for (let i2 = 0; i2 < originalColumnNames.length; i2++) {
18723
+ name = name.replace(originalColumnNames[i2], columnNames[i2]);
18724
+ }
18725
+ }
18726
+ primaryKeysObject[name] = {
18727
+ name,
18820
18728
  columns: columnNames
18821
18729
  };
18822
18730
  });
18823
18731
  uniqueConstraints == null ? void 0 : uniqueConstraints.map((unq) => {
18824
- const columnNames = unq.columns.map((c) => c.name);
18732
+ const columnNames = unq.columns.map((c) => getColumnCasing(c, casing2));
18825
18733
  const name = unq.name ?? (0, import_pg_core2.uniqueKeyName)(table4, columnNames);
18826
18734
  const existingUnique = uniqueConstraintObject[name];
18827
18735
  if (typeof existingUnique !== "undefined") {
@@ -18848,15 +18756,25 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
18848
18756
  };
18849
18757
  });
18850
18758
  const fks = foreignKeys.map((fk4) => {
18851
- const name = fk4.getName();
18852
18759
  const tableFrom = tableName;
18853
18760
  const onDelete = fk4.onDelete;
18854
18761
  const onUpdate = fk4.onUpdate;
18855
18762
  const reference = fk4.reference();
18856
18763
  const tableTo = (0, import_drizzle_orm5.getTableName)(reference.foreignTable);
18857
18764
  const schemaTo = (0, import_pg_core3.getTableConfig)(reference.foreignTable).schema;
18858
- const columnsFrom = reference.columns.map((it) => it.name);
18859
- const columnsTo = reference.foreignColumns.map((it) => it.name);
18765
+ const originalColumnsFrom = reference.columns.map((it) => it.name);
18766
+ const columnsFrom = reference.columns.map((it) => getColumnCasing(it, casing2));
18767
+ const originalColumnsTo = reference.foreignColumns.map((it) => it.name);
18768
+ const columnsTo = reference.foreignColumns.map((it) => getColumnCasing(it, casing2));
18769
+ let name = fk4.getName();
18770
+ if (casing2 !== void 0) {
18771
+ for (let i2 = 0; i2 < originalColumnsFrom.length; i2++) {
18772
+ name = name.replace(originalColumnsFrom[i2], columnsFrom[i2]);
18773
+ }
18774
+ for (let i2 = 0; i2 < originalColumnsTo.length; i2++) {
18775
+ name = name.replace(originalColumnsTo[i2], columnsTo[i2]);
18776
+ }
18777
+ }
18860
18778
  return {
18861
18779
  name,
18862
18780
  tableFrom,
@@ -18882,19 +18800,20 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
18882
18800
  ${withStyle.errorWarning(
18883
18801
  `Please specify an index name in ${(0, import_drizzle_orm5.getTableName)(
18884
18802
  value.config.table
18885
- )} table that has "${dialect5.sqlToQuery(it).sql}" expression. We can generate index names for indexes on columns only; for expressions in indexes, you need to specify the name yourself.`
18803
+ )} table that has "${dialect4.sqlToQuery(it).sql}" expression. We can generate index names for indexes on columns only; for expressions in indexes, you need to specify the name yourself.`
18886
18804
  )}`
18887
18805
  );
18888
18806
  process.exit(1);
18889
18807
  }
18890
18808
  }
18891
18809
  it = it;
18810
+ const name2 = getColumnCasing(it, casing2);
18892
18811
  if (!(0, import_drizzle_orm5.is)(it, import_drizzle_orm5.SQL) && it.type === "PgVector" && typeof it.indexConfig.opClass === "undefined") {
18893
18812
  console.log(
18894
18813
  `
18895
18814
  ${withStyle.errorWarning(
18896
18815
  `You are specifying an index on the ${source_default.blueBright(
18897
- it.name
18816
+ name2
18898
18817
  )} column inside the ${source_default.blueBright(
18899
18818
  tableName
18900
18819
  )} table with the ${source_default.blueBright(
@@ -18904,7 +18823,7 @@ ${withStyle.errorWarning(
18904
18823
  )}].
18905
18824
 
18906
18825
  You can specify it using current syntax: ${source_default.underline(
18907
- `index("${value.config.name}").using("${value.config.method}", table.${it.name}.op("${vectorOps[0]}"))`
18826
+ `index("${value.config.name}").using("${value.config.method}", table.${name2}.op("${vectorOps[0]}"))`
18908
18827
  )}
18909
18828
 
18910
18829
  You can check the "pg_vector" docs for more info: https://github.com/pgvector/pgvector?tab=readme-ov-file#indexing
@@ -18913,7 +18832,7 @@ You can check the "pg_vector" docs for more info: https://github.com/pgvector/pg
18913
18832
  );
18914
18833
  process.exit(1);
18915
18834
  }
18916
- indexColumnNames.push(it.name);
18835
+ indexColumnNames.push(name2);
18917
18836
  });
18918
18837
  const name = value.config.name ? value.config.name : indexName2(tableName, indexColumnNames);
18919
18838
  let indexColumns = columns2.map(
@@ -18921,7 +18840,7 @@ You can check the "pg_vector" docs for more info: https://github.com/pgvector/pg
18921
18840
  var _a2, _b2, _c2, _d2, _e2;
18922
18841
  if ((0, import_drizzle_orm5.is)(it, import_drizzle_orm5.SQL)) {
18923
18842
  return {
18924
- expression: dialect5.sqlToQuery(it, "indexes").sql,
18843
+ expression: dialect4.sqlToQuery(it, "indexes").sql,
18925
18844
  asc: true,
18926
18845
  isExpression: true,
18927
18846
  nulls: "last"
@@ -18929,7 +18848,7 @@ You can check the "pg_vector" docs for more info: https://github.com/pgvector/pg
18929
18848
  } else {
18930
18849
  it = it;
18931
18850
  return {
18932
- expression: it.name,
18851
+ expression: getColumnCasing(it, casing2),
18933
18852
  isExpression: false,
18934
18853
  asc: ((_a2 = it.indexConfig) == null ? void 0 : _a2.order) === "asc",
18935
18854
  nulls: ((_b2 = it.indexConfig) == null ? void 0 : _b2.nulls) ? (_c2 = it.indexConfig) == null ? void 0 : _c2.nulls : ((_d2 = it.indexConfig) == null ? void 0 : _d2.order) === "desc" ? "first" : "last",
@@ -18960,39 +18879,12 @@ ${withStyle.errorWarning(
18960
18879
  name,
18961
18880
  columns: indexColumns,
18962
18881
  isUnique: value.config.unique ?? false,
18963
- where: value.config.where ? dialect5.sqlToQuery(value.config.where).sql : void 0,
18882
+ where: value.config.where ? dialect4.sqlToQuery(value.config.where).sql : void 0,
18964
18883
  concurrently: value.config.concurrently ?? false,
18965
18884
  method: value.config.method ?? "btree",
18966
18885
  with: value.config.with ?? {}
18967
18886
  };
18968
18887
  });
18969
- checks.forEach((check2) => {
18970
- const checkName = check2.name;
18971
- if (typeof checksInTable[`"${schema5 ?? "public"}"."${tableName}"`] !== "undefined") {
18972
- if (checksInTable[`"${schema5 ?? "public"}"."${tableName}"`].includes(check2.name)) {
18973
- console.log(
18974
- `
18975
- ${withStyle.errorWarning(
18976
- `We've found duplicated check constraint name across ${source_default.underline.blue(
18977
- schema5 ?? "public"
18978
- )} schema in ${source_default.underline.blue(
18979
- tableName
18980
- )}. Please rename your check constraint in either the ${source_default.underline.blue(
18981
- tableName
18982
- )} table or the table with the duplicated check contraint name`
18983
- )}`
18984
- );
18985
- process.exit(1);
18986
- }
18987
- checksInTable[`"${schema5 ?? "public"}"."${tableName}"`].push(checkName);
18988
- } else {
18989
- checksInTable[`"${schema5 ?? "public"}"."${tableName}"`] = [check2.name];
18990
- }
18991
- checksObject[checkName] = {
18992
- name: checkName,
18993
- value: dialect5.sqlToQuery(check2.value).sql
18994
- };
18995
- });
18996
18888
  const tableKey2 = `${schema5 ?? "public"}.${tableName}`;
18997
18889
  result[tableKey2] = {
18998
18890
  name: tableName,
@@ -19001,8 +18893,7 @@ ${withStyle.errorWarning(
19001
18893
  indexes: indexesObject,
19002
18894
  foreignKeys: foreignKeysObject,
19003
18895
  compositePrimaryKeys: primaryKeysObject,
19004
- uniqueConstraints: uniqueConstraintObject,
19005
- checkConstraints: checksObject
18896
+ uniqueConstraints: uniqueConstraintObject
19006
18897
  };
19007
18898
  }
19008
18899
  for (const sequence of sequences) {
@@ -19093,7 +18984,6 @@ ${withStyle.errorWarning(
19093
18984
  let indexesCount = 0;
19094
18985
  let foreignKeysCount = 0;
19095
18986
  let tableCount = 0;
19096
- let checksCount = 0;
19097
18987
  const sequencesToReturn = {};
19098
18988
  const seqWhere = schemaFilters.map((t2) => `schemaname = '${t2}'`).join(" or ");
19099
18989
  const allSequences = await db.query(
@@ -19165,8 +19055,7 @@ ${withStyle.errorWarning(
19165
19055
  const indexToReturn = {};
19166
19056
  const foreignKeysToReturn = {};
19167
19057
  const primaryKeys = {};
19168
- const uniqueConstraints = {};
19169
- const checkConstraints = {};
19058
+ const uniqueConstrains = {};
19170
19059
  const tableResponse = await db.query(
19171
19060
  `SELECT a.attrelid::regclass::text, a.attname, is_nullable, a.attndims as array_dimensions
19172
19061
  , CASE WHEN a.atttypid = ANY ('{int,int8,int2}'::regtype[])
@@ -19204,97 +19093,55 @@ ${withStyle.errorWarning(
19204
19093
  ORDER BY a.attnum;`
19205
19094
  );
19206
19095
  const tableConstraints = await db.query(
19207
- `SELECT c.column_name,
19208
- c.data_type,
19209
- tc.constraint_type,
19210
- tc.constraint_name,
19211
- tc.constraint_schema,
19212
- pg_get_constraintdef(con.oid) AS check_constraint_definition
19213
- FROM information_schema.table_constraints tc
19214
- JOIN information_schema.constraint_column_usage AS ccu
19215
- USING (constraint_schema, constraint_name)
19216
- JOIN information_schema.columns AS c
19217
- ON c.table_schema = tc.constraint_schema
19218
- AND tc.table_name = c.table_name
19219
- AND ccu.column_name = c.column_name
19220
- JOIN pg_constraint con
19221
- ON con.conname = tc.constraint_name
19222
- AND con.conrelid = (
19223
- SELECT oid
19224
- FROM pg_class
19225
- WHERE relname = tc.table_name
19226
- AND relnamespace = (
19227
- SELECT oid
19228
- FROM pg_namespace
19229
- WHERE nspname = tc.constraint_schema
19230
- )
19231
- )
19232
- WHERE tc.table_name = '${tableName}' AND tc.constraint_schema = '${tableSchema}';`
19096
+ `SELECT c.column_name, c.data_type, constraint_type, constraint_name, constraint_schema
19097
+ FROM information_schema.table_constraints tc
19098
+ JOIN information_schema.constraint_column_usage AS ccu USING (constraint_schema, constraint_name)
19099
+ JOIN information_schema.columns AS c ON c.table_schema = tc.constraint_schema
19100
+ AND tc.table_name = c.table_name AND ccu.column_name = c.column_name
19101
+ WHERE tc.table_name = '${tableName}' and constraint_schema = '${tableSchema}';`
19233
19102
  );
19234
- const tableChecks = await db.query(`SELECT
19235
- tc.constraint_name,
19236
- tc.constraint_type,
19237
- pg_get_constraintdef(con.oid) AS constraint_definition
19238
- FROM
19239
- information_schema.table_constraints AS tc
19240
- JOIN pg_constraint AS con
19241
- ON tc.constraint_name = con.conname
19242
- AND con.conrelid = (
19243
- SELECT oid
19244
- FROM pg_class
19245
- WHERE relname = tc.table_name
19246
- AND relnamespace = (
19247
- SELECT oid
19248
- FROM pg_namespace
19249
- WHERE nspname = tc.constraint_schema
19250
- )
19251
- )
19252
- WHERE
19253
- tc.table_name = '${tableName}'
19254
- AND tc.constraint_schema = '${tableSchema}'
19255
- AND tc.constraint_type = 'CHECK';`);
19256
19103
  columnsCount += tableResponse.length;
19257
19104
  if (progressCallback) {
19258
19105
  progressCallback("columns", columnsCount, "fetching");
19259
19106
  }
19260
19107
  const tableForeignKeys = await db.query(
19261
19108
  `SELECT
19262
- con.contype AS constraint_type,
19263
- nsp.nspname AS constraint_schema,
19264
- con.conname AS constraint_name,
19265
- rel.relname AS table_name,
19266
- att.attname AS column_name,
19267
- fnsp.nspname AS foreign_table_schema,
19268
- frel.relname AS foreign_table_name,
19269
- fatt.attname AS foreign_column_name,
19270
- CASE con.confupdtype
19271
- WHEN 'a' THEN 'NO ACTION'
19272
- WHEN 'r' THEN 'RESTRICT'
19273
- WHEN 'n' THEN 'SET NULL'
19274
- WHEN 'c' THEN 'CASCADE'
19275
- WHEN 'd' THEN 'SET DEFAULT'
19276
- END AS update_rule,
19277
- CASE con.confdeltype
19278
- WHEN 'a' THEN 'NO ACTION'
19279
- WHEN 'r' THEN 'RESTRICT'
19280
- WHEN 'n' THEN 'SET NULL'
19281
- WHEN 'c' THEN 'CASCADE'
19282
- WHEN 'd' THEN 'SET DEFAULT'
19283
- END AS delete_rule
19284
- FROM
19285
- pg_catalog.pg_constraint con
19286
- JOIN pg_catalog.pg_class rel ON rel.oid = con.conrelid
19287
- JOIN pg_catalog.pg_namespace nsp ON nsp.oid = con.connamespace
19288
- LEFT JOIN pg_catalog.pg_attribute att ON att.attnum = ANY (con.conkey)
19289
- AND att.attrelid = con.conrelid
19290
- LEFT JOIN pg_catalog.pg_class frel ON frel.oid = con.confrelid
19291
- LEFT JOIN pg_catalog.pg_namespace fnsp ON fnsp.oid = frel.relnamespace
19292
- LEFT JOIN pg_catalog.pg_attribute fatt ON fatt.attnum = ANY (con.confkey)
19293
- AND fatt.attrelid = con.confrelid
19294
- WHERE
19295
- nsp.nspname = '${tableSchema}'
19296
- AND rel.relname = '${tableName}'
19297
- AND con.contype IN ('f');`
19109
+ con.contype AS constraint_type,
19110
+ nsp.nspname AS constraint_schema,
19111
+ con.conname AS constraint_name,
19112
+ rel.relname AS table_name,
19113
+ att.attname AS column_name,
19114
+ fnsp.nspname AS foreign_table_schema,
19115
+ frel.relname AS foreign_table_name,
19116
+ fatt.attname AS foreign_column_name,
19117
+ CASE con.confupdtype
19118
+ WHEN 'a' THEN 'NO ACTION'
19119
+ WHEN 'r' THEN 'RESTRICT'
19120
+ WHEN 'n' THEN 'SET NULL'
19121
+ WHEN 'c' THEN 'CASCADE'
19122
+ WHEN 'd' THEN 'SET DEFAULT'
19123
+ END AS update_rule,
19124
+ CASE con.confdeltype
19125
+ WHEN 'a' THEN 'NO ACTION'
19126
+ WHEN 'r' THEN 'RESTRICT'
19127
+ WHEN 'n' THEN 'SET NULL'
19128
+ WHEN 'c' THEN 'CASCADE'
19129
+ WHEN 'd' THEN 'SET DEFAULT'
19130
+ END AS delete_rule
19131
+ FROM
19132
+ pg_catalog.pg_constraint con
19133
+ JOIN pg_catalog.pg_class rel ON rel.oid = con.conrelid
19134
+ JOIN pg_catalog.pg_namespace nsp ON nsp.oid = con.connamespace
19135
+ LEFT JOIN pg_catalog.pg_attribute att ON att.attnum = ANY (con.conkey)
19136
+ AND att.attrelid = con.conrelid
19137
+ LEFT JOIN pg_catalog.pg_class frel ON frel.oid = con.confrelid
19138
+ LEFT JOIN pg_catalog.pg_namespace fnsp ON fnsp.oid = frel.relnamespace
19139
+ LEFT JOIN pg_catalog.pg_attribute fatt ON fatt.attnum = ANY (con.confkey)
19140
+ AND fatt.attrelid = con.confrelid
19141
+ WHERE
19142
+ nsp.nspname = '${tableSchema}'
19143
+ AND rel.relname = '${tableName}'
19144
+ AND con.contype IN ('f');`
19298
19145
  );
19299
19146
  foreignKeysCount += tableForeignKeys.length;
19300
19147
  if (progressCallback) {
@@ -19336,29 +19183,16 @@ ${withStyle.errorWarning(
19336
19183
  for (const unqs of uniqueConstrainsRows) {
19337
19184
  const columnName = unqs.column_name;
19338
19185
  const constraintName = unqs.constraint_name;
19339
- if (typeof uniqueConstraints[constraintName] !== "undefined") {
19340
- uniqueConstraints[constraintName].columns.push(columnName);
19186
+ if (typeof uniqueConstrains[constraintName] !== "undefined") {
19187
+ uniqueConstrains[constraintName].columns.push(columnName);
19341
19188
  } else {
19342
- uniqueConstraints[constraintName] = {
19189
+ uniqueConstrains[constraintName] = {
19343
19190
  columns: [columnName],
19344
19191
  nullsNotDistinct: false,
19345
19192
  name: constraintName
19346
19193
  };
19347
19194
  }
19348
19195
  }
19349
- checksCount += tableChecks.length;
19350
- if (progressCallback) {
19351
- progressCallback("checks", checksCount, "fetching");
19352
- }
19353
- for (const checks of tableChecks) {
19354
- let checkValue = checks.constraint_definition;
19355
- const constraintName = checks.constraint_name;
19356
- checkValue = checkValue.replace(/^CHECK\s*\(\(/, "").replace(/\)\)\s*$/, "");
19357
- checkConstraints[constraintName] = {
19358
- name: constraintName,
19359
- value: checkValue
19360
- };
19361
- }
19362
19196
  for (const columnResponse of tableResponse) {
19363
19197
  const columnName = columnResponse.attname;
19364
19198
  const columnAdditionalDT = columnResponse.additional_dt;
@@ -19483,7 +19317,7 @@ ${withStyle.errorWarning(
19483
19317
  schema: tableSchema
19484
19318
  } : void 0
19485
19319
  };
19486
- if (identityName) {
19320
+ if (identityName && typeof identityName === "string") {
19487
19321
  delete sequencesToReturn[`${tableSchema}.${identityName.startsWith('"') && identityName.endsWith('"') ? identityName.slice(1, -1) : identityName}`];
19488
19322
  delete sequencesToReturn[identityName];
19489
19323
  }
@@ -19603,8 +19437,7 @@ ${withStyle.errorWarning(
19603
19437
  indexes: indexToReturn,
19604
19438
  foreignKeys: foreignKeysToReturn,
19605
19439
  compositePrimaryKeys: primaryKeys,
19606
- uniqueConstraints,
19607
- checkConstraints
19440
+ uniqueConstraints: uniqueConstrains
19608
19441
  };
19609
19442
  } catch (e2) {
19610
19443
  rej(e2);
@@ -19622,7 +19455,6 @@ ${withStyle.errorWarning(
19622
19455
  progressCallback("columns", columnsCount, "done");
19623
19456
  progressCallback("indexes", indexesCount, "done");
19624
19457
  progressCallback("fks", foreignKeysCount, "done");
19625
- progressCallback("checks", checksCount, "done");
19626
19458
  }
19627
19459
  const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
19628
19460
  return {
@@ -19816,7 +19648,7 @@ function extractGeneratedColumns(input) {
19816
19648
  }
19817
19649
  return columns;
19818
19650
  }
19819
- var import_drizzle_orm7, import_sqlite_core2, dialect6, generateSqliteSnapshot, fromDatabase3;
19651
+ var import_drizzle_orm7, import_sqlite_core2, generateSqliteSnapshot, fromDatabase3;
19820
19652
  var init_sqliteSerializer = __esm({
19821
19653
  "src/serializer/sqliteSerializer.ts"() {
19822
19654
  "use strict";
@@ -19824,9 +19656,10 @@ var init_sqliteSerializer = __esm({
19824
19656
  import_drizzle_orm7 = require("drizzle-orm");
19825
19657
  import_sqlite_core2 = require("drizzle-orm/sqlite-core");
19826
19658
  init_outputs();
19659
+ init_utils();
19827
19660
  init_serializer();
19828
- dialect6 = new import_sqlite_core2.SQLiteSyncDialect();
19829
- generateSqliteSnapshot = (tables) => {
19661
+ generateSqliteSnapshot = (tables, casing2) => {
19662
+ const dialect4 = new import_sqlite_core2.SQLiteSyncDialect({ casing: casing2 });
19830
19663
  const result = {};
19831
19664
  const internal = { indexes: {} };
19832
19665
  for (const table4 of tables) {
@@ -19835,40 +19668,38 @@ var init_sqliteSerializer = __esm({
19835
19668
  const foreignKeysObject = {};
19836
19669
  const primaryKeysObject = {};
19837
19670
  const uniqueConstraintObject = {};
19838
- const checkConstraintObject = {};
19839
- const checksInTable = {};
19840
19671
  const {
19841
19672
  name: tableName,
19842
19673
  columns,
19843
19674
  indexes,
19844
- checks,
19845
19675
  foreignKeys: tableForeignKeys,
19846
19676
  primaryKeys,
19847
19677
  uniqueConstraints
19848
19678
  } = (0, import_sqlite_core2.getTableConfig)(table4);
19849
19679
  columns.forEach((column7) => {
19680
+ const name = getColumnCasing(column7, casing2);
19850
19681
  const notNull = column7.notNull;
19851
19682
  const primaryKey = column7.primary;
19852
19683
  const generated = column7.generated;
19853
19684
  const columnToSet = {
19854
- name: column7.name,
19685
+ name,
19855
19686
  type: column7.getSQLType(),
19856
19687
  primaryKey,
19857
19688
  notNull,
19858
19689
  autoincrement: (0, import_drizzle_orm7.is)(column7, import_sqlite_core2.SQLiteBaseInteger) ? column7.autoIncrement : false,
19859
19690
  generated: generated ? {
19860
- as: (0, import_drizzle_orm7.is)(generated.as, import_drizzle_orm7.SQL) ? `(${dialect6.sqlToQuery(generated.as, "indexes").sql})` : typeof generated.as === "function" ? `(${dialect6.sqlToQuery(generated.as(), "indexes").sql})` : `(${generated.as})`,
19691
+ as: (0, import_drizzle_orm7.is)(generated.as, import_drizzle_orm7.SQL) ? `(${dialect4.sqlToQuery(generated.as, "indexes").sql})` : typeof generated.as === "function" ? `(${dialect4.sqlToQuery(generated.as(), "indexes").sql})` : `(${generated.as})`,
19861
19692
  type: generated.mode ?? "virtual"
19862
19693
  } : void 0
19863
19694
  };
19864
19695
  if (column7.default !== void 0) {
19865
19696
  if ((0, import_drizzle_orm7.is)(column7.default, import_drizzle_orm7.SQL)) {
19866
- columnToSet.default = sqlToStr(column7.default);
19697
+ columnToSet.default = sqlToStr(column7.default, casing2);
19867
19698
  } else {
19868
19699
  columnToSet.default = typeof column7.default === "string" ? `'${column7.default}'` : typeof column7.default === "object" || Array.isArray(column7.default) ? `'${JSON.stringify(column7.default)}'` : column7.default;
19869
19700
  }
19870
19701
  }
19871
- columnsObject[column7.name] = columnToSet;
19702
+ columnsObject[name] = columnToSet;
19872
19703
  if (column7.isUnique) {
19873
19704
  const existingUnique = indexesObject[column7.uniqueName];
19874
19705
  if (typeof existingUnique !== "undefined") {
@@ -19880,7 +19711,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
19880
19711
  The unique constraint ${source_default.underline.blue(
19881
19712
  column7.uniqueName
19882
19713
  )} on the ${source_default.underline.blue(
19883
- column7.name
19714
+ name
19884
19715
  )} column is confilcting with a unique constraint name already defined for ${source_default.underline.blue(
19885
19716
  existingUnique.columns.join(",")
19886
19717
  )} columns
@@ -19896,15 +19727,25 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
19896
19727
  }
19897
19728
  });
19898
19729
  const foreignKeys = tableForeignKeys.map((fk4) => {
19899
- const name = fk4.getName();
19900
19730
  const tableFrom = tableName;
19901
19731
  const onDelete = fk4.onDelete ?? "no action";
19902
19732
  const onUpdate = fk4.onUpdate ?? "no action";
19903
19733
  const reference = fk4.reference();
19904
19734
  const referenceFT = reference.foreignTable;
19905
19735
  const tableTo = (0, import_drizzle_orm7.getTableName)(referenceFT);
19906
- const columnsFrom = reference.columns.map((it) => it.name);
19907
- const columnsTo = reference.foreignColumns.map((it) => it.name);
19736
+ const originalColumnsFrom = reference.columns.map((it) => it.name);
19737
+ const columnsFrom = reference.columns.map((it) => getColumnCasing(it, casing2));
19738
+ const originalColumnsTo = reference.foreignColumns.map((it) => it.name);
19739
+ const columnsTo = reference.foreignColumns.map((it) => getColumnCasing(it, casing2));
19740
+ let name = fk4.getName();
19741
+ if (casing2 !== void 0) {
19742
+ for (let i2 = 0; i2 < originalColumnsFrom.length; i2++) {
19743
+ name = name.replace(originalColumnsFrom[i2], columnsFrom[i2]);
19744
+ }
19745
+ for (let i2 = 0; i2 < originalColumnsTo.length; i2++) {
19746
+ name = name.replace(originalColumnsTo[i2], columnsTo[i2]);
19747
+ }
19748
+ }
19908
19749
  return {
19909
19750
  name,
19910
19751
  tableFrom,
@@ -19924,7 +19765,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
19924
19765
  let indexColumns = columns2.map((it) => {
19925
19766
  var _a;
19926
19767
  if ((0, import_drizzle_orm7.is)(it, import_drizzle_orm7.SQL)) {
19927
- const sql = dialect6.sqlToQuery(it, "indexes").sql;
19768
+ const sql = dialect4.sqlToQuery(it, "indexes").sql;
19928
19769
  if (typeof internal.indexes[name] === "undefined") {
19929
19770
  internal.indexes[name] = {
19930
19771
  columns: {
@@ -19944,13 +19785,13 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
19944
19785
  }
19945
19786
  return sql;
19946
19787
  } else {
19947
- return it.name;
19788
+ return getColumnCasing(it, casing2);
19948
19789
  }
19949
19790
  });
19950
19791
  let where = void 0;
19951
19792
  if (value.config.where !== void 0) {
19952
19793
  if ((0, import_drizzle_orm7.is)(value.config.where, import_drizzle_orm7.SQL)) {
19953
- where = dialect6.sqlToQuery(value.config.where).sql;
19794
+ where = dialect4.sqlToQuery(value.config.where).sql;
19954
19795
  }
19955
19796
  }
19956
19797
  indexesObject[name] = {
@@ -19961,7 +19802,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
19961
19802
  };
19962
19803
  });
19963
19804
  uniqueConstraints == null ? void 0 : uniqueConstraints.map((unq) => {
19964
- const columnNames = unq.columns.map((c) => c.name);
19805
+ const columnNames = unq.columns.map((c) => getColumnCasing(c, casing2));
19965
19806
  const name = unq.name ?? (0, import_sqlite_core2.uniqueKeyName)(table4, columnNames);
19966
19807
  const existingUnique = indexesObject[name];
19967
19808
  if (typeof existingUnique !== "undefined") {
@@ -19991,38 +19832,21 @@ The unique constraint ${source_default.underline.blue(
19991
19832
  });
19992
19833
  primaryKeys.forEach((it) => {
19993
19834
  if (it.columns.length > 1) {
19994
- primaryKeysObject[it.getName()] = {
19995
- columns: it.columns.map((it2) => it2.name),
19996
- name: it.getName()
19997
- };
19998
- } else {
19999
- columnsObject[it.columns[0].name].primaryKey = true;
20000
- }
20001
- });
20002
- checks.forEach((check2) => {
20003
- const checkName = check2.name;
20004
- if (typeof checksInTable[tableName] !== "undefined") {
20005
- if (checksInTable[tableName].includes(check2.name)) {
20006
- console.log(
20007
- `
20008
- ${withStyle.errorWarning(
20009
- `We've found duplicated check constraint name in ${source_default.underline.blue(
20010
- tableName
20011
- )}. Please rename your check constraint in the ${source_default.underline.blue(
20012
- tableName
20013
- )} table`
20014
- )}`
20015
- );
20016
- process.exit(1);
19835
+ const originalColumnNames = it.columns.map((c) => c.name);
19836
+ const columnNames = it.columns.map((c) => getColumnCasing(c, casing2));
19837
+ let name = it.getName();
19838
+ if (casing2 !== void 0) {
19839
+ for (let i2 = 0; i2 < originalColumnNames.length; i2++) {
19840
+ name = name.replace(originalColumnNames[i2], columnNames[i2]);
19841
+ }
20017
19842
  }
20018
- checksInTable[tableName].push(checkName);
19843
+ primaryKeysObject[name] = {
19844
+ columns: columnNames,
19845
+ name
19846
+ };
20019
19847
  } else {
20020
- checksInTable[tableName] = [check2.name];
19848
+ columnsObject[getColumnCasing(it.columns[0], casing2)].primaryKey = true;
20021
19849
  }
20022
- checkConstraintObject[checkName] = {
20023
- name: checkName,
20024
- value: dialect6.sqlToQuery(check2.value).sql
20025
- };
20026
19850
  });
20027
19851
  result[tableName] = {
20028
19852
  name: tableName,
@@ -20030,8 +19854,7 @@ ${withStyle.errorWarning(
20030
19854
  indexes: indexesObject,
20031
19855
  foreignKeys: foreignKeysObject,
20032
19856
  compositePrimaryKeys: primaryKeysObject,
20033
- uniqueConstraints: uniqueConstraintObject,
20034
- checkConstraints: checkConstraintObject
19857
+ uniqueConstraints: uniqueConstraintObject
20035
19858
  };
20036
19859
  }
20037
19860
  return {
@@ -20078,7 +19901,6 @@ ${withStyle.errorWarning(
20078
19901
  let tablesCount = /* @__PURE__ */ new Set();
20079
19902
  let indexesCount = 0;
20080
19903
  let foreignKeysCount = 0;
20081
- let checksCount = 0;
20082
19904
  const tableToPk = {};
20083
19905
  let tableToGeneratedColumnsInfo = {};
20084
19906
  for (const column7 of columns) {
@@ -20137,8 +19959,7 @@ ${withStyle.errorWarning(
20137
19959
  compositePrimaryKeys: {},
20138
19960
  indexes: {},
20139
19961
  foreignKeys: {},
20140
- uniqueConstraints: {},
20141
- checkConstraints: {}
19962
+ uniqueConstraints: {}
20142
19963
  };
20143
19964
  } else {
20144
19965
  result[tableName].columns[columnName] = newColumn;
@@ -20254,57 +20075,6 @@ WHERE
20254
20075
  progressCallback("indexes", indexesCount, "done");
20255
20076
  progressCallback("enums", 0, "done");
20256
20077
  }
20257
- const namedCheckPattern = /CONSTRAINT\s*["']?(\w+)["']?\s*CHECK\s*\((.*?)\)/gi;
20258
- const unnamedCheckPattern = /CHECK\s*\((.*?)\)/gi;
20259
- let checkCounter = 0;
20260
- const checkConstraints = {};
20261
- const checks = await db.query(`SELECT name as "tableName", sql as "sql"
20262
- FROM sqlite_master
20263
- WHERE type = 'table' AND name != 'sqlite_sequence';`);
20264
- for (const check2 of checks) {
20265
- if (!tablesFilter(check2.tableName))
20266
- continue;
20267
- const { tableName, sql } = check2;
20268
- let namedChecks = [...sql.matchAll(namedCheckPattern)];
20269
- if (namedChecks.length > 0) {
20270
- namedChecks.forEach(([_2, checkName, checkValue]) => {
20271
- checkConstraints[checkName] = {
20272
- name: checkName,
20273
- value: checkValue.trim()
20274
- };
20275
- });
20276
- } else {
20277
- let unnamedChecks = [...sql.matchAll(unnamedCheckPattern)];
20278
- unnamedChecks.forEach(([_2, checkValue]) => {
20279
- let checkName = `${tableName}_check_${++checkCounter}`;
20280
- checkConstraints[checkName] = {
20281
- name: checkName,
20282
- value: checkValue.trim()
20283
- };
20284
- });
20285
- }
20286
- checksCount += Object.values(checkConstraints).length;
20287
- if (progressCallback) {
20288
- progressCallback("checks", checksCount, "fetching");
20289
- }
20290
- const table4 = result[tableName];
20291
- if (!table4) {
20292
- result[tableName] = {
20293
- name: tableName,
20294
- columns: {},
20295
- compositePrimaryKeys: {},
20296
- indexes: {},
20297
- foreignKeys: {},
20298
- uniqueConstraints: {},
20299
- checkConstraints
20300
- };
20301
- } else {
20302
- result[tableName].checkConstraints = checkConstraints;
20303
- }
20304
- }
20305
- if (progressCallback) {
20306
- progressCallback("checks", checksCount, "done");
20307
- }
20308
20078
  return {
20309
20079
  version: "6",
20310
20080
  dialect: "sqlite",
@@ -20320,16 +20090,17 @@ WHERE
20320
20090
  });
20321
20091
 
20322
20092
  // src/serializer/index.ts
20323
- var import_fs3, glob, import_path3, sqlToStr, serializeMySql, serializePg, serializeSQLite, prepareFilenames;
20093
+ var import_casing2, import_fs3, glob, import_path3, sqlToStr, serializeMySql, serializePg, serializeSQLite, prepareFilenames;
20324
20094
  var init_serializer = __esm({
20325
20095
  "src/serializer/index.ts"() {
20326
20096
  "use strict";
20327
20097
  init_source();
20098
+ import_casing2 = require("drizzle-orm/casing");
20328
20099
  import_fs3 = __toESM(require("fs"));
20329
20100
  glob = __toESM(require_glob());
20330
20101
  import_path3 = __toESM(require("path"));
20331
20102
  init_views();
20332
- sqlToStr = (sql) => {
20103
+ sqlToStr = (sql, casing2) => {
20333
20104
  return sql.toQuery({
20334
20105
  escapeName: () => {
20335
20106
  throw new Error("we don't support params for `sql` default values");
@@ -20339,10 +20110,11 @@ var init_serializer = __esm({
20339
20110
  },
20340
20111
  escapeString: () => {
20341
20112
  throw new Error("we don't support params for `sql` default values");
20342
- }
20113
+ },
20114
+ casing: new import_casing2.CasingCache(casing2)
20343
20115
  }).sql;
20344
20116
  };
20345
- serializeMySql = async (path5) => {
20117
+ serializeMySql = async (path5, casing2) => {
20346
20118
  const filenames = prepareFilenames(path5);
20347
20119
  console.log(source_default.gray(`Reading schema files:
20348
20120
  ${filenames.join("\n")}
@@ -20350,23 +20122,23 @@ ${filenames.join("\n")}
20350
20122
  const { prepareFromMySqlImports: prepareFromMySqlImports2 } = await Promise.resolve().then(() => (init_mysqlImports(), mysqlImports_exports));
20351
20123
  const { generateMySqlSnapshot: generateMySqlSnapshot2 } = await Promise.resolve().then(() => (init_mysqlSerializer(), mysqlSerializer_exports));
20352
20124
  const { tables } = await prepareFromMySqlImports2(filenames);
20353
- return generateMySqlSnapshot2(tables);
20125
+ return generateMySqlSnapshot2(tables, casing2);
20354
20126
  };
20355
- serializePg = async (path5, schemaFilter) => {
20127
+ serializePg = async (path5, casing2, schemaFilter) => {
20356
20128
  const filenames = prepareFilenames(path5);
20357
20129
  const { prepareFromPgImports: prepareFromPgImports2 } = await Promise.resolve().then(() => (init_pgImports(), pgImports_exports));
20358
20130
  const { generatePgSnapshot: generatePgSnapshot2 } = await Promise.resolve().then(() => (init_pgSerializer(), pgSerializer_exports));
20359
20131
  const { tables, enums, schemas, sequences } = await prepareFromPgImports2(
20360
20132
  filenames
20361
20133
  );
20362
- return generatePgSnapshot2(tables, enums, schemas, sequences, schemaFilter);
20134
+ return generatePgSnapshot2(tables, enums, schemas, sequences, casing2, schemaFilter);
20363
20135
  };
20364
- serializeSQLite = async (path5) => {
20136
+ serializeSQLite = async (path5, casing2) => {
20365
20137
  const filenames = prepareFilenames(path5);
20366
20138
  const { prepareFromSqliteImports: prepareFromSqliteImports2 } = await Promise.resolve().then(() => (init_sqliteImports(), sqliteImports_exports));
20367
20139
  const { generateSqliteSnapshot: generateSqliteSnapshot2 } = await Promise.resolve().then(() => (init_sqliteSerializer(), sqliteSerializer_exports));
20368
20140
  const { tables } = await prepareFromSqliteImports2(filenames);
20369
- return generateSqliteSnapshot2(tables);
20141
+ return generateSqliteSnapshot2(tables, casing2);
20370
20142
  };
20371
20143
  prepareFilenames = (path5) => {
20372
20144
  if (typeof path5 === "string") {
@@ -20415,45 +20187,45 @@ var init_migrationPreparator = __esm({
20415
20187
  init_mysqlSchema();
20416
20188
  init_pgSchema();
20417
20189
  init_sqliteSchema();
20418
- prepareMySqlDbPushSnapshot = async (prev, schemaPath) => {
20419
- const serialized = await serializeMySql(schemaPath);
20190
+ prepareMySqlDbPushSnapshot = async (prev, schemaPath, casing2) => {
20191
+ const serialized = await serializeMySql(schemaPath, casing2);
20420
20192
  const id = (0, import_crypto.randomUUID)();
20421
20193
  const idPrev = prev.id;
20422
- const { version: version3, dialect: dialect7, ...rest } = serialized;
20423
- const result = { version: version3, dialect: dialect7, id, prevId: idPrev, ...rest };
20194
+ const { version: version3, dialect: dialect4, ...rest } = serialized;
20195
+ const result = { version: version3, dialect: dialect4, id, prevId: idPrev, ...rest };
20424
20196
  return { prev, cur: result };
20425
20197
  };
20426
- prepareSQLiteDbPushSnapshot = async (prev, schemaPath) => {
20427
- const serialized = await serializeSQLite(schemaPath);
20198
+ prepareSQLiteDbPushSnapshot = async (prev, schemaPath, casing2) => {
20199
+ const serialized = await serializeSQLite(schemaPath, casing2);
20428
20200
  const id = (0, import_crypto.randomUUID)();
20429
20201
  const idPrev = prev.id;
20430
- const { version: version3, dialect: dialect7, ...rest } = serialized;
20202
+ const { version: version3, dialect: dialect4, ...rest } = serialized;
20431
20203
  const result = {
20432
20204
  version: version3,
20433
- dialect: dialect7,
20205
+ dialect: dialect4,
20434
20206
  id,
20435
20207
  prevId: idPrev,
20436
20208
  ...rest
20437
20209
  };
20438
20210
  return { prev, cur: result };
20439
20211
  };
20440
- preparePgDbPushSnapshot = async (prev, schemaPath, schemaFilter = ["public"]) => {
20441
- const serialized = await serializePg(schemaPath, schemaFilter);
20212
+ preparePgDbPushSnapshot = async (prev, schemaPath, casing2, schemaFilter = ["public"]) => {
20213
+ const serialized = await serializePg(schemaPath, casing2, schemaFilter);
20442
20214
  const id = (0, import_crypto.randomUUID)();
20443
20215
  const idPrev = prev.id;
20444
- const { version: version3, dialect: dialect7, ...rest } = serialized;
20445
- const result = { version: version3, dialect: dialect7, id, prevId: idPrev, ...rest };
20216
+ const { version: version3, dialect: dialect4, ...rest } = serialized;
20217
+ const result = { version: version3, dialect: dialect4, id, prevId: idPrev, ...rest };
20446
20218
  return { prev, cur: result };
20447
20219
  };
20448
- prepareMySqlMigrationSnapshot = async (migrationFolders, schemaPath) => {
20220
+ prepareMySqlMigrationSnapshot = async (migrationFolders, schemaPath, casing2) => {
20449
20221
  const prevSnapshot = mysqlSchema.parse(
20450
20222
  preparePrevSnapshot(migrationFolders, dryMySql)
20451
20223
  );
20452
- const serialized = await serializeMySql(schemaPath);
20224
+ const serialized = await serializeMySql(schemaPath, casing2);
20453
20225
  const id = (0, import_crypto.randomUUID)();
20454
20226
  const idPrev = prevSnapshot.id;
20455
- const { version: version3, dialect: dialect7, ...rest } = serialized;
20456
- const result = { version: version3, dialect: dialect7, id, prevId: idPrev, ...rest };
20227
+ const { version: version3, dialect: dialect4, ...rest } = serialized;
20228
+ const result = { version: version3, dialect: dialect4, id, prevId: idPrev, ...rest };
20457
20229
  const { id: _ignoredId, prevId: _ignoredPrevId, ...prevRest } = prevSnapshot;
20458
20230
  const custom2 = {
20459
20231
  id,
@@ -20462,17 +20234,17 @@ var init_migrationPreparator = __esm({
20462
20234
  };
20463
20235
  return { prev: prevSnapshot, cur: result, custom: custom2 };
20464
20236
  };
20465
- prepareSqliteMigrationSnapshot = async (snapshots, schemaPath) => {
20237
+ prepareSqliteMigrationSnapshot = async (snapshots, schemaPath, casing2) => {
20466
20238
  const prevSnapshot = sqliteSchema.parse(
20467
20239
  preparePrevSnapshot(snapshots, drySQLite)
20468
20240
  );
20469
- const serialized = await serializeSQLite(schemaPath);
20241
+ const serialized = await serializeSQLite(schemaPath, casing2);
20470
20242
  const id = (0, import_crypto.randomUUID)();
20471
20243
  const idPrev = prevSnapshot.id;
20472
- const { version: version3, dialect: dialect7, ...rest } = serialized;
20244
+ const { version: version3, dialect: dialect4, ...rest } = serialized;
20473
20245
  const result = {
20474
20246
  version: version3,
20475
- dialect: dialect7,
20247
+ dialect: dialect4,
20476
20248
  id,
20477
20249
  prevId: idPrev,
20478
20250
  ...rest
@@ -20492,9 +20264,9 @@ var init_migrationPreparator = __esm({
20492
20264
  }) => {
20493
20265
  return { id, prevId: idPrev, ...serialized };
20494
20266
  };
20495
- preparePgMigrationSnapshot = async (snapshots, schemaPath) => {
20267
+ preparePgMigrationSnapshot = async (snapshots, schemaPath, casing2) => {
20496
20268
  const prevSnapshot = pgSchema.parse(preparePrevSnapshot(snapshots, dryPg));
20497
- const serialized = await serializePg(schemaPath);
20269
+ const serialized = await serializePg(schemaPath, casing2);
20498
20270
  const id = (0, import_crypto.randomUUID)();
20499
20271
  const idPrev = prevSnapshot.id;
20500
20272
  const result = { id, prevId: idPrev, ...serialized };
@@ -23043,21 +22815,6 @@ var init_jsonDiffer = __esm({
23043
22815
  return !it[0].endsWith("__deleted") && !it[0].endsWith("__added");
23044
22816
  })
23045
22817
  );
23046
- const addedCheckConstraints = Object.fromEntries(
23047
- Object.entries(table4.checkConstraints || {}).filter((it) => {
23048
- return it[0].endsWith("__added");
23049
- })
23050
- );
23051
- const deletedCheckConstraints = Object.fromEntries(
23052
- Object.entries(table4.checkConstraints || {}).filter((it) => {
23053
- return it[0].endsWith("__deleted");
23054
- })
23055
- );
23056
- const alteredCheckConstraints = Object.fromEntries(
23057
- Object.entries(table4.checkConstraints || {}).filter((it) => {
23058
- return !it[0].endsWith("__deleted") && !it[0].endsWith("__added");
23059
- })
23060
- );
23061
22818
  const mappedAltered = altered.map((it) => alternationsInColumn(it)).filter(Boolean);
23062
22819
  return {
23063
22820
  name: table4.name,
@@ -23074,10 +22831,7 @@ var init_jsonDiffer = __esm({
23074
22831
  alteredCompositePKs,
23075
22832
  addedUniqueConstraints,
23076
22833
  deletedUniqueConstraints,
23077
- alteredUniqueConstraints,
23078
- addedCheckConstraints,
23079
- deletedCheckConstraints,
23080
- alteredCheckConstraints
22834
+ alteredUniqueConstraints
23081
22835
  };
23082
22836
  };
23083
22837
  alternationsInColumn = (column7) => {
@@ -23331,32 +23085,6 @@ var init_jsonDiffer = __esm({
23331
23085
  };
23332
23086
  }
23333
23087
  return it;
23334
- }).map((it) => {
23335
- if ("" in it) {
23336
- return {
23337
- ...it,
23338
- autoincrement: {
23339
- type: "changed",
23340
- old: it.autoincrement.__old,
23341
- new: it.autoincrement.__new
23342
- }
23343
- };
23344
- }
23345
- if ("autoincrement__added" in it) {
23346
- const { autoincrement__added, ...others } = it;
23347
- return {
23348
- ...others,
23349
- autoincrement: { type: "added", value: it.autoincrement__added }
23350
- };
23351
- }
23352
- if ("autoincrement__deleted" in it) {
23353
- const { autoincrement__deleted, ...others } = it;
23354
- return {
23355
- ...others,
23356
- autoincrement: { type: "deleted", value: it.autoincrement__deleted }
23357
- };
23358
- }
23359
- return it;
23360
23088
  }).filter(Boolean);
23361
23089
  return result[0];
23362
23090
  };
@@ -23364,10 +23092,10 @@ var init_jsonDiffer = __esm({
23364
23092
  });
23365
23093
 
23366
23094
  // src/sqlgenerator.ts
23367
- function fromJson(statements, dialect7, action, json2) {
23095
+ function fromJson(statements, dialect4, action, json2) {
23368
23096
  const result = statements.flatMap((statement) => {
23369
23097
  const filtered = convertors.filter((it) => {
23370
- return it.can(statement, dialect7);
23098
+ return it.can(statement, dialect4);
23371
23099
  });
23372
23100
  const convertor = filtered.length === 1 ? filtered[0] : void 0;
23373
23101
  if (!convertor) {
@@ -23377,7 +23105,7 @@ function fromJson(statements, dialect7, action, json2) {
23377
23105
  }).filter((it) => it !== "");
23378
23106
  return result;
23379
23107
  }
23380
- var pgNativeTypes, isPgNativeType, Convertor, PgCreateTableConvertor, MySqlCreateTableConvertor, SQLiteCreateTableConvertor, PgAlterTableAlterColumnSetGenerated, PgAlterTableAlterColumnDropGenerated, PgAlterTableAlterColumnAlterGenerated, PgAlterTableAddUniqueConstraintConvertor, PgAlterTableDropUniqueConstraintConvertor, PgAlterTableAddCheckConstraintConvertor, PgAlterTableDeleteCheckConstraintConvertor, MySQLAlterTableAddUniqueConstraintConvertor, MySQLAlterTableDropUniqueConstraintConvertor, MySqlAlterTableAddCheckConstraintConvertor, MySqlAlterTableDeleteCheckConstraintConvertor, CreatePgSequenceConvertor, DropPgSequenceConvertor, RenamePgSequenceConvertor, MovePgSequenceConvertor, AlterPgSequenceConvertor, CreateTypeEnumConvertor, AlterTypeAddValueConvertor, PgDropTableConvertor, MySQLDropTableConvertor, SQLiteDropTableConvertor, PgRenameTableConvertor, SqliteRenameTableConvertor, MySqlRenameTableConvertor, PgAlterTableRenameColumnConvertor, MySqlAlterTableRenameColumnConvertor, SQLiteAlterTableRenameColumnConvertor, PgAlterTableDropColumnConvertor, MySqlAlterTableDropColumnConvertor, SQLiteAlterTableDropColumnConvertor, PgAlterTableAddColumnConvertor, MySqlAlterTableAddColumnConvertor, SQLiteAlterTableAddColumnConvertor, PgAlterTableAlterColumnSetTypeConvertor, PgAlterTableAlterColumnSetDefaultConvertor, PgAlterTableAlterColumnDropDefaultConvertor, PgAlterTableAlterColumnDropGeneratedConvertor, PgAlterTableAlterColumnSetExpressionConvertor, PgAlterTableAlterColumnAlterrGeneratedConvertor, SqliteAlterTableAlterColumnDropGeneratedConvertor, SqliteAlterTableAlterColumnSetExpressionConvertor, SqliteAlterTableAlterColumnAlterGeneratedConvertor, MySqlAlterTableAlterColumnAlterrGeneratedConvertor, MySqlAlterTableAddPk, MySqlAlterTableDropPk, LibSQLModifyColumn, MySqlModifyColumn, PgAlterTableCreateCompositePrimaryKeyConvertor, PgAlterTableDeleteCompositePrimaryKeyConvertor, PgAlterTableAlterCompositePrimaryKeyConvertor, MySqlAlterTableCreateCompositePrimaryKeyConvertor, MySqlAlterTableDeleteCompositePrimaryKeyConvertor, MySqlAlterTableAlterCompositePrimaryKeyConvertor, PgAlterTableAlterColumnSetPrimaryKeyConvertor, PgAlterTableAlterColumnDropPrimaryKeyConvertor, PgAlterTableAlterColumnSetNotNullConvertor, PgAlterTableAlterColumnDropNotNullConvertor, PgCreateForeignKeyConvertor, LibSQLCreateForeignKeyConvertor, MySqlCreateForeignKeyConvertor, PgAlterForeignKeyConvertor, PgDeleteForeignKeyConvertor, MySqlDeleteForeignKeyConvertor, CreatePgIndexConvertor, CreateMySqlIndexConvertor, CreateSqliteIndexConvertor, PgDropIndexConvertor, PgCreateSchemaConvertor, PgRenameSchemaConvertor, PgDropSchemaConvertor, PgAlterTableSetSchemaConvertor, PgAlterTableSetNewSchemaConvertor, PgAlterTableRemoveFromSchemaConvertor, SqliteDropIndexConvertor, MySqlDropIndexConvertor, SQLiteRecreateTableConvertor, LibSQLRecreateTableConvertor, convertors;
23108
+ var pgNativeTypes, isPgNativeType, Convertor, PgCreateTableConvertor, MySqlCreateTableConvertor, SQLiteCreateTableConvertor, PgAlterTableAlterColumnSetGenerated, PgAlterTableAlterColumnDropGenerated, PgAlterTableAlterColumnAlterGenerated, PgAlterTableAddUniqueConstraintConvertor, PgAlterTableDropUniqueConstraintConvertor, MySQLAlterTableAddUniqueConstraintConvertor, MySQLAlterTableDropUniqueConstraintConvertor, CreatePgSequenceConvertor, DropPgSequenceConvertor, RenamePgSequenceConvertor, MovePgSequenceConvertor, AlterPgSequenceConvertor, CreateTypeEnumConvertor, DropTypeEnumConvertor, AlterTypeAddValueConvertor, AlterTypeSetSchemaConvertor, AlterRenameTypeConvertor, AlterTypeDropValueConvertor, PgDropTableConvertor, MySQLDropTableConvertor, SQLiteDropTableConvertor, PgRenameTableConvertor, SqliteRenameTableConvertor, MySqlRenameTableConvertor, PgAlterTableRenameColumnConvertor, MySqlAlterTableRenameColumnConvertor, SQLiteAlterTableRenameColumnConvertor, PgAlterTableDropColumnConvertor, MySqlAlterTableDropColumnConvertor, SQLiteAlterTableDropColumnConvertor, PgAlterTableAddColumnConvertor, MySqlAlterTableAddColumnConvertor, SQLiteAlterTableAddColumnConvertor, PgAlterTableAlterColumnSetTypeConvertor, PgAlterTableAlterColumnSetDefaultConvertor, PgAlterTableAlterColumnDropDefaultConvertor, PgAlterTableAlterColumnDropGeneratedConvertor, PgAlterTableAlterColumnSetExpressionConvertor, PgAlterTableAlterColumnAlterrGeneratedConvertor, SqliteAlterTableAlterColumnDropGeneratedConvertor, SqliteAlterTableAlterColumnSetExpressionConvertor, SqliteAlterTableAlterColumnAlterGeneratedConvertor, MySqlAlterTableAlterColumnAlterrGeneratedConvertor, MySqlAlterTableAddPk, MySqlAlterTableDropPk, LibSQLModifyColumn, MySqlModifyColumn, PgAlterTableCreateCompositePrimaryKeyConvertor, PgAlterTableDeleteCompositePrimaryKeyConvertor, PgAlterTableAlterCompositePrimaryKeyConvertor, MySqlAlterTableCreateCompositePrimaryKeyConvertor, MySqlAlterTableDeleteCompositePrimaryKeyConvertor, MySqlAlterTableAlterCompositePrimaryKeyConvertor, PgAlterTableAlterColumnSetPrimaryKeyConvertor, PgAlterTableAlterColumnDropPrimaryKeyConvertor, PgAlterTableAlterColumnSetNotNullConvertor, PgAlterTableAlterColumnDropNotNullConvertor, PgCreateForeignKeyConvertor, LibSQLCreateForeignKeyConvertor, MySqlCreateForeignKeyConvertor, PgAlterForeignKeyConvertor, PgDeleteForeignKeyConvertor, MySqlDeleteForeignKeyConvertor, CreatePgIndexConvertor, CreateMySqlIndexConvertor, CreateSqliteIndexConvertor, PgDropIndexConvertor, PgCreateSchemaConvertor, PgRenameSchemaConvertor, PgDropSchemaConvertor, PgAlterTableSetSchemaConvertor, PgAlterTableSetNewSchemaConvertor, PgAlterTableRemoveFromSchemaConvertor, SqliteDropIndexConvertor, MySqlDropIndexConvertor, SQLiteRecreateTableConvertor, LibSQLRecreateTableConvertor, convertors;
23381
23109
  var init_sqlgenerator = __esm({
23382
23110
  "src/sqlgenerator.ts"() {
23383
23111
  "use strict";
@@ -23435,11 +23163,11 @@ var init_sqlgenerator = __esm({
23435
23163
  Convertor = class {
23436
23164
  };
23437
23165
  PgCreateTableConvertor = class extends Convertor {
23438
- can(statement, dialect7) {
23439
- return statement.type === "create_table" && dialect7 === "postgresql";
23166
+ can(statement, dialect4) {
23167
+ return statement.type === "create_table" && dialect4 === "postgresql";
23440
23168
  }
23441
23169
  convert(st) {
23442
- const { tableName, schema: schema5, columns, compositePKs, uniqueConstraints, checkConstraints } = st;
23170
+ const { tableName, schema: schema5, columns, compositePKs, uniqueConstraints } = st;
23443
23171
  let statement = "";
23444
23172
  const name = schema5 ? `"${schema5}"."${tableName}"` : `"${tableName}"`;
23445
23173
  statement += `CREATE TABLE IF NOT EXISTS ${name} (
@@ -23472,13 +23200,6 @@ var init_sqlgenerator = __esm({
23472
23200
  statement += ` CONSTRAINT "${unsquashedUnique.name}" UNIQUE${unsquashedUnique.nullsNotDistinct ? " NULLS NOT DISTINCT" : ""}("${unsquashedUnique.columns.join(`","`)}")`;
23473
23201
  }
23474
23202
  }
23475
- if (typeof checkConstraints !== "undefined" && checkConstraints.length > 0) {
23476
- for (const checkConstraint4 of checkConstraints) {
23477
- statement += ",\n";
23478
- const unsquashedCheck = PgSquasher.unsquashCheck(checkConstraint4);
23479
- statement += ` CONSTRAINT "${unsquashedCheck.name}" CHECK (${unsquashedCheck.value})`;
23480
- }
23481
- }
23482
23203
  statement += `
23483
23204
  );`;
23484
23205
  statement += `
@@ -23487,8 +23208,8 @@ var init_sqlgenerator = __esm({
23487
23208
  }
23488
23209
  };
23489
23210
  MySqlCreateTableConvertor = class extends Convertor {
23490
- can(statement, dialect7) {
23491
- return statement.type === "create_table" && dialect7 === "mysql";
23211
+ can(statement, dialect4) {
23212
+ return statement.type === "create_table" && dialect4 === "mysql";
23492
23213
  }
23493
23214
  convert(st) {
23494
23215
  var _a, _b;
@@ -23496,7 +23217,6 @@ var init_sqlgenerator = __esm({
23496
23217
  tableName,
23497
23218
  columns,
23498
23219
  schema: schema5,
23499
- checkConstraints,
23500
23220
  compositePKs,
23501
23221
  uniqueConstraints,
23502
23222
  internals
@@ -23531,13 +23251,6 @@ var init_sqlgenerator = __esm({
23531
23251
  statement += ` CONSTRAINT \`${unsquashedUnique.name}\` UNIQUE(${uniqueString})`;
23532
23252
  }
23533
23253
  }
23534
- if (typeof checkConstraints !== "undefined" && checkConstraints.length > 0) {
23535
- for (const checkConstraint4 of checkConstraints) {
23536
- statement += ",\n";
23537
- const unsquashedCheck = MySqlSquasher.unsquashCheck(checkConstraint4);
23538
- statement += ` CONSTRAINT \`${unsquashedCheck.name}\` CHECK(${unsquashedCheck.value})`;
23539
- }
23540
- }
23541
23254
  statement += `
23542
23255
  );`;
23543
23256
  statement += `
@@ -23546,8 +23259,8 @@ var init_sqlgenerator = __esm({
23546
23259
  }
23547
23260
  };
23548
23261
  SQLiteCreateTableConvertor = class extends Convertor {
23549
- can(statement, dialect7) {
23550
- return statement.type === "sqlite_create_table" && (dialect7 === "sqlite" || dialect7 === "turso");
23262
+ can(statement, dialect4) {
23263
+ return statement.type === "sqlite_create_table" && (dialect4 === "sqlite" || dialect4 === "turso");
23551
23264
  }
23552
23265
  convert(st) {
23553
23266
  const {
@@ -23555,8 +23268,7 @@ var init_sqlgenerator = __esm({
23555
23268
  columns,
23556
23269
  referenceData,
23557
23270
  compositePKs,
23558
- uniqueConstraints,
23559
- checkConstraints
23271
+ uniqueConstraints
23560
23272
  } = st;
23561
23273
  let statement = "";
23562
23274
  statement += `CREATE TABLE \`${tableName}\` (
@@ -23597,17 +23309,10 @@ var init_sqlgenerator = __esm({
23597
23309
  if (typeof uniqueConstraints !== "undefined" && uniqueConstraints.length > 0) {
23598
23310
  for (const uniqueConstraint4 of uniqueConstraints) {
23599
23311
  statement += ",\n";
23600
- const unsquashedUnique = SQLiteSquasher.unsquashUnique(uniqueConstraint4);
23312
+ const unsquashedUnique = MySqlSquasher.unsquashUnique(uniqueConstraint4);
23601
23313
  statement += ` CONSTRAINT ${unsquashedUnique.name} UNIQUE(\`${unsquashedUnique.columns.join(`\`,\``)}\`)`;
23602
23314
  }
23603
23315
  }
23604
- if (typeof checkConstraints !== "undefined" && checkConstraints.length > 0) {
23605
- for (const check2 of checkConstraints) {
23606
- statement += ",\n";
23607
- const { value, name } = SQLiteSquasher.unsquashCheck(check2);
23608
- statement += ` CONSTRAINT "${name}" CHECK(${value})`;
23609
- }
23610
- }
23611
23316
  statement += `
23612
23317
  `;
23613
23318
  statement += `);`;
@@ -23617,8 +23322,8 @@ var init_sqlgenerator = __esm({
23617
23322
  }
23618
23323
  };
23619
23324
  PgAlterTableAlterColumnSetGenerated = class extends Convertor {
23620
- can(statement, dialect7) {
23621
- return statement.type === "alter_table_alter_column_set_identity" && dialect7 === "postgresql";
23325
+ can(statement, dialect4) {
23326
+ return statement.type === "alter_table_alter_column_set_identity" && dialect4 === "postgresql";
23622
23327
  }
23623
23328
  convert(statement) {
23624
23329
  const { identity, tableName, columnName, schema: schema5 } = statement;
@@ -23630,8 +23335,8 @@ var init_sqlgenerator = __esm({
23630
23335
  }
23631
23336
  };
23632
23337
  PgAlterTableAlterColumnDropGenerated = class extends Convertor {
23633
- can(statement, dialect7) {
23634
- return statement.type === "alter_table_alter_column_drop_identity" && dialect7 === "postgresql";
23338
+ can(statement, dialect4) {
23339
+ return statement.type === "alter_table_alter_column_drop_identity" && dialect4 === "postgresql";
23635
23340
  }
23636
23341
  convert(statement) {
23637
23342
  const { tableName, columnName, schema: schema5 } = statement;
@@ -23640,8 +23345,8 @@ var init_sqlgenerator = __esm({
23640
23345
  }
23641
23346
  };
23642
23347
  PgAlterTableAlterColumnAlterGenerated = class extends Convertor {
23643
- can(statement, dialect7) {
23644
- return statement.type === "alter_table_alter_column_change_identity" && dialect7 === "postgresql";
23348
+ can(statement, dialect4) {
23349
+ return statement.type === "alter_table_alter_column_change_identity" && dialect4 === "postgresql";
23645
23350
  }
23646
23351
  convert(statement) {
23647
23352
  const { identity, oldIdentity, tableName, columnName, schema: schema5 } = statement;
@@ -23688,8 +23393,8 @@ var init_sqlgenerator = __esm({
23688
23393
  }
23689
23394
  };
23690
23395
  PgAlterTableAddUniqueConstraintConvertor = class extends Convertor {
23691
- can(statement, dialect7) {
23692
- return statement.type === "create_unique_constraint" && dialect7 === "postgresql";
23396
+ can(statement, dialect4) {
23397
+ return statement.type === "create_unique_constraint" && dialect4 === "postgresql";
23693
23398
  }
23694
23399
  convert(statement) {
23695
23400
  const unsquashed = PgSquasher.unsquashUnique(statement.data);
@@ -23698,8 +23403,8 @@ var init_sqlgenerator = __esm({
23698
23403
  }
23699
23404
  };
23700
23405
  PgAlterTableDropUniqueConstraintConvertor = class extends Convertor {
23701
- can(statement, dialect7) {
23702
- return statement.type === "delete_unique_constraint" && dialect7 === "postgresql";
23406
+ can(statement, dialect4) {
23407
+ return statement.type === "delete_unique_constraint" && dialect4 === "postgresql";
23703
23408
  }
23704
23409
  convert(statement) {
23705
23410
  const unsquashed = PgSquasher.unsquashUnique(statement.data);
@@ -23707,28 +23412,9 @@ var init_sqlgenerator = __esm({
23707
23412
  return `ALTER TABLE ${tableNameWithSchema} DROP CONSTRAINT "${unsquashed.name}";`;
23708
23413
  }
23709
23414
  };
23710
- PgAlterTableAddCheckConstraintConvertor = class extends Convertor {
23711
- can(statement, dialect7) {
23712
- return statement.type === "create_check_constraint" && dialect7 === "postgresql";
23713
- }
23714
- convert(statement) {
23715
- const unsquashed = PgSquasher.unsquashCheck(statement.data);
23716
- const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
23717
- return `ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT "${unsquashed.name}" CHECK (${unsquashed.value});`;
23718
- }
23719
- };
23720
- PgAlterTableDeleteCheckConstraintConvertor = class extends Convertor {
23721
- can(statement, dialect7) {
23722
- return statement.type === "delete_check_constraint" && dialect7 === "postgresql";
23723
- }
23724
- convert(statement) {
23725
- const tableNameWithSchema = statement.schema ? `"${statement.schema}"."${statement.tableName}"` : `"${statement.tableName}"`;
23726
- return `ALTER TABLE ${tableNameWithSchema} DROP CONSTRAINT "${statement.constraintName}";`;
23727
- }
23728
- };
23729
23415
  MySQLAlterTableAddUniqueConstraintConvertor = class extends Convertor {
23730
- can(statement, dialect7) {
23731
- return statement.type === "create_unique_constraint" && dialect7 === "mysql";
23416
+ can(statement, dialect4) {
23417
+ return statement.type === "create_unique_constraint" && dialect4 === "mysql";
23732
23418
  }
23733
23419
  convert(statement) {
23734
23420
  const unsquashed = MySqlSquasher.unsquashUnique(statement.data);
@@ -23736,36 +23422,17 @@ var init_sqlgenerator = __esm({
23736
23422
  }
23737
23423
  };
23738
23424
  MySQLAlterTableDropUniqueConstraintConvertor = class extends Convertor {
23739
- can(statement, dialect7) {
23740
- return statement.type === "delete_unique_constraint" && dialect7 === "mysql";
23425
+ can(statement, dialect4) {
23426
+ return statement.type === "delete_unique_constraint" && dialect4 === "mysql";
23741
23427
  }
23742
23428
  convert(statement) {
23743
23429
  const unsquashed = MySqlSquasher.unsquashUnique(statement.data);
23744
23430
  return `ALTER TABLE \`${statement.tableName}\` DROP INDEX \`${unsquashed.name}\`;`;
23745
23431
  }
23746
23432
  };
23747
- MySqlAlterTableAddCheckConstraintConvertor = class extends Convertor {
23748
- can(statement, dialect7) {
23749
- return statement.type === "create_check_constraint" && dialect7 === "mysql";
23750
- }
23751
- convert(statement) {
23752
- const unsquashed = MySqlSquasher.unsquashCheck(statement.data);
23753
- const { tableName } = statement;
23754
- return `ALTER TABLE \`${tableName}\` ADD CONSTRAINT \`${unsquashed.name}\` CHECK (${unsquashed.value});`;
23755
- }
23756
- };
23757
- MySqlAlterTableDeleteCheckConstraintConvertor = class extends Convertor {
23758
- can(statement, dialect7) {
23759
- return statement.type === "delete_check_constraint" && dialect7 === "mysql";
23760
- }
23761
- convert(statement) {
23762
- const { tableName } = statement;
23763
- return `ALTER TABLE \`${tableName}\` DROP CONSTRAINT \`${statement.constraintName}\`;`;
23764
- }
23765
- };
23766
23433
  CreatePgSequenceConvertor = class extends Convertor {
23767
- can(statement, dialect7) {
23768
- return statement.type === "create_sequence" && dialect7 === "postgresql";
23434
+ can(statement, dialect4) {
23435
+ return statement.type === "create_sequence" && dialect4 === "postgresql";
23769
23436
  }
23770
23437
  convert(st) {
23771
23438
  const { name, values, schema: schema5 } = st;
@@ -23774,8 +23441,8 @@ var init_sqlgenerator = __esm({
23774
23441
  }
23775
23442
  };
23776
23443
  DropPgSequenceConvertor = class extends Convertor {
23777
- can(statement, dialect7) {
23778
- return statement.type === "drop_sequence" && dialect7 === "postgresql";
23444
+ can(statement, dialect4) {
23445
+ return statement.type === "drop_sequence" && dialect4 === "postgresql";
23779
23446
  }
23780
23447
  convert(st) {
23781
23448
  const { name, schema: schema5 } = st;
@@ -23784,8 +23451,8 @@ var init_sqlgenerator = __esm({
23784
23451
  }
23785
23452
  };
23786
23453
  RenamePgSequenceConvertor = class extends Convertor {
23787
- can(statement, dialect7) {
23788
- return statement.type === "rename_sequence" && dialect7 === "postgresql";
23454
+ can(statement, dialect4) {
23455
+ return statement.type === "rename_sequence" && dialect4 === "postgresql";
23789
23456
  }
23790
23457
  convert(st) {
23791
23458
  const { nameFrom, nameTo, schema: schema5 } = st;
@@ -23795,8 +23462,8 @@ var init_sqlgenerator = __esm({
23795
23462
  }
23796
23463
  };
23797
23464
  MovePgSequenceConvertor = class extends Convertor {
23798
- can(statement, dialect7) {
23799
- return statement.type === "move_sequence" && dialect7 === "postgresql";
23465
+ can(statement, dialect4) {
23466
+ return statement.type === "move_sequence" && dialect4 === "postgresql";
23800
23467
  }
23801
23468
  convert(st) {
23802
23469
  const { schemaFrom, schemaTo, name } = st;
@@ -23806,8 +23473,8 @@ var init_sqlgenerator = __esm({
23806
23473
  }
23807
23474
  };
23808
23475
  AlterPgSequenceConvertor = class extends Convertor {
23809
- can(statement, dialect7) {
23810
- return statement.type === "alter_sequence" && dialect7 === "postgresql";
23476
+ can(statement, dialect4) {
23477
+ return statement.type === "alter_sequence" && dialect4 === "postgresql";
23811
23478
  }
23812
23479
  convert(st) {
23813
23480
  const { name, schema: schema5, values } = st;
@@ -23822,20 +23489,22 @@ var init_sqlgenerator = __esm({
23822
23489
  }
23823
23490
  convert(st) {
23824
23491
  const { name, values, schema: schema5 } = st;
23825
- const tableNameWithSchema = schema5 ? `"${schema5}"."${name}"` : `"${name}"`;
23492
+ const enumNameWithSchema = schema5 ? `"${schema5}"."${name}"` : `"${name}"`;
23826
23493
  let valuesStatement = "(";
23827
23494
  valuesStatement += values.map((it) => `'${it}'`).join(", ");
23828
23495
  valuesStatement += ")";
23829
- let statement = "DO $$ BEGIN";
23830
- statement += "\n";
23831
- statement += ` CREATE TYPE ${tableNameWithSchema} AS ENUM${valuesStatement};`;
23832
- statement += "\n";
23833
- statement += "EXCEPTION";
23834
- statement += "\n";
23835
- statement += " WHEN duplicate_object THEN null;";
23836
- statement += "\n";
23837
- statement += "END $$;";
23838
- statement += "\n";
23496
+ let statement = `CREATE TYPE ${enumNameWithSchema} AS ENUM${valuesStatement};`;
23497
+ return statement;
23498
+ }
23499
+ };
23500
+ DropTypeEnumConvertor = class extends Convertor {
23501
+ can(statement) {
23502
+ return statement.type === "drop_type_enum";
23503
+ }
23504
+ convert(st) {
23505
+ const { name, schema: schema5 } = st;
23506
+ const enumNameWithSchema = schema5 ? `"${schema5}"."${name}"` : `"${name}"`;
23507
+ let statement = `DROP TYPE ${enumNameWithSchema} CASCADE;`;
23839
23508
  return statement;
23840
23509
  }
23841
23510
  };
@@ -23844,14 +23513,61 @@ var init_sqlgenerator = __esm({
23844
23513
  return statement.type === "alter_type_add_value";
23845
23514
  }
23846
23515
  convert(st) {
23847
- const { name, schema: schema5, value } = st;
23848
- const schemaPrefix = schema5 && schema5 !== "public" ? `"${schema5}".` : "";
23849
- return `ALTER TYPE ${schemaPrefix}"${name}" ADD VALUE '${value}';`;
23516
+ const { name, schema: schema5, value, before } = st;
23517
+ const enumNameWithSchema = schema5 ? `"${schema5}"."${name}"` : `"${name}"`;
23518
+ return `ALTER TYPE ${enumNameWithSchema} ADD VALUE '${value}'${before.length ? ` BEFORE '${before}'` : ""};`;
23519
+ }
23520
+ };
23521
+ AlterTypeSetSchemaConvertor = class extends Convertor {
23522
+ can(statement) {
23523
+ return statement.type === "move_type_enum";
23524
+ }
23525
+ convert(st) {
23526
+ const { name, schemaFrom, schemaTo } = st;
23527
+ const enumNameWithSchema = schemaFrom ? `"${schemaFrom}"."${name}"` : `"${name}"`;
23528
+ return `ALTER TYPE ${enumNameWithSchema} SET SCHEMA "${schemaTo}";`;
23529
+ }
23530
+ };
23531
+ AlterRenameTypeConvertor = class extends Convertor {
23532
+ can(statement) {
23533
+ return statement.type === "rename_type_enum";
23534
+ }
23535
+ convert(st) {
23536
+ const { nameTo, nameFrom, schema: schema5 } = st;
23537
+ const enumNameWithSchema = schema5 ? `"${schema5}"."${nameFrom}"` : `"${nameFrom}"`;
23538
+ return `ALTER TYPE ${enumNameWithSchema} RENAME TO "${nameTo}";`;
23539
+ }
23540
+ };
23541
+ AlterTypeDropValueConvertor = class extends Convertor {
23542
+ can(statement) {
23543
+ return statement.type === "alter_type_drop_value";
23544
+ }
23545
+ convert(st) {
23546
+ const { columnsWithEnum, name, newValues, schema: schema5 } = st;
23547
+ const statements = [];
23548
+ for (const withEnum of columnsWithEnum) {
23549
+ statements.push(
23550
+ `ALTER TABLE "${withEnum.schema}"."${withEnum.table}" ALTER COLUMN "${withEnum.column}" SET DATA TYPE text;`
23551
+ );
23552
+ }
23553
+ statements.push(new DropTypeEnumConvertor().convert({ name, schema: schema5, type: "drop_type_enum" }));
23554
+ statements.push(new CreateTypeEnumConvertor().convert({
23555
+ name,
23556
+ schema: schema5,
23557
+ values: newValues,
23558
+ type: "create_type_enum"
23559
+ }));
23560
+ for (const withEnum of columnsWithEnum) {
23561
+ statements.push(
23562
+ `ALTER TABLE "${withEnum.schema}"."${withEnum.table}" ALTER COLUMN "${withEnum.column}" SET DATA TYPE "${schema5}"."${name}" USING "${withEnum.column}"::"${schema5}"."${name}";`
23563
+ );
23564
+ }
23565
+ return statements;
23850
23566
  }
23851
23567
  };
23852
23568
  PgDropTableConvertor = class extends Convertor {
23853
- can(statement, dialect7) {
23854
- return statement.type === "drop_table" && dialect7 === "postgresql";
23569
+ can(statement, dialect4) {
23570
+ return statement.type === "drop_table" && dialect4 === "postgresql";
23855
23571
  }
23856
23572
  convert(statement) {
23857
23573
  const { tableName, schema: schema5 } = statement;
@@ -23860,8 +23576,8 @@ var init_sqlgenerator = __esm({
23860
23576
  }
23861
23577
  };
23862
23578
  MySQLDropTableConvertor = class extends Convertor {
23863
- can(statement, dialect7) {
23864
- return statement.type === "drop_table" && dialect7 === "mysql";
23579
+ can(statement, dialect4) {
23580
+ return statement.type === "drop_table" && dialect4 === "mysql";
23865
23581
  }
23866
23582
  convert(statement) {
23867
23583
  const { tableName } = statement;
@@ -23869,8 +23585,8 @@ var init_sqlgenerator = __esm({
23869
23585
  }
23870
23586
  };
23871
23587
  SQLiteDropTableConvertor = class extends Convertor {
23872
- can(statement, dialect7) {
23873
- return statement.type === "drop_table" && (dialect7 === "sqlite" || dialect7 === "turso");
23588
+ can(statement, dialect4) {
23589
+ return statement.type === "drop_table" && (dialect4 === "sqlite" || dialect4 === "turso");
23874
23590
  }
23875
23591
  convert(statement) {
23876
23592
  const { tableName } = statement;
@@ -23878,8 +23594,8 @@ var init_sqlgenerator = __esm({
23878
23594
  }
23879
23595
  };
23880
23596
  PgRenameTableConvertor = class extends Convertor {
23881
- can(statement, dialect7) {
23882
- return statement.type === "rename_table" && dialect7 === "postgresql";
23597
+ can(statement, dialect4) {
23598
+ return statement.type === "rename_table" && dialect4 === "postgresql";
23883
23599
  }
23884
23600
  convert(statement) {
23885
23601
  const { tableNameFrom, tableNameTo, toSchema, fromSchema } = statement;
@@ -23889,8 +23605,8 @@ var init_sqlgenerator = __esm({
23889
23605
  }
23890
23606
  };
23891
23607
  SqliteRenameTableConvertor = class extends Convertor {
23892
- can(statement, dialect7) {
23893
- return statement.type === "rename_table" && (dialect7 === "sqlite" || dialect7 === "turso");
23608
+ can(statement, dialect4) {
23609
+ return statement.type === "rename_table" && (dialect4 === "sqlite" || dialect4 === "turso");
23894
23610
  }
23895
23611
  convert(statement) {
23896
23612
  const { tableNameFrom, tableNameTo } = statement;
@@ -23898,8 +23614,8 @@ var init_sqlgenerator = __esm({
23898
23614
  }
23899
23615
  };
23900
23616
  MySqlRenameTableConvertor = class extends Convertor {
23901
- can(statement, dialect7) {
23902
- return statement.type === "rename_table" && dialect7 === "mysql";
23617
+ can(statement, dialect4) {
23618
+ return statement.type === "rename_table" && dialect4 === "mysql";
23903
23619
  }
23904
23620
  convert(statement) {
23905
23621
  const { tableNameFrom, tableNameTo } = statement;
@@ -23907,8 +23623,8 @@ var init_sqlgenerator = __esm({
23907
23623
  }
23908
23624
  };
23909
23625
  PgAlterTableRenameColumnConvertor = class extends Convertor {
23910
- can(statement, dialect7) {
23911
- return statement.type === "alter_table_rename_column" && dialect7 === "postgresql";
23626
+ can(statement, dialect4) {
23627
+ return statement.type === "alter_table_rename_column" && dialect4 === "postgresql";
23912
23628
  }
23913
23629
  convert(statement) {
23914
23630
  const { tableName, oldColumnName, newColumnName, schema: schema5 } = statement;
@@ -23917,8 +23633,8 @@ var init_sqlgenerator = __esm({
23917
23633
  }
23918
23634
  };
23919
23635
  MySqlAlterTableRenameColumnConvertor = class extends Convertor {
23920
- can(statement, dialect7) {
23921
- return statement.type === "alter_table_rename_column" && dialect7 === "mysql";
23636
+ can(statement, dialect4) {
23637
+ return statement.type === "alter_table_rename_column" && dialect4 === "mysql";
23922
23638
  }
23923
23639
  convert(statement) {
23924
23640
  const { tableName, oldColumnName, newColumnName } = statement;
@@ -23926,8 +23642,8 @@ var init_sqlgenerator = __esm({
23926
23642
  }
23927
23643
  };
23928
23644
  SQLiteAlterTableRenameColumnConvertor = class extends Convertor {
23929
- can(statement, dialect7) {
23930
- return statement.type === "alter_table_rename_column" && (dialect7 === "sqlite" || dialect7 === "turso");
23645
+ can(statement, dialect4) {
23646
+ return statement.type === "alter_table_rename_column" && (dialect4 === "sqlite" || dialect4 === "turso");
23931
23647
  }
23932
23648
  convert(statement) {
23933
23649
  const { tableName, oldColumnName, newColumnName } = statement;
@@ -23935,8 +23651,8 @@ var init_sqlgenerator = __esm({
23935
23651
  }
23936
23652
  };
23937
23653
  PgAlterTableDropColumnConvertor = class extends Convertor {
23938
- can(statement, dialect7) {
23939
- return statement.type === "alter_table_drop_column" && dialect7 === "postgresql";
23654
+ can(statement, dialect4) {
23655
+ return statement.type === "alter_table_drop_column" && dialect4 === "postgresql";
23940
23656
  }
23941
23657
  convert(statement) {
23942
23658
  const { tableName, columnName, schema: schema5 } = statement;
@@ -23945,8 +23661,8 @@ var init_sqlgenerator = __esm({
23945
23661
  }
23946
23662
  };
23947
23663
  MySqlAlterTableDropColumnConvertor = class extends Convertor {
23948
- can(statement, dialect7) {
23949
- return statement.type === "alter_table_drop_column" && dialect7 === "mysql";
23664
+ can(statement, dialect4) {
23665
+ return statement.type === "alter_table_drop_column" && dialect4 === "mysql";
23950
23666
  }
23951
23667
  convert(statement) {
23952
23668
  const { tableName, columnName } = statement;
@@ -23954,8 +23670,8 @@ var init_sqlgenerator = __esm({
23954
23670
  }
23955
23671
  };
23956
23672
  SQLiteAlterTableDropColumnConvertor = class extends Convertor {
23957
- can(statement, dialect7) {
23958
- return statement.type === "alter_table_drop_column" && (dialect7 === "sqlite" || dialect7 === "turso");
23673
+ can(statement, dialect4) {
23674
+ return statement.type === "alter_table_drop_column" && (dialect4 === "sqlite" || dialect4 === "turso");
23959
23675
  }
23960
23676
  convert(statement) {
23961
23677
  const { tableName, columnName } = statement;
@@ -23963,8 +23679,8 @@ var init_sqlgenerator = __esm({
23963
23679
  }
23964
23680
  };
23965
23681
  PgAlterTableAddColumnConvertor = class extends Convertor {
23966
- can(statement, dialect7) {
23967
- return statement.type === "alter_table_add_column" && dialect7 === "postgresql";
23682
+ can(statement, dialect4) {
23683
+ return statement.type === "alter_table_add_column" && dialect4 === "postgresql";
23968
23684
  }
23969
23685
  convert(statement) {
23970
23686
  const { tableName, column: column7, schema: schema5 } = statement;
@@ -23983,8 +23699,8 @@ var init_sqlgenerator = __esm({
23983
23699
  }
23984
23700
  };
23985
23701
  MySqlAlterTableAddColumnConvertor = class extends Convertor {
23986
- can(statement, dialect7) {
23987
- return statement.type === "alter_table_add_column" && dialect7 === "mysql";
23702
+ can(statement, dialect4) {
23703
+ return statement.type === "alter_table_add_column" && dialect4 === "mysql";
23988
23704
  }
23989
23705
  convert(statement) {
23990
23706
  const { tableName, column: column7 } = statement;
@@ -24007,8 +23723,8 @@ var init_sqlgenerator = __esm({
24007
23723
  }
24008
23724
  };
24009
23725
  SQLiteAlterTableAddColumnConvertor = class extends Convertor {
24010
- can(statement, dialect7) {
24011
- return statement.type === "sqlite_alter_table_add_column" && (dialect7 === "sqlite" || dialect7 === "turso");
23726
+ can(statement, dialect4) {
23727
+ return statement.type === "sqlite_alter_table_add_column" && (dialect4 === "sqlite" || dialect4 === "turso");
24012
23728
  }
24013
23729
  convert(statement) {
24014
23730
  const { tableName, column: column7, referenceData } = statement;
@@ -24023,8 +23739,8 @@ var init_sqlgenerator = __esm({
24023
23739
  }
24024
23740
  };
24025
23741
  PgAlterTableAlterColumnSetTypeConvertor = class extends Convertor {
24026
- can(statement, dialect7) {
24027
- return statement.type === "alter_table_alter_column_set_type" && dialect7 === "postgresql";
23742
+ can(statement, dialect4) {
23743
+ return statement.type === "alter_table_alter_column_set_type" && dialect4 === "postgresql";
24028
23744
  }
24029
23745
  convert(statement) {
24030
23746
  const { tableName, columnName, newDataType, schema: schema5 } = statement;
@@ -24033,8 +23749,8 @@ var init_sqlgenerator = __esm({
24033
23749
  }
24034
23750
  };
24035
23751
  PgAlterTableAlterColumnSetDefaultConvertor = class extends Convertor {
24036
- can(statement, dialect7) {
24037
- return statement.type === "alter_table_alter_column_set_default" && dialect7 === "postgresql";
23752
+ can(statement, dialect4) {
23753
+ return statement.type === "alter_table_alter_column_set_default" && dialect4 === "postgresql";
24038
23754
  }
24039
23755
  convert(statement) {
24040
23756
  const { tableName, columnName, schema: schema5 } = statement;
@@ -24043,8 +23759,8 @@ var init_sqlgenerator = __esm({
24043
23759
  }
24044
23760
  };
24045
23761
  PgAlterTableAlterColumnDropDefaultConvertor = class extends Convertor {
24046
- can(statement, dialect7) {
24047
- return statement.type === "alter_table_alter_column_drop_default" && dialect7 === "postgresql";
23762
+ can(statement, dialect4) {
23763
+ return statement.type === "alter_table_alter_column_drop_default" && dialect4 === "postgresql";
24048
23764
  }
24049
23765
  convert(statement) {
24050
23766
  const { tableName, columnName, schema: schema5 } = statement;
@@ -24053,8 +23769,8 @@ var init_sqlgenerator = __esm({
24053
23769
  }
24054
23770
  };
24055
23771
  PgAlterTableAlterColumnDropGeneratedConvertor = class extends Convertor {
24056
- can(statement, dialect7) {
24057
- return statement.type === "alter_table_alter_column_drop_generated" && dialect7 === "postgresql";
23772
+ can(statement, dialect4) {
23773
+ return statement.type === "alter_table_alter_column_drop_generated" && dialect4 === "postgresql";
24058
23774
  }
24059
23775
  convert(statement) {
24060
23776
  const { tableName, columnName, schema: schema5 } = statement;
@@ -24063,8 +23779,8 @@ var init_sqlgenerator = __esm({
24063
23779
  }
24064
23780
  };
24065
23781
  PgAlterTableAlterColumnSetExpressionConvertor = class extends Convertor {
24066
- can(statement, dialect7) {
24067
- return statement.type === "alter_table_alter_column_set_generated" && dialect7 === "postgresql";
23782
+ can(statement, dialect4) {
23783
+ return statement.type === "alter_table_alter_column_set_generated" && dialect4 === "postgresql";
24068
23784
  }
24069
23785
  convert(statement) {
24070
23786
  const {
@@ -24101,8 +23817,8 @@ var init_sqlgenerator = __esm({
24101
23817
  }
24102
23818
  };
24103
23819
  PgAlterTableAlterColumnAlterrGeneratedConvertor = class extends Convertor {
24104
- can(statement, dialect7) {
24105
- return statement.type === "alter_table_alter_column_alter_generated" && dialect7 === "postgresql";
23820
+ can(statement, dialect4) {
23821
+ return statement.type === "alter_table_alter_column_alter_generated" && dialect4 === "postgresql";
24106
23822
  }
24107
23823
  convert(statement) {
24108
23824
  const {
@@ -24139,8 +23855,8 @@ var init_sqlgenerator = __esm({
24139
23855
  }
24140
23856
  };
24141
23857
  SqliteAlterTableAlterColumnDropGeneratedConvertor = class extends Convertor {
24142
- can(statement, dialect7) {
24143
- return statement.type === "alter_table_alter_column_drop_generated" && (dialect7 === "sqlite" || dialect7 === "turso");
23858
+ can(statement, dialect4) {
23859
+ return statement.type === "alter_table_alter_column_drop_generated" && (dialect4 === "sqlite" || dialect4 === "turso");
24144
23860
  }
24145
23861
  convert(statement) {
24146
23862
  const {
@@ -24180,8 +23896,8 @@ var init_sqlgenerator = __esm({
24180
23896
  }
24181
23897
  };
24182
23898
  SqliteAlterTableAlterColumnSetExpressionConvertor = class extends Convertor {
24183
- can(statement, dialect7) {
24184
- return statement.type === "alter_table_alter_column_set_generated" && (dialect7 === "sqlite" || dialect7 === "turso");
23899
+ can(statement, dialect4) {
23900
+ return statement.type === "alter_table_alter_column_set_generated" && (dialect4 === "sqlite" || dialect4 === "turso");
24185
23901
  }
24186
23902
  convert(statement) {
24187
23903
  const {
@@ -24221,8 +23937,8 @@ var init_sqlgenerator = __esm({
24221
23937
  }
24222
23938
  };
24223
23939
  SqliteAlterTableAlterColumnAlterGeneratedConvertor = class extends Convertor {
24224
- can(statement, dialect7) {
24225
- return statement.type === "alter_table_alter_column_alter_generated" && (dialect7 === "sqlite" || dialect7 === "turso");
23940
+ can(statement, dialect4) {
23941
+ return statement.type === "alter_table_alter_column_alter_generated" && (dialect4 === "sqlite" || dialect4 === "turso");
24226
23942
  }
24227
23943
  convert(statement) {
24228
23944
  const {
@@ -24262,8 +23978,8 @@ var init_sqlgenerator = __esm({
24262
23978
  }
24263
23979
  };
24264
23980
  MySqlAlterTableAlterColumnAlterrGeneratedConvertor = class extends Convertor {
24265
- can(statement, dialect7) {
24266
- return statement.type === "alter_table_alter_column_alter_generated" && dialect7 === "mysql";
23981
+ can(statement, dialect4) {
23982
+ return statement.type === "alter_table_alter_column_alter_generated" && dialect4 === "mysql";
24267
23983
  }
24268
23984
  convert(statement) {
24269
23985
  const {
@@ -24300,24 +24016,24 @@ var init_sqlgenerator = __esm({
24300
24016
  }
24301
24017
  };
24302
24018
  MySqlAlterTableAddPk = class extends Convertor {
24303
- can(statement, dialect7) {
24304
- return statement.type === "alter_table_alter_column_set_pk" && dialect7 === "mysql";
24019
+ can(statement, dialect4) {
24020
+ return statement.type === "alter_table_alter_column_set_pk" && dialect4 === "mysql";
24305
24021
  }
24306
24022
  convert(statement) {
24307
24023
  return `ALTER TABLE \`${statement.tableName}\` ADD PRIMARY KEY (\`${statement.columnName}\`);`;
24308
24024
  }
24309
24025
  };
24310
24026
  MySqlAlterTableDropPk = class extends Convertor {
24311
- can(statement, dialect7) {
24312
- return statement.type === "alter_table_alter_column_drop_pk" && dialect7 === "mysql";
24027
+ can(statement, dialect4) {
24028
+ return statement.type === "alter_table_alter_column_drop_pk" && dialect4 === "mysql";
24313
24029
  }
24314
24030
  convert(statement) {
24315
24031
  return `ALTER TABLE \`${statement.tableName}\` DROP PRIMARY KEY`;
24316
24032
  }
24317
24033
  };
24318
24034
  LibSQLModifyColumn = class extends Convertor {
24319
- can(statement, dialect7) {
24320
- return (statement.type === "alter_table_alter_column_set_type" || statement.type === "alter_table_alter_column_drop_notnull" || statement.type === "alter_table_alter_column_set_notnull" || statement.type === "alter_table_alter_column_set_default" || statement.type === "alter_table_alter_column_drop_default" || statement.type === "create_check_constraint" || statement.type === "delete_check_constraint") && dialect7 === "turso";
24035
+ can(statement, dialect4) {
24036
+ return (statement.type === "alter_table_alter_column_set_type" || statement.type === "alter_table_alter_column_drop_notnull" || statement.type === "alter_table_alter_column_set_notnull" || statement.type === "alter_table_alter_column_set_default" || statement.type === "alter_table_alter_column_drop_default") && dialect4 === "turso";
24321
24037
  }
24322
24038
  convert(statement, json2) {
24323
24039
  const { tableName, columnName } = statement;
@@ -24377,8 +24093,8 @@ var init_sqlgenerator = __esm({
24377
24093
  }
24378
24094
  };
24379
24095
  MySqlModifyColumn = class extends Convertor {
24380
- can(statement, dialect7) {
24381
- return (statement.type === "alter_table_alter_column_set_type" || statement.type === "alter_table_alter_column_set_notnull" || statement.type === "alter_table_alter_column_drop_notnull" || statement.type === "alter_table_alter_column_drop_on_update" || statement.type === "alter_table_alter_column_set_on_update" || statement.type === "alter_table_alter_column_set_autoincrement" || statement.type === "alter_table_alter_column_drop_autoincrement" || statement.type === "alter_table_alter_column_set_default" || statement.type === "alter_table_alter_column_drop_default" || statement.type === "alter_table_alter_column_set_generated" || statement.type === "alter_table_alter_column_drop_generated") && dialect7 === "mysql";
24096
+ can(statement, dialect4) {
24097
+ return (statement.type === "alter_table_alter_column_set_type" || statement.type === "alter_table_alter_column_set_notnull" || statement.type === "alter_table_alter_column_drop_notnull" || statement.type === "alter_table_alter_column_drop_on_update" || statement.type === "alter_table_alter_column_set_on_update" || statement.type === "alter_table_alter_column_set_autoincrement" || statement.type === "alter_table_alter_column_drop_autoincrement" || statement.type === "alter_table_alter_column_set_default" || statement.type === "alter_table_alter_column_drop_default" || statement.type === "alter_table_alter_column_set_generated" || statement.type === "alter_table_alter_column_drop_generated") && dialect4 === "mysql";
24382
24098
  }
24383
24099
  convert(statement) {
24384
24100
  var _a, _b, _c, _d, _e, _f, _g;
@@ -24515,8 +24231,8 @@ var init_sqlgenerator = __esm({
24515
24231
  }
24516
24232
  };
24517
24233
  PgAlterTableCreateCompositePrimaryKeyConvertor = class extends Convertor {
24518
- can(statement, dialect7) {
24519
- return statement.type === "create_composite_pk" && dialect7 === "postgresql";
24234
+ can(statement, dialect4) {
24235
+ return statement.type === "create_composite_pk" && dialect4 === "postgresql";
24520
24236
  }
24521
24237
  convert(statement) {
24522
24238
  const { name, columns } = PgSquasher.unsquashPK(statement.data);
@@ -24525,8 +24241,8 @@ var init_sqlgenerator = __esm({
24525
24241
  }
24526
24242
  };
24527
24243
  PgAlterTableDeleteCompositePrimaryKeyConvertor = class extends Convertor {
24528
- can(statement, dialect7) {
24529
- return statement.type === "delete_composite_pk" && dialect7 === "postgresql";
24244
+ can(statement, dialect4) {
24245
+ return statement.type === "delete_composite_pk" && dialect4 === "postgresql";
24530
24246
  }
24531
24247
  convert(statement) {
24532
24248
  const { name, columns } = PgSquasher.unsquashPK(statement.data);
@@ -24535,8 +24251,8 @@ var init_sqlgenerator = __esm({
24535
24251
  }
24536
24252
  };
24537
24253
  PgAlterTableAlterCompositePrimaryKeyConvertor = class extends Convertor {
24538
- can(statement, dialect7) {
24539
- return statement.type === "alter_composite_pk" && dialect7 === "postgresql";
24254
+ can(statement, dialect4) {
24255
+ return statement.type === "alter_composite_pk" && dialect4 === "postgresql";
24540
24256
  }
24541
24257
  convert(statement) {
24542
24258
  const { name, columns } = PgSquasher.unsquashPK(statement.old);
@@ -24549,8 +24265,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
24549
24265
  }
24550
24266
  };
24551
24267
  MySqlAlterTableCreateCompositePrimaryKeyConvertor = class extends Convertor {
24552
- can(statement, dialect7) {
24553
- return statement.type === "create_composite_pk" && dialect7 === "mysql";
24268
+ can(statement, dialect4) {
24269
+ return statement.type === "create_composite_pk" && dialect4 === "mysql";
24554
24270
  }
24555
24271
  convert(statement) {
24556
24272
  const { name, columns } = MySqlSquasher.unsquashPK(statement.data);
@@ -24558,8 +24274,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
24558
24274
  }
24559
24275
  };
24560
24276
  MySqlAlterTableDeleteCompositePrimaryKeyConvertor = class extends Convertor {
24561
- can(statement, dialect7) {
24562
- return statement.type === "delete_composite_pk" && dialect7 === "mysql";
24277
+ can(statement, dialect4) {
24278
+ return statement.type === "delete_composite_pk" && dialect4 === "mysql";
24563
24279
  }
24564
24280
  convert(statement) {
24565
24281
  const { name, columns } = MySqlSquasher.unsquashPK(statement.data);
@@ -24567,8 +24283,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
24567
24283
  }
24568
24284
  };
24569
24285
  MySqlAlterTableAlterCompositePrimaryKeyConvertor = class extends Convertor {
24570
- can(statement, dialect7) {
24571
- return statement.type === "alter_composite_pk" && dialect7 === "mysql";
24286
+ can(statement, dialect4) {
24287
+ return statement.type === "alter_composite_pk" && dialect4 === "mysql";
24572
24288
  }
24573
24289
  convert(statement) {
24574
24290
  const { name, columns } = MySqlSquasher.unsquashPK(statement.old);
@@ -24579,8 +24295,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
24579
24295
  }
24580
24296
  };
24581
24297
  PgAlterTableAlterColumnSetPrimaryKeyConvertor = class extends Convertor {
24582
- can(statement, dialect7) {
24583
- return statement.type === "alter_table_alter_column_set_pk" && dialect7 === "postgresql";
24298
+ can(statement, dialect4) {
24299
+ return statement.type === "alter_table_alter_column_set_pk" && dialect4 === "postgresql";
24584
24300
  }
24585
24301
  convert(statement) {
24586
24302
  const { tableName, columnName } = statement;
@@ -24589,8 +24305,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
24589
24305
  }
24590
24306
  };
24591
24307
  PgAlterTableAlterColumnDropPrimaryKeyConvertor = class extends Convertor {
24592
- can(statement, dialect7) {
24593
- return statement.type === "alter_table_alter_column_drop_pk" && dialect7 === "postgresql";
24308
+ can(statement, dialect4) {
24309
+ return statement.type === "alter_table_alter_column_drop_pk" && dialect4 === "postgresql";
24594
24310
  }
24595
24311
  convert(statement) {
24596
24312
  const { tableName, columnName, schema: schema5 } = statement;
@@ -24613,8 +24329,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
24613
24329
  }
24614
24330
  };
24615
24331
  PgAlterTableAlterColumnSetNotNullConvertor = class extends Convertor {
24616
- can(statement, dialect7) {
24617
- return statement.type === "alter_table_alter_column_set_notnull" && dialect7 === "postgresql";
24332
+ can(statement, dialect4) {
24333
+ return statement.type === "alter_table_alter_column_set_notnull" && dialect4 === "postgresql";
24618
24334
  }
24619
24335
  convert(statement) {
24620
24336
  const { tableName, columnName } = statement;
@@ -24623,8 +24339,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
24623
24339
  }
24624
24340
  };
24625
24341
  PgAlterTableAlterColumnDropNotNullConvertor = class extends Convertor {
24626
- can(statement, dialect7) {
24627
- return statement.type === "alter_table_alter_column_drop_notnull" && dialect7 === "postgresql";
24342
+ can(statement, dialect4) {
24343
+ return statement.type === "alter_table_alter_column_drop_notnull" && dialect4 === "postgresql";
24628
24344
  }
24629
24345
  convert(statement) {
24630
24346
  const { tableName, columnName } = statement;
@@ -24633,8 +24349,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
24633
24349
  }
24634
24350
  };
24635
24351
  PgCreateForeignKeyConvertor = class extends Convertor {
24636
- can(statement, dialect7) {
24637
- return statement.type === "create_reference" && dialect7 === "postgresql";
24352
+ can(statement, dialect4) {
24353
+ return statement.type === "create_reference" && dialect4 === "postgresql";
24638
24354
  }
24639
24355
  convert(statement) {
24640
24356
  const {
@@ -24663,8 +24379,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
24663
24379
  }
24664
24380
  };
24665
24381
  LibSQLCreateForeignKeyConvertor = class extends Convertor {
24666
- can(statement, dialect7) {
24667
- return statement.type === "create_reference" && dialect7 === "turso";
24382
+ can(statement, dialect4) {
24383
+ return statement.type === "create_reference" && dialect4 === "turso";
24668
24384
  }
24669
24385
  convert(statement, json2, action) {
24670
24386
  const { columnsFrom, columnsTo, tableFrom, onDelete, onUpdate, tableTo } = action === "push" ? SQLiteSquasher.unsquashPushFK(statement.data) : SQLiteSquasher.unsquashFK(statement.data);
@@ -24680,8 +24396,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
24680
24396
  }
24681
24397
  };
24682
24398
  MySqlCreateForeignKeyConvertor = class extends Convertor {
24683
- can(statement, dialect7) {
24684
- return statement.type === "create_reference" && dialect7 === "mysql";
24399
+ can(statement, dialect4) {
24400
+ return statement.type === "create_reference" && dialect4 === "mysql";
24685
24401
  }
24686
24402
  convert(statement) {
24687
24403
  const {
@@ -24701,8 +24417,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
24701
24417
  }
24702
24418
  };
24703
24419
  PgAlterForeignKeyConvertor = class extends Convertor {
24704
- can(statement, dialect7) {
24705
- return statement.type === "alter_reference" && dialect7 === "postgresql";
24420
+ can(statement, dialect4) {
24421
+ return statement.type === "alter_reference" && dialect4 === "postgresql";
24706
24422
  }
24707
24423
  convert(statement) {
24708
24424
  const newFk = PgSquasher.unsquashFK(statement.data);
@@ -24726,8 +24442,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
24726
24442
  }
24727
24443
  };
24728
24444
  PgDeleteForeignKeyConvertor = class extends Convertor {
24729
- can(statement, dialect7) {
24730
- return statement.type === "delete_reference" && dialect7 === "postgresql";
24445
+ can(statement, dialect4) {
24446
+ return statement.type === "delete_reference" && dialect4 === "postgresql";
24731
24447
  }
24732
24448
  convert(statement) {
24733
24449
  const tableFrom = statement.tableName;
@@ -24738,8 +24454,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
24738
24454
  }
24739
24455
  };
24740
24456
  MySqlDeleteForeignKeyConvertor = class extends Convertor {
24741
- can(statement, dialect7) {
24742
- return statement.type === "delete_reference" && dialect7 === "mysql";
24457
+ can(statement, dialect4) {
24458
+ return statement.type === "delete_reference" && dialect4 === "mysql";
24743
24459
  }
24744
24460
  convert(statement) {
24745
24461
  const tableFrom = statement.tableName;
@@ -24749,8 +24465,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
24749
24465
  }
24750
24466
  };
24751
24467
  CreatePgIndexConvertor = class extends Convertor {
24752
- can(statement, dialect7) {
24753
- return statement.type === "create_index_pg" && dialect7 === "postgresql";
24468
+ can(statement, dialect4) {
24469
+ return statement.type === "create_index_pg" && dialect4 === "postgresql";
24754
24470
  }
24755
24471
  convert(statement) {
24756
24472
  const {
@@ -24781,8 +24497,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
24781
24497
  }
24782
24498
  };
24783
24499
  CreateMySqlIndexConvertor = class extends Convertor {
24784
- can(statement, dialect7) {
24785
- return statement.type === "create_index" && dialect7 === "mysql";
24500
+ can(statement, dialect4) {
24501
+ return statement.type === "create_index" && dialect4 === "mysql";
24786
24502
  }
24787
24503
  convert(statement) {
24788
24504
  const { name, columns, isUnique } = MySqlSquasher.unsquashIdx(
@@ -24797,8 +24513,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
24797
24513
  }
24798
24514
  };
24799
24515
  CreateSqliteIndexConvertor = class extends Convertor {
24800
- can(statement, dialect7) {
24801
- return statement.type === "create_index" && (dialect7 === "sqlite" || dialect7 === "turso");
24516
+ can(statement, dialect4) {
24517
+ return statement.type === "create_index" && (dialect4 === "sqlite" || dialect4 === "turso");
24802
24518
  }
24803
24519
  convert(statement) {
24804
24520
  const { name, columns, isUnique, where } = SQLiteSquasher.unsquashIdx(
@@ -24814,8 +24530,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
24814
24530
  }
24815
24531
  };
24816
24532
  PgDropIndexConvertor = class extends Convertor {
24817
- can(statement, dialect7) {
24818
- return statement.type === "drop_index" && dialect7 === "postgresql";
24533
+ can(statement, dialect4) {
24534
+ return statement.type === "drop_index" && dialect4 === "postgresql";
24819
24535
  }
24820
24536
  convert(statement) {
24821
24537
  const { name } = PgSquasher.unsquashIdx(statement.data);
@@ -24823,8 +24539,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
24823
24539
  }
24824
24540
  };
24825
24541
  PgCreateSchemaConvertor = class extends Convertor {
24826
- can(statement, dialect7) {
24827
- return statement.type === "create_schema" && dialect7 === "postgresql";
24542
+ can(statement, dialect4) {
24543
+ return statement.type === "create_schema" && dialect4 === "postgresql";
24828
24544
  }
24829
24545
  convert(statement) {
24830
24546
  const { name } = statement;
@@ -24833,8 +24549,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
24833
24549
  }
24834
24550
  };
24835
24551
  PgRenameSchemaConvertor = class extends Convertor {
24836
- can(statement, dialect7) {
24837
- return statement.type === "rename_schema" && dialect7 === "postgresql";
24552
+ can(statement, dialect4) {
24553
+ return statement.type === "rename_schema" && dialect4 === "postgresql";
24838
24554
  }
24839
24555
  convert(statement) {
24840
24556
  const { from, to } = statement;
@@ -24843,8 +24559,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
24843
24559
  }
24844
24560
  };
24845
24561
  PgDropSchemaConvertor = class extends Convertor {
24846
- can(statement, dialect7) {
24847
- return statement.type === "drop_schema" && dialect7 === "postgresql";
24562
+ can(statement, dialect4) {
24563
+ return statement.type === "drop_schema" && dialect4 === "postgresql";
24848
24564
  }
24849
24565
  convert(statement) {
24850
24566
  const { name } = statement;
@@ -24853,8 +24569,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
24853
24569
  }
24854
24570
  };
24855
24571
  PgAlterTableSetSchemaConvertor = class extends Convertor {
24856
- can(statement, dialect7) {
24857
- return statement.type === "alter_table_set_schema" && dialect7 === "postgresql";
24572
+ can(statement, dialect4) {
24573
+ return statement.type === "alter_table_set_schema" && dialect4 === "postgresql";
24858
24574
  }
24859
24575
  convert(statement) {
24860
24576
  const { tableName, schemaFrom, schemaTo } = statement;
@@ -24863,8 +24579,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
24863
24579
  }
24864
24580
  };
24865
24581
  PgAlterTableSetNewSchemaConvertor = class extends Convertor {
24866
- can(statement, dialect7) {
24867
- return statement.type === "alter_table_set_new_schema" && dialect7 === "postgresql";
24582
+ can(statement, dialect4) {
24583
+ return statement.type === "alter_table_set_new_schema" && dialect4 === "postgresql";
24868
24584
  }
24869
24585
  convert(statement) {
24870
24586
  const { tableName, to, from } = statement;
@@ -24874,8 +24590,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
24874
24590
  }
24875
24591
  };
24876
24592
  PgAlterTableRemoveFromSchemaConvertor = class extends Convertor {
24877
- can(statement, dialect7) {
24878
- return statement.type === "alter_table_remove_from_schema" && dialect7 === "postgresql";
24593
+ can(statement, dialect4) {
24594
+ return statement.type === "alter_table_remove_from_schema" && dialect4 === "postgresql";
24879
24595
  }
24880
24596
  convert(statement) {
24881
24597
  const { tableName, schema: schema5 } = statement;
@@ -24885,8 +24601,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
24885
24601
  }
24886
24602
  };
24887
24603
  SqliteDropIndexConvertor = class extends Convertor {
24888
- can(statement, dialect7) {
24889
- return statement.type === "drop_index" && (dialect7 === "sqlite" || dialect7 === "turso");
24604
+ can(statement, dialect4) {
24605
+ return statement.type === "drop_index" && (dialect4 === "sqlite" || dialect4 === "turso");
24890
24606
  }
24891
24607
  convert(statement) {
24892
24608
  const { name } = PgSquasher.unsquashIdx(statement.data);
@@ -24894,8 +24610,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
24894
24610
  }
24895
24611
  };
24896
24612
  MySqlDropIndexConvertor = class extends Convertor {
24897
- can(statement, dialect7) {
24898
- return statement.type === "drop_index" && dialect7 === "mysql";
24613
+ can(statement, dialect4) {
24614
+ return statement.type === "drop_index" && dialect4 === "mysql";
24899
24615
  }
24900
24616
  convert(statement) {
24901
24617
  const { name } = MySqlSquasher.unsquashIdx(statement.data);
@@ -24903,26 +24619,22 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
24903
24619
  }
24904
24620
  };
24905
24621
  SQLiteRecreateTableConvertor = class extends Convertor {
24906
- can(statement, dialect7) {
24907
- return statement.type === "recreate_table" && dialect7 === "sqlite";
24622
+ can(statement, dialect4) {
24623
+ return statement.type === "recreate_table" && dialect4 === "sqlite";
24908
24624
  }
24909
24625
  convert(statement) {
24910
- const { tableName, columns, compositePKs, referenceData, checkConstraints } = statement;
24626
+ const { tableName, columns, compositePKs, referenceData } = statement;
24911
24627
  const columnNames = columns.map((it) => `"${it.name}"`).join(", ");
24912
24628
  const newTableName = `__new_${tableName}`;
24913
24629
  const sqlStatements = [];
24914
24630
  sqlStatements.push(`PRAGMA foreign_keys=OFF;`);
24915
- const mappedCheckConstraints = checkConstraints.map(
24916
- (it) => it.replaceAll(`"${tableName}".`, `"${newTableName}".`).replaceAll(`\`${tableName}\`.`, `\`${newTableName}\`.`).replaceAll(`${tableName}.`, `${newTableName}.`).replaceAll(`'${tableName}'.`, `'${newTableName}'.`)
24917
- );
24918
24631
  sqlStatements.push(
24919
24632
  new SQLiteCreateTableConvertor().convert({
24920
24633
  type: "sqlite_create_table",
24921
24634
  tableName: newTableName,
24922
24635
  columns,
24923
24636
  referenceData,
24924
- compositePKs,
24925
- checkConstraints: mappedCheckConstraints
24637
+ compositePKs
24926
24638
  })
24927
24639
  );
24928
24640
  sqlStatements.push(
@@ -24949,17 +24661,14 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
24949
24661
  }
24950
24662
  };
24951
24663
  LibSQLRecreateTableConvertor = class extends Convertor {
24952
- can(statement, dialect7) {
24953
- return statement.type === "recreate_table" && dialect7 === "turso";
24664
+ can(statement, dialect4) {
24665
+ return statement.type === "recreate_table" && dialect4 === "turso";
24954
24666
  }
24955
24667
  convert(statement) {
24956
- const { tableName, columns, compositePKs, referenceData, checkConstraints } = statement;
24668
+ const { tableName, columns, compositePKs, referenceData } = statement;
24957
24669
  const columnNames = columns.map((it) => `"${it.name}"`).join(", ");
24958
24670
  const newTableName = `__new_${tableName}`;
24959
24671
  const sqlStatements = [];
24960
- const mappedCheckConstraints = checkConstraints.map(
24961
- (it) => it.replaceAll(`"${tableName}".`, `"${newTableName}".`).replaceAll(`\`${tableName}\`.`, `\`${newTableName}\`.`).replaceAll(`${tableName}.`, `${newTableName}.`).replaceAll(`'${tableName}'.`, `\`${newTableName}\`.`)
24962
- );
24963
24672
  sqlStatements.push(`PRAGMA foreign_keys=OFF;`);
24964
24673
  sqlStatements.push(
24965
24674
  new SQLiteCreateTableConvertor().convert({
@@ -24967,8 +24676,7 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
24967
24676
  tableName: newTableName,
24968
24677
  columns,
24969
24678
  referenceData,
24970
- compositePKs,
24971
- checkConstraints: mappedCheckConstraints
24679
+ compositePKs
24972
24680
  })
24973
24681
  );
24974
24682
  sqlStatements.push(
@@ -25001,6 +24709,11 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
25001
24709
  convertors.push(new SQLiteRecreateTableConvertor());
25002
24710
  convertors.push(new LibSQLRecreateTableConvertor());
25003
24711
  convertors.push(new CreateTypeEnumConvertor());
24712
+ convertors.push(new DropTypeEnumConvertor());
24713
+ convertors.push(new AlterTypeAddValueConvertor());
24714
+ convertors.push(new AlterTypeSetSchemaConvertor());
24715
+ convertors.push(new AlterRenameTypeConvertor());
24716
+ convertors.push(new AlterTypeDropValueConvertor());
25004
24717
  convertors.push(new CreatePgSequenceConvertor());
25005
24718
  convertors.push(new DropPgSequenceConvertor());
25006
24719
  convertors.push(new RenamePgSequenceConvertor());
@@ -25024,10 +24737,6 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
25024
24737
  convertors.push(new PgAlterTableAlterColumnSetTypeConvertor());
25025
24738
  convertors.push(new PgAlterTableAddUniqueConstraintConvertor());
25026
24739
  convertors.push(new PgAlterTableDropUniqueConstraintConvertor());
25027
- convertors.push(new PgAlterTableAddCheckConstraintConvertor());
25028
- convertors.push(new PgAlterTableDeleteCheckConstraintConvertor());
25029
- convertors.push(new MySqlAlterTableAddCheckConstraintConvertor());
25030
- convertors.push(new MySqlAlterTableDeleteCheckConstraintConvertor());
25031
24740
  convertors.push(new MySQLAlterTableAddUniqueConstraintConvertor());
25032
24741
  convertors.push(new MySQLAlterTableDropUniqueConstraintConvertor());
25033
24742
  convertors.push(new CreatePgIndexConvertor());
@@ -25036,7 +24745,6 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
25036
24745
  convertors.push(new PgDropIndexConvertor());
25037
24746
  convertors.push(new SqliteDropIndexConvertor());
25038
24747
  convertors.push(new MySqlDropIndexConvertor());
25039
- convertors.push(new AlterTypeAddValueConvertor());
25040
24748
  convertors.push(new PgAlterTableAlterColumnSetPrimaryKeyConvertor());
25041
24749
  convertors.push(new PgAlterTableAlterColumnDropPrimaryKeyConvertor());
25042
24750
  convertors.push(new PgAlterTableAlterColumnSetNotNullConvertor());
@@ -25119,10 +24827,6 @@ var init_sqlitePushUtils = __esm({
25119
24827
  const compositePKs = Object.values(
25120
24828
  json.tables[tableName].compositePrimaryKeys
25121
24829
  ).map((it) => SQLiteSquasher.unsquashPK(it));
25122
- const checkConstraints = Object.values(json.tables[tableName].checkConstraints);
25123
- const mappedCheckConstraints = checkConstraints.map(
25124
- (it) => it.replaceAll(`"${tableName}".`, `"${newTableName}".`).replaceAll(`\`${tableName}\`.`, `\`${newTableName}\`.`).replaceAll(`${tableName}.`, `${newTableName}.`).replaceAll(`'${tableName}'.`, `\`${newTableName}\`.`)
25125
- );
25126
24830
  const fks = referenceData.map((it) => SQLiteSquasher.unsquashPushFK(it));
25127
24831
  statements.push(
25128
24832
  new SQLiteCreateTableConvertor().convert({
@@ -25130,8 +24834,7 @@ var init_sqlitePushUtils = __esm({
25130
24834
  tableName: newTableName,
25131
24835
  columns: tableColumns,
25132
24836
  referenceData: fks,
25133
- compositePKs,
25134
- checkConstraints: mappedCheckConstraints
24837
+ compositePKs
25135
24838
  })
25136
24839
  );
25137
24840
  if (!dataLoss) {
@@ -25343,7 +25046,7 @@ var init_sqlitePushUtils = __esm({
25343
25046
  });
25344
25047
 
25345
25048
  // src/jsonStatements.ts
25346
- var preparePgCreateTableJson, prepareMySqlCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareDropEnumJson, prepareMoveEnumJson, prepareRenameEnumJson, prepareCreateSequenceJson, prepareAlterSequenceJson, prepareDropSequenceJson, prepareMoveSequenceJson, prepareRenameSequenceJson, prepareCreateSchemasJson, prepareRenameSchemasJson, prepareDeleteSchemasJson, prepareRenameColumns, _prepareDropColumns, _prepareAddColumns, _prepareSqliteAddColumns, prepareAlterColumnsMysql, preparePgAlterColumns, prepareSqliteAlterColumns, preparePgCreateIndexesJson, prepareCreateIndexesJson, prepareCreateReferencesJson, prepareLibSQLCreateReferencesJson, prepareDropReferencesJson, prepareLibSQLDropReferencesJson, prepareAlterReferencesJson, prepareDropIndexesJson, prepareAddCompositePrimaryKeySqlite, prepareDeleteCompositePrimaryKeySqlite, prepareAlterCompositePrimaryKeySqlite, prepareAddCompositePrimaryKeyPg, prepareDeleteCompositePrimaryKeyPg, prepareAlterCompositePrimaryKeyPg, prepareAddUniqueConstraintPg, prepareDeleteUniqueConstraintPg, prepareAddCheckConstraint, prepareDeleteCheckConstraint, prepareAddCompositePrimaryKeyMySql, prepareDeleteCompositePrimaryKeyMySql, prepareAlterCompositePrimaryKeyMySql;
25049
+ var preparePgCreateTableJson, prepareMySqlCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareDropEnumValues, prepareDropEnumJson, prepareMoveEnumJson, prepareRenameEnumJson, prepareCreateSequenceJson, prepareAlterSequenceJson, prepareDropSequenceJson, prepareMoveSequenceJson, prepareRenameSequenceJson, prepareCreateSchemasJson, prepareRenameSchemasJson, prepareDeleteSchemasJson, prepareRenameColumns, _prepareDropColumns, _prepareAddColumns, _prepareSqliteAddColumns, prepareAlterColumnsMysql, preparePgAlterColumns, prepareSqliteAlterColumns, preparePgCreateIndexesJson, prepareCreateIndexesJson, prepareCreateReferencesJson, prepareLibSQLCreateReferencesJson, prepareDropReferencesJson, prepareLibSQLDropReferencesJson, prepareAlterReferencesJson, prepareDropIndexesJson, prepareAddCompositePrimaryKeySqlite, prepareDeleteCompositePrimaryKeySqlite, prepareAlterCompositePrimaryKeySqlite, prepareAddCompositePrimaryKeyPg, prepareDeleteCompositePrimaryKeyPg, prepareAlterCompositePrimaryKeyPg, prepareAddUniqueConstraintPg, prepareDeleteUniqueConstraintPg, prepareAddCompositePrimaryKeyMySql, prepareDeleteCompositePrimaryKeyMySql, prepareAlterCompositePrimaryKeyMySql;
25347
25050
  var init_jsonStatements = __esm({
25348
25051
  "src/jsonStatements.ts"() {
25349
25052
  "use strict";
@@ -25354,7 +25057,7 @@ var init_jsonStatements = __esm({
25354
25057
  init_pgSchema();
25355
25058
  init_sqliteSchema();
25356
25059
  preparePgCreateTableJson = (table4, json2) => {
25357
- const { name, schema: schema5, columns, compositePrimaryKeys, uniqueConstraints, checkConstraints } = table4;
25060
+ const { name, schema: schema5, columns, compositePrimaryKeys, uniqueConstraints } = table4;
25358
25061
  const tableKey2 = `${schema5 || "public"}.${name}`;
25359
25062
  const compositePkName = Object.values(compositePrimaryKeys).length > 0 ? json2.tables[tableKey2].compositePrimaryKeys[`${PgSquasher.unsquashPK(Object.values(compositePrimaryKeys)[0]).name}`].name : "";
25360
25063
  return {
@@ -25364,12 +25067,11 @@ var init_jsonStatements = __esm({
25364
25067
  columns: Object.values(columns),
25365
25068
  compositePKs: Object.values(compositePrimaryKeys),
25366
25069
  compositePkName,
25367
- uniqueConstraints: Object.values(uniqueConstraints),
25368
- checkConstraints: Object.values(checkConstraints)
25070
+ uniqueConstraints: Object.values(uniqueConstraints)
25369
25071
  };
25370
25072
  };
25371
25073
  prepareMySqlCreateTableJson = (table4, json2, internals) => {
25372
- const { name, schema: schema5, columns, compositePrimaryKeys, uniqueConstraints, checkConstraints } = table4;
25074
+ const { name, schema: schema5, columns, compositePrimaryKeys, uniqueConstraints } = table4;
25373
25075
  return {
25374
25076
  type: "create_table",
25375
25077
  tableName: name,
@@ -25378,12 +25080,11 @@ var init_jsonStatements = __esm({
25378
25080
  compositePKs: Object.values(compositePrimaryKeys),
25379
25081
  compositePkName: Object.values(compositePrimaryKeys).length > 0 ? json2.tables[name].compositePrimaryKeys[MySqlSquasher.unsquashPK(Object.values(compositePrimaryKeys)[0]).name].name : "",
25380
25082
  uniqueConstraints: Object.values(uniqueConstraints),
25381
- internals,
25382
- checkConstraints: Object.values(checkConstraints)
25083
+ internals
25383
25084
  };
25384
25085
  };
25385
25086
  prepareSQLiteCreateTable = (table4, action) => {
25386
- const { name, columns, uniqueConstraints, checkConstraints } = table4;
25087
+ const { name, columns, uniqueConstraints } = table4;
25387
25088
  const references2 = Object.values(table4.foreignKeys);
25388
25089
  const composites = Object.values(table4.compositePrimaryKeys).map(
25389
25090
  (it) => SQLiteSquasher.unsquashPK(it)
@@ -25397,8 +25098,7 @@ var init_jsonStatements = __esm({
25397
25098
  columns: Object.values(columns),
25398
25099
  referenceData: fks,
25399
25100
  compositePKs: composites,
25400
- uniqueConstraints: Object.values(uniqueConstraints),
25401
- checkConstraints: Object.values(checkConstraints)
25101
+ uniqueConstraints: Object.values(uniqueConstraints)
25402
25102
  };
25403
25103
  };
25404
25104
  prepareDropTableJson = (table4) => {
@@ -25436,6 +25136,28 @@ var init_jsonStatements = __esm({
25436
25136
  };
25437
25137
  });
25438
25138
  };
25139
+ prepareDropEnumValues = (name, schema5, removedValues, json2) => {
25140
+ if (!removedValues.length)
25141
+ return [];
25142
+ const affectedColumns = [];
25143
+ for (const tableKey2 in json2.tables) {
25144
+ const table4 = json2.tables[tableKey2];
25145
+ for (const columnKey in table4.columns) {
25146
+ const column7 = table4.columns[columnKey];
25147
+ if (column7.type === name && column7.typeSchema === schema5) {
25148
+ affectedColumns.push({ schema: table4.schema || "public", table: table4.name, column: column7.name });
25149
+ }
25150
+ }
25151
+ }
25152
+ return [{
25153
+ type: "alter_type_drop_value",
25154
+ name,
25155
+ schema: schema5,
25156
+ deletedValues: removedValues,
25157
+ newValues: json2.enums[`${schema5}.${name}`].values,
25158
+ columnsWithEnum: affectedColumns
25159
+ }];
25160
+ };
25439
25161
  prepareDropEnumJson = (name, schema5) => {
25440
25162
  return {
25441
25163
  type: "drop_type_enum",
@@ -26646,26 +26368,6 @@ var init_jsonStatements = __esm({
26646
26368
  };
26647
26369
  });
26648
26370
  };
26649
- prepareAddCheckConstraint = (tableName, schema5, check2) => {
26650
- return Object.values(check2).map((it) => {
26651
- return {
26652
- type: "create_check_constraint",
26653
- tableName,
26654
- data: it,
26655
- schema: schema5
26656
- };
26657
- });
26658
- };
26659
- prepareDeleteCheckConstraint = (tableName, schema5, check2) => {
26660
- return Object.values(check2).map((it) => {
26661
- return {
26662
- type: "delete_check_constraint",
26663
- tableName,
26664
- constraintName: PgSquasher.unsquashCheck(it).name,
26665
- schema: schema5
26666
- };
26667
- });
26668
- };
26669
26371
  prepareAddCompositePrimaryKeyMySql = (tableName, pks, json1, json2) => {
26670
26372
  var _a, _b;
26671
26373
  const res = [];
@@ -26716,7 +26418,7 @@ var init_statementCombiner = __esm({
26716
26418
  init_jsonStatements();
26717
26419
  init_sqliteSchema();
26718
26420
  prepareLibSQLRecreateTable = (table4, action) => {
26719
- const { name, columns, uniqueConstraints, indexes, checkConstraints } = table4;
26421
+ const { name, columns, uniqueConstraints, indexes } = table4;
26720
26422
  const composites = Object.values(table4.compositePrimaryKeys).map(
26721
26423
  (it) => SQLiteSquasher.unsquashPK(it)
26722
26424
  );
@@ -26731,8 +26433,7 @@ var init_statementCombiner = __esm({
26731
26433
  columns: Object.values(columns),
26732
26434
  compositePKs: composites,
26733
26435
  referenceData: fks,
26734
- uniqueConstraints: Object.values(uniqueConstraints),
26735
- checkConstraints: Object.values(checkConstraints)
26436
+ uniqueConstraints: Object.values(uniqueConstraints)
26736
26437
  }
26737
26438
  ];
26738
26439
  if (Object.keys(indexes).length) {
@@ -26741,7 +26442,7 @@ var init_statementCombiner = __esm({
26741
26442
  return statements;
26742
26443
  };
26743
26444
  prepareSQLiteRecreateTable = (table4, action) => {
26744
- const { name, columns, uniqueConstraints, indexes, checkConstraints } = table4;
26445
+ const { name, columns, uniqueConstraints, indexes } = table4;
26745
26446
  const composites = Object.values(table4.compositePrimaryKeys).map(
26746
26447
  (it) => SQLiteSquasher.unsquashPK(it)
26747
26448
  );
@@ -26756,8 +26457,7 @@ var init_statementCombiner = __esm({
26756
26457
  columns: Object.values(columns),
26757
26458
  compositePKs: composites,
26758
26459
  referenceData: fks,
26759
- uniqueConstraints: Object.values(uniqueConstraints),
26760
- checkConstraints: Object.values(checkConstraints)
26460
+ uniqueConstraints: Object.values(uniqueConstraints)
26761
26461
  }
26762
26462
  ];
26763
26463
  if (Object.keys(indexes).length) {
@@ -26768,7 +26468,7 @@ var init_statementCombiner = __esm({
26768
26468
  libSQLCombineStatements = (statements, json2, action) => {
26769
26469
  const newStatements = {};
26770
26470
  for (const statement of statements) {
26771
- if (statement.type === "alter_table_alter_column_drop_autoincrement" || statement.type === "alter_table_alter_column_set_autoincrement" || statement.type === "alter_table_alter_column_drop_pk" || statement.type === "alter_table_alter_column_set_pk" || statement.type === "create_composite_pk" || statement.type === "alter_composite_pk" || statement.type === "delete_composite_pk" || statement.type === "create_check_constraint" || statement.type === "delete_check_constraint") {
26471
+ if (statement.type === "alter_table_alter_column_drop_autoincrement" || statement.type === "alter_table_alter_column_set_autoincrement" || statement.type === "alter_table_alter_column_drop_pk" || statement.type === "alter_table_alter_column_set_pk" || statement.type === "create_composite_pk" || statement.type === "alter_composite_pk" || statement.type === "delete_composite_pk") {
26772
26472
  const tableName2 = statement.tableName;
26773
26473
  const statementsForTable2 = newStatements[tableName2];
26774
26474
  if (!statementsForTable2) {
@@ -26909,16 +26609,16 @@ var init_statementCombiner = __esm({
26909
26609
  sqliteCombineStatements = (statements, json2, action) => {
26910
26610
  const newStatements = {};
26911
26611
  for (const statement of statements) {
26912
- if (statement.type === "alter_table_alter_column_set_type" || statement.type === "alter_table_alter_column_set_default" || statement.type === "alter_table_alter_column_drop_default" || statement.type === "alter_table_alter_column_set_notnull" || statement.type === "alter_table_alter_column_drop_notnull" || statement.type === "alter_table_alter_column_drop_autoincrement" || statement.type === "alter_table_alter_column_set_autoincrement" || statement.type === "alter_table_alter_column_drop_pk" || statement.type === "alter_table_alter_column_set_pk" || statement.type === "delete_reference" || statement.type === "alter_reference" || statement.type === "create_composite_pk" || statement.type === "alter_composite_pk" || statement.type === "delete_composite_pk" || statement.type === "create_unique_constraint" || statement.type === "delete_unique_constraint" || statement.type === "create_check_constraint" || statement.type === "delete_check_constraint") {
26612
+ if (statement.type === "alter_table_alter_column_set_type" || statement.type === "alter_table_alter_column_set_default" || statement.type === "alter_table_alter_column_drop_default" || statement.type === "alter_table_alter_column_set_notnull" || statement.type === "alter_table_alter_column_drop_notnull" || statement.type === "alter_table_alter_column_drop_autoincrement" || statement.type === "alter_table_alter_column_set_autoincrement" || statement.type === "alter_table_alter_column_drop_pk" || statement.type === "alter_table_alter_column_set_pk" || statement.type === "delete_reference" || statement.type === "alter_reference" || statement.type === "create_composite_pk" || statement.type === "alter_composite_pk" || statement.type === "delete_composite_pk" || statement.type === "create_unique_constraint" || statement.type === "delete_unique_constraint") {
26913
26613
  const tableName2 = statement.tableName;
26914
26614
  const statementsForTable2 = newStatements[tableName2];
26915
26615
  if (!statementsForTable2) {
26916
- newStatements[tableName2] = prepareSQLiteRecreateTable(json2.tables[tableName2], action);
26616
+ newStatements[tableName2] = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
26917
26617
  continue;
26918
26618
  }
26919
26619
  if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
26920
26620
  const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
26921
- const preparedStatements = prepareSQLiteRecreateTable(json2.tables[tableName2], action);
26621
+ const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
26922
26622
  if (wasRename) {
26923
26623
  newStatements[tableName2].push(...preparedStatements);
26924
26624
  } else {
@@ -26932,12 +26632,12 @@ var init_statementCombiner = __esm({
26932
26632
  const tableName2 = statement.tableName;
26933
26633
  const statementsForTable2 = newStatements[tableName2];
26934
26634
  if (!statementsForTable2) {
26935
- newStatements[tableName2] = prepareSQLiteRecreateTable(json2.tables[tableName2], action);
26635
+ newStatements[tableName2] = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
26936
26636
  continue;
26937
26637
  }
26938
26638
  if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
26939
26639
  const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
26940
- const preparedStatements = prepareSQLiteRecreateTable(json2.tables[tableName2], action);
26640
+ const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
26941
26641
  if (wasRename) {
26942
26642
  newStatements[tableName2].push(...preparedStatements);
26943
26643
  } else {
@@ -26962,7 +26662,7 @@ var init_statementCombiner = __esm({
26962
26662
  }
26963
26663
  if (!statementsForTable2.some(({ type }) => type === "recreate_table")) {
26964
26664
  const wasRename = statementsForTable2.some(({ type }) => type === "rename_table");
26965
- const preparedStatements = prepareSQLiteRecreateTable(json2.tables[tableName2], action);
26665
+ const preparedStatements = prepareLibSQLRecreateTable(json2.tables[tableName2], action);
26966
26666
  if (wasRename) {
26967
26667
  newStatements[tableName2].push(...preparedStatements);
26968
26668
  } else {
@@ -27097,8 +26797,7 @@ var init_snapshotsDiffer = __esm({
27097
26797
  indexes: recordType(stringType(), stringType()),
27098
26798
  foreignKeys: recordType(stringType(), stringType()),
27099
26799
  compositePrimaryKeys: recordType(stringType(), stringType()).default({}),
27100
- uniqueConstraints: recordType(stringType(), stringType()).default({}),
27101
- checkConstraints: recordType(stringType(), stringType()).default({})
26800
+ uniqueConstraints: recordType(stringType(), stringType()).default({})
27102
26801
  }).strict();
27103
26802
  alteredTableScheme = objectType({
27104
26803
  name: stringType(),
@@ -27139,21 +26838,6 @@ var init_snapshotsDiffer = __esm({
27139
26838
  __new: stringType(),
27140
26839
  __old: stringType()
27141
26840
  })
27142
- ),
27143
- addedCheckConstraints: recordType(
27144
- stringType(),
27145
- stringType()
27146
- ),
27147
- deletedCheckConstraints: recordType(
27148
- stringType(),
27149
- stringType()
27150
- ),
27151
- alteredCheckConstraints: recordType(
27152
- stringType(),
27153
- objectType({
27154
- __new: stringType(),
27155
- __old: stringType()
27156
- })
27157
26841
  )
27158
26842
  }).strict();
27159
26843
  diffResultScheme = objectType({
@@ -27494,8 +27178,6 @@ var init_snapshotsDiffer = __esm({
27494
27178
  schemaTo: it.schemaTo || "public"
27495
27179
  });
27496
27180
  }
27497
- const jsonDeletedCheckConstraints = [];
27498
- const jsonCreatedCheckConstraints = [];
27499
27181
  for (let it of alteredTables) {
27500
27182
  let addedColumns = [];
27501
27183
  for (const addedPkName of Object.keys(it.addedCompositePKs)) {
@@ -27535,8 +27217,6 @@ var init_snapshotsDiffer = __esm({
27535
27217
  let addedUniqueConstraints = [];
27536
27218
  let deletedUniqueConstraints = [];
27537
27219
  let alteredUniqueConstraints = [];
27538
- let createCheckConstraints = [];
27539
- let deleteCheckConstraints = [];
27540
27220
  addedUniqueConstraints = prepareAddUniqueConstraintPg(
27541
27221
  it.name,
27542
27222
  it.schema,
@@ -27561,24 +27241,6 @@ var init_snapshotsDiffer = __esm({
27561
27241
  ...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
27562
27242
  );
27563
27243
  }
27564
- createCheckConstraints = prepareAddCheckConstraint(it.name, it.schema, it.addedCheckConstraints);
27565
- deleteCheckConstraints = prepareDeleteCheckConstraint(
27566
- it.name,
27567
- it.schema,
27568
- it.deletedCheckConstraints
27569
- );
27570
- if (it.alteredCheckConstraints && action !== "push") {
27571
- const added = {};
27572
- const deleted = {};
27573
- for (const k of Object.keys(it.alteredCheckConstraints)) {
27574
- added[k] = it.alteredCheckConstraints[k].__new;
27575
- deleted[k] = it.alteredCheckConstraints[k].__old;
27576
- }
27577
- createCheckConstraints.push(...prepareAddCheckConstraint(it.name, it.schema, added));
27578
- deleteCheckConstraints.push(...prepareDeleteCheckConstraint(it.name, it.schema, deleted));
27579
- }
27580
- jsonCreatedCheckConstraints.push(...createCheckConstraints);
27581
- jsonDeletedCheckConstraints.push(...deleteCheckConstraints);
27582
27244
  jsonAddedCompositePKs.push(...addedCompositePKs);
27583
27245
  jsonDeletedCompositePKs.push(...deletedCompositePKs);
27584
27246
  jsonAlteredCompositePKs.push(...alteredCompositePKs);
@@ -27689,6 +27351,9 @@ var init_snapshotsDiffer = __esm({
27689
27351
  const jsonAlterEnumsWithAddedValues = typedResult.alteredEnums.map((it) => {
27690
27352
  return prepareAddValuesToEnumJson(it.name, it.schema, it.addedValues);
27691
27353
  }).flat() ?? [];
27354
+ const jsonAlterEnumsWithDroppedValues = typedResult.alteredEnums.map((it) => {
27355
+ return prepareDropEnumValues(it.name, it.schema, it.deletedValues, curFull);
27356
+ }).flat() ?? [];
27692
27357
  const createSequences = createdSequences.map((it) => {
27693
27358
  return prepareCreateSequenceJson(it);
27694
27359
  }) ?? [];
@@ -27732,7 +27397,6 @@ var init_snapshotsDiffer = __esm({
27732
27397
  jsonStatements.push(...jsonRenameTables);
27733
27398
  jsonStatements.push(...jsonRenameColumnsStatements);
27734
27399
  jsonStatements.push(...jsonDeletedUniqueConstraints);
27735
- jsonStatements.push(...jsonDeletedCheckConstraints);
27736
27400
  jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
27737
27401
  jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
27738
27402
  jsonStatements.push(...jsonDeletedCompositePKs);
@@ -27746,8 +27410,8 @@ var init_snapshotsDiffer = __esm({
27746
27410
  jsonStatements.push(...jsonDropColumnsStatemets);
27747
27411
  jsonStatements.push(...jsonAlteredCompositePKs);
27748
27412
  jsonStatements.push(...jsonAddedUniqueConstraints);
27749
- jsonStatements.push(...jsonCreatedCheckConstraints);
27750
27413
  jsonStatements.push(...jsonAlteredUniqueConstraints);
27414
+ jsonStatements.push(...jsonAlterEnumsWithDroppedValues);
27751
27415
  jsonStatements.push(...dropEnums);
27752
27416
  jsonStatements.push(...dropSequences);
27753
27417
  jsonStatements.push(...dropSchemas);
@@ -27910,8 +27574,6 @@ var init_snapshotsDiffer = __esm({
27910
27574
  const jsonAddedUniqueConstraints = [];
27911
27575
  const jsonDeletedUniqueConstraints = [];
27912
27576
  const jsonAlteredUniqueConstraints = [];
27913
- const jsonCreatedCheckConstraints = [];
27914
- const jsonDeletedCheckConstraints = [];
27915
27577
  const jsonRenameColumnsStatements = columnRenames.map((it) => prepareRenameColumns(it.table, "", it.renames)).flat();
27916
27578
  const jsonAddColumnsStatemets = columnCreates.map((it) => _prepareAddColumns(it.table, "", it.columns)).flat();
27917
27579
  const jsonDropColumnsStatemets = columnDeletes.map((it) => _prepareDropColumns(it.table, "", it.columns)).flat();
@@ -27950,8 +27612,6 @@ var init_snapshotsDiffer = __esm({
27950
27612
  let addedUniqueConstraints = [];
27951
27613
  let deletedUniqueConstraints = [];
27952
27614
  let alteredUniqueConstraints = [];
27953
- let createdCheckConstraints = [];
27954
- let deletedCheckConstraints = [];
27955
27615
  addedUniqueConstraints = prepareAddUniqueConstraintPg(
27956
27616
  it.name,
27957
27617
  it.schema,
@@ -27976,30 +27636,12 @@ var init_snapshotsDiffer = __esm({
27976
27636
  ...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
27977
27637
  );
27978
27638
  }
27979
- createdCheckConstraints = prepareAddCheckConstraint(it.name, it.schema, it.addedCheckConstraints);
27980
- deletedCheckConstraints = prepareDeleteCheckConstraint(
27981
- it.name,
27982
- it.schema,
27983
- it.deletedCheckConstraints
27984
- );
27985
- if (it.alteredCheckConstraints && action !== "push") {
27986
- const added = {};
27987
- const deleted = {};
27988
- for (const k of Object.keys(it.alteredCheckConstraints)) {
27989
- added[k] = it.alteredCheckConstraints[k].__new;
27990
- deleted[k] = it.alteredCheckConstraints[k].__old;
27991
- }
27992
- createdCheckConstraints.push(...prepareAddCheckConstraint(it.name, it.schema, added));
27993
- deletedCheckConstraints.push(...prepareDeleteCheckConstraint(it.name, it.schema, deleted));
27994
- }
27995
27639
  jsonAddedCompositePKs.push(...addedCompositePKs);
27996
27640
  jsonDeletedCompositePKs.push(...deletedCompositePKs);
27997
27641
  jsonAlteredCompositePKs.push(...alteredCompositePKs);
27998
27642
  jsonAddedUniqueConstraints.push(...addedUniqueConstraints);
27999
27643
  jsonDeletedUniqueConstraints.push(...deletedUniqueConstraints);
28000
27644
  jsonAlteredUniqueConstraints.push(...alteredUniqueConstraints);
28001
- jsonCreatedCheckConstraints.push(...createdCheckConstraints);
28002
- jsonDeletedCheckConstraints.push(...deletedCheckConstraints);
28003
27645
  });
28004
27646
  const rColumns = jsonRenameColumnsStatements.map((it) => {
28005
27647
  const tableName = it.tableName;
@@ -28095,7 +27737,6 @@ var init_snapshotsDiffer = __esm({
28095
27737
  jsonStatements.push(...jsonRenameTables);
28096
27738
  jsonStatements.push(...jsonRenameColumnsStatements);
28097
27739
  jsonStatements.push(...jsonDeletedUniqueConstraints);
28098
- jsonStatements.push(...jsonDeletedCheckConstraints);
28099
27740
  jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
28100
27741
  jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
28101
27742
  jsonStatements.push(...jsonDeletedCompositePKs);
@@ -28106,11 +27747,11 @@ var init_snapshotsDiffer = __esm({
28106
27747
  jsonStatements.push(...jsonAddColumnsStatemets);
28107
27748
  jsonStatements.push(...jsonCreateReferencesForCreatedTables);
28108
27749
  jsonStatements.push(...jsonCreateIndexesForCreatedTables);
28109
- jsonStatements.push(...jsonCreatedCheckConstraints);
28110
27750
  jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
28111
27751
  jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
28112
27752
  jsonStatements.push(...jsonDropColumnsStatemets);
28113
27753
  jsonStatements.push(...jsonAlteredCompositePKs);
27754
+ jsonStatements.push(...jsonAddedUniqueConstraints);
28114
27755
  jsonStatements.push(...jsonAlteredUniqueConstraints);
28115
27756
  const sqlStatements = fromJson(jsonStatements, "mysql");
28116
27757
  const uniqueSqlStatements = [];
@@ -28238,8 +27879,6 @@ var init_snapshotsDiffer = __esm({
28238
27879
  const jsonAddedUniqueConstraints = [];
28239
27880
  const jsonDeletedUniqueConstraints = [];
28240
27881
  const jsonAlteredUniqueConstraints = [];
28241
- const jsonDeletedCheckConstraints = [];
28242
- const jsonCreatedCheckConstraints = [];
28243
27882
  allAltered.forEach((it) => {
28244
27883
  let addedColumns = [];
28245
27884
  for (const addedPkName of Object.keys(it.addedCompositePKs)) {
@@ -28296,56 +27935,12 @@ var init_snapshotsDiffer = __esm({
28296
27935
  ...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
28297
27936
  );
28298
27937
  }
28299
- let createdCheckConstraints = [];
28300
- let deletedCheckConstraints = [];
28301
- addedUniqueConstraints = prepareAddUniqueConstraintPg(
28302
- it.name,
28303
- it.schema,
28304
- it.addedUniqueConstraints
28305
- );
28306
- deletedUniqueConstraints = prepareDeleteUniqueConstraintPg(
28307
- it.name,
28308
- it.schema,
28309
- it.deletedUniqueConstraints
28310
- );
28311
- if (it.alteredUniqueConstraints) {
28312
- const added = {};
28313
- const deleted = {};
28314
- for (const k of Object.keys(it.alteredUniqueConstraints)) {
28315
- added[k] = it.alteredUniqueConstraints[k].__new;
28316
- deleted[k] = it.alteredUniqueConstraints[k].__old;
28317
- }
28318
- addedUniqueConstraints.push(
28319
- ...prepareAddUniqueConstraintPg(it.name, it.schema, added)
28320
- );
28321
- deletedUniqueConstraints.push(
28322
- ...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
28323
- );
28324
- }
28325
- createdCheckConstraints = prepareAddCheckConstraint(it.name, it.schema, it.addedCheckConstraints);
28326
- deletedCheckConstraints = prepareDeleteCheckConstraint(
28327
- it.name,
28328
- it.schema,
28329
- it.deletedCheckConstraints
28330
- );
28331
- if (it.alteredCheckConstraints && action !== "push") {
28332
- const added = {};
28333
- const deleted = {};
28334
- for (const k of Object.keys(it.alteredCheckConstraints)) {
28335
- added[k] = it.alteredCheckConstraints[k].__new;
28336
- deleted[k] = it.alteredCheckConstraints[k].__old;
28337
- }
28338
- createdCheckConstraints.push(...prepareAddCheckConstraint(it.name, it.schema, added));
28339
- deletedCheckConstraints.push(...prepareDeleteCheckConstraint(it.name, it.schema, deleted));
28340
- }
28341
27938
  jsonAddedCompositePKs.push(...addedCompositePKs);
28342
27939
  jsonDeletedCompositePKs.push(...deletedCompositePKs);
28343
27940
  jsonAlteredCompositePKs.push(...alteredCompositePKs);
28344
27941
  jsonAddedUniqueConstraints.push(...addedUniqueConstraints);
28345
27942
  jsonDeletedUniqueConstraints.push(...deletedUniqueConstraints);
28346
27943
  jsonAlteredUniqueConstraints.push(...alteredUniqueConstraints);
28347
- jsonCreatedCheckConstraints.push(...createdCheckConstraints);
28348
- jsonDeletedCheckConstraints.push(...deletedCheckConstraints);
28349
27944
  });
28350
27945
  const rColumns = jsonRenameColumnsStatements.map((it) => {
28351
27946
  const tableName = it.tableName;
@@ -28430,7 +28025,6 @@ var init_snapshotsDiffer = __esm({
28430
28025
  jsonStatements.push(...jsonRenameTables);
28431
28026
  jsonStatements.push(...jsonRenameColumnsStatements);
28432
28027
  jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
28433
- jsonStatements.push(...jsonDeletedCheckConstraints);
28434
28028
  jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
28435
28029
  jsonStatements.push(...jsonDeletedCompositePKs);
28436
28030
  jsonStatements.push(...jsonTableAlternations);
@@ -28438,7 +28032,6 @@ var init_snapshotsDiffer = __esm({
28438
28032
  jsonStatements.push(...jsonAddColumnsStatemets);
28439
28033
  jsonStatements.push(...jsonCreateIndexesForCreatedTables);
28440
28034
  jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
28441
- jsonStatements.push(...jsonCreatedCheckConstraints);
28442
28035
  jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
28443
28036
  jsonStatements.push(...jsonDropColumnsStatemets);
28444
28037
  jsonStatements.push(...jsonAlteredCompositePKs);
@@ -28582,8 +28175,6 @@ var init_snapshotsDiffer = __esm({
28582
28175
  const jsonAddedUniqueConstraints = [];
28583
28176
  const jsonDeletedUniqueConstraints = [];
28584
28177
  const jsonAlteredUniqueConstraints = [];
28585
- const jsonDeletedCheckConstraints = [];
28586
- const jsonCreatedCheckConstraints = [];
28587
28178
  allAltered.forEach((it) => {
28588
28179
  let addedColumns = [];
28589
28180
  for (const addedPkName of Object.keys(it.addedCompositePKs)) {
@@ -28616,8 +28207,6 @@ var init_snapshotsDiffer = __esm({
28616
28207
  let addedUniqueConstraints = [];
28617
28208
  let deletedUniqueConstraints = [];
28618
28209
  let alteredUniqueConstraints = [];
28619
- let createdCheckConstraints = [];
28620
- let deletedCheckConstraints = [];
28621
28210
  addedUniqueConstraints = prepareAddUniqueConstraintPg(
28622
28211
  it.name,
28623
28212
  it.schema,
@@ -28642,30 +28231,12 @@ var init_snapshotsDiffer = __esm({
28642
28231
  ...prepareDeleteUniqueConstraintPg(it.name, it.schema, deleted)
28643
28232
  );
28644
28233
  }
28645
- createdCheckConstraints = prepareAddCheckConstraint(it.name, it.schema, it.addedCheckConstraints);
28646
- deletedCheckConstraints = prepareDeleteCheckConstraint(
28647
- it.name,
28648
- it.schema,
28649
- it.deletedCheckConstraints
28650
- );
28651
- if (it.alteredCheckConstraints && action !== "push") {
28652
- const added = {};
28653
- const deleted = {};
28654
- for (const k of Object.keys(it.alteredCheckConstraints)) {
28655
- added[k] = it.alteredCheckConstraints[k].__new;
28656
- deleted[k] = it.alteredCheckConstraints[k].__old;
28657
- }
28658
- createdCheckConstraints.push(...prepareAddCheckConstraint(it.name, it.schema, added));
28659
- deletedCheckConstraints.push(...prepareDeleteCheckConstraint(it.name, it.schema, deleted));
28660
- }
28661
28234
  jsonAddedCompositePKs.push(...addedCompositePKs);
28662
28235
  jsonDeletedCompositePKs.push(...deletedCompositePKs);
28663
28236
  jsonAlteredCompositePKs.push(...alteredCompositePKs);
28664
28237
  jsonAddedUniqueConstraints.push(...addedUniqueConstraints);
28665
28238
  jsonDeletedUniqueConstraints.push(...deletedUniqueConstraints);
28666
28239
  jsonAlteredUniqueConstraints.push(...alteredUniqueConstraints);
28667
- jsonCreatedCheckConstraints.push(...createdCheckConstraints);
28668
- jsonDeletedCheckConstraints.push(...deletedCheckConstraints);
28669
28240
  });
28670
28241
  const jsonTableAlternations = allAltered.map((it) => {
28671
28242
  return prepareSqliteAlterColumns(it.name, it.schema, it.altered, json2);
@@ -28743,7 +28314,6 @@ var init_snapshotsDiffer = __esm({
28743
28314
  jsonStatements.push(...jsonRenameTables);
28744
28315
  jsonStatements.push(...jsonRenameColumnsStatements);
28745
28316
  jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
28746
- jsonStatements.push(...jsonDeletedCheckConstraints);
28747
28317
  jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
28748
28318
  jsonStatements.push(...jsonDeletedCompositePKs);
28749
28319
  jsonStatements.push(...jsonTableAlternations);
@@ -28751,7 +28321,6 @@ var init_snapshotsDiffer = __esm({
28751
28321
  jsonStatements.push(...jsonAddColumnsStatemets);
28752
28322
  jsonStatements.push(...jsonCreateIndexesForCreatedTables);
28753
28323
  jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
28754
- jsonStatements.push(...jsonCreatedCheckConstraints);
28755
28324
  jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
28756
28325
  jsonStatements.push(...jsonDropColumnsStatemets);
28757
28326
  jsonStatements.push(...jsonAlteredCompositePKs);
@@ -30223,6 +29792,7 @@ var init_migrate = __esm({
30223
29792
  prepareAndMigratePg = async (config) => {
30224
29793
  const outFolder = config.out;
30225
29794
  const schemaPath = config.schema;
29795
+ const casing2 = config.casing;
30226
29796
  try {
30227
29797
  assertV1OutFolder(outFolder);
30228
29798
  const { snapshots, journal } = prepareMigrationFolder(
@@ -30231,7 +29801,8 @@ var init_migrate = __esm({
30231
29801
  );
30232
29802
  const { prev, cur, custom: custom2 } = await preparePgMigrationSnapshot(
30233
29803
  snapshots,
30234
- schemaPath
29804
+ schemaPath,
29805
+ casing2
30235
29806
  );
30236
29807
  const validatedPrev = pgSchema.parse(prev);
30237
29808
  const validatedCur = pgSchema.parse(cur);
@@ -30274,10 +29845,11 @@ var init_migrate = __esm({
30274
29845
  console.error(e2);
30275
29846
  }
30276
29847
  };
30277
- preparePgPush = async (schemaPath, snapshot, schemaFilter) => {
29848
+ preparePgPush = async (schemaPath, snapshot, schemaFilter, casing2) => {
30278
29849
  const { prev, cur } = await preparePgDbPushSnapshot(
30279
29850
  snapshot,
30280
29851
  schemaPath,
29852
+ casing2,
30281
29853
  schemaFilter
30282
29854
  );
30283
29855
  const validatedPrev = pgSchema.parse(prev);
@@ -30298,11 +29870,12 @@ var init_migrate = __esm({
30298
29870
  );
30299
29871
  return { sqlStatements, statements, squashedPrev, squashedCur };
30300
29872
  };
30301
- prepareMySQLPush = async (schemaPath, snapshot) => {
29873
+ prepareMySQLPush = async (schemaPath, snapshot, casing2) => {
30302
29874
  try {
30303
29875
  const { prev, cur } = await prepareMySqlDbPushSnapshot(
30304
29876
  snapshot,
30305
- schemaPath
29877
+ schemaPath,
29878
+ casing2
30306
29879
  );
30307
29880
  const validatedPrev = mysqlSchema.parse(prev);
30308
29881
  const validatedCur = mysqlSchema.parse(cur);
@@ -30326,12 +29899,14 @@ var init_migrate = __esm({
30326
29899
  prepareAndMigrateMysql = async (config) => {
30327
29900
  const outFolder = config.out;
30328
29901
  const schemaPath = config.schema;
29902
+ const casing2 = config.casing;
30329
29903
  try {
30330
29904
  assertV1OutFolder(outFolder);
30331
29905
  const { snapshots, journal } = prepareMigrationFolder(outFolder, "mysql");
30332
29906
  const { prev, cur, custom: custom2 } = await prepareMySqlMigrationSnapshot(
30333
29907
  snapshots,
30334
- schemaPath
29908
+ schemaPath,
29909
+ casing2
30335
29910
  );
30336
29911
  const validatedPrev = mysqlSchema.parse(prev);
30337
29912
  const validatedCur = mysqlSchema.parse(cur);
@@ -30375,12 +29950,14 @@ var init_migrate = __esm({
30375
29950
  prepareAndMigrateSqlite = async (config) => {
30376
29951
  const outFolder = config.out;
30377
29952
  const schemaPath = config.schema;
29953
+ const casing2 = config.casing;
30378
29954
  try {
30379
29955
  assertV1OutFolder(outFolder);
30380
29956
  const { snapshots, journal } = prepareMigrationFolder(outFolder, "sqlite");
30381
29957
  const { prev, cur, custom: custom2 } = await prepareSqliteMigrationSnapshot(
30382
29958
  snapshots,
30383
- schemaPath
29959
+ schemaPath,
29960
+ casing2
30384
29961
  );
30385
29962
  const validatedPrev = sqliteSchema.parse(prev);
30386
29963
  const validatedCur = sqliteSchema.parse(cur);
@@ -30426,12 +30003,14 @@ var init_migrate = __esm({
30426
30003
  prepareAndMigrateLibSQL = async (config) => {
30427
30004
  const outFolder = config.out;
30428
30005
  const schemaPath = config.schema;
30006
+ const casing2 = config.casing;
30429
30007
  try {
30430
30008
  assertV1OutFolder(outFolder);
30431
30009
  const { snapshots, journal } = prepareMigrationFolder(outFolder, "sqlite");
30432
30010
  const { prev, cur, custom: custom2 } = await prepareSqliteMigrationSnapshot(
30433
30011
  snapshots,
30434
- schemaPath
30012
+ schemaPath,
30013
+ casing2
30435
30014
  );
30436
30015
  const validatedPrev = sqliteSchema.parse(prev);
30437
30016
  const validatedCur = sqliteSchema.parse(cur);
@@ -30474,8 +30053,8 @@ var init_migrate = __esm({
30474
30053
  console.error(e2);
30475
30054
  }
30476
30055
  };
30477
- prepareSQLitePush = async (schemaPath, snapshot) => {
30478
- const { prev, cur } = await prepareSQLiteDbPushSnapshot(snapshot, schemaPath);
30056
+ prepareSQLitePush = async (schemaPath, snapshot, casing2) => {
30057
+ const { prev, cur } = await prepareSQLiteDbPushSnapshot(snapshot, schemaPath, casing2);
30479
30058
  const validatedPrev = sqliteSchema.parse(prev);
30480
30059
  const validatedCur = sqliteSchema.parse(cur);
30481
30060
  const squashedPrev = squashSqliteScheme(validatedPrev, "push");
@@ -30497,8 +30076,8 @@ var init_migrate = __esm({
30497
30076
  meta: _meta
30498
30077
  };
30499
30078
  };
30500
- prepareLibSQLPush = async (schemaPath, snapshot) => {
30501
- const { prev, cur } = await prepareSQLiteDbPushSnapshot(snapshot, schemaPath);
30079
+ prepareLibSQLPush = async (schemaPath, snapshot, casing2) => {
30080
+ const { prev, cur } = await prepareSQLiteDbPushSnapshot(snapshot, schemaPath, casing2);
30502
30081
  const validatedPrev = sqliteSchema.parse(prev);
30503
30082
  const validatedCur = sqliteSchema.parse(cur);
30504
30083
  const squashedPrev = squashSqliteScheme(validatedPrev, "push");
@@ -63185,7 +62764,7 @@ var init_studio2 = __esm({
63185
62764
  });
63186
62765
  };
63187
62766
  prepareServer = async ({
63188
- dialect: dialect7,
62767
+ dialect: dialect4,
63189
62768
  driver: driver2,
63190
62769
  proxy,
63191
62770
  customDefaults,
@@ -63235,7 +62814,7 @@ var init_studio2 = __esm({
63235
62814
  }));
63236
62815
  return c.json({
63237
62816
  version: "6",
63238
- dialect: dialect7,
62817
+ dialect: dialect4,
63239
62818
  driver: driver2,
63240
62819
  schemaFiles,
63241
62820
  customDefaults: preparedDefaults,
@@ -77644,19 +77223,14 @@ var init_libSqlPushUtils = __esm({
77644
77223
  const compositePKs = Object.values(
77645
77224
  json.tables[tableName].compositePrimaryKeys
77646
77225
  ).map((it) => SQLiteSquasher.unsquashPK(it));
77647
- const checkConstraints = Object.values(json.tables[tableName].checkConstraints);
77648
77226
  const fks = referenceData.map((it) => SQLiteSquasher.unsquashPushFK(it));
77649
- const mappedCheckConstraints = checkConstraints.map(
77650
- (it) => it.replaceAll(`"${tableName}".`, `"${newTableName}".`).replaceAll(`\`${tableName}\`.`, `\`${newTableName}\`.`).replaceAll(`${tableName}.`, `${newTableName}.`).replaceAll(`'${tableName}'.`, `\`${newTableName}\`.`)
77651
- );
77652
77227
  statements.push(
77653
77228
  new SQLiteCreateTableConvertor().convert({
77654
77229
  type: "sqlite_create_table",
77655
77230
  tableName: newTableName,
77656
77231
  columns: tableColumns,
77657
77232
  referenceData: fks,
77658
- compositePKs,
77659
- checkConstraints: mappedCheckConstraints
77233
+ compositePKs
77660
77234
  })
77661
77235
  );
77662
77236
  if (!dataLoss) {
@@ -79547,11 +79121,13 @@ var init_pgIntrospect = __esm({
79547
79121
  });
79548
79122
 
79549
79123
  // src/introspect-sqlite.ts
79550
- var sqliteImportsList, indexName3, objToStatement2, relations, escapeColumnKey, withCasing, schemaToTypeScript, isCyclic, isSelf, mapColumnDefault, column4, createTableColumns, createTableIndexes, createTableUniques, createTableChecks, createTablePKs, createTableFKs;
79124
+ var import_casing3, sqliteImportsList, indexName3, objToStatement2, relations, escapeColumnKey, withCasing, dbColumnName, schemaToTypeScript, isCyclic, isSelf, mapColumnDefault, column4, createTableColumns, createTableIndexes, createTableUniques, createTablePKs, createTableFKs;
79551
79125
  var init_introspect_sqlite = __esm({
79552
79126
  "src/introspect-sqlite.ts"() {
79553
79127
  "use strict";
79128
+ import_casing3 = require("drizzle-orm/casing");
79554
79129
  init_utils3();
79130
+ init_global();
79555
79131
  sqliteImportsList = /* @__PURE__ */ new Set([
79556
79132
  "sqliteTable",
79557
79133
  "integer",
@@ -79589,6 +79165,15 @@ var init_introspect_sqlite = __esm({
79589
79165
  }
79590
79166
  return value;
79591
79167
  };
79168
+ dbColumnName = ({ name, casing: casing2, withMode = false }) => {
79169
+ if (casing2 === "preserve") {
79170
+ return "";
79171
+ }
79172
+ if (casing2 === "camel") {
79173
+ return (0, import_casing3.toCamelCase)(name) === name ? "" : withMode ? `"${name}", ` : `"${name}"`;
79174
+ }
79175
+ assertUnreachable(casing2);
79176
+ };
79592
79177
  schemaToTypeScript = (schema5, casing2) => {
79593
79178
  Object.values(schema5.tables).forEach((table4) => {
79594
79179
  Object.values(table4.foreignKeys).forEach((fk4) => {
@@ -79606,14 +79191,10 @@ var init_introspect_sqlite = __esm({
79606
79191
  const uniqueImports = Object.values(it.uniqueConstraints).map(
79607
79192
  (it2) => "unique"
79608
79193
  );
79609
- const checkImports = Object.values(it.checkConstraints).map(
79610
- (it2) => "check"
79611
- );
79612
79194
  res.sqlite.push(...idxImports);
79613
79195
  res.sqlite.push(...fkImpots);
79614
79196
  res.sqlite.push(...pkImports);
79615
79197
  res.sqlite.push(...uniqueImports);
79616
- res.sqlite.push(...checkImports);
79617
79198
  const columnImports = Object.values(it.columns).map((col) => {
79618
79199
  return col.type;
79619
79200
  }).filter((type) => {
@@ -79646,7 +79227,7 @@ var init_introspect_sqlite = __esm({
79646
79227
  const filteredFKs = Object.values(table4.foreignKeys).filter((it) => {
79647
79228
  return it.columnsFrom.length > 1 || isSelf(it);
79648
79229
  });
79649
- if (Object.keys(table4.indexes).length > 0 || filteredFKs.length > 0 || Object.keys(table4.compositePrimaryKeys).length > 0 || Object.keys(table4.uniqueConstraints).length > 0 || Object.keys(table4.checkConstraints).length > 0) {
79230
+ if (Object.keys(table4.indexes).length > 0 || filteredFKs.length > 0 || Object.keys(table4.compositePrimaryKeys).length > 0 || Object.keys(table4.uniqueConstraints).length > 0) {
79650
79231
  statement += ",\n";
79651
79232
  statement += "(table) => {\n";
79652
79233
  statement += " return {\n";
@@ -79664,10 +79245,6 @@ var init_introspect_sqlite = __esm({
79664
79245
  Object.values(table4.uniqueConstraints),
79665
79246
  casing2
79666
79247
  );
79667
- statement += createTableChecks(
79668
- Object.values(table4.checkConstraints),
79669
- casing2
79670
- );
79671
79248
  statement += " }\n";
79672
79249
  statement += "}";
79673
79250
  }
@@ -79716,13 +79293,14 @@ var init_introspect_sqlite = __esm({
79716
79293
  };
79717
79294
  column4 = (type, name, defaultValue, autoincrement, casing2) => {
79718
79295
  let lowered = type;
79296
+ casing2 = casing2;
79719
79297
  if (lowered === "integer") {
79720
- let out = `${withCasing(name, casing2)}: integer("${name}")`;
79298
+ let out = `${withCasing(name, casing2)}: integer(${dbColumnName({ name, casing: casing2 })})`;
79721
79299
  out += typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault(defaultValue)})` : "";
79722
79300
  return out;
79723
79301
  }
79724
79302
  if (lowered === "real") {
79725
- let out = `${withCasing(name, casing2)}: real("${name}")`;
79303
+ let out = `${withCasing(name, casing2)}: real(${dbColumnName({ name, casing: casing2 })})`;
79726
79304
  out += defaultValue ? `.default(${mapColumnDefault(defaultValue)})` : "";
79727
79305
  return out;
79728
79306
  }
@@ -79730,20 +79308,20 @@ var init_introspect_sqlite = __esm({
79730
79308
  const match2 = lowered.match(/\d+/);
79731
79309
  let out;
79732
79310
  if (match2) {
79733
- out = `${withCasing(name, casing2)}: text("${name}", { length: ${match2[0]} })`;
79311
+ out = `${withCasing(name, casing2)}: text(${dbColumnName({ name, casing: casing2, withMode: true })}{ length: ${match2[0]} })`;
79734
79312
  } else {
79735
- out = `${withCasing(name, casing2)}: text("${name}")`;
79313
+ out = `${withCasing(name, casing2)}: text(${dbColumnName({ name, casing: casing2 })})`;
79736
79314
  }
79737
79315
  out += defaultValue ? `.default("${mapColumnDefault(defaultValue)}")` : "";
79738
79316
  return out;
79739
79317
  }
79740
79318
  if (lowered === "blob") {
79741
- let out = `${withCasing(name, casing2)}: blob("${name}")`;
79319
+ let out = `${withCasing(name, casing2)}: blob(${dbColumnName({ name, casing: casing2 })})`;
79742
79320
  out += defaultValue ? `.default(${mapColumnDefault(defaultValue)})` : "";
79743
79321
  return out;
79744
79322
  }
79745
79323
  if (lowered === "numeric") {
79746
- let out = `${withCasing(name, casing2)}: numeric("${name}")`;
79324
+ let out = `${withCasing(name, casing2)}: numeric(${dbColumnName({ name, casing: casing2 })})`;
79747
79325
  out += defaultValue ? `.default(${mapColumnDefault(defaultValue)})` : "";
79748
79326
  return out;
79749
79327
  }
@@ -79818,19 +79396,6 @@ var init_introspect_sqlite = __esm({
79818
79396
  statement += `"${it.name}")`;
79819
79397
  statement += `.on(${it.columns.map((it2) => `table.${withCasing(it2, casing2)}`).join(", ")}),`;
79820
79398
  statement += `
79821
- `;
79822
- });
79823
- return statement;
79824
- };
79825
- createTableChecks = (checks, casing2) => {
79826
- let statement = "";
79827
- checks.forEach((it) => {
79828
- const checkKey = withCasing(it.name, casing2);
79829
- statement += ` ${checkKey}: `;
79830
- statement += "check(";
79831
- statement += `"${it.name}", `;
79832
- statement += `sql\`${it.value}\`)`;
79833
- statement += `,
79834
79399
  `;
79835
79400
  });
79836
79401
  return statement;
@@ -79980,13 +79545,13 @@ var init_push = __esm({
79980
79545
  init_mysqlPushUtils();
79981
79546
  init_pgPushUtils();
79982
79547
  init_sqlitePushUtils();
79983
- mysqlPush = async (schemaPath, credentials2, tablesFilter, strict, verbose, force) => {
79548
+ mysqlPush = async (schemaPath, credentials2, tablesFilter, strict, verbose, force, casing2) => {
79984
79549
  const { connectToMySQL: connectToMySQL2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
79985
79550
  const { mysqlPushIntrospect: mysqlPushIntrospect2 } = await Promise.resolve().then(() => (init_mysqlIntrospect(), mysqlIntrospect_exports));
79986
79551
  const { db, database } = await connectToMySQL2(credentials2);
79987
79552
  const { schema: schema5 } = await mysqlPushIntrospect2(db, database, tablesFilter);
79988
79553
  const { prepareMySQLPush: prepareMySQLPush2 } = await Promise.resolve().then(() => (init_migrate(), migrate_exports));
79989
- const statements = await prepareMySQLPush2(schemaPath, schema5);
79554
+ const statements = await prepareMySQLPush2(schemaPath, schema5, casing2);
79990
79555
  const filteredStatements = filterStatements(
79991
79556
  statements.statements ?? [],
79992
79557
  statements.validatedCur,
@@ -80081,13 +79646,13 @@ var init_push = __esm({
80081
79646
  console.log(e2);
80082
79647
  }
80083
79648
  };
80084
- pgPush = async (schemaPath, verbose, strict, credentials2, tablesFilter, schemasFilter, force) => {
79649
+ pgPush = async (schemaPath, verbose, strict, credentials2, tablesFilter, schemasFilter, force, casing2) => {
80085
79650
  const { preparePostgresDB: preparePostgresDB2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
80086
79651
  const { pgPushIntrospect: pgPushIntrospect2 } = await Promise.resolve().then(() => (init_pgIntrospect(), pgIntrospect_exports));
80087
79652
  const db = await preparePostgresDB2(credentials2);
80088
79653
  const { schema: schema5 } = await pgPushIntrospect2(db, tablesFilter, schemasFilter);
80089
79654
  const { preparePgPush: preparePgPush2 } = await Promise.resolve().then(() => (init_migrate(), migrate_exports));
80090
- const statements = await preparePgPush2(schemaPath, schema5, schemasFilter);
79655
+ const statements = await preparePgPush2(schemaPath, schema5, schemasFilter, casing2);
80091
79656
  try {
80092
79657
  if (statements.sqlStatements.length === 0) {
80093
79658
  (0, import_hanji11.render)(`[${source_default.blue("i")}] No changes detected`);
@@ -80155,13 +79720,13 @@ var init_push = __esm({
80155
79720
  console.error(e2);
80156
79721
  }
80157
79722
  };
80158
- sqlitePush = async (schemaPath, verbose, strict, credentials2, tablesFilter, force) => {
79723
+ sqlitePush = async (schemaPath, verbose, strict, credentials2, tablesFilter, force, casing2) => {
80159
79724
  const { connectToSQLite: connectToSQLite2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
80160
79725
  const { sqlitePushIntrospect: sqlitePushIntrospect2 } = await Promise.resolve().then(() => (init_sqliteIntrospect(), sqliteIntrospect_exports));
80161
79726
  const db = await connectToSQLite2(credentials2);
80162
79727
  const { schema: schema5 } = await sqlitePushIntrospect2(db, tablesFilter);
80163
79728
  const { prepareSQLitePush: prepareSQLitePush2 } = await Promise.resolve().then(() => (init_migrate(), migrate_exports));
80164
- const statements = await prepareSQLitePush2(schemaPath, schema5);
79729
+ const statements = await prepareSQLitePush2(schemaPath, schema5, casing2);
80165
79730
  if (statements.sqlStatements.length === 0) {
80166
79731
  (0, import_hanji11.render)(`
80167
79732
  [${source_default.blue("i")}] No changes detected`);
@@ -80243,13 +79808,13 @@ var init_push = __esm({
80243
79808
  }
80244
79809
  }
80245
79810
  };
80246
- libSQLPush = async (schemaPath, verbose, strict, credentials2, tablesFilter, force) => {
79811
+ libSQLPush = async (schemaPath, verbose, strict, credentials2, tablesFilter, force, casing2) => {
80247
79812
  const { connectToLibSQL: connectToLibSQL2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
80248
79813
  const { sqlitePushIntrospect: sqlitePushIntrospect2 } = await Promise.resolve().then(() => (init_sqliteIntrospect(), sqliteIntrospect_exports));
80249
79814
  const db = await connectToLibSQL2(credentials2);
80250
79815
  const { schema: schema5 } = await sqlitePushIntrospect2(db, tablesFilter);
80251
79816
  const { prepareLibSQLPush: prepareLibSQLPush2 } = await Promise.resolve().then(() => (init_migrate(), migrate_exports));
80252
- const statements = await prepareLibSQLPush2(schemaPath, schema5);
79817
+ const statements = await prepareLibSQLPush2(schemaPath, schema5, casing2);
80253
79818
  if (statements.sqlStatements.length === 0) {
80254
79819
  (0, import_hanji11.render)(`
80255
79820
  [${source_default.blue("i")}] No changes detected`);
@@ -80679,11 +80244,13 @@ var require_pluralize = __commonJS({
80679
80244
  });
80680
80245
 
80681
80246
  // src/introspect-mysql.ts
80682
- var mysqlImportsList, objToStatement22, timeConfig, binaryConfig, importsPatch, relations2, escapeColumnKey2, prepareCasing, schemaToTypeScript2, isCyclic2, isSelf2, mapColumnDefault2, mapColumnDefaultForJson, column5, createTableColumns2, createTableIndexes2, createTableUniques2, createTableChecks2, createTablePKs2, createTableFKs2;
80247
+ var import_casing4, mysqlImportsList, objToStatement22, timeConfig, binaryConfig, importsPatch, relations2, escapeColumnKey2, prepareCasing, dbColumnName2, schemaToTypeScript2, isCyclic2, isSelf2, mapColumnDefault2, mapColumnDefaultForJson, column5, createTableColumns2, createTableIndexes2, createTableUniques2, createTablePKs2, createTableFKs2;
80683
80248
  var init_introspect_mysql = __esm({
80684
80249
  "src/introspect-mysql.ts"() {
80685
80250
  "use strict";
80251
+ import_casing4 = require("drizzle-orm/casing");
80686
80252
  init_utils3();
80253
+ init_global();
80687
80254
  init_mysqlSerializer();
80688
80255
  mysqlImportsList = /* @__PURE__ */ new Set([
80689
80256
  "mysqlTable",
@@ -80763,7 +80330,16 @@ var init_introspect_mysql = __esm({
80763
80330
  if (casing2 === "camel") {
80764
80331
  return escapeColumnKey2(value.camelCase());
80765
80332
  }
80766
- return escapeColumnKey2(value);
80333
+ assertUnreachable(casing2);
80334
+ };
80335
+ dbColumnName2 = ({ name, casing: casing2, withMode = false }) => {
80336
+ if (casing2 === "preserve") {
80337
+ return "";
80338
+ }
80339
+ if (casing2 === "camel") {
80340
+ return (0, import_casing4.toCamelCase)(name) === name ? "" : withMode ? `"${name}", ` : `"${name}"`;
80341
+ }
80342
+ assertUnreachable(casing2);
80767
80343
  };
80768
80344
  schemaToTypeScript2 = (schema5, casing2) => {
80769
80345
  const withCasing4 = prepareCasing(casing2);
@@ -80783,14 +80359,10 @@ var init_introspect_mysql = __esm({
80783
80359
  const uniqueImports = Object.values(it.uniqueConstraints).map(
80784
80360
  (it2) => "unique"
80785
80361
  );
80786
- const checkImports = Object.values(it.checkConstraint).map(
80787
- (it2) => "check"
80788
- );
80789
80362
  res.mysql.push(...idxImports);
80790
80363
  res.mysql.push(...fkImpots);
80791
80364
  res.mysql.push(...pkImports);
80792
80365
  res.mysql.push(...uniqueImports);
80793
- res.mysql.push(...checkImports);
80794
80366
  const columnImports = Object.values(it.columns).map((col) => {
80795
80367
  let patched = importsPatch[col.type] ?? col.type;
80796
80368
  patched = patched.startsWith("varchar(") ? "varchar" : patched;
@@ -80828,6 +80400,7 @@ var init_introspect_mysql = __esm({
80828
80400
  Object.values(table4.columns),
80829
80401
  Object.values(table4.foreignKeys),
80830
80402
  withCasing4,
80403
+ casing2,
80831
80404
  table4.name,
80832
80405
  schema5
80833
80406
  );
@@ -80835,7 +80408,7 @@ var init_introspect_mysql = __esm({
80835
80408
  const filteredFKs = Object.values(table4.foreignKeys).filter((it) => {
80836
80409
  return it.columnsFrom.length > 1 || isSelf2(it);
80837
80410
  });
80838
- if (Object.keys(table4.indexes).length > 0 || filteredFKs.length > 0 || Object.keys(table4.compositePrimaryKeys).length > 0 || Object.keys(table4.uniqueConstraints).length > 0 || Object.keys(table4.checkConstraint).length > 0) {
80411
+ if (Object.keys(table4.indexes).length > 0 || filteredFKs.length > 0 || Object.keys(table4.compositePrimaryKeys).length > 0 || Object.keys(table4.uniqueConstraints).length > 0) {
80839
80412
  statement += ",\n";
80840
80413
  statement += "(table) => {\n";
80841
80414
  statement += " return {\n";
@@ -80853,10 +80426,6 @@ var init_introspect_mysql = __esm({
80853
80426
  Object.values(table4.uniqueConstraints),
80854
80427
  withCasing4
80855
80428
  );
80856
- statement += createTableChecks2(
80857
- Object.values(table4.checkConstraint),
80858
- withCasing4
80859
- );
80860
80429
  statement += " }\n";
80861
80430
  statement += "}";
80862
80431
  }
@@ -80911,51 +80480,51 @@ import { sql } from "drizzle-orm"
80911
80480
  }
80912
80481
  return defaultValue;
80913
80482
  };
80914
- column5 = (type, name, casing2, defaultValue, autoincrement, onUpdate, isExpression) => {
80483
+ column5 = (type, name, casing2, rawCasing, defaultValue, autoincrement, onUpdate, isExpression) => {
80915
80484
  let lowered = type;
80916
80485
  if (!type.startsWith("enum(")) {
80917
80486
  lowered = type.toLowerCase();
80918
80487
  }
80919
80488
  if (lowered === "serial") {
80920
- return `${casing2(name)}: serial("${name}")`;
80489
+ return `${casing2(name)}: serial(${dbColumnName2({ name, casing: rawCasing })})`;
80921
80490
  }
80922
80491
  if (lowered.startsWith("int")) {
80923
80492
  const isUnsigned = lowered.startsWith("int unsigned");
80924
- let out = `${casing2(name)}: int("${name}"${isUnsigned ? ", { unsigned: true }" : ""})`;
80493
+ let out = `${casing2(name)}: int(${dbColumnName2({ name, casing: rawCasing, withMode: isUnsigned })}${isUnsigned ? "{ unsigned: true }" : ""})`;
80925
80494
  out += autoincrement ? `.autoincrement()` : "";
80926
80495
  out += typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
80927
80496
  return out;
80928
80497
  }
80929
80498
  if (lowered.startsWith("tinyint")) {
80930
80499
  const isUnsigned = lowered.startsWith("tinyint unsigned");
80931
- let out = `${casing2(name)}: tinyint("${name}"${isUnsigned ? ", { unsigned: true }" : ""})`;
80500
+ let out = `${casing2(name)}: tinyint(${dbColumnName2({ name, casing: rawCasing, withMode: isUnsigned })}${isUnsigned ? ", { unsigned: true }" : ""})`;
80932
80501
  out += autoincrement ? `.autoincrement()` : "";
80933
80502
  out += typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
80934
80503
  return out;
80935
80504
  }
80936
80505
  if (lowered.startsWith("smallint")) {
80937
80506
  const isUnsigned = lowered.startsWith("smallint unsigned");
80938
- let out = `${casing2(name)}: smallint("${name}"${isUnsigned ? ", { unsigned: true }" : ""})`;
80507
+ let out = `${casing2(name)}: smallint(${dbColumnName2({ name, casing: rawCasing, withMode: isUnsigned })}${isUnsigned ? ", { unsigned: true }" : ""})`;
80939
80508
  out += autoincrement ? `.autoincrement()` : "";
80940
80509
  out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
80941
80510
  return out;
80942
80511
  }
80943
80512
  if (lowered.startsWith("mediumint")) {
80944
80513
  const isUnsigned = lowered.startsWith("mediumint unsigned");
80945
- let out = `${casing2(name)}: mediumint("${name}"${isUnsigned ? ", { unsigned: true }" : ""})`;
80514
+ let out = `${casing2(name)}: mediumint(${dbColumnName2({ name, casing: rawCasing, withMode: isUnsigned })}${isUnsigned ? ", { unsigned: true }" : ""})`;
80946
80515
  out += autoincrement ? `.autoincrement()` : "";
80947
80516
  out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
80948
80517
  return out;
80949
80518
  }
80950
80519
  if (lowered.startsWith("bigint")) {
80951
80520
  const isUnsigned = lowered.startsWith("bigint unsigned");
80952
- let out = `${casing2(name)}: bigint("${name}", { mode: "number"${isUnsigned ? ", unsigned: true" : ""} })`;
80521
+ let out = `${casing2(name)}: bigint(${dbColumnName2({ name, casing: rawCasing, withMode: true })}{ mode: "number"${isUnsigned ? ", unsigned: true" : ""} })`;
80953
80522
  out += autoincrement ? `.autoincrement()` : "";
80954
80523
  out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
80955
80524
  return out;
80956
80525
  }
80957
80526
  if (lowered === "boolean") {
80958
- let out = `${casing2(name)}: boolean("${name}")`;
80527
+ let out = `${casing2(name)}: boolean(${dbColumnName2({ name, casing: rawCasing })})`;
80959
80528
  out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
80960
80529
  return out;
80961
80530
  }
@@ -80965,17 +80534,18 @@ import { sql } from "drizzle-orm"
80965
80534
  const [precision, scale] = lowered.slice(7, lowered.length - 1).split(",");
80966
80535
  params = { precision, scale };
80967
80536
  }
80968
- let out = params ? `${casing2(name)}: double("${name}", ${timeConfig(params)})` : `${casing2(name)}: double("${name}")`;
80537
+ const timeConfigParams = params ? timeConfig(params) : void 0;
80538
+ let out = params ? `${casing2(name)}: double(${dbColumnName2({ name, casing: rawCasing, withMode: timeConfigParams !== void 0 })}${timeConfig(params)})` : `${casing2(name)}: double(${dbColumnName2({ name, casing: rawCasing })})`;
80969
80539
  out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
80970
80540
  return out;
80971
80541
  }
80972
80542
  if (lowered === "float") {
80973
- let out = `${casing2(name)}: float("${name}")`;
80543
+ let out = `${casing2(name)}: float(${dbColumnName2({ name, casing: rawCasing })})`;
80974
80544
  out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
80975
80545
  return out;
80976
80546
  }
80977
80547
  if (lowered === "real") {
80978
- let out = `${casing2(name)}: real("${name}")`;
80548
+ let out = `${casing2(name)}: real(${dbColumnName2({ name, casing: rawCasing })})`;
80979
80549
  out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
80980
80550
  return out;
80981
80551
  }
@@ -80984,7 +80554,7 @@ import { sql } from "drizzle-orm"
80984
80554
  let fsp = lowered.length > keyLength ? Number(lowered.substring(keyLength, lowered.length - 1)) : null;
80985
80555
  fsp = fsp ? fsp : null;
80986
80556
  const params = timeConfig({ fsp, mode: "'string'" });
80987
- let out = params ? `${casing2(name)}: timestamp("${name}", ${params})` : `${casing2(name)}: timestamp("${name}")`;
80557
+ let out = params ? `${casing2(name)}: timestamp(${dbColumnName2({ name, casing: rawCasing, withMode: params !== void 0 })}${params})` : `${casing2(name)}: timestamp(${dbColumnName2({ name, casing: rawCasing })})`;
80988
80558
  defaultValue = defaultValue === "now()" || defaultValue === "(CURRENT_TIMESTAMP)" ? ".defaultNow()" : defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
80989
80559
  out += defaultValue;
80990
80560
  let onUpdateNow = onUpdate ? ".onUpdateNow()" : "";
@@ -80996,7 +80566,7 @@ import { sql } from "drizzle-orm"
80996
80566
  let fsp = lowered.length > keyLength ? Number(lowered.substring(keyLength, lowered.length - 1)) : null;
80997
80567
  fsp = fsp ? fsp : null;
80998
80568
  const params = timeConfig({ fsp });
80999
- let out = params ? `${casing2(name)}: time("${name}", ${params})` : `${casing2(name)}: time("${name}")`;
80569
+ let out = params ? `${casing2(name)}: time(${dbColumnName2({ name, casing: rawCasing, withMode: params !== void 0 })}${params})` : `${casing2(name)}: time(${dbColumnName2({ name, casing: rawCasing })})`;
81000
80570
  defaultValue = defaultValue === "now()" ? ".defaultNow()" : defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
81001
80571
  out += defaultValue;
81002
80572
  return out;
@@ -81005,45 +80575,45 @@ import { sql } from "drizzle-orm"
81005
80575
  let out = `// you can use { mode: 'date' }, if you want to have Date as type for this column
81006
80576
  ${casing2(
81007
80577
  name
81008
- )}: date("${name}", { mode: 'string' })`;
80578
+ )}: date(${dbColumnName2({ name, casing: rawCasing, withMode: true })}{ mode: 'string' })`;
81009
80579
  defaultValue = defaultValue === "now()" ? ".defaultNow()" : defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
81010
80580
  out += defaultValue;
81011
80581
  return out;
81012
80582
  }
81013
80583
  if (lowered === "text") {
81014
- let out = `${casing2(name)}: text("${name}")`;
80584
+ let out = `${casing2(name)}: text(${dbColumnName2({ name, casing: rawCasing })})`;
81015
80585
  out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
81016
80586
  return out;
81017
80587
  }
81018
80588
  if (lowered === "tinytext") {
81019
- let out = `${casing2(name)}: tinytext("${name}")`;
80589
+ let out = `${casing2(name)}: tinytext(${dbColumnName2({ name, casing: rawCasing })})`;
81020
80590
  out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
81021
80591
  return out;
81022
80592
  }
81023
80593
  if (lowered === "mediumtext") {
81024
- let out = `${casing2(name)}: mediumtext("${name}")`;
80594
+ let out = `${casing2(name)}: mediumtext(${dbColumnName2({ name, casing: rawCasing })})`;
81025
80595
  out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
81026
80596
  return out;
81027
80597
  }
81028
80598
  if (lowered === "longtext") {
81029
- let out = `${casing2(name)}: longtext("${name}")`;
80599
+ let out = `${casing2(name)}: longtext(${dbColumnName2({ name, casing: rawCasing })})`;
81030
80600
  out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
81031
80601
  return out;
81032
80602
  }
81033
80603
  if (lowered === "year") {
81034
- let out = `${casing2(name)}: year("${name}")`;
80604
+ let out = `${casing2(name)}: year(${dbColumnName2({ name, casing: rawCasing })})`;
81035
80605
  out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
81036
80606
  return out;
81037
80607
  }
81038
80608
  if (lowered === "json") {
81039
- let out = `${casing2(name)}: json("${name}")`;
80609
+ let out = `${casing2(name)}: json(${dbColumnName2({ name, casing: rawCasing })})`;
81040
80610
  out += defaultValue ? `.default(${mapColumnDefaultForJson(defaultValue)})` : "";
81041
80611
  return out;
81042
80612
  }
81043
80613
  if (lowered.startsWith("varchar")) {
81044
80614
  let out = `${casing2(
81045
80615
  name
81046
- )}: varchar("${name}", { length: ${lowered.substring(
80616
+ )}: varchar(${dbColumnName2({ name, casing: rawCasing, withMode: true })}{ length: ${lowered.substring(
81047
80617
  "varchar".length + 1,
81048
80618
  lowered.length - 1
81049
80619
  )} })`;
@@ -81053,7 +80623,7 @@ import { sql } from "drizzle-orm"
81053
80623
  if (lowered.startsWith("char")) {
81054
80624
  let out = `${casing2(
81055
80625
  name
81056
- )}: char("${name}", { length: ${lowered.substring(
80626
+ )}: char(${dbColumnName2({ name, casing: rawCasing, withMode: true })}{ length: ${lowered.substring(
81057
80627
  "char".length + 1,
81058
80628
  lowered.length - 1
81059
80629
  )} })`;
@@ -81066,10 +80636,10 @@ import { sql } from "drizzle-orm"
81066
80636
  const fsp = lowered.startsWith("datetime(") ? lowered.substring("datetime".length + 1, lowered.length - 1) : void 0;
81067
80637
  out = fsp ? `${casing2(
81068
80638
  name
81069
- )}: datetime("${name}", { mode: 'string', fsp: ${lowered.substring(
80639
+ )}: datetime(${dbColumnName2({ name, casing: rawCasing, withMode: true })}{ mode: 'string', fsp: ${lowered.substring(
81070
80640
  "datetime".length + 1,
81071
80641
  lowered.length - 1
81072
- )} })` : `${casing2(name)}: datetime("${name}", { mode: 'string'})`;
80642
+ )} })` : `${casing2(name)}: datetime(${dbColumnName2({ name, casing: rawCasing, withMode: true })}{ mode: 'string'})`;
81073
80643
  defaultValue = defaultValue === "now()" ? ".defaultNow()" : defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
81074
80644
  out += defaultValue;
81075
80645
  return out;
@@ -81080,7 +80650,8 @@ import { sql } from "drizzle-orm"
81080
80650
  const [precision, scale] = lowered.slice(8, lowered.length - 1).split(",");
81081
80651
  params = { precision, scale };
81082
80652
  }
81083
- let out = params ? `${casing2(name)}: decimal("${name}", ${timeConfig(params)})` : `${casing2(name)}: decimal("${name}")`;
80653
+ const timeConfigParams = params ? timeConfig(params) : void 0;
80654
+ let out = params ? `${casing2(name)}: decimal(${dbColumnName2({ name, casing: rawCasing, withMode: timeConfigParams !== void 0 })}${timeConfigParams})` : `${casing2(name)}: decimal(${dbColumnName2({ name, casing: rawCasing })})`;
81084
80655
  defaultValue = typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
81085
80656
  out += defaultValue;
81086
80657
  return out;
@@ -81090,14 +80661,14 @@ import { sql } from "drizzle-orm"
81090
80661
  let length = lowered.length > keyLength ? Number(lowered.substring(keyLength, lowered.length - 1)) : null;
81091
80662
  length = length ? length : null;
81092
80663
  const params = binaryConfig({ length });
81093
- let out = params ? `${casing2(name)}: binary("${name}", ${params})` : `${casing2(name)}: binary("${name}")`;
80664
+ let out = params ? `${casing2(name)}: binary(${dbColumnName2({ name, casing: rawCasing, withMode: params !== void 0 })}${params})` : `${casing2(name)}: binary(${dbColumnName2({ name, casing: rawCasing })})`;
81094
80665
  defaultValue = defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
81095
80666
  out += defaultValue;
81096
80667
  return out;
81097
80668
  }
81098
80669
  if (lowered.startsWith("enum")) {
81099
80670
  const values = lowered.substring("enum".length + 1, lowered.length - 1);
81100
- let out = `${casing2(name)}: mysqlEnum("${name}", [${values}])`;
80671
+ let out = `${casing2(name)}: mysqlEnum(${dbColumnName2({ name, casing: rawCasing, withMode: true })}[${values}])`;
81101
80672
  out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
81102
80673
  return out;
81103
80674
  }
@@ -81106,7 +80677,7 @@ import { sql } from "drizzle-orm"
81106
80677
  let length = lowered.length > keyLength ? Number(lowered.substring(keyLength, lowered.length - 1)) : null;
81107
80678
  length = length ? length : null;
81108
80679
  const params = binaryConfig({ length });
81109
- let out = params ? `${casing2(name)}: varbinary("${name}", ${params})` : `${casing2(name)}: varbinary("${name}")`;
80680
+ let out = params ? `${casing2(name)}: varbinary(${dbColumnName2({ name, casing: rawCasing, withMode: params !== void 0 })}${params})` : `${casing2(name)}: varbinary(${dbColumnName2({ name, casing: rawCasing })})`;
81110
80681
  defaultValue = defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
81111
80682
  out += defaultValue;
81112
80683
  return out;
@@ -81115,7 +80686,7 @@ import { sql } from "drizzle-orm"
81115
80686
  return `// Warning: Can't parse ${type} from database
81116
80687
  // ${type}Type: ${type}("${name}")`;
81117
80688
  };
81118
- createTableColumns2 = (columns, fks, casing2, tableName, schema5) => {
80689
+ createTableColumns2 = (columns, fks, casing2, rawCasing, tableName, schema5) => {
81119
80690
  let statement = "";
81120
80691
  const oneColumnsFKs = Object.values(fks).filter((it) => {
81121
80692
  return !isSelf2(it);
@@ -81133,6 +80704,7 @@ import { sql } from "drizzle-orm"
81133
80704
  it.type,
81134
80705
  it.name,
81135
80706
  casing2,
80707
+ rawCasing,
81136
80708
  it.default,
81137
80709
  it.autoincrement,
81138
80710
  it.onUpdate,
@@ -81193,19 +80765,6 @@ import { sql } from "drizzle-orm"
81193
80765
  statement += `"${it.name}")`;
81194
80766
  statement += `.on(${it.columns.map((it2) => `table.${casing2(it2)}`).join(", ")}),`;
81195
80767
  statement += `
81196
- `;
81197
- });
81198
- return statement;
81199
- };
81200
- createTableChecks2 = (checks, casing2) => {
81201
- let statement = "";
81202
- checks.forEach((it) => {
81203
- const checkKey = casing2(it.name);
81204
- statement += ` ${checkKey}: `;
81205
- statement += "check(";
81206
- statement += `"${it.name}", `;
81207
- statement += `sql\`${it.value.replace(/`/g, "\\`")}\`)`;
81208
- statement += `,
81209
80768
  `;
81210
80769
  });
81211
80770
  return statement;
@@ -81276,13 +80835,14 @@ function generateIdentityParams(identity) {
81276
80835
  }
81277
80836
  return `.generatedByDefaultAsIdentity(${paramsObj})`;
81278
80837
  }
81279
- var import_drizzle_orm9, import_relations, pgImportsList, timeConfig2, possibleIntervals, intervalStrToObj, intervalConfig, mapColumnDefault3, importsPatch2, relations3, escapeColumnKey3, withCasing2, paramNameFor, schemaToTypeScript3, isCyclic3, isSelf3, buildArrayDefault, mapDefault, column6, dimensionsInArray, createTableColumns3, createTableIndexes3, createTablePKs3, createTableUniques3, createTableChecks3, createTableFKs3;
80838
+ var import_drizzle_orm9, import_relations, import_casing5, pgImportsList, timeConfig2, possibleIntervals, intervalStrToObj, intervalConfig, mapColumnDefault3, importsPatch2, relations3, escapeColumnKey3, withCasing2, dbColumnName3, paramNameFor, schemaToTypeScript3, isCyclic3, isSelf3, buildArrayDefault, mapDefault, column6, dimensionsInArray, createTableColumns3, createTableIndexes3, createTablePKs3, createTableUniques3, createTableFKs3;
81280
80839
  var init_introspect_pg = __esm({
81281
80840
  "src/introspect-pg.ts"() {
81282
80841
  "use strict";
81283
80842
  import_drizzle_orm9 = require("drizzle-orm");
81284
80843
  import_relations = require("drizzle-orm/relations");
81285
80844
  init_utils3();
80845
+ import_casing5 = require("drizzle-orm/casing");
81286
80846
  init_vector();
81287
80847
  init_global();
81288
80848
  init_pgSerializer();
@@ -81408,6 +80968,15 @@ var init_introspect_pg = __esm({
81408
80968
  }
81409
80969
  assertUnreachable(casing2);
81410
80970
  };
80971
+ dbColumnName3 = ({ name, casing: casing2, withMode = false }) => {
80972
+ if (casing2 === "preserve") {
80973
+ return "";
80974
+ }
80975
+ if (casing2 === "camel") {
80976
+ return (0, import_casing5.toCamelCase)(name) === name ? "" : withMode ? `"${name}", ` : `"${name}"`;
80977
+ }
80978
+ assertUnreachable(casing2);
80979
+ };
81411
80980
  paramNameFor = (name, schema5) => {
81412
80981
  const schemaSuffix = schema5 && schema5 !== "public" ? `In${schema5.capitalise()}` : "";
81413
80982
  return `${name}${schemaSuffix}`;
@@ -81444,9 +81013,6 @@ var init_introspect_pg = __esm({
81444
81013
  const uniqueImports = Object.values(it.uniqueConstraints).map(
81445
81014
  (it2) => "unique"
81446
81015
  );
81447
- const checkImports = Object.values(it.checkConstraints).map(
81448
- (it2) => "check"
81449
- );
81450
81016
  if (it.schema && it.schema !== "public" && it.schema !== "") {
81451
81017
  res.pg.push("pgSchema");
81452
81018
  }
@@ -81454,7 +81020,6 @@ var init_introspect_pg = __esm({
81454
81020
  res.pg.push(...fkImpots);
81455
81021
  res.pg.push(...pkImports);
81456
81022
  res.pg.push(...uniqueImports);
81457
- res.pg.push(...checkImports);
81458
81023
  const columnImports = Object.values(it.columns).map((col) => {
81459
81024
  let patched = (importsPatch2[col.type] || col.type).replace("[]", "");
81460
81025
  patched = patched === "double precision" ? "doublePrecision" : patched;
@@ -81544,7 +81109,7 @@ var init_introspect_pg = __esm({
81544
81109
  schema5.internal
81545
81110
  );
81546
81111
  statement += "}";
81547
- if (Object.keys(table4.indexes).length > 0 || Object.values(table4.foreignKeys).length > 0 || Object.keys(table4.compositePrimaryKeys).length > 0 || Object.keys(table4.uniqueConstraints).length > 0 || Object.keys(table4.checkConstraints).length > 0) {
81112
+ if (Object.keys(table4.indexes).length > 0 || Object.values(table4.foreignKeys).length > 0 || Object.keys(table4.compositePrimaryKeys).length > 0 || Object.keys(table4.uniqueConstraints).length > 0) {
81548
81113
  statement += ",\n";
81549
81114
  statement += "(table) => {\n";
81550
81115
  statement += " return {\n";
@@ -81562,10 +81127,6 @@ var init_introspect_pg = __esm({
81562
81127
  Object.values(table4.uniqueConstraints),
81563
81128
  casing2
81564
81129
  );
81565
- statement += createTableChecks3(
81566
- Object.values(table4.checkConstraints),
81567
- casing2
81568
- );
81569
81130
  statement += " }\n";
81570
81131
  statement += "}";
81571
81132
  }
@@ -81711,49 +81272,49 @@ var init_introspect_pg = __esm({
81711
81272
  let out = `${withCasing2(name, casing2)}: ${withCasing2(
81712
81273
  paramNameFor(type.replace("[]", ""), typeSchema),
81713
81274
  casing2
81714
- )}("${name}")`;
81275
+ )}(${dbColumnName3({ name, casing: casing2 })})`;
81715
81276
  return out;
81716
81277
  }
81717
81278
  if (lowered.startsWith("serial")) {
81718
- return `${withCasing2(name, casing2)}: serial("${name}")`;
81279
+ return `${withCasing2(name, casing2)}: serial(${dbColumnName3({ name, casing: casing2 })})`;
81719
81280
  }
81720
81281
  if (lowered.startsWith("smallserial")) {
81721
- return `${withCasing2(name, casing2)}: smallserial("${name}")`;
81282
+ return `${withCasing2(name, casing2)}: smallserial(${dbColumnName3({ name, casing: casing2 })})`;
81722
81283
  }
81723
81284
  if (lowered.startsWith("bigserial")) {
81724
81285
  return `${withCasing2(
81725
81286
  name,
81726
81287
  casing2
81727
- )}: bigserial("${name}", { mode: "bigint" })`;
81288
+ )}: bigserial(${dbColumnName3({ name, casing: casing2, withMode: true })}{ mode: "bigint" })`;
81728
81289
  }
81729
81290
  if (lowered.startsWith("integer")) {
81730
- let out = `${withCasing2(name, casing2)}: integer("${name}")`;
81291
+ let out = `${withCasing2(name, casing2)}: integer(${dbColumnName3({ name, casing: casing2 })})`;
81731
81292
  return out;
81732
81293
  }
81733
81294
  if (lowered.startsWith("smallint")) {
81734
- let out = `${withCasing2(name, casing2)}: smallint("${name}")`;
81295
+ let out = `${withCasing2(name, casing2)}: smallint(${dbColumnName3({ name, casing: casing2 })})`;
81735
81296
  return out;
81736
81297
  }
81737
81298
  if (lowered.startsWith("bigint")) {
81738
81299
  let out = `// You can use { mode: "bigint" } if numbers are exceeding js number limitations
81739
81300
  `;
81740
- out += `${withCasing2(name, casing2)}: bigint("${name}", { mode: "number" })`;
81301
+ out += `${withCasing2(name, casing2)}: bigint(${dbColumnName3({ name, casing: casing2, withMode: true })}{ mode: "number" })`;
81741
81302
  return out;
81742
81303
  }
81743
81304
  if (lowered.startsWith("boolean")) {
81744
- let out = `${withCasing2(name, casing2)}: boolean("${name}")`;
81305
+ let out = `${withCasing2(name, casing2)}: boolean(${dbColumnName3({ name, casing: casing2 })})`;
81745
81306
  return out;
81746
81307
  }
81747
81308
  if (lowered.startsWith("double precision")) {
81748
- let out = `${withCasing2(name, casing2)}: doublePrecision("${name}")`;
81309
+ let out = `${withCasing2(name, casing2)}: doublePrecision(${dbColumnName3({ name, casing: casing2 })})`;
81749
81310
  return out;
81750
81311
  }
81751
81312
  if (lowered.startsWith("real")) {
81752
- let out = `${withCasing2(name, casing2)}: real("${name}")`;
81313
+ let out = `${withCasing2(name, casing2)}: real(${dbColumnName3({ name, casing: casing2 })})`;
81753
81314
  return out;
81754
81315
  }
81755
81316
  if (lowered.startsWith("uuid")) {
81756
- let out = `${withCasing2(name, casing2)}: uuid("${name}")`;
81317
+ let out = `${withCasing2(name, casing2)}: uuid(${dbColumnName3({ name, casing: casing2 })})`;
81757
81318
  return out;
81758
81319
  }
81759
81320
  if (lowered.startsWith("numeric")) {
@@ -81762,7 +81323,7 @@ var init_introspect_pg = __esm({
81762
81323
  const [precision, scale] = lowered.slice(8, lowered.length - 1).split(",");
81763
81324
  params = { precision, scale };
81764
81325
  }
81765
- let out = params ? `${withCasing2(name, casing2)}: numeric("${name}", ${timeConfig2(params)})` : `${withCasing2(name, casing2)}: numeric("${name}")`;
81326
+ let out = params ? `${withCasing2(name, casing2)}: numeric(${dbColumnName3({ name, casing: casing2, withMode: true })}${timeConfig2(params)})` : `${withCasing2(name, casing2)}: numeric(${dbColumnName3({ name, casing: casing2 })})`;
81766
81327
  return out;
81767
81328
  }
81768
81329
  if (lowered.startsWith("timestamp")) {
@@ -81776,7 +81337,7 @@ var init_introspect_pg = __esm({
81776
81337
  withTimezone,
81777
81338
  mode: "'string'"
81778
81339
  });
81779
- let out = params ? `${withCasing2(name, casing2)}: timestamp("${name}", ${params})` : `${withCasing2(name, casing2)}: timestamp("${name}")`;
81340
+ let out = params ? `${withCasing2(name, casing2)}: timestamp(${dbColumnName3({ name, casing: casing2, withMode: true })}${params})` : `${withCasing2(name, casing2)}: timestamp(${dbColumnName3({ name, casing: casing2 })})`;
81780
81341
  return out;
81781
81342
  }
81782
81343
  if (lowered.startsWith("time")) {
@@ -81786,44 +81347,44 @@ var init_introspect_pg = __esm({
81786
81347
  ) : null;
81787
81348
  precision = precision ? precision : null;
81788
81349
  const params = timeConfig2({ precision, withTimezone });
81789
- let out = params ? `${withCasing2(name, casing2)}: time("${name}", ${params})` : `${withCasing2(name, casing2)}: time("${name}")`;
81350
+ let out = params ? `${withCasing2(name, casing2)}: time(${dbColumnName3({ name, casing: casing2, withMode: true })}${params})` : `${withCasing2(name, casing2)}: time(${dbColumnName3({ name, casing: casing2 })})`;
81790
81351
  return out;
81791
81352
  }
81792
81353
  if (lowered.startsWith("interval")) {
81793
81354
  const params = intervalConfig(lowered);
81794
- let out = params ? `${withCasing2(name, casing2)}: interval("${name}", ${params})` : `${withCasing2(name, casing2)}: interval("${name}")`;
81355
+ let out = params ? `${withCasing2(name, casing2)}: interval(${dbColumnName3({ name, casing: casing2, withMode: true })}${params})` : `${withCasing2(name, casing2)}: interval(${dbColumnName3({ name, casing: casing2 })})`;
81795
81356
  return out;
81796
81357
  }
81797
81358
  if (lowered === "date") {
81798
- let out = `${withCasing2(name, casing2)}: date("${name}")`;
81359
+ let out = `${withCasing2(name, casing2)}: date(${dbColumnName3({ name, casing: casing2 })})`;
81799
81360
  return out;
81800
81361
  }
81801
81362
  if (lowered.startsWith("text")) {
81802
- let out = `${withCasing2(name, casing2)}: text("${name}")`;
81363
+ let out = `${withCasing2(name, casing2)}: text(${dbColumnName3({ name, casing: casing2 })})`;
81803
81364
  return out;
81804
81365
  }
81805
81366
  if (lowered.startsWith("jsonb")) {
81806
- let out = `${withCasing2(name, casing2)}: jsonb("${name}")`;
81367
+ let out = `${withCasing2(name, casing2)}: jsonb(${dbColumnName3({ name, casing: casing2 })})`;
81807
81368
  return out;
81808
81369
  }
81809
81370
  if (lowered.startsWith("json")) {
81810
- let out = `${withCasing2(name, casing2)}: json("${name}")`;
81371
+ let out = `${withCasing2(name, casing2)}: json(${dbColumnName3({ name, casing: casing2 })})`;
81811
81372
  return out;
81812
81373
  }
81813
81374
  if (lowered.startsWith("inet")) {
81814
- let out = `${withCasing2(name, casing2)}: inet("${name}")`;
81375
+ let out = `${withCasing2(name, casing2)}: inet(${dbColumnName3({ name, casing: casing2 })})`;
81815
81376
  return out;
81816
81377
  }
81817
81378
  if (lowered.startsWith("cidr")) {
81818
- let out = `${withCasing2(name, casing2)}: cidr("${name}")`;
81379
+ let out = `${withCasing2(name, casing2)}: cidr(${dbColumnName3({ name, casing: casing2 })})`;
81819
81380
  return out;
81820
81381
  }
81821
81382
  if (lowered.startsWith("macaddr8")) {
81822
- let out = `${withCasing2(name, casing2)}: macaddr8("${name}")`;
81383
+ let out = `${withCasing2(name, casing2)}: macaddr8(${dbColumnName3({ name, casing: casing2 })})`;
81823
81384
  return out;
81824
81385
  }
81825
81386
  if (lowered.startsWith("macaddr")) {
81826
- let out = `${withCasing2(name, casing2)}: macaddr("${name}")`;
81387
+ let out = `${withCasing2(name, casing2)}: macaddr(${dbColumnName3({ name, casing: casing2 })})`;
81827
81388
  return out;
81828
81389
  }
81829
81390
  if (lowered.startsWith("varchar")) {
@@ -81832,21 +81393,21 @@ var init_introspect_pg = __esm({
81832
81393
  out = `${withCasing2(
81833
81394
  name,
81834
81395
  casing2
81835
- )}: varchar("${name}", { length: ${lowered.substring(
81396
+ )}: varchar(${dbColumnName3({ name, casing: casing2, withMode: true })}{ length: ${lowered.substring(
81836
81397
  8,
81837
81398
  lowered.length - 1
81838
81399
  )} })`;
81839
81400
  } else {
81840
- out = `${withCasing2(name, casing2)}: varchar("${name}")`;
81401
+ out = `${withCasing2(name, casing2)}: varchar(${dbColumnName3({ name, casing: casing2 })})`;
81841
81402
  }
81842
81403
  return out;
81843
81404
  }
81844
81405
  if (lowered.startsWith("point")) {
81845
- let out = `${withCasing2(name, casing2)}: point("${name}")`;
81406
+ let out = `${withCasing2(name, casing2)}: point(${dbColumnName3({ name, casing: casing2 })})`;
81846
81407
  return out;
81847
81408
  }
81848
81409
  if (lowered.startsWith("line")) {
81849
- let out = `${withCasing2(name, casing2)}: point("${name}")`;
81410
+ let out = `${withCasing2(name, casing2)}: point(${dbColumnName3({ name, casing: casing2 })})`;
81850
81411
  return out;
81851
81412
  }
81852
81413
  if (lowered.startsWith("geometry")) {
@@ -81855,14 +81416,14 @@ var init_introspect_pg = __esm({
81855
81416
  if (lowered.length !== 8) {
81856
81417
  const geometryOptions = lowered.slice(9, -1).split(",");
81857
81418
  if (geometryOptions.length === 1 && geometryOptions[0] !== "") {
81858
- out = `${withCasing2(name, casing2)}: geometry("${name}", { type: "${geometryOptions[0]}" })`;
81419
+ out = `${withCasing2(name, casing2)}: geometry(${dbColumnName3({ name, casing: casing2, withMode: true })}{ type: "${geometryOptions[0]}" })`;
81859
81420
  } else if (geometryOptions.length === 2) {
81860
- out = `${withCasing2(name, casing2)}: geometry("${name}", { type: "${geometryOptions[0]}", srid: ${geometryOptions[1]} })`;
81421
+ out = `${withCasing2(name, casing2)}: geometry(${dbColumnName3({ name, casing: casing2, withMode: true })}{ type: "${geometryOptions[0]}", srid: ${geometryOptions[1]} })`;
81861
81422
  } else {
81862
81423
  isGeoUnknown = true;
81863
81424
  }
81864
81425
  } else {
81865
- out = `${withCasing2(name, casing2)}: geometry("${name}")`;
81426
+ out = `${withCasing2(name, casing2)}: geometry(${dbColumnName3({ name, casing: casing2 })})`;
81866
81427
  }
81867
81428
  if (isGeoUnknown) {
81868
81429
  let unknown2 = `// TODO: failed to parse geometry type because found more than 2 options inside geometry function '${type}'
@@ -81879,12 +81440,12 @@ var init_introspect_pg = __esm({
81879
81440
  out = `${withCasing2(
81880
81441
  name,
81881
81442
  casing2
81882
- )}: vector("${name}", { dimensions: ${lowered.substring(
81443
+ )}: vector(${dbColumnName3({ name, casing: casing2, withMode: true })}{ dimensions: ${lowered.substring(
81883
81444
  7,
81884
81445
  lowered.length - 1
81885
81446
  )} })`;
81886
81447
  } else {
81887
- out = `${withCasing2(name, casing2)}: vector("${name}")`;
81448
+ out = `${withCasing2(name, casing2)}: vector(${dbColumnName3({ name, casing: casing2 })})`;
81888
81449
  }
81889
81450
  return out;
81890
81451
  }
@@ -81894,12 +81455,12 @@ var init_introspect_pg = __esm({
81894
81455
  out = `${withCasing2(
81895
81456
  name,
81896
81457
  casing2
81897
- )}: char("${name}", { length: ${lowered.substring(
81458
+ )}: char(${dbColumnName3({ name, casing: casing2, withMode: true })}{ length: ${lowered.substring(
81898
81459
  5,
81899
81460
  lowered.length - 1
81900
81461
  )} })`;
81901
81462
  } else {
81902
- out = `${withCasing2(name, casing2)}: char("${name}")`;
81463
+ out = `${withCasing2(name, casing2)}: char(${dbColumnName3({ name, casing: casing2 })})`;
81903
81464
  }
81904
81465
  return out;
81905
81466
  }
@@ -82028,19 +81589,6 @@ var init_introspect_pg = __esm({
82028
81589
  statement += `.on(${it.columns.map((it2) => `table.${withCasing2(it2, casing2)}`).join(", ")})`;
82029
81590
  statement += it.nullsNotDistinct ? `.nullsNotDistinct()` : "";
82030
81591
  statement += `,
82031
- `;
82032
- });
82033
- return statement;
82034
- };
82035
- createTableChecks3 = (checkConstraints, casing2) => {
82036
- let statement = "";
82037
- checkConstraints.forEach((it) => {
82038
- const checkKey = withCasing2(it.name, casing2);
82039
- statement += ` ${checkKey}: `;
82040
- statement += "check(";
82041
- statement += `"${it.name}", `;
82042
- statement += `sql\`${it.value}\`)`;
82043
- statement += `,
82044
81592
  `;
82045
81593
  });
82046
81594
  return statement;
@@ -84010,9 +83558,9 @@ init_source();
84010
83558
 
84011
83559
  // src/cli/commands/check.ts
84012
83560
  init_utils();
84013
- var checkHandler = (out, dialect7) => {
84014
- const { snapshots } = prepareOutFolder(out, dialect7);
84015
- const report = validateWithReport(snapshots, dialect7);
83561
+ var checkHandler = (out, dialect4) => {
83562
+ const { snapshots } = prepareOutFolder(out, dialect4);
83563
+ const report = validateWithReport(snapshots, dialect4);
84016
83564
  if (report.nonLatest.length > 0) {
84017
83565
  console.log(
84018
83566
  report.nonLatest.map((it) => {
@@ -85299,12 +84847,14 @@ var optionBreakpoints = boolean().desc(
85299
84847
  `Prepare SQL statements with breakpoints`
85300
84848
  );
85301
84849
  var optionDriver = string().enum(...drivers).desc("Database driver");
84850
+ var optionCasing = string().enum("camelCase", "snake_case").desc("Casing for serialization");
85302
84851
  var generate = command({
85303
84852
  name: "generate",
85304
84853
  options: {
85305
84854
  config: optionConfig,
85306
84855
  dialect: optionDialect,
85307
84856
  driver: optionDriver,
84857
+ casing: optionCasing,
85308
84858
  schema: string().desc("Path to a schema file or folder"),
85309
84859
  out: optionOut,
85310
84860
  name: string().desc("Migration file name"),
@@ -85317,7 +84867,7 @@ var generate = command({
85317
84867
  "generate",
85318
84868
  opts,
85319
84869
  ["prefix", "name", "custom"],
85320
- ["driver", "breakpoints", "schema", "out", "dialect"]
84870
+ ["driver", "breakpoints", "schema", "out", "dialect", "casing"]
85321
84871
  );
85322
84872
  return prepareGenerateConfig(opts, from);
85323
84873
  },
@@ -85330,17 +84880,17 @@ var generate = command({
85330
84880
  prepareAndMigrateSqlite: prepareAndMigrateSqlite2,
85331
84881
  prepareAndMigrateLibSQL: prepareAndMigrateLibSQL2
85332
84882
  } = await Promise.resolve().then(() => (init_migrate(), migrate_exports));
85333
- const dialect7 = opts.dialect;
85334
- if (dialect7 === "postgresql") {
84883
+ const dialect4 = opts.dialect;
84884
+ if (dialect4 === "postgresql") {
85335
84885
  await prepareAndMigratePg2(opts);
85336
- } else if (dialect7 === "mysql") {
84886
+ } else if (dialect4 === "mysql") {
85337
84887
  await prepareAndMigrateMysql2(opts);
85338
- } else if (dialect7 === "sqlite") {
84888
+ } else if (dialect4 === "sqlite") {
85339
84889
  await prepareAndMigrateSqlite2(opts);
85340
- } else if (dialect7 === "turso") {
84890
+ } else if (dialect4 === "turso") {
85341
84891
  await prepareAndMigrateLibSQL2(opts);
85342
84892
  } else {
85343
- assertUnreachable(dialect7);
84893
+ assertUnreachable(dialect4);
85344
84894
  }
85345
84895
  }
85346
84896
  });
@@ -85355,9 +84905,9 @@ var migrate = command({
85355
84905
  handler: async (opts) => {
85356
84906
  await assertOrmCoreVersion();
85357
84907
  await assertPackages("drizzle-orm");
85358
- const { dialect: dialect7, schema: schema5, table: table4, out, credentials: credentials2 } = opts;
84908
+ const { dialect: dialect4, schema: schema5, table: table4, out, credentials: credentials2 } = opts;
85359
84909
  try {
85360
- if (dialect7 === "postgresql") {
84910
+ if (dialect4 === "postgresql") {
85361
84911
  if ("driver" in credentials2) {
85362
84912
  const { driver: driver2 } = credentials2;
85363
84913
  if (driver2 === "aws-data-api") {
@@ -85388,7 +84938,7 @@ var migrate = command({
85388
84938
  migrationsSchema: schema5
85389
84939
  })
85390
84940
  );
85391
- } else if (dialect7 === "mysql") {
84941
+ } else if (dialect4 === "mysql") {
85392
84942
  const { connectToMySQL: connectToMySQL2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
85393
84943
  const { migrate: migrate2 } = await connectToMySQL2(credentials2);
85394
84944
  await (0, import_hanji13.renderWithTask)(
@@ -85399,7 +84949,7 @@ var migrate = command({
85399
84949
  migrationsSchema: schema5
85400
84950
  })
85401
84951
  );
85402
- } else if (dialect7 === "sqlite") {
84952
+ } else if (dialect4 === "sqlite") {
85403
84953
  const { connectToSQLite: connectToSQLite2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
85404
84954
  const { migrate: migrate2 } = await connectToSQLite2(credentials2);
85405
84955
  await (0, import_hanji13.renderWithTask)(
@@ -85410,7 +84960,7 @@ var migrate = command({
85410
84960
  migrationsSchema: schema5
85411
84961
  })
85412
84962
  );
85413
- } else if (dialect7 === "turso") {
84963
+ } else if (dialect4 === "turso") {
85414
84964
  const { connectToLibSQL: connectToLibSQL2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
85415
84965
  const { migrate: migrate2 } = await connectToLibSQL2(credentials2);
85416
84966
  await (0, import_hanji13.renderWithTask)(
@@ -85422,7 +84972,7 @@ var migrate = command({
85422
84972
  })
85423
84973
  );
85424
84974
  } else {
85425
- assertUnreachable(dialect7);
84975
+ assertUnreachable(dialect4);
85426
84976
  }
85427
84977
  } catch (e2) {
85428
84978
  console.error(e2);
@@ -85456,6 +85006,7 @@ var push = command({
85456
85006
  options: {
85457
85007
  config: optionConfig,
85458
85008
  dialect: optionDialect,
85009
+ casing: optionCasing,
85459
85010
  schema: string().desc("Path to a schema file or folder"),
85460
85011
  ...optionsFilters,
85461
85012
  ...optionsDatabaseCredentials,
@@ -85484,7 +85035,8 @@ var push = command({
85484
85035
  "authToken",
85485
85036
  "schemaFilters",
85486
85037
  "extensionsFilters",
85487
- "tablesFilter"
85038
+ "tablesFilter",
85039
+ "casing"
85488
85040
  ]
85489
85041
  );
85490
85042
  return preparePushConfig(opts, from);
@@ -85493,17 +85045,18 @@ var push = command({
85493
85045
  await assertPackages("drizzle-orm");
85494
85046
  await assertOrmCoreVersion();
85495
85047
  const {
85496
- dialect: dialect7,
85048
+ dialect: dialect4,
85497
85049
  schemaPath,
85498
85050
  strict,
85499
85051
  verbose,
85500
85052
  credentials: credentials2,
85501
85053
  tablesFilter,
85502
85054
  schemasFilter,
85503
- force
85055
+ force,
85056
+ casing: casing2
85504
85057
  } = config;
85505
85058
  try {
85506
- if (dialect7 === "mysql") {
85059
+ if (dialect4 === "mysql") {
85507
85060
  const { mysqlPush: mysqlPush2 } = await Promise.resolve().then(() => (init_push(), push_exports));
85508
85061
  await mysqlPush2(
85509
85062
  schemaPath,
@@ -85511,9 +85064,10 @@ var push = command({
85511
85064
  tablesFilter,
85512
85065
  strict,
85513
85066
  verbose,
85514
- force
85067
+ force,
85068
+ casing2
85515
85069
  );
85516
- } else if (dialect7 === "postgresql") {
85070
+ } else if (dialect4 === "postgresql") {
85517
85071
  if ("driver" in credentials2) {
85518
85072
  const { driver: driver2 } = credentials2;
85519
85073
  if (driver2 === "aws-data-api") {
@@ -85542,9 +85096,10 @@ var push = command({
85542
85096
  credentials2,
85543
85097
  tablesFilter,
85544
85098
  schemasFilter,
85545
- force
85099
+ force,
85100
+ casing2
85546
85101
  );
85547
- } else if (dialect7 === "sqlite") {
85102
+ } else if (dialect4 === "sqlite") {
85548
85103
  const { sqlitePush: sqlitePush2 } = await Promise.resolve().then(() => (init_push(), push_exports));
85549
85104
  await sqlitePush2(
85550
85105
  schemaPath,
@@ -85552,9 +85107,10 @@ var push = command({
85552
85107
  strict,
85553
85108
  credentials2,
85554
85109
  tablesFilter,
85555
- force
85110
+ force,
85111
+ casing2
85556
85112
  );
85557
- } else if (dialect7 === "turso") {
85113
+ } else if (dialect4 === "turso") {
85558
85114
  const { libSQLPush: libSQLPush2 } = await Promise.resolve().then(() => (init_push(), push_exports));
85559
85115
  await libSQLPush2(
85560
85116
  schemaPath,
@@ -85562,10 +85118,11 @@ var push = command({
85562
85118
  strict,
85563
85119
  credentials2,
85564
85120
  tablesFilter,
85565
- force
85121
+ force,
85122
+ casing2
85566
85123
  );
85567
85124
  } else {
85568
- assertUnreachable(dialect7);
85125
+ assertUnreachable(dialect4);
85569
85126
  }
85570
85127
  } catch (e2) {
85571
85128
  console.error(e2);
@@ -85586,8 +85143,8 @@ var check = command({
85586
85143
  },
85587
85144
  handler: async (config) => {
85588
85145
  await assertOrmCoreVersion();
85589
- const { out, dialect: dialect7 } = config;
85590
- checkHandler(out, dialect7);
85146
+ const { out, dialect: dialect4 } = config;
85147
+ checkHandler(out, dialect4);
85591
85148
  console.log("Everything's fine \u{1F436}\u{1F525}");
85592
85149
  }
85593
85150
  });
@@ -85604,15 +85161,15 @@ var up = command({
85604
85161
  },
85605
85162
  handler: async (config) => {
85606
85163
  await assertOrmCoreVersion();
85607
- const { out, dialect: dialect7 } = config;
85164
+ const { out, dialect: dialect4 } = config;
85608
85165
  await assertPackages("drizzle-orm");
85609
- if (dialect7 === "postgresql") {
85166
+ if (dialect4 === "postgresql") {
85610
85167
  upPgHandler(out);
85611
85168
  }
85612
- if (dialect7 === "mysql") {
85169
+ if (dialect4 === "mysql") {
85613
85170
  upMysqlHandler(out);
85614
85171
  }
85615
- if (dialect7 === "sqlite" || dialect7 === "turso") {
85172
+ if (dialect4 === "sqlite" || dialect4 === "turso") {
85616
85173
  upSqliteHandler(out);
85617
85174
  }
85618
85175
  }
@@ -85659,7 +85216,7 @@ var pull = command({
85659
85216
  await assertPackages("drizzle-orm");
85660
85217
  await assertOrmCoreVersion();
85661
85218
  const {
85662
- dialect: dialect7,
85219
+ dialect: dialect4,
85663
85220
  credentials: credentials2,
85664
85221
  out,
85665
85222
  casing: casing2,
@@ -85676,7 +85233,7 @@ var pull = command({
85676
85233
  );
85677
85234
  console.log();
85678
85235
  try {
85679
- if (dialect7 === "postgresql") {
85236
+ if (dialect4 === "postgresql") {
85680
85237
  if ("driver" in credentials2) {
85681
85238
  const { driver: driver2 } = credentials2;
85682
85239
  if (driver2 === "aws-data-api") {
@@ -85707,7 +85264,7 @@ var pull = command({
85707
85264
  schemasFilter,
85708
85265
  prefix2
85709
85266
  );
85710
- } else if (dialect7 === "mysql") {
85267
+ } else if (dialect4 === "mysql") {
85711
85268
  const { introspectMysql: introspectMysql2 } = await Promise.resolve().then(() => (init_introspect(), introspect_exports));
85712
85269
  await introspectMysql2(
85713
85270
  casing2,
@@ -85717,7 +85274,7 @@ var pull = command({
85717
85274
  tablesFilter,
85718
85275
  prefix2
85719
85276
  );
85720
- } else if (dialect7 === "sqlite") {
85277
+ } else if (dialect4 === "sqlite") {
85721
85278
  const { introspectSqlite: introspectSqlite2 } = await Promise.resolve().then(() => (init_introspect(), introspect_exports));
85722
85279
  await introspectSqlite2(
85723
85280
  casing2,
@@ -85727,7 +85284,7 @@ var pull = command({
85727
85284
  tablesFilter,
85728
85285
  prefix2
85729
85286
  );
85730
- } else if (dialect7 === "turso") {
85287
+ } else if (dialect4 === "turso") {
85731
85288
  const { introspectLibSQL: introspectLibSQL2 } = await Promise.resolve().then(() => (init_introspect(), introspect_exports));
85732
85289
  await introspectLibSQL2(
85733
85290
  casing2,
@@ -85738,7 +85295,7 @@ var pull = command({
85738
85295
  prefix2
85739
85296
  );
85740
85297
  } else {
85741
- assertUnreachable(dialect7);
85298
+ assertUnreachable(dialect4);
85742
85299
  }
85743
85300
  } catch (e2) {
85744
85301
  console.error(e2);
@@ -85776,7 +85333,7 @@ var studio = command({
85776
85333
  await assertPackages("drizzle-orm");
85777
85334
  assertStudioNodeVersion();
85778
85335
  const {
85779
- dialect: dialect7,
85336
+ dialect: dialect4,
85780
85337
  schema: schemaPath,
85781
85338
  port,
85782
85339
  host,
@@ -85792,7 +85349,7 @@ var studio = command({
85792
85349
  } = await Promise.resolve().then(() => (init_studio2(), studio_exports));
85793
85350
  let setup;
85794
85351
  try {
85795
- if (dialect7 === "postgresql") {
85352
+ if (dialect4 === "postgresql") {
85796
85353
  if ("driver" in credentials2) {
85797
85354
  const { driver: driver2 } = credentials2;
85798
85355
  if (driver2 === "aws-data-api") {
@@ -85815,17 +85372,17 @@ var studio = command({
85815
85372
  }
85816
85373
  const { schema: schema5, relations: relations4, files } = schemaPath ? await preparePgSchema2(schemaPath) : { schema: {}, relations: {}, files: [] };
85817
85374
  setup = await drizzleForPostgres2(credentials2, schema5, relations4, files);
85818
- } else if (dialect7 === "mysql") {
85375
+ } else if (dialect4 === "mysql") {
85819
85376
  const { schema: schema5, relations: relations4, files } = schemaPath ? await prepareMySqlSchema2(schemaPath) : { schema: {}, relations: {}, files: [] };
85820
85377
  setup = await drizzleForMySQL2(credentials2, schema5, relations4, files);
85821
- } else if (dialect7 === "sqlite") {
85378
+ } else if (dialect4 === "sqlite") {
85822
85379
  const { schema: schema5, relations: relations4, files } = schemaPath ? await prepareSQLiteSchema2(schemaPath) : { schema: {}, relations: {}, files: [] };
85823
85380
  setup = await drizzleForSQLite2(credentials2, schema5, relations4, files);
85824
- } else if (dialect7 === "turso") {
85381
+ } else if (dialect4 === "turso") {
85825
85382
  const { schema: schema5, relations: relations4, files } = schemaPath ? await prepareSQLiteSchema2(schemaPath) : { schema: {}, relations: {}, files: [] };
85826
85383
  setup = await drizzleForLibSQL(credentials2, schema5, relations4, files);
85827
85384
  } else {
85828
- assertUnreachable(dialect7);
85385
+ assertUnreachable(dialect4);
85829
85386
  }
85830
85387
  const { prepareServer: prepareServer2 } = await Promise.resolve().then(() => (init_studio2(), studio_exports));
85831
85388
  const server = await prepareServer2(setup);
@@ -85876,7 +85433,7 @@ init_utils2();
85876
85433
  var version2 = async () => {
85877
85434
  const { npmVersion } = await ormCoreVersions();
85878
85435
  const ormVersion = npmVersion ? `drizzle-orm: v${npmVersion}` : "";
85879
- const envVersion = "0.25.0-178591";
85436
+ const envVersion = "0.25.0-1f15bfd";
85880
85437
  const kitVersion = envVersion ? `v${envVersion}` : "--";
85881
85438
  const versions = `drizzle-kit: ${kitVersion}
85882
85439
  ${ormVersion}`;