drizzle-kit 0.20.14-1f99bf7 → 0.20.14-3ab22ec

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. package/bin.cjs +36859 -33936
  2. package/cli/commands/migrate.d.ts +24 -24
  3. package/cli/commands/mysqlIntrospect.d.ts +8 -8
  4. package/cli/commands/mysqlPushUtils.d.ts +2 -2
  5. package/cli/commands/mysqlUp.d.ts +2 -2
  6. package/cli/commands/pgConnect.d.ts +1 -1
  7. package/cli/commands/pgIntrospect.d.ts +9 -9
  8. package/cli/commands/pgPushUtils.d.ts +2 -2
  9. package/cli/commands/pgUp.d.ts +2 -2
  10. package/cli/commands/sqliteIntrospect.d.ts +9 -9
  11. package/cli/commands/sqlitePushUtils.d.ts +3 -3
  12. package/cli/commands/sqliteUtils.d.ts +162 -0
  13. package/cli/commands/upFolders.d.ts +1 -1
  14. package/cli/commands/utils.d.ts +259 -14
  15. package/cli/validations/common.d.ts +7 -205
  16. package/cli/validations/mysql.d.ts +1 -6
  17. package/cli/validations/pg.d.ts +1 -6
  18. package/cli/views.d.ts +1 -1
  19. package/global.d.ts +1 -1
  20. package/index.d.mts +6 -8
  21. package/index.d.ts +6 -8
  22. package/index.js +0 -1
  23. package/introspect-mysql.d.ts +1 -1
  24. package/introspect-pg.d.ts +1 -1
  25. package/introspect-sqlite.d.ts +1 -1
  26. package/jsonStatements.d.ts +1 -1
  27. package/package.json +8 -5
  28. package/payload.js +1527 -1841
  29. package/payload.mjs +1531 -1844
  30. package/schemaValidator.d.ts +40 -40
  31. package/serializer/mysqlSchema.d.ts +616 -1854
  32. package/serializer/mysqlSerializer.d.ts +2 -2
  33. package/serializer/pgSchema.d.ts +684 -1009
  34. package/serializer/sqliteSchema.d.ts +570 -144
  35. package/serializer/sqliteSerializer.d.ts +2 -2
  36. package/snapshotsDiffer.d.ts +20 -24
  37. package/utils-studio.js +8 -21
  38. package/utils-studio.mjs +8 -20
  39. package/utils.d.ts +12 -12
  40. package/utils.js +735 -849
  41. package/utils.mjs +736 -849
  42. package/cli/validations/cli.d.ts +0 -104
  43. package/cli/validations/sqlite.d.ts +0 -382
package/payload.mjs CHANGED
@@ -1085,7 +1085,6 @@ var require_hanji = __commonJS({
1085
1085
  var import_hanji, info, error, schema, isRenamePromptItem, ResolveColumnSelect, ResolveTableSelect, ResolveSchemasSelect;
1086
1086
  var init_views = __esm({
1087
1087
  "src/cli/views.ts"() {
1088
- "use strict";
1089
1088
  init_source();
1090
1089
  import_hanji = __toESM(require_hanji());
1091
1090
  info = (msg, greyMsg = "") => {
@@ -1107,7 +1106,7 @@ var init_views = __esm({
1107
1106
  )}`;
1108
1107
  }).join("\n");
1109
1108
  msg += "\n";
1110
- const enums = Object.values("enums" in schema4 ? schema4["enums"] || {} : {});
1109
+ const enums = Object.values(schema4["enums"] || {});
1111
1110
  if (enums.length > 0) {
1112
1111
  msg += "\n";
1113
1112
  msg += source_default.bold(`${enums.length} enums
@@ -1122,7 +1121,7 @@ var init_views = __esm({
1122
1121
  return msg;
1123
1122
  };
1124
1123
  isRenamePromptItem = (item) => {
1125
- return "from" in item && "to" in item;
1124
+ return item["from"] && item["to"];
1126
1125
  };
1127
1126
  ResolveColumnSelect = class extends import_hanji.Prompt {
1128
1127
  constructor(tableName, base, data) {
@@ -1272,7 +1271,6 @@ import { is } from "drizzle-orm";
1272
1271
  var prepareFromExports, prepareFromMySqlImports;
1273
1272
  var init_mysqlImports = __esm({
1274
1273
  "src/serializer/mysqlImports.ts"() {
1275
- "use strict";
1276
1274
  init_utils();
1277
1275
  prepareFromExports = (exports) => {
1278
1276
  const tables = [];
@@ -1312,7 +1310,6 @@ var init_mysqlImports = __esm({
1312
1310
  var withStyle;
1313
1311
  var init_outputs = __esm({
1314
1312
  "src/cli/validations/outputs.ts"() {
1315
- "use strict";
1316
1313
  init_source();
1317
1314
  withStyle = {
1318
1315
  error: (str) => `${source_default.red(`${source_default.white.bgRed(" Invalid input ")} ${str}`)}`,
@@ -1358,7 +1355,6 @@ function clearDefaults(defaultValue, collate) {
1358
1355
  var dialect, indexName, generateMySqlSnapshot, fromDatabase;
1359
1356
  var init_mysqlSerializer = __esm({
1360
1357
  "src/serializer/mysqlSerializer.ts"() {
1361
- "use strict";
1362
1358
  init_serializer();
1363
1359
  init_outputs();
1364
1360
  init_source();
@@ -1570,8 +1566,7 @@ We have encountered a collision between the index name on columns ${source_defau
1570
1566
  lock: value.config.lock
1571
1567
  };
1572
1568
  });
1573
- const tableKey = `${schema4 || "public"}.${tableName}`;
1574
- result[tableKey] = {
1569
+ result[tableName] = {
1575
1570
  name: tableName,
1576
1571
  schema: schema4,
1577
1572
  columns: columnsObject,
@@ -1585,7 +1580,7 @@ We have encountered a collision between the index name on columns ${source_defau
1585
1580
  mysqlSchemas.map((it) => [it.schemaName, it.schemaName])
1586
1581
  );
1587
1582
  return {
1588
- version: "6",
1583
+ version: "5",
1589
1584
  dialect: "mysql",
1590
1585
  tables: result,
1591
1586
  schemas,
@@ -1840,7 +1835,7 @@ We have encountered a collision between the index name on columns ${source_defau
1840
1835
  }
1841
1836
  const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
1842
1837
  return {
1843
- version: "6",
1838
+ version: "5",
1844
1839
  dialect: "mysql",
1845
1840
  tables: result,
1846
1841
  schemas: schemasObject,
@@ -1871,7 +1866,6 @@ import { is as is3, SQL as SQL2, getTableName as getTableName2 } from "drizzle-o
1871
1866
  var dialect2, indexName2, generatePgSnapshot, trimChar, fromDatabase2, columnToDefault, defaultForColumn;
1872
1867
  var init_pgSerializer = __esm({
1873
1868
  "src/serializer/pgSerializer.ts"() {
1874
- "use strict";
1875
1869
  init_serializer();
1876
1870
  init_source();
1877
1871
  init_outputs();
@@ -2059,8 +2053,7 @@ ${withStyle.errorWarning(
2059
2053
  isUnique: value.config.unique ?? false
2060
2054
  };
2061
2055
  });
2062
- const tableKey = `${schema4 ?? "public"}.${tableName}`;
2063
- result[tableKey] = {
2056
+ result[tableName] = {
2064
2057
  name: tableName,
2065
2058
  schema: schema4 ?? "",
2066
2059
  columns: columnsObject,
@@ -2089,7 +2082,7 @@ ${withStyle.errorWarning(
2089
2082
  }).map((it) => [it.schemaName, it.schemaName])
2090
2083
  );
2091
2084
  return {
2092
- version: "6",
2085
+ version: "5",
2093
2086
  dialect: "pg",
2094
2087
  tables: result,
2095
2088
  enums: enumsToReturn,
@@ -2110,7 +2103,7 @@ ${withStyle.errorWarning(
2110
2103
  --end;
2111
2104
  return start > 0 || end < str.length ? str.substring(start, end) : str.toString();
2112
2105
  };
2113
- fromDatabase2 = async (db, tablesFilter = () => true, schemaFilters, progressCallback) => {
2106
+ fromDatabase2 = async (db, tablesFilter = (table4) => true, schemaFilters, progressCallback) => {
2114
2107
  const result = {};
2115
2108
  const internals = { tables: {} };
2116
2109
  const where = schemaFilters.map((t) => `table_schema = '${t}'`).join(" or ");
@@ -2437,7 +2430,7 @@ ${withStyle.errorWarning(
2437
2430
  }
2438
2431
  const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
2439
2432
  return {
2440
- version: "6",
2433
+ version: "5",
2441
2434
  dialect: "pg",
2442
2435
  tables: result,
2443
2436
  enums: enumsToReturn,
@@ -2520,7 +2513,6 @@ import { is as is4 } from "drizzle-orm";
2520
2513
  var prepareFromExports2, prepareFromSqliteImports;
2521
2514
  var init_sqliteImports = __esm({
2522
2515
  "src/serializer/sqliteImports.ts"() {
2523
- "use strict";
2524
2516
  init_utils();
2525
2517
  prepareFromExports2 = (exports) => {
2526
2518
  const tables = [];
@@ -2601,7 +2593,6 @@ function mapSqlToSqliteType(sqlType) {
2601
2593
  var dialect3, generateSqliteSnapshot, fromDatabase3;
2602
2594
  var init_sqliteSerializer = __esm({
2603
2595
  "src/serializer/sqliteSerializer.ts"() {
2604
- "use strict";
2605
2596
  init_serializer();
2606
2597
  init_outputs();
2607
2598
  init_source();
@@ -2975,7 +2966,6 @@ import * as glob from "glob";
2975
2966
  var sqlToStr, serializeMySql, serializePg, serializeSQLite, prepareFilenames;
2976
2967
  var init_serializer = __esm({
2977
2968
  "src/serializer/index.ts"() {
2978
- "use strict";
2979
2969
  init_source();
2980
2970
  init_views();
2981
2971
  sqlToStr = (sql2) => {
@@ -3042,26 +3032,6 @@ ${filenames.join("\n")}
3042
3032
  }
3043
3033
  });
3044
3034
 
3045
- // src/global.ts
3046
- function assertUnreachable(x) {
3047
- throw new Error("Didn't expect to get here");
3048
- }
3049
- var originUUID, snapshotVersion, mapValues;
3050
- var init_global = __esm({
3051
- "src/global.ts"() {
3052
- "use strict";
3053
- originUUID = "00000000-0000-0000-0000-000000000000";
3054
- snapshotVersion = "6";
3055
- mapValues = (obj, map) => {
3056
- const result = Object.keys(obj).reduce(function(result2, key) {
3057
- result2[key] = map(obj[key]);
3058
- return result2;
3059
- }, {});
3060
- return result;
3061
- };
3062
- }
3063
- });
3064
-
3065
3035
  // node_modules/.pnpm/zod@3.20.2/node_modules/zod/lib/index.mjs
3066
3036
  function getErrorMap() {
3067
3037
  return overrideErrorMap;
@@ -6208,1250 +6178,132 @@ var init_lib = __esm({
6208
6178
  }
6209
6179
  });
6210
6180
 
6211
- // src/serializer/mysqlSchema.ts
6212
- var index, fk, column, tableV3, compositePK, uniqueConstraint, tableV4, table, kitInternals, dialect4, schemaHash, schemaInternalV3, schemaInternalV4, schemaInternalV5, schemaInternalV6, schemaInternal, schemaV3, schemaV4, schemaV5, schema2, tableSquashedV4, tableSquashed, schemaSquashed, schemaSquashedV4, MySqlSquasher, squashMysqlScheme, mysqlSchema, mysqlSchemaV5, mysqlSchemaSquashed, backwardCompatibleMysqlSchema, dryMySql;
6213
- var init_mysqlSchema = __esm({
6214
- "src/serializer/mysqlSchema.ts"() {
6215
- "use strict";
6216
- init_global();
6217
- init_lib();
6218
- index = objectType({
6219
- name: stringType(),
6220
- columns: stringType().array(),
6221
- isUnique: booleanType(),
6222
- using: enumType(["btree", "hash"]).optional(),
6223
- algorithm: enumType(["default", "inplace", "copy"]).optional(),
6224
- lock: enumType(["default", "none", "shared", "exclusive"]).optional()
6225
- }).strict();
6226
- fk = objectType({
6227
- name: stringType(),
6228
- tableFrom: stringType(),
6229
- columnsFrom: stringType().array(),
6230
- tableTo: stringType(),
6231
- columnsTo: stringType().array(),
6232
- onUpdate: stringType().optional(),
6233
- onDelete: stringType().optional()
6234
- }).strict();
6235
- column = objectType({
6236
- name: stringType(),
6237
- type: stringType(),
6238
- primaryKey: booleanType(),
6239
- notNull: booleanType(),
6240
- autoincrement: booleanType().optional(),
6241
- default: anyType().optional(),
6242
- onUpdate: anyType().optional()
6243
- }).strict();
6244
- tableV3 = objectType({
6245
- name: stringType(),
6246
- columns: recordType(stringType(), column),
6247
- indexes: recordType(stringType(), index),
6248
- foreignKeys: recordType(stringType(), fk)
6249
- }).strict();
6250
- compositePK = objectType({
6251
- name: stringType(),
6252
- columns: stringType().array()
6253
- }).strict();
6254
- uniqueConstraint = objectType({
6255
- name: stringType(),
6256
- columns: stringType().array()
6257
- }).strict();
6258
- tableV4 = objectType({
6259
- name: stringType(),
6260
- schema: stringType().optional(),
6261
- columns: recordType(stringType(), column),
6262
- indexes: recordType(stringType(), index),
6263
- foreignKeys: recordType(stringType(), fk)
6264
- }).strict();
6265
- table = objectType({
6266
- name: stringType(),
6267
- schema: stringType().optional(),
6268
- columns: recordType(stringType(), column),
6269
- indexes: recordType(stringType(), index),
6270
- foreignKeys: recordType(stringType(), fk),
6271
- compositePrimaryKeys: recordType(stringType(), compositePK),
6272
- uniqueConstraints: recordType(stringType(), uniqueConstraint).default({})
6273
- }).strict();
6274
- kitInternals = objectType({
6275
- tables: recordType(
6276
- stringType(),
6277
- objectType({
6278
- columns: recordType(
6279
- stringType(),
6280
- objectType({ isDefaultAnExpression: booleanType().optional() }).optional()
6281
- )
6282
- }).optional()
6283
- )
6284
- }).optional();
6285
- dialect4 = literalType("mysql");
6286
- schemaHash = objectType({
6287
- id: stringType(),
6288
- prevId: stringType()
6289
- });
6290
- schemaInternalV3 = objectType({
6291
- version: literalType("3"),
6292
- dialect: dialect4,
6293
- tables: recordType(stringType(), tableV3)
6294
- }).strict();
6295
- schemaInternalV4 = objectType({
6296
- version: literalType("4"),
6297
- dialect: dialect4,
6298
- tables: recordType(stringType(), tableV4),
6299
- schemas: recordType(stringType(), stringType())
6300
- }).strict();
6301
- schemaInternalV5 = objectType({
6302
- version: literalType("5"),
6303
- dialect: dialect4,
6304
- tables: recordType(stringType(), table),
6305
- schemas: recordType(stringType(), stringType()),
6306
- _meta: objectType({
6307
- schemas: recordType(stringType(), stringType()),
6308
- tables: recordType(stringType(), stringType()),
6309
- columns: recordType(stringType(), stringType())
6310
- }),
6311
- internal: kitInternals
6312
- }).strict();
6313
- schemaInternalV6 = objectType({
6314
- version: literalType("6"),
6315
- dialect: dialect4,
6316
- tables: recordType(stringType(), table),
6317
- schemas: recordType(stringType(), stringType()),
6318
- _meta: objectType({
6319
- schemas: recordType(stringType(), stringType()),
6320
- tables: recordType(stringType(), stringType()),
6321
- columns: recordType(stringType(), stringType())
6322
- }),
6323
- internal: kitInternals
6324
- }).strict();
6325
- schemaInternal = objectType({
6326
- version: literalType("6"),
6327
- dialect: dialect4,
6328
- tables: recordType(stringType(), table),
6329
- schemas: recordType(stringType(), stringType()),
6330
- _meta: objectType({
6331
- schemas: recordType(stringType(), stringType()),
6332
- tables: recordType(stringType(), stringType()),
6333
- columns: recordType(stringType(), stringType())
6334
- }),
6335
- internal: kitInternals
6336
- }).strict();
6337
- schemaV3 = schemaInternalV3.merge(schemaHash);
6338
- schemaV4 = schemaInternalV4.merge(schemaHash);
6339
- schemaV5 = schemaInternalV5.merge(schemaHash);
6340
- schema2 = schemaInternal.merge(schemaHash);
6341
- tableSquashedV4 = objectType({
6342
- name: stringType(),
6343
- schema: stringType().optional(),
6344
- columns: recordType(stringType(), column),
6345
- indexes: recordType(stringType(), stringType()),
6346
- foreignKeys: recordType(stringType(), stringType())
6347
- }).strict();
6348
- tableSquashed = objectType({
6349
- name: stringType(),
6350
- schema: stringType().optional(),
6351
- columns: recordType(stringType(), column),
6352
- indexes: recordType(stringType(), stringType()),
6353
- foreignKeys: recordType(stringType(), stringType()),
6354
- compositePrimaryKeys: recordType(stringType(), stringType()),
6355
- uniqueConstraints: recordType(stringType(), stringType()).default({})
6356
- }).strict();
6357
- schemaSquashed = objectType({
6358
- version: literalType("5"),
6359
- dialect: dialect4,
6360
- tables: recordType(stringType(), tableSquashed),
6361
- schemas: recordType(stringType(), stringType())
6362
- }).strict();
6363
- schemaSquashedV4 = objectType({
6364
- version: literalType("4"),
6365
- dialect: dialect4,
6366
- tables: recordType(stringType(), tableSquashedV4),
6367
- schemas: recordType(stringType(), stringType())
6368
- }).strict();
6369
- MySqlSquasher = {
6370
- squashIdx: (idx) => {
6371
- index.parse(idx);
6372
- return `${idx.name};${idx.columns.join(",")};${idx.isUnique};${idx.using ?? ""};${idx.algorithm ?? ""};${idx.lock ?? ""}`;
6373
- },
6374
- unsquashIdx: (input) => {
6375
- const [name, columnsString, isUnique, using, algorithm, lock] = input.split(";");
6376
- const destructed = {
6377
- name,
6378
- columns: columnsString.split(","),
6379
- isUnique: isUnique === "true",
6380
- using: using ? using : void 0,
6381
- algorithm: algorithm ? algorithm : void 0,
6382
- lock: lock ? lock : void 0
6383
- };
6384
- return index.parse(destructed);
6385
- },
6386
- squashPK: (pk) => {
6387
- return `${pk.name};${pk.columns.join(",")}`;
6388
- },
6389
- unsquashPK: (pk) => {
6390
- const splitted = pk.split(";");
6391
- return { name: splitted[0], columns: splitted[1].split(",") };
6392
- },
6393
- squashUnique: (unq) => {
6394
- return `${unq.name};${unq.columns.join(",")}`;
6395
- },
6396
- unsquashUnique: (unq) => {
6397
- const [name, columns] = unq.split(";");
6398
- return { name, columns: columns.split(",") };
6399
- },
6400
- squashFK: (fk4) => {
6401
- return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""}`;
6402
- },
6403
- unsquashFK: (input) => {
6404
- const [
6405
- name,
6406
- tableFrom,
6407
- columnsFromStr,
6408
- tableTo,
6409
- columnsToStr,
6410
- onUpdate,
6411
- onDelete
6412
- ] = input.split(";");
6413
- const result = fk.parse({
6414
- name,
6415
- tableFrom,
6416
- columnsFrom: columnsFromStr.split(","),
6417
- tableTo,
6418
- columnsTo: columnsToStr.split(","),
6419
- onUpdate,
6420
- onDelete
6421
- });
6422
- return result;
6181
+ // src/cli/commands/_es5.ts
6182
+ var es5_exports = {};
6183
+ __export(es5_exports, {
6184
+ default: () => es5_default
6185
+ });
6186
+ var _, es5_default;
6187
+ var init_es5 = __esm({
6188
+ "src/cli/commands/_es5.ts"() {
6189
+ _ = "";
6190
+ es5_default = _;
6191
+ }
6192
+ });
6193
+
6194
+ // node_modules/.pnpm/ms@2.1.2/node_modules/ms/index.js
6195
+ var require_ms = __commonJS({
6196
+ "node_modules/.pnpm/ms@2.1.2/node_modules/ms/index.js"(exports, module) {
6197
+ var s = 1e3;
6198
+ var m = s * 60;
6199
+ var h = m * 60;
6200
+ var d = h * 24;
6201
+ var w = d * 7;
6202
+ var y = d * 365.25;
6203
+ module.exports = function(val, options) {
6204
+ options = options || {};
6205
+ var type = typeof val;
6206
+ if (type === "string" && val.length > 0) {
6207
+ return parse(val);
6208
+ } else if (type === "number" && isFinite(val)) {
6209
+ return options.long ? fmtLong(val) : fmtShort(val);
6423
6210
  }
6424
- };
6425
- squashMysqlScheme = (json) => {
6426
- const mappedTables = Object.fromEntries(
6427
- Object.entries(json.tables).map((it) => {
6428
- const squashedIndexes = mapValues(it[1].indexes, (index4) => {
6429
- return MySqlSquasher.squashIdx(index4);
6430
- });
6431
- const squashedFKs = mapValues(it[1].foreignKeys, (fk4) => {
6432
- return MySqlSquasher.squashFK(fk4);
6433
- });
6434
- const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => {
6435
- return MySqlSquasher.squashPK(pk);
6436
- });
6437
- const squashedUniqueConstraints = mapValues(
6438
- it[1].uniqueConstraints,
6439
- (unq) => {
6440
- return MySqlSquasher.squashUnique(unq);
6441
- }
6442
- );
6443
- return [
6444
- it[0],
6445
- {
6446
- name: it[1].name,
6447
- schema: it[1].schema,
6448
- columns: it[1].columns,
6449
- indexes: squashedIndexes,
6450
- foreignKeys: squashedFKs,
6451
- compositePrimaryKeys: squashedPKs,
6452
- uniqueConstraints: squashedUniqueConstraints
6453
- }
6454
- ];
6455
- })
6211
+ throw new Error(
6212
+ "val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
6456
6213
  );
6457
- return {
6458
- version: "5",
6459
- dialect: json.dialect,
6460
- tables: mappedTables,
6461
- schemas: json.schemas
6462
- };
6463
6214
  };
6464
- mysqlSchema = schema2;
6465
- mysqlSchemaV5 = schemaV5;
6466
- mysqlSchemaSquashed = schemaSquashed;
6467
- backwardCompatibleMysqlSchema = unionType([mysqlSchemaV5, schema2]);
6468
- dryMySql = mysqlSchema.parse({
6469
- version: snapshotVersion,
6470
- dialect: "mysql",
6471
- id: originUUID,
6472
- prevId: "",
6473
- tables: {},
6474
- schemas: {},
6475
- _meta: {
6476
- schemas: {},
6477
- tables: {},
6478
- columns: {}
6215
+ function parse(str) {
6216
+ str = String(str);
6217
+ if (str.length > 100) {
6218
+ return;
6479
6219
  }
6480
- });
6481
- }
6482
- });
6483
-
6484
- // src/serializer/pgSchema.ts
6485
- var indexV2, columnV2, tableV2, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, index2, fk2, column2, tableV32, compositePK2, uniqueConstraint2, tableV42, table2, schemaHash2, kitInternals2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternalV5, pgSchemaExternal, pgSchemaInternal, tableSquashed2, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchemaV5, pgSchema, backwardCompatiblePgSchema, PgSquasher, squashPgScheme, dryPg;
6486
- var init_pgSchema = __esm({
6487
- "src/serializer/pgSchema.ts"() {
6488
- "use strict";
6489
- init_global();
6490
- init_lib();
6491
- indexV2 = objectType({
6492
- name: stringType(),
6493
- columns: recordType(
6494
- stringType(),
6495
- objectType({
6496
- name: stringType()
6497
- })
6498
- ),
6499
- isUnique: booleanType()
6500
- }).strict();
6501
- columnV2 = objectType({
6502
- name: stringType(),
6503
- type: stringType(),
6504
- primaryKey: booleanType(),
6505
- notNull: booleanType(),
6506
- default: anyType().optional(),
6507
- references: stringType().optional()
6508
- }).strict();
6509
- tableV2 = objectType({
6510
- name: stringType(),
6511
- columns: recordType(stringType(), columnV2),
6512
- indexes: recordType(stringType(), indexV2)
6513
- }).strict();
6514
- enumSchema = objectType({
6515
- name: stringType(),
6516
- values: recordType(stringType(), stringType())
6517
- }).strict();
6518
- pgSchemaV2 = objectType({
6519
- version: literalType("2"),
6520
- tables: recordType(stringType(), tableV2),
6521
- enums: recordType(stringType(), enumSchema)
6522
- }).strict();
6523
- references = objectType({
6524
- foreignKeyName: stringType(),
6525
- table: stringType(),
6526
- column: stringType(),
6527
- onDelete: stringType().optional(),
6528
- onUpdate: stringType().optional()
6529
- }).strict();
6530
- columnV1 = objectType({
6531
- name: stringType(),
6532
- type: stringType(),
6533
- primaryKey: booleanType(),
6534
- notNull: booleanType(),
6535
- default: anyType().optional(),
6536
- references: references.optional()
6537
- }).strict();
6538
- tableV1 = objectType({
6539
- name: stringType(),
6540
- columns: recordType(stringType(), columnV1),
6541
- indexes: recordType(stringType(), indexV2)
6542
- }).strict();
6543
- pgSchemaV1 = objectType({
6544
- version: literalType("1"),
6545
- tables: recordType(stringType(), tableV1),
6546
- enums: recordType(stringType(), enumSchema)
6547
- }).strict();
6548
- index2 = objectType({
6549
- name: stringType(),
6550
- columns: stringType().array(),
6551
- isUnique: booleanType()
6552
- }).strict();
6553
- fk2 = objectType({
6554
- name: stringType(),
6555
- tableFrom: stringType(),
6556
- columnsFrom: stringType().array(),
6557
- tableTo: stringType(),
6558
- schemaTo: stringType().optional(),
6559
- columnsTo: stringType().array(),
6560
- onUpdate: stringType().optional(),
6561
- onDelete: stringType().optional()
6562
- }).strict();
6563
- column2 = objectType({
6564
- name: stringType(),
6565
- type: stringType(),
6566
- primaryKey: booleanType(),
6567
- notNull: booleanType(),
6568
- default: anyType().optional(),
6569
- isUnique: anyType().optional(),
6570
- uniqueName: stringType().optional(),
6571
- nullsNotDistinct: booleanType().optional()
6572
- }).strict();
6573
- tableV32 = objectType({
6574
- name: stringType(),
6575
- columns: recordType(stringType(), column2),
6576
- indexes: recordType(stringType(), index2),
6577
- foreignKeys: recordType(stringType(), fk2)
6578
- }).strict();
6579
- compositePK2 = objectType({
6580
- name: stringType(),
6581
- columns: stringType().array()
6582
- }).strict();
6583
- uniqueConstraint2 = objectType({
6584
- name: stringType(),
6585
- columns: stringType().array(),
6586
- nullsNotDistinct: booleanType()
6587
- }).strict();
6588
- tableV42 = objectType({
6589
- name: stringType(),
6590
- schema: stringType(),
6591
- columns: recordType(stringType(), column2),
6592
- indexes: recordType(stringType(), index2),
6593
- foreignKeys: recordType(stringType(), fk2)
6594
- }).strict();
6595
- table2 = objectType({
6596
- name: stringType(),
6597
- schema: stringType(),
6598
- columns: recordType(stringType(), column2),
6599
- indexes: recordType(stringType(), index2),
6600
- foreignKeys: recordType(stringType(), fk2),
6601
- compositePrimaryKeys: recordType(stringType(), compositePK2),
6602
- uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
6603
- }).strict();
6604
- schemaHash2 = objectType({
6605
- id: stringType(),
6606
- prevId: stringType()
6607
- });
6608
- kitInternals2 = objectType({
6609
- tables: recordType(
6610
- stringType(),
6611
- objectType({
6612
- columns: recordType(
6613
- stringType(),
6614
- objectType({
6615
- isArray: booleanType().optional(),
6616
- dimensions: numberType().optional(),
6617
- rawType: stringType().optional()
6618
- }).optional()
6619
- )
6620
- }).optional()
6621
- )
6622
- }).optional();
6623
- pgSchemaInternalV3 = objectType({
6624
- version: literalType("3"),
6625
- dialect: literalType("pg"),
6626
- tables: recordType(stringType(), tableV32),
6627
- enums: recordType(stringType(), enumSchema)
6628
- }).strict();
6629
- pgSchemaInternalV4 = objectType({
6630
- version: literalType("4"),
6631
- dialect: literalType("pg"),
6632
- tables: recordType(stringType(), tableV42),
6633
- enums: recordType(stringType(), enumSchema),
6634
- schemas: recordType(stringType(), stringType())
6635
- }).strict();
6636
- pgSchemaInternalV5 = objectType({
6637
- version: literalType("5"),
6638
- dialect: literalType("pg"),
6639
- tables: recordType(stringType(), table2),
6640
- enums: recordType(stringType(), enumSchema),
6641
- schemas: recordType(stringType(), stringType()),
6642
- _meta: objectType({
6643
- schemas: recordType(stringType(), stringType()),
6644
- tables: recordType(stringType(), stringType()),
6645
- columns: recordType(stringType(), stringType())
6646
- }),
6647
- internal: kitInternals2
6648
- }).strict();
6649
- pgSchemaExternal = objectType({
6650
- version: literalType("5"),
6651
- dialect: literalType("pg"),
6652
- tables: arrayType(table2),
6653
- enums: arrayType(enumSchema),
6654
- schemas: arrayType(objectType({ name: stringType() })),
6655
- _meta: objectType({
6656
- schemas: recordType(stringType(), stringType()),
6657
- tables: recordType(stringType(), stringType()),
6658
- columns: recordType(stringType(), stringType())
6659
- })
6660
- }).strict();
6661
- pgSchemaInternal = objectType({
6662
- version: literalType("6"),
6663
- dialect: literalType("pg"),
6664
- tables: recordType(stringType(), table2),
6665
- enums: recordType(stringType(), enumSchema),
6666
- schemas: recordType(stringType(), stringType()),
6667
- _meta: objectType({
6668
- schemas: recordType(stringType(), stringType()),
6669
- tables: recordType(stringType(), stringType()),
6670
- columns: recordType(stringType(), stringType())
6671
- }),
6672
- internal: kitInternals2
6673
- }).strict();
6674
- tableSquashed2 = objectType({
6675
- name: stringType(),
6676
- schema: stringType(),
6677
- columns: recordType(stringType(), column2),
6678
- indexes: recordType(stringType(), stringType()),
6679
- foreignKeys: recordType(stringType(), stringType()),
6680
- compositePrimaryKeys: recordType(stringType(), stringType()),
6681
- uniqueConstraints: recordType(stringType(), stringType())
6682
- }).strict();
6683
- tableSquashedV42 = objectType({
6684
- name: stringType(),
6685
- schema: stringType(),
6686
- columns: recordType(stringType(), column2),
6687
- indexes: recordType(stringType(), stringType()),
6688
- foreignKeys: recordType(stringType(), stringType())
6689
- }).strict();
6690
- pgSchemaSquashedV4 = objectType({
6691
- version: literalType("4"),
6692
- dialect: enumType(["pg"]),
6693
- tables: recordType(stringType(), tableSquashedV42),
6694
- enums: recordType(stringType(), enumSchema),
6695
- schemas: recordType(stringType(), stringType())
6696
- }).strict();
6697
- pgSchemaSquashed = objectType({
6698
- version: literalType("6"),
6699
- dialect: enumType(["pg"]),
6700
- tables: recordType(stringType(), tableSquashed2),
6701
- enums: recordType(stringType(), enumSchema),
6702
- schemas: recordType(stringType(), stringType())
6703
- }).strict();
6704
- pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash2);
6705
- pgSchemaV4 = pgSchemaInternalV4.merge(schemaHash2);
6706
- pgSchemaV5 = pgSchemaInternalV5.merge(schemaHash2);
6707
- pgSchema = pgSchemaInternal.merge(schemaHash2);
6708
- backwardCompatiblePgSchema = unionType([pgSchemaV5, pgSchema]);
6709
- PgSquasher = {
6710
- squashIdx: (idx) => {
6711
- index2.parse(idx);
6712
- return `${idx.name};${idx.columns.join(",")};${idx.isUnique}`;
6713
- },
6714
- unsquashIdx: (input) => {
6715
- const [name, columnsString, isUnique] = input.split(";");
6716
- const result = index2.parse({
6717
- name,
6718
- columns: columnsString.split(","),
6719
- isUnique: isUnique === "true"
6720
- });
6721
- return result;
6722
- },
6723
- squashFK: (fk4) => {
6724
- return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""};${fk4.schemaTo ?? ""}`;
6725
- },
6726
- squashPK: (pk) => {
6727
- return `${pk.columns.join(",")};${pk.name}`;
6728
- },
6729
- unsquashPK: (pk) => {
6730
- const splitted = pk.split(";");
6731
- return { name: splitted[1], columns: splitted[0].split(",") };
6732
- },
6733
- squashUnique: (unq) => {
6734
- return `${unq.name};${unq.columns.join(",")};${unq.nullsNotDistinct}`;
6735
- },
6736
- unsquashUnique: (unq) => {
6737
- const [name, columns, nullsNotDistinct] = unq.split(";");
6738
- return {
6739
- name,
6740
- columns: columns.split(","),
6741
- nullsNotDistinct: nullsNotDistinct === "true"
6742
- };
6743
- },
6744
- unsquashFK: (input) => {
6745
- const [
6746
- name,
6747
- tableFrom,
6748
- columnsFromStr,
6749
- tableTo,
6750
- columnsToStr,
6751
- onUpdate,
6752
- onDelete,
6753
- schemaTo
6754
- ] = input.split(";");
6755
- const result = fk2.parse({
6756
- name,
6757
- tableFrom,
6758
- columnsFrom: columnsFromStr.split(","),
6759
- schemaTo,
6760
- tableTo,
6761
- columnsTo: columnsToStr.split(","),
6762
- onUpdate,
6763
- onDelete
6764
- });
6765
- return result;
6766
- }
6767
- };
6768
- squashPgScheme = (json) => {
6769
- const mappedTables = Object.fromEntries(
6770
- Object.entries(json.tables).map((it) => {
6771
- const squashedIndexes = mapValues(it[1].indexes, (index4) => {
6772
- return PgSquasher.squashIdx(index4);
6773
- });
6774
- const squashedFKs = mapValues(it[1].foreignKeys, (fk4) => {
6775
- return PgSquasher.squashFK(fk4);
6776
- });
6777
- const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => {
6778
- return PgSquasher.squashPK(pk);
6779
- });
6780
- const squashedUniqueConstraints = mapValues(
6781
- it[1].uniqueConstraints,
6782
- (unq) => {
6783
- return PgSquasher.squashUnique(unq);
6784
- }
6785
- );
6786
- return [
6787
- it[0],
6788
- {
6789
- name: it[1].name,
6790
- schema: it[1].schema,
6791
- columns: it[1].columns,
6792
- indexes: squashedIndexes,
6793
- foreignKeys: squashedFKs,
6794
- compositePrimaryKeys: squashedPKs,
6795
- uniqueConstraints: squashedUniqueConstraints
6796
- }
6797
- ];
6798
- })
6799
- );
6800
- return {
6801
- version: "6",
6802
- dialect: json.dialect,
6803
- tables: mappedTables,
6804
- enums: json.enums,
6805
- schemas: json.schemas
6806
- };
6807
- };
6808
- dryPg = pgSchema.parse({
6809
- version: snapshotVersion,
6810
- dialect: "pg",
6811
- id: originUUID,
6812
- prevId: "",
6813
- tables: {},
6814
- enums: {},
6815
- schemas: {},
6816
- _meta: {
6817
- schemas: {},
6818
- tables: {},
6819
- columns: {}
6820
- }
6821
- });
6822
- }
6823
- });
6824
-
6825
- // src/serializer/sqliteSchema.ts
6826
- var index3, fk3, compositePK3, column3, tableV33, uniqueConstraint3, table3, dialect5, schemaHash3, schemaInternalV32, schemaInternalV42, latestVersion, schemaInternal2, schemaV32, schemaV42, schema3, tableSquashed3, schemaSquashed2, SQLiteSquasher, squashSqliteScheme, drySQLite, sqliteSchema, SQLiteSchemaSquashed, backwardCompatibleSqliteSchema;
6827
- var init_sqliteSchema = __esm({
6828
- "src/serializer/sqliteSchema.ts"() {
6829
- "use strict";
6830
- init_global();
6831
- init_lib();
6832
- index3 = objectType({
6833
- name: stringType(),
6834
- columns: stringType().array(),
6835
- where: stringType().optional(),
6836
- isUnique: booleanType()
6837
- }).strict();
6838
- fk3 = objectType({
6839
- name: stringType(),
6840
- tableFrom: stringType(),
6841
- columnsFrom: stringType().array(),
6842
- tableTo: stringType(),
6843
- columnsTo: stringType().array(),
6844
- onUpdate: stringType().optional(),
6845
- onDelete: stringType().optional()
6846
- }).strict();
6847
- compositePK3 = objectType({
6848
- columns: stringType().array(),
6849
- name: stringType().optional()
6850
- }).strict();
6851
- column3 = objectType({
6852
- name: stringType(),
6853
- type: stringType(),
6854
- primaryKey: booleanType(),
6855
- notNull: booleanType(),
6856
- autoincrement: booleanType().optional(),
6857
- default: anyType().optional()
6858
- }).strict();
6859
- tableV33 = objectType({
6860
- name: stringType(),
6861
- columns: recordType(stringType(), column3),
6862
- indexes: recordType(stringType(), index3),
6863
- foreignKeys: recordType(stringType(), fk3)
6864
- }).strict();
6865
- uniqueConstraint3 = objectType({
6866
- name: stringType(),
6867
- columns: stringType().array()
6868
- }).strict();
6869
- table3 = objectType({
6870
- name: stringType(),
6871
- columns: recordType(stringType(), column3),
6872
- indexes: recordType(stringType(), index3),
6873
- foreignKeys: recordType(stringType(), fk3),
6874
- compositePrimaryKeys: recordType(stringType(), compositePK3),
6875
- uniqueConstraints: recordType(stringType(), uniqueConstraint3).default({})
6876
- }).strict();
6877
- dialect5 = enumType(["sqlite"]);
6878
- schemaHash3 = objectType({
6879
- id: stringType(),
6880
- prevId: stringType()
6881
- }).strict();
6882
- schemaInternalV32 = objectType({
6883
- version: literalType("3"),
6884
- dialect: dialect5,
6885
- tables: recordType(stringType(), tableV33),
6886
- enums: objectType({})
6887
- }).strict();
6888
- schemaInternalV42 = objectType({
6889
- version: literalType("4"),
6890
- dialect: dialect5,
6891
- tables: recordType(stringType(), table3),
6892
- enums: objectType({})
6893
- }).strict();
6894
- latestVersion = literalType("5");
6895
- schemaInternal2 = objectType({
6896
- version: latestVersion,
6897
- dialect: dialect5,
6898
- tables: recordType(stringType(), table3),
6899
- enums: objectType({}),
6900
- _meta: objectType({
6901
- tables: recordType(stringType(), stringType()),
6902
- columns: recordType(stringType(), stringType())
6903
- })
6904
- }).strict();
6905
- schemaV32 = schemaInternalV32.merge(schemaHash3).strict();
6906
- schemaV42 = schemaInternalV42.merge(schemaHash3).strict();
6907
- schema3 = schemaInternal2.merge(schemaHash3).strict();
6908
- tableSquashed3 = objectType({
6909
- name: stringType(),
6910
- columns: recordType(stringType(), column3),
6911
- indexes: recordType(stringType(), stringType()),
6912
- foreignKeys: recordType(stringType(), stringType()),
6913
- compositePrimaryKeys: recordType(stringType(), stringType()),
6914
- uniqueConstraints: recordType(stringType(), stringType()).default({})
6915
- }).strict();
6916
- schemaSquashed2 = objectType({
6917
- version: latestVersion,
6918
- dialect: dialect5,
6919
- tables: recordType(stringType(), tableSquashed3),
6920
- enums: anyType()
6921
- }).strict();
6922
- SQLiteSquasher = {
6923
- squashIdx: (idx) => {
6924
- index3.parse(idx);
6925
- return `${idx.name};${idx.columns.join(",")};${idx.isUnique};${idx.where ?? ""}`;
6926
- },
6927
- unsquashIdx: (input) => {
6928
- const [name, columnsString, isUnique, where] = input.split(";");
6929
- const result = index3.parse({
6930
- name,
6931
- columns: columnsString.split(","),
6932
- isUnique: isUnique === "true",
6933
- where: where ?? void 0
6934
- });
6935
- return result;
6936
- },
6937
- squashUnique: (unq) => {
6938
- return `${unq.name};${unq.columns.join(",")}`;
6939
- },
6940
- unsquashUnique: (unq) => {
6941
- const [name, columns] = unq.split(";");
6942
- return { name, columns: columns.split(",") };
6943
- },
6944
- squashFK: (fk4) => {
6945
- return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""}`;
6946
- },
6947
- unsquashFK: (input) => {
6948
- const [
6949
- name,
6950
- tableFrom,
6951
- columnsFromStr,
6952
- tableTo,
6953
- columnsToStr,
6954
- onUpdate,
6955
- onDelete
6956
- ] = input.split(";");
6957
- const result = fk3.parse({
6958
- name,
6959
- tableFrom,
6960
- columnsFrom: columnsFromStr.split(","),
6961
- tableTo,
6962
- columnsTo: columnsToStr.split(","),
6963
- onUpdate,
6964
- onDelete
6965
- });
6966
- return result;
6967
- },
6968
- squashPK: (pk) => {
6969
- return pk.columns.join(",");
6970
- },
6971
- unsquashPK: (pk) => {
6972
- return pk.split(",");
6973
- }
6974
- };
6975
- squashSqliteScheme = (json) => {
6976
- const mappedTables = Object.fromEntries(
6977
- Object.entries(json.tables).map((it) => {
6978
- const squashedIndexes = mapValues(it[1].indexes, (index4) => {
6979
- return SQLiteSquasher.squashIdx(index4);
6980
- });
6981
- const squashedFKs = mapValues(it[1].foreignKeys, (fk4) => {
6982
- return SQLiteSquasher.squashFK(fk4);
6983
- });
6984
- const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => {
6985
- return SQLiteSquasher.squashPK(pk);
6986
- });
6987
- const squashedUniqueConstraints = mapValues(
6988
- it[1].uniqueConstraints,
6989
- (unq) => {
6990
- return SQLiteSquasher.squashUnique(unq);
6991
- }
6992
- );
6993
- return [
6994
- it[0],
6995
- {
6996
- name: it[1].name,
6997
- columns: it[1].columns,
6998
- indexes: squashedIndexes,
6999
- foreignKeys: squashedFKs,
7000
- compositePrimaryKeys: squashedPKs,
7001
- uniqueConstraints: squashedUniqueConstraints
7002
- }
7003
- ];
7004
- })
7005
- );
7006
- return {
7007
- version: "5",
7008
- dialect: json.dialect,
7009
- tables: mappedTables,
7010
- enums: json.enums
7011
- };
7012
- };
7013
- drySQLite = schema3.parse({
7014
- version: "5",
7015
- dialect: "sqlite",
7016
- id: originUUID,
7017
- prevId: "",
7018
- tables: {},
7019
- enums: {},
7020
- _meta: {
7021
- tables: {},
7022
- columns: {}
7023
- }
7024
- });
7025
- sqliteSchema = schema3;
7026
- SQLiteSchemaSquashed = schemaSquashed2;
7027
- backwardCompatibleSqliteSchema = schema3;
7028
- }
7029
- });
7030
-
7031
- // src/schemaValidator.ts
7032
- var dialect6, commonSquashedSchema, commonSchema;
7033
- var init_schemaValidator = __esm({
7034
- "src/schemaValidator.ts"() {
7035
- "use strict";
7036
- init_lib();
7037
- init_mysqlSchema();
7038
- init_pgSchema();
7039
- init_sqliteSchema();
7040
- dialect6 = enumType(["pg", "mysql", "sqlite"]);
7041
- commonSquashedSchema = unionType([
7042
- pgSchemaSquashed,
7043
- mysqlSchemaSquashed,
7044
- SQLiteSchemaSquashed
7045
- ]);
7046
- commonSchema = unionType([
7047
- pgSchema,
7048
- mysqlSchema,
7049
- sqliteSchema
7050
- ]);
7051
- }
7052
- });
7053
-
7054
- // src/cli/validations/common.ts
7055
- var driver, configCommonSchema, introspectCasing, configIntrospectSchema, configIntrospectCliSchema, configGenerateSchema, configPushSchema, mysqlConnectionSchema, mySqlCliConfigSchema;
7056
- var init_common = __esm({
7057
- "src/cli/validations/common.ts"() {
7058
- "use strict";
7059
- init_outputs();
7060
- init_lib();
7061
- init_schemaValidator();
7062
- driver = unionType([
7063
- literalType("better-sqlite"),
7064
- literalType("turso"),
7065
- literalType("libsql"),
7066
- literalType("d1"),
7067
- literalType("expo"),
7068
- literalType("pg"),
7069
- literalType("mysql2")
7070
- ]);
7071
- configCommonSchema = objectType({
7072
- dialect: dialect6,
7073
- schema: unionType([stringType(), stringType().array()]),
7074
- out: stringType().optional(),
7075
- breakpoints: booleanType().default(true),
7076
- driver: driver.optional(),
7077
- tablesFilter: unionType([stringType(), stringType().array()]).optional(),
7078
- schemaFilter: unionType([stringType(), stringType().array()]).default(["public"])
7079
- });
7080
- introspectCasing = objectType({
7081
- casing: unionType([literalType("camel"), literalType("preserve")]).default("camel")
7082
- }).default({ casing: "camel" });
7083
- configIntrospectSchema = objectType({
7084
- schema: unionType([stringType(), stringType().array()]).optional(),
7085
- out: stringType().optional().default("./drizzle"),
7086
- breakpoints: booleanType().default(true),
7087
- tablesFilter: unionType([stringType(), stringType().array()]).optional(),
7088
- schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
7089
- introspect: introspectCasing
7090
- });
7091
- configIntrospectCliSchema = objectType({
7092
- schema: unionType([stringType(), stringType().array()]).optional(),
7093
- out: stringType().optional().default("./drizzle"),
7094
- breakpoints: booleanType().default(true),
7095
- tablesFilter: unionType([stringType(), stringType().array()]).optional(),
7096
- schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
7097
- introspectCasing: unionType([literalType("camel"), literalType("preserve")]).default(
7098
- "camel"
7099
- )
7100
- });
7101
- configGenerateSchema = objectType({
7102
- schema: unionType([stringType(), stringType().array()]),
7103
- out: stringType().optional().default("./drizzle"),
7104
- breakpoints: booleanType().default(true)
7105
- });
7106
- configPushSchema = objectType({
7107
- dialect: dialect6,
7108
- schema: unionType([stringType(), stringType().array()]),
7109
- tablesFilter: unionType([stringType(), stringType().array()]).optional(),
7110
- schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
7111
- verbose: booleanType().default(false),
7112
- strict: booleanType().default(false)
7113
- });
7114
- mysqlConnectionSchema = unionType([
7115
- objectType({
7116
- host: stringType(),
7117
- port: coerce.number().optional(),
7118
- user: stringType().default("mysql"),
7119
- password: stringType().optional(),
7120
- database: stringType()
7121
- // ssl: boolean().optional(),
7122
- }),
7123
- objectType({
7124
- connectionString: stringType()
7125
- }),
7126
- objectType({})
7127
- ]);
7128
- mySqlCliConfigSchema = intersectionType(
7129
- configCommonSchema,
7130
- mysqlConnectionSchema
7131
- );
7132
- }
7133
- });
7134
-
7135
- // src/cli/validations/mysql.ts
7136
- var mysqlConnectionCli, mysql2credentials, mysqlConnectionConfig, mysqlConfigIntrospectSchema, mysqlCliIntrospectParams, mysqlCliPushParams, mysqlConfigPushParams;
7137
- var init_mysql = __esm({
7138
- "src/cli/validations/mysql.ts"() {
7139
- "use strict";
7140
- init_lib();
7141
- init_utils();
7142
- init_common();
7143
- init_common();
7144
- init_outputs();
7145
- mysqlConnectionCli = unionType([
7146
- objectType({
7147
- driver: literalType("mysql2"),
7148
- host: stringType(),
7149
- port: coerce.number().optional(),
7150
- user: stringType().default("mysql"),
7151
- password: stringType().optional(),
7152
- database: stringType()
7153
- }),
7154
- objectType({
7155
- driver: literalType("mysql2"),
7156
- uri: stringType()
7157
- // TODO: change docs
7158
- })
7159
- ]);
7160
- mysql2credentials = unionType([
7161
- objectType({
7162
- host: stringType(),
7163
- port: coerce.number().optional(),
7164
- user: stringType().default("mysql"),
7165
- password: stringType().optional(),
7166
- database: stringType()
7167
- }),
7168
- objectType({
7169
- uri: stringType()
7170
- // TODO: change docs
7171
- })
7172
- ]);
7173
- mysqlConnectionConfig = objectType({
7174
- driver: literalType("mysql2"),
7175
- dbCredentials: mysql2credentials
7176
- });
7177
- mysqlConfigIntrospectSchema = intersectionType(
7178
- configIntrospectSchema,
7179
- mysqlConnectionConfig
7180
- );
7181
- mysqlCliIntrospectParams = intersectionType(
7182
- configIntrospectCliSchema,
7183
- mysqlConnectionCli
7184
- );
7185
- mysqlCliPushParams = intersectionType(
7186
- configPushSchema,
7187
- mysqlConnectionCli
7188
- );
7189
- mysqlConfigPushParams = intersectionType(
7190
- configPushSchema,
7191
- mysqlConnectionConfig
7192
- );
7193
- }
7194
- });
7195
-
7196
- // src/cli/validations/pg.ts
7197
- var pgConnectionCli, pgConnectionConfig, pgConfigIntrospectSchema, pgCliIntrospectParams, pgCliPushParams, pgConfigPushParams;
7198
- var init_pg = __esm({
7199
- "src/cli/validations/pg.ts"() {
7200
- "use strict";
7201
- init_lib();
7202
- init_utils();
7203
- init_common();
7204
- init_common();
7205
- init_outputs();
7206
- pgConnectionCli = unionType([
7207
- objectType({
7208
- driver: literalType("pg"),
7209
- host: stringType(),
7210
- port: coerce.number().optional(),
7211
- user: stringType().default("postgres"),
7212
- password: stringType().optional(),
7213
- database: stringType(),
7214
- ssl: coerce.boolean().optional(),
7215
- type: literalType("params").default("params")
7216
- }),
7217
- objectType({
7218
- driver: literalType("pg"),
7219
- connectionString: stringType(),
7220
- type: literalType("url").default("url")
7221
- })
7222
- ]);
7223
- pgConnectionConfig = unionType([
7224
- objectType({
7225
- driver: literalType("pg"),
7226
- dbCredentials: objectType({
7227
- host: stringType(),
7228
- port: coerce.number().optional(),
7229
- user: stringType().default("postgres"),
7230
- password: stringType().optional(),
7231
- database: stringType(),
7232
- ssl: coerce.boolean().optional(),
7233
- type: literalType("params").default("params").optional()
7234
- })
7235
- }),
7236
- objectType({
7237
- driver: literalType("pg"),
7238
- dbCredentials: objectType({
7239
- connectionString: stringType(),
7240
- type: literalType("url").default("url").optional()
7241
- })
7242
- })
7243
- ]);
7244
- pgConfigIntrospectSchema = intersectionType(
7245
- configIntrospectSchema,
7246
- pgConnectionConfig
7247
- );
7248
- pgCliIntrospectParams = intersectionType(
7249
- configIntrospectCliSchema,
7250
- pgConnectionCli
7251
- );
7252
- pgCliPushParams = intersectionType(
7253
- configPushSchema,
7254
- pgConnectionCli
7255
- );
7256
- pgConfigPushParams = intersectionType(
7257
- configPushSchema,
7258
- pgConnectionConfig
7259
- );
7260
- }
7261
- });
7262
-
7263
- // src/cli/validations/sqlite.ts
7264
- var sqliteConnectionCli, sqliteConnectionSchema, sqliteCliConfigSchema, sqliteCliIntrospectParams, sqliteCliPushParams, sqliteConfigPushParams;
7265
- var init_sqlite = __esm({
7266
- "src/cli/validations/sqlite.ts"() {
7267
- "use strict";
7268
- init_lib();
7269
- init_utils();
7270
- init_common();
7271
- init_common();
7272
- init_outputs();
7273
- sqliteConnectionCli = unionType([
7274
- objectType({
7275
- driver: literalType("turso"),
7276
- url: stringType(),
7277
- authToken: stringType()
7278
- }),
7279
- objectType({
7280
- driver: literalType("better-sqlite"),
7281
- url: stringType()
7282
- }),
7283
- objectType({
7284
- driver: literalType("libsql"),
7285
- url: stringType()
7286
- })
7287
- ]);
7288
- sqliteConnectionSchema = unionType([
7289
- objectType({
7290
- driver: literalType("turso"),
7291
- dbCredentials: objectType({
7292
- url: stringType(),
7293
- authToken: stringType().optional()
7294
- })
7295
- }),
7296
- objectType({
7297
- driver: literalType("libsql"),
7298
- dbCredentials: objectType({
7299
- url: stringType()
7300
- })
7301
- }),
7302
- objectType({
7303
- driver: literalType("better-sqlite"),
7304
- dbCredentials: objectType({
7305
- url: stringType()
7306
- })
7307
- })
7308
- ]);
7309
- sqliteCliConfigSchema = intersectionType(
7310
- configIntrospectSchema,
7311
- sqliteConnectionSchema
7312
- );
7313
- sqliteCliIntrospectParams = intersectionType(
7314
- configIntrospectCliSchema,
7315
- sqliteConnectionCli
7316
- );
7317
- sqliteCliPushParams = intersectionType(
7318
- configPushSchema,
7319
- sqliteConnectionCli
7320
- );
7321
- sqliteConfigPushParams = intersectionType(
7322
- configPushSchema,
7323
- sqliteConnectionSchema
7324
- );
7325
- }
7326
- });
7327
-
7328
- // src/cli/commands/_es5.ts
7329
- var es5_exports = {};
7330
- __export(es5_exports, {
7331
- default: () => es5_default
7332
- });
7333
- var _, es5_default;
7334
- var init_es5 = __esm({
7335
- "src/cli/commands/_es5.ts"() {
7336
- "use strict";
7337
- _ = "";
7338
- es5_default = _;
7339
- }
7340
- });
7341
-
7342
- // node_modules/.pnpm/ms@2.1.2/node_modules/ms/index.js
7343
- var require_ms = __commonJS({
7344
- "node_modules/.pnpm/ms@2.1.2/node_modules/ms/index.js"(exports, module) {
7345
- var s = 1e3;
7346
- var m = s * 60;
7347
- var h = m * 60;
7348
- var d = h * 24;
7349
- var w = d * 7;
7350
- var y = d * 365.25;
7351
- module.exports = function(val, options) {
7352
- options = options || {};
7353
- var type = typeof val;
7354
- if (type === "string" && val.length > 0) {
7355
- return parse(val);
7356
- } else if (type === "number" && isFinite(val)) {
7357
- return options.long ? fmtLong(val) : fmtShort(val);
7358
- }
7359
- throw new Error(
7360
- "val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
7361
- );
7362
- };
7363
- function parse(str) {
7364
- str = String(str);
7365
- if (str.length > 100) {
7366
- return;
7367
- }
7368
- var match2 = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
7369
- str
7370
- );
7371
- if (!match2) {
7372
- return;
7373
- }
7374
- var n = parseFloat(match2[1]);
7375
- var type = (match2[2] || "ms").toLowerCase();
7376
- switch (type) {
7377
- case "years":
7378
- case "year":
7379
- case "yrs":
7380
- case "yr":
7381
- case "y":
7382
- return n * y;
7383
- case "weeks":
7384
- case "week":
7385
- case "w":
7386
- return n * w;
7387
- case "days":
7388
- case "day":
7389
- case "d":
7390
- return n * d;
7391
- case "hours":
7392
- case "hour":
7393
- case "hrs":
7394
- case "hr":
7395
- case "h":
7396
- return n * h;
7397
- case "minutes":
7398
- case "minute":
7399
- case "mins":
7400
- case "min":
7401
- case "m":
7402
- return n * m;
7403
- case "seconds":
7404
- case "second":
7405
- case "secs":
7406
- case "sec":
7407
- case "s":
7408
- return n * s;
7409
- case "milliseconds":
7410
- case "millisecond":
7411
- case "msecs":
7412
- case "msec":
7413
- case "ms":
7414
- return n;
7415
- default:
7416
- return void 0;
7417
- }
7418
- }
7419
- function fmtShort(ms) {
7420
- var msAbs = Math.abs(ms);
7421
- if (msAbs >= d) {
7422
- return Math.round(ms / d) + "d";
7423
- }
7424
- if (msAbs >= h) {
7425
- return Math.round(ms / h) + "h";
7426
- }
7427
- if (msAbs >= m) {
7428
- return Math.round(ms / m) + "m";
7429
- }
7430
- if (msAbs >= s) {
7431
- return Math.round(ms / s) + "s";
7432
- }
7433
- return ms + "ms";
7434
- }
7435
- function fmtLong(ms) {
7436
- var msAbs = Math.abs(ms);
7437
- if (msAbs >= d) {
7438
- return plural(ms, msAbs, d, "day");
7439
- }
7440
- if (msAbs >= h) {
7441
- return plural(ms, msAbs, h, "hour");
7442
- }
7443
- if (msAbs >= m) {
7444
- return plural(ms, msAbs, m, "minute");
7445
- }
7446
- if (msAbs >= s) {
7447
- return plural(ms, msAbs, s, "second");
7448
- }
7449
- return ms + " ms";
7450
- }
7451
- function plural(ms, msAbs, n, name) {
7452
- var isPlural = msAbs >= n * 1.5;
7453
- return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
7454
- }
6220
+ var match2 = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
6221
+ str
6222
+ );
6223
+ if (!match2) {
6224
+ return;
6225
+ }
6226
+ var n = parseFloat(match2[1]);
6227
+ var type = (match2[2] || "ms").toLowerCase();
6228
+ switch (type) {
6229
+ case "years":
6230
+ case "year":
6231
+ case "yrs":
6232
+ case "yr":
6233
+ case "y":
6234
+ return n * y;
6235
+ case "weeks":
6236
+ case "week":
6237
+ case "w":
6238
+ return n * w;
6239
+ case "days":
6240
+ case "day":
6241
+ case "d":
6242
+ return n * d;
6243
+ case "hours":
6244
+ case "hour":
6245
+ case "hrs":
6246
+ case "hr":
6247
+ case "h":
6248
+ return n * h;
6249
+ case "minutes":
6250
+ case "minute":
6251
+ case "mins":
6252
+ case "min":
6253
+ case "m":
6254
+ return n * m;
6255
+ case "seconds":
6256
+ case "second":
6257
+ case "secs":
6258
+ case "sec":
6259
+ case "s":
6260
+ return n * s;
6261
+ case "milliseconds":
6262
+ case "millisecond":
6263
+ case "msecs":
6264
+ case "msec":
6265
+ case "ms":
6266
+ return n;
6267
+ default:
6268
+ return void 0;
6269
+ }
6270
+ }
6271
+ function fmtShort(ms) {
6272
+ var msAbs = Math.abs(ms);
6273
+ if (msAbs >= d) {
6274
+ return Math.round(ms / d) + "d";
6275
+ }
6276
+ if (msAbs >= h) {
6277
+ return Math.round(ms / h) + "h";
6278
+ }
6279
+ if (msAbs >= m) {
6280
+ return Math.round(ms / m) + "m";
6281
+ }
6282
+ if (msAbs >= s) {
6283
+ return Math.round(ms / s) + "s";
6284
+ }
6285
+ return ms + "ms";
6286
+ }
6287
+ function fmtLong(ms) {
6288
+ var msAbs = Math.abs(ms);
6289
+ if (msAbs >= d) {
6290
+ return plural(ms, msAbs, d, "day");
6291
+ }
6292
+ if (msAbs >= h) {
6293
+ return plural(ms, msAbs, h, "hour");
6294
+ }
6295
+ if (msAbs >= m) {
6296
+ return plural(ms, msAbs, m, "minute");
6297
+ }
6298
+ if (msAbs >= s) {
6299
+ return plural(ms, msAbs, s, "second");
6300
+ }
6301
+ return ms + " ms";
6302
+ }
6303
+ function plural(ms, msAbs, n, name) {
6304
+ var isPlural = msAbs >= n * 1.5;
6305
+ return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
6306
+ }
7455
6307
  }
7456
6308
  });
7457
6309
 
@@ -12776,285 +11628,1148 @@ var require_node2 = __commonJS({
12776
11628
  return jsoncParse(content);
12777
11629
  }
12778
11630
  });
12779
- var getOptions = (cwd) => {
12780
- var _a, _b, _c, _d;
12781
- const { data, path: path3 } = joycon.loadSync(["tsconfig.json", "jsconfig.json"], cwd);
12782
- if (path3 && data) {
11631
+ var getOptions = (cwd) => {
11632
+ var _a, _b, _c, _d;
11633
+ const { data, path: path3 } = joycon.loadSync(["tsconfig.json", "jsconfig.json"], cwd);
11634
+ if (path3 && data) {
11635
+ return {
11636
+ jsxFactory: (_a = data.compilerOptions) == null ? void 0 : _a.jsxFactory,
11637
+ jsxFragment: (_b = data.compilerOptions) == null ? void 0 : _b.jsxFragmentFactory,
11638
+ target: (_d = (_c = data.compilerOptions) == null ? void 0 : _c.target) == null ? void 0 : _d.toLowerCase()
11639
+ };
11640
+ }
11641
+ return {};
11642
+ };
11643
+ var inferPackageFormat = (cwd, filename) => {
11644
+ if (filename.endsWith(".mjs")) {
11645
+ return "esm";
11646
+ }
11647
+ if (filename.endsWith(".cjs")) {
11648
+ return "cjs";
11649
+ }
11650
+ const { data } = joycon.loadSync(["package.json"], cwd);
11651
+ return data && data.type === "module" && /\.m?js$/.test(filename) ? "esm" : "cjs";
11652
+ };
11653
+ var import_tsconfig_paths = __toModule(require_lib4());
11654
+ var noOp = () => {
11655
+ };
11656
+ function registerTsconfigPaths() {
11657
+ const configLoaderResult = (0, import_tsconfig_paths.loadConfig)(process.cwd());
11658
+ if (configLoaderResult.resultType === "failed") {
11659
+ return noOp;
11660
+ }
11661
+ const matchPath = (0, import_tsconfig_paths.createMatchPath)(configLoaderResult.absoluteBaseUrl, configLoaderResult.paths, configLoaderResult.mainFields, configLoaderResult.addMatchAll);
11662
+ const Module = __require("module");
11663
+ const originalResolveFilename = Module._resolveFilename;
11664
+ Module._resolveFilename = function(request, _parent) {
11665
+ const isCoreModule = _module2.builtinModules.includes(request);
11666
+ if (!isCoreModule) {
11667
+ const found = matchPath(request);
11668
+ if (found) {
11669
+ const modifiedArguments = [found, ...[].slice.call(arguments, 1)];
11670
+ return originalResolveFilename.apply(this, modifiedArguments);
11671
+ }
11672
+ }
11673
+ return originalResolveFilename.apply(this, arguments);
11674
+ };
11675
+ return () => {
11676
+ Module._resolveFilename = originalResolveFilename;
11677
+ };
11678
+ }
11679
+ var _debug = require_src2();
11680
+ var _debug2 = _interopRequireDefault2(_debug);
11681
+ var debug = _debug2.default.call(void 0, "esbuild-register");
11682
+ var IMPORT_META_URL_VARIABLE_NAME = "__esbuild_register_import_meta_url__";
11683
+ var map = {};
11684
+ function installSourceMapSupport() {
11685
+ if (_process2.default.setSourceMapsEnabled) {
11686
+ ;
11687
+ _process2.default.setSourceMapsEnabled(true);
11688
+ } else {
11689
+ import_source_map_support.default.install({
11690
+ handleUncaughtExceptions: false,
11691
+ environment: "node",
11692
+ retrieveSourceMap(file) {
11693
+ if (map[file]) {
11694
+ return {
11695
+ url: file,
11696
+ map: map[file]
11697
+ };
11698
+ }
11699
+ return null;
11700
+ }
11701
+ });
11702
+ }
11703
+ }
11704
+ function patchCommonJsLoader(compile) {
11705
+ const extensions = _module3.default.Module._extensions;
11706
+ const jsHandler = extensions[".js"];
11707
+ extensions[".js"] = function(module2, filename) {
11708
+ try {
11709
+ return jsHandler.call(this, module2, filename);
11710
+ } catch (error2) {
11711
+ if (error2.code !== "ERR_REQUIRE_ESM") {
11712
+ throw error2;
11713
+ }
11714
+ let content = _fs3.default.readFileSync(filename, "utf8");
11715
+ content = compile(content, filename, "cjs");
11716
+ module2._compile(content, filename);
11717
+ }
11718
+ };
11719
+ return () => {
11720
+ extensions[".js"] = jsHandler;
11721
+ };
11722
+ }
11723
+ var FILE_LOADERS = {
11724
+ ".js": "js",
11725
+ ".jsx": "jsx",
11726
+ ".ts": "ts",
11727
+ ".tsx": "tsx",
11728
+ ".mjs": "js",
11729
+ ".mts": "ts",
11730
+ ".cts": "ts"
11731
+ };
11732
+ var DEFAULT_EXTENSIONS = Object.keys(FILE_LOADERS);
11733
+ var getLoader = (filename) => FILE_LOADERS[_path2.extname.call(void 0, filename)];
11734
+ function register(esbuildOptions = {}) {
11735
+ const {
11736
+ extensions = DEFAULT_EXTENSIONS,
11737
+ hookIgnoreNodeModules = true,
11738
+ hookMatcher,
11739
+ ...overrides
11740
+ } = esbuildOptions;
11741
+ const compile = function compile2(code, filename, format) {
11742
+ const define = {
11743
+ "import.meta.url": IMPORT_META_URL_VARIABLE_NAME,
11744
+ ...overrides.define
11745
+ };
11746
+ const banner = `const ${IMPORT_META_URL_VARIABLE_NAME} = require('url').pathToFileURL(__filename).href;${overrides.banner || ""}`;
11747
+ if (code.includes(banner)) {
11748
+ return code;
11749
+ }
11750
+ const dir = _path2.dirname.call(void 0, filename);
11751
+ const options = getOptions(dir);
11752
+ format = format != null ? format : inferPackageFormat(dir, filename);
11753
+ const result = _esbuild.transformSync.call(void 0, code, {
11754
+ sourcefile: filename,
11755
+ loader: getLoader(filename),
11756
+ sourcemap: "both",
11757
+ target: options.target,
11758
+ jsxFactory: options.jsxFactory,
11759
+ jsxFragment: options.jsxFragment,
11760
+ format,
11761
+ define,
11762
+ banner,
11763
+ ...overrides
11764
+ });
11765
+ const js = result.code;
11766
+ debug("compiled %s", filename);
11767
+ debug("%s", js);
11768
+ const warnings = result.warnings;
11769
+ if (warnings && warnings.length > 0) {
11770
+ for (const warning of warnings) {
11771
+ console.log(warning.location);
11772
+ console.log(warning.text);
11773
+ }
11774
+ }
11775
+ if (format === "esm")
11776
+ return js;
11777
+ return removeNodePrefix(js);
11778
+ };
11779
+ const revert = (0, import_pirates.addHook)(compile, {
11780
+ exts: extensions,
11781
+ ignoreNodeModules: hookIgnoreNodeModules,
11782
+ matcher: hookMatcher
11783
+ });
11784
+ installSourceMapSupport();
11785
+ const unpatchCommonJsLoader = patchCommonJsLoader(compile);
11786
+ const unregisterTsconfigPaths = registerTsconfigPaths();
11787
+ return {
11788
+ unregister() {
11789
+ revert();
11790
+ unpatchCommonJsLoader();
11791
+ unregisterTsconfigPaths();
11792
+ }
11793
+ };
11794
+ }
11795
+ exports.register = register;
11796
+ }
11797
+ });
11798
+
11799
+ // src/cli/commands/utils.ts
11800
+ var import_hanji2, assertES5, safeRegister, driver, configCommonSchema, introspectCasing, configIntrospectSchema, configIntrospectCliSchema, configGenerateSchema, configPushSchema, mysqlConnectionSchema, mySqlCliConfigSchema, mySqlIntrospectConfigSchema;
11801
+ var init_utils = __esm({
11802
+ "src/cli/commands/utils.ts"() {
11803
+ init_serializer();
11804
+ init_lib();
11805
+ init_source();
11806
+ init_views();
11807
+ import_hanji2 = __toESM(require_hanji());
11808
+ assertES5 = async (unregister) => {
11809
+ try {
11810
+ init_es5();
11811
+ } catch (e) {
11812
+ if ("errors" in e && Array.isArray(e.errors) && e.errors.length > 0) {
11813
+ const es5Error = e.errors.filter(
11814
+ (it) => {
11815
+ var _a;
11816
+ return (_a = it.text) == null ? void 0 : _a.includes(`("es5") is not supported yet`);
11817
+ }
11818
+ ).length > 0;
11819
+ if (es5Error) {
11820
+ console.log(
11821
+ error(
11822
+ `Please change compilerOptions.target from 'es5' to 'es6' or above in your tsconfig.json`
11823
+ )
11824
+ );
11825
+ process.exit(1);
11826
+ }
11827
+ }
11828
+ console.error(e);
11829
+ process.exit(1);
11830
+ }
11831
+ };
11832
+ safeRegister = async () => {
11833
+ const { register } = await Promise.resolve().then(() => __toESM(require_node2()));
11834
+ let res;
11835
+ try {
11836
+ res = register({
11837
+ format: "cjs",
11838
+ loader: "ts"
11839
+ });
11840
+ } catch {
11841
+ res = {
11842
+ unregister: () => {
11843
+ }
11844
+ };
11845
+ }
11846
+ await assertES5(res.unregister);
11847
+ return res;
11848
+ };
11849
+ driver = unionType([
11850
+ literalType("better-sqlite"),
11851
+ literalType("turso"),
11852
+ literalType("libsql"),
11853
+ literalType("d1"),
11854
+ literalType("expo"),
11855
+ literalType("pg"),
11856
+ literalType("mysql2")
11857
+ ]);
11858
+ configCommonSchema = objectType({
11859
+ schema: unionType([stringType(), stringType().array()]),
11860
+ out: stringType().optional(),
11861
+ breakpoints: booleanType().default(true),
11862
+ driver: driver.optional(),
11863
+ tablesFilter: unionType([stringType(), stringType().array()]).optional(),
11864
+ schemaFilter: unionType([stringType(), stringType().array()]).default(["public"])
11865
+ });
11866
+ introspectCasing = objectType({
11867
+ casing: unionType([literalType("camel"), literalType("preserve")]).default("camel")
11868
+ }).default({ casing: "camel" });
11869
+ configIntrospectSchema = objectType({
11870
+ schema: unionType([stringType(), stringType().array()]).optional(),
11871
+ out: stringType().optional().default("./drizzle"),
11872
+ breakpoints: booleanType().default(true),
11873
+ tablesFilter: unionType([stringType(), stringType().array()]).optional(),
11874
+ schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
11875
+ introspect: introspectCasing
11876
+ });
11877
+ configIntrospectCliSchema = objectType({
11878
+ schema: unionType([stringType(), stringType().array()]).optional(),
11879
+ out: stringType().optional().default("./drizzle"),
11880
+ breakpoints: booleanType().default(true),
11881
+ tablesFilter: unionType([stringType(), stringType().array()]).optional(),
11882
+ schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
11883
+ introspectCasing: unionType([literalType("camel"), literalType("preserve")]).default(
11884
+ "camel"
11885
+ )
11886
+ });
11887
+ configGenerateSchema = objectType({
11888
+ schema: unionType([stringType(), stringType().array()]),
11889
+ out: stringType().optional().default("./drizzle"),
11890
+ breakpoints: booleanType().default(true)
11891
+ });
11892
+ configPushSchema = objectType({
11893
+ schema: unionType([stringType(), stringType().array()]),
11894
+ tablesFilter: unionType([stringType(), stringType().array()]).optional(),
11895
+ schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
11896
+ verbose: booleanType().default(false),
11897
+ strict: booleanType().default(false)
11898
+ });
11899
+ mysqlConnectionSchema = unionType([
11900
+ objectType({
11901
+ host: stringType(),
11902
+ port: coerce.number().optional(),
11903
+ user: stringType().default("mysql"),
11904
+ password: stringType().optional(),
11905
+ database: stringType()
11906
+ // ssl: boolean().optional(),
11907
+ }),
11908
+ objectType({
11909
+ connectionString: stringType()
11910
+ }),
11911
+ objectType({})
11912
+ ]);
11913
+ mySqlCliConfigSchema = intersectionType(
11914
+ configCommonSchema,
11915
+ mysqlConnectionSchema
11916
+ );
11917
+ mySqlIntrospectConfigSchema = intersectionType(
11918
+ configIntrospectSchema,
11919
+ mysqlConnectionSchema
11920
+ );
11921
+ }
11922
+ });
11923
+
11924
+ // src/serializer/pgImports.ts
11925
+ var pgImports_exports = {};
11926
+ __export(pgImports_exports, {
11927
+ prepareFromExports: () => prepareFromExports3,
11928
+ prepareFromPgImports: () => prepareFromPgImports
11929
+ });
11930
+ import {
11931
+ PgTable,
11932
+ PgSchema as PgSchema2,
11933
+ isPgEnum
11934
+ } from "drizzle-orm/pg-core";
11935
+ import { is as is6 } from "drizzle-orm";
11936
+ var prepareFromExports3, prepareFromPgImports;
11937
+ var init_pgImports = __esm({
11938
+ "src/serializer/pgImports.ts"() {
11939
+ init_utils();
11940
+ prepareFromExports3 = (exports) => {
11941
+ const tables = [];
11942
+ const enums = [];
11943
+ const schemas = [];
11944
+ const i0values = Object.values(exports);
11945
+ i0values.forEach((t) => {
11946
+ if (isPgEnum(t)) {
11947
+ enums.push(t);
11948
+ return;
11949
+ }
11950
+ if (is6(t, PgTable)) {
11951
+ tables.push(t);
11952
+ }
11953
+ if (is6(t, PgSchema2)) {
11954
+ schemas.push(t);
11955
+ }
11956
+ });
11957
+ return { tables, enums, schemas };
11958
+ };
11959
+ prepareFromPgImports = async (imports) => {
11960
+ let tables = [];
11961
+ let enums = [];
11962
+ let schemas = [];
11963
+ const { unregister } = await safeRegister();
11964
+ for (let i = 0; i < imports.length; i++) {
11965
+ const it = imports[i];
11966
+ const i0 = __require(`${it}`);
11967
+ const prepared = prepareFromExports3(i0);
11968
+ tables.push(...prepared.tables);
11969
+ enums.push(...prepared.enums);
11970
+ schemas.push(...prepared.schemas);
11971
+ }
11972
+ unregister();
11973
+ return { tables: Array.from(new Set(tables)), enums, schemas };
11974
+ };
11975
+ }
11976
+ });
11977
+
11978
+ // src/global.ts
11979
+ var originUUID, snapshotVersion, mapValues;
11980
+ var init_global = __esm({
11981
+ "src/global.ts"() {
11982
+ originUUID = "00000000-0000-0000-0000-000000000000";
11983
+ snapshotVersion = "5";
11984
+ mapValues = (obj, map) => {
11985
+ const result = Object.keys(obj).reduce(function(result2, key) {
11986
+ result2[key] = map(obj[key]);
11987
+ return result2;
11988
+ }, {});
11989
+ return result;
11990
+ };
11991
+ }
11992
+ });
11993
+
11994
+ // src/serializer/pgSchema.ts
11995
+ var indexV2, columnV2, tableV2, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, index, fk, column, tableV3, compositePK, uniqueConstraint, tableV4, table, schemaHash, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaExternal, kitInternals, pgSchemaInternal, tableSquashed, tableSquashedV4, pgSchemaSquashedV4, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchema, backwardCompatiblePgSchema, PgSquasher, squashPgScheme, dryPg;
11996
+ var init_pgSchema = __esm({
11997
+ "src/serializer/pgSchema.ts"() {
11998
+ init_global();
11999
+ init_lib();
12000
+ indexV2 = objectType({
12001
+ name: stringType(),
12002
+ columns: recordType(
12003
+ stringType(),
12004
+ objectType({
12005
+ name: stringType()
12006
+ })
12007
+ ),
12008
+ isUnique: booleanType()
12009
+ }).strict();
12010
+ columnV2 = objectType({
12011
+ name: stringType(),
12012
+ type: stringType(),
12013
+ primaryKey: booleanType(),
12014
+ notNull: booleanType(),
12015
+ default: anyType().optional(),
12016
+ references: stringType().optional()
12017
+ }).strict();
12018
+ tableV2 = objectType({
12019
+ name: stringType(),
12020
+ columns: recordType(stringType(), columnV2),
12021
+ indexes: recordType(stringType(), indexV2)
12022
+ }).strict();
12023
+ enumSchema = objectType({
12024
+ name: stringType(),
12025
+ values: recordType(stringType(), stringType())
12026
+ }).strict();
12027
+ pgSchemaV2 = objectType({
12028
+ version: literalType("2"),
12029
+ tables: recordType(stringType(), tableV2),
12030
+ enums: recordType(stringType(), enumSchema)
12031
+ }).strict();
12032
+ references = objectType({
12033
+ foreignKeyName: stringType(),
12034
+ table: stringType(),
12035
+ column: stringType(),
12036
+ onDelete: stringType().optional(),
12037
+ onUpdate: stringType().optional()
12038
+ }).strict();
12039
+ columnV1 = objectType({
12040
+ name: stringType(),
12041
+ type: stringType(),
12042
+ primaryKey: booleanType(),
12043
+ notNull: booleanType(),
12044
+ default: anyType().optional(),
12045
+ references: references.optional()
12046
+ }).strict();
12047
+ tableV1 = objectType({
12048
+ name: stringType(),
12049
+ columns: recordType(stringType(), columnV1),
12050
+ indexes: recordType(stringType(), indexV2)
12051
+ }).strict();
12052
+ pgSchemaV1 = objectType({
12053
+ version: literalType("1"),
12054
+ tables: recordType(stringType(), tableV1),
12055
+ enums: recordType(stringType(), enumSchema)
12056
+ }).strict();
12057
+ index = objectType({
12058
+ name: stringType(),
12059
+ columns: stringType().array(),
12060
+ isUnique: booleanType()
12061
+ }).strict();
12062
+ fk = objectType({
12063
+ name: stringType(),
12064
+ tableFrom: stringType(),
12065
+ columnsFrom: stringType().array(),
12066
+ tableTo: stringType(),
12067
+ schemaTo: stringType().optional(),
12068
+ columnsTo: stringType().array(),
12069
+ onUpdate: stringType().optional(),
12070
+ onDelete: stringType().optional()
12071
+ }).strict();
12072
+ column = objectType({
12073
+ name: stringType(),
12074
+ type: stringType(),
12075
+ primaryKey: booleanType(),
12076
+ notNull: booleanType(),
12077
+ default: anyType().optional(),
12078
+ isUnique: anyType().optional(),
12079
+ uniqueName: stringType().optional(),
12080
+ nullsNotDistinct: booleanType().optional()
12081
+ }).strict();
12082
+ tableV3 = objectType({
12083
+ name: stringType(),
12084
+ columns: recordType(stringType(), column),
12085
+ indexes: recordType(stringType(), index),
12086
+ foreignKeys: recordType(stringType(), fk)
12087
+ }).strict();
12088
+ compositePK = objectType({
12089
+ name: stringType(),
12090
+ columns: stringType().array()
12091
+ }).strict();
12092
+ uniqueConstraint = objectType({
12093
+ name: stringType(),
12094
+ columns: stringType().array(),
12095
+ nullsNotDistinct: booleanType()
12096
+ }).strict();
12097
+ tableV4 = objectType({
12098
+ name: stringType(),
12099
+ schema: stringType(),
12100
+ columns: recordType(stringType(), column),
12101
+ indexes: recordType(stringType(), index),
12102
+ foreignKeys: recordType(stringType(), fk)
12103
+ }).strict();
12104
+ table = objectType({
12105
+ name: stringType(),
12106
+ schema: stringType(),
12107
+ columns: recordType(stringType(), column),
12108
+ indexes: recordType(stringType(), index),
12109
+ foreignKeys: recordType(stringType(), fk),
12110
+ compositePrimaryKeys: recordType(stringType(), compositePK),
12111
+ uniqueConstraints: recordType(stringType(), uniqueConstraint).default({})
12112
+ }).strict();
12113
+ schemaHash = objectType({
12114
+ id: stringType(),
12115
+ prevId: stringType()
12116
+ });
12117
+ pgSchemaInternalV3 = objectType({
12118
+ version: literalType("3"),
12119
+ dialect: literalType("pg"),
12120
+ tables: recordType(stringType(), tableV3),
12121
+ enums: recordType(stringType(), enumSchema)
12122
+ }).strict();
12123
+ pgSchemaInternalV4 = objectType({
12124
+ version: literalType("4"),
12125
+ dialect: literalType("pg"),
12126
+ tables: recordType(stringType(), tableV4),
12127
+ enums: recordType(stringType(), enumSchema),
12128
+ schemas: recordType(stringType(), stringType())
12129
+ }).strict();
12130
+ pgSchemaExternal = objectType({
12131
+ version: literalType("5"),
12132
+ dialect: literalType("pg"),
12133
+ tables: arrayType(table),
12134
+ enums: arrayType(enumSchema),
12135
+ schemas: arrayType(objectType({ name: stringType() })),
12136
+ _meta: objectType({
12137
+ schemas: recordType(stringType(), stringType()),
12138
+ tables: recordType(stringType(), stringType()),
12139
+ columns: recordType(stringType(), stringType())
12140
+ })
12141
+ }).strict();
12142
+ kitInternals = objectType({
12143
+ tables: recordType(
12144
+ stringType(),
12145
+ objectType({
12146
+ columns: recordType(
12147
+ stringType(),
12148
+ objectType({
12149
+ isArray: booleanType().optional(),
12150
+ dimensions: numberType().optional(),
12151
+ rawType: stringType().optional()
12152
+ }).optional()
12153
+ )
12154
+ }).optional()
12155
+ )
12156
+ }).optional();
12157
+ pgSchemaInternal = objectType({
12158
+ version: literalType("5"),
12159
+ dialect: literalType("pg"),
12160
+ tables: recordType(stringType(), table),
12161
+ enums: recordType(stringType(), enumSchema),
12162
+ schemas: recordType(stringType(), stringType()),
12163
+ _meta: objectType({
12164
+ schemas: recordType(stringType(), stringType()),
12165
+ tables: recordType(stringType(), stringType()),
12166
+ columns: recordType(stringType(), stringType())
12167
+ }),
12168
+ internal: kitInternals
12169
+ }).strict();
12170
+ tableSquashed = objectType({
12171
+ name: stringType(),
12172
+ schema: stringType(),
12173
+ columns: recordType(stringType(), column),
12174
+ indexes: recordType(stringType(), stringType()),
12175
+ foreignKeys: recordType(stringType(), stringType()),
12176
+ compositePrimaryKeys: recordType(stringType(), stringType()),
12177
+ uniqueConstraints: recordType(stringType(), stringType())
12178
+ }).strict();
12179
+ tableSquashedV4 = objectType({
12180
+ name: stringType(),
12181
+ schema: stringType(),
12182
+ columns: recordType(stringType(), column),
12183
+ indexes: recordType(stringType(), stringType()),
12184
+ foreignKeys: recordType(stringType(), stringType())
12185
+ }).strict();
12186
+ pgSchemaSquashedV4 = objectType({
12187
+ version: literalType("4"),
12188
+ dialect: enumType(["pg"]),
12189
+ tables: recordType(stringType(), tableSquashedV4),
12190
+ enums: recordType(stringType(), enumSchema),
12191
+ schemas: recordType(stringType(), stringType())
12192
+ }).strict();
12193
+ pgSchemaSquashed = objectType({
12194
+ version: literalType("5"),
12195
+ dialect: enumType(["pg"]),
12196
+ tables: recordType(stringType(), tableSquashed),
12197
+ enums: recordType(stringType(), enumSchema),
12198
+ schemas: recordType(stringType(), stringType())
12199
+ }).strict();
12200
+ pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash);
12201
+ pgSchemaV4 = pgSchemaInternalV4.merge(schemaHash);
12202
+ pgSchema = pgSchemaInternal.merge(schemaHash);
12203
+ backwardCompatiblePgSchema = unionType([
12204
+ pgSchemaV1,
12205
+ pgSchemaV2,
12206
+ pgSchemaV3,
12207
+ pgSchemaV4,
12208
+ pgSchema
12209
+ ]);
12210
+ PgSquasher = {
12211
+ squashIdx: (idx) => {
12212
+ index.parse(idx);
12213
+ return `${idx.name};${idx.columns.join(",")};${idx.isUnique}`;
12214
+ },
12215
+ unsquashIdx: (input) => {
12216
+ const [name, columnsString, isUnique] = input.split(";");
12217
+ const result = index.parse({
12218
+ name,
12219
+ columns: columnsString.split(","),
12220
+ isUnique: isUnique === "true"
12221
+ });
12222
+ return result;
12223
+ },
12224
+ squashFK: (fk4) => {
12225
+ return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""};${fk4.schemaTo ?? ""}`;
12226
+ },
12227
+ squashPK: (pk) => {
12228
+ return `${pk.columns.join(",")};${pk.name}`;
12229
+ },
12230
+ unsquashPK: (pk) => {
12231
+ const splitted = pk.split(";");
12232
+ return { name: splitted[1], columns: splitted[0].split(",") };
12233
+ },
12234
+ squashUnique: (unq) => {
12235
+ return `${unq.name};${unq.columns.join(",")};${unq.nullsNotDistinct}`;
12236
+ },
12237
+ unsquashUnique: (unq) => {
12238
+ const [name, columns, nullsNotDistinct] = unq.split(";");
12783
12239
  return {
12784
- jsxFactory: (_a = data.compilerOptions) == null ? void 0 : _a.jsxFactory,
12785
- jsxFragment: (_b = data.compilerOptions) == null ? void 0 : _b.jsxFragmentFactory,
12786
- target: (_d = (_c = data.compilerOptions) == null ? void 0 : _c.target) == null ? void 0 : _d.toLowerCase()
12240
+ name,
12241
+ columns: columns.split(","),
12242
+ nullsNotDistinct: nullsNotDistinct === "true"
12787
12243
  };
12244
+ },
12245
+ unsquashFK: (input) => {
12246
+ const [
12247
+ name,
12248
+ tableFrom,
12249
+ columnsFromStr,
12250
+ tableTo,
12251
+ columnsToStr,
12252
+ onUpdate,
12253
+ onDelete,
12254
+ schemaTo
12255
+ ] = input.split(";");
12256
+ const result = fk.parse({
12257
+ name,
12258
+ tableFrom,
12259
+ columnsFrom: columnsFromStr.split(","),
12260
+ schemaTo,
12261
+ tableTo,
12262
+ columnsTo: columnsToStr.split(","),
12263
+ onUpdate,
12264
+ onDelete
12265
+ });
12266
+ return result;
12788
12267
  }
12789
- return {};
12790
- };
12791
- var inferPackageFormat = (cwd, filename) => {
12792
- if (filename.endsWith(".mjs")) {
12793
- return "esm";
12794
- }
12795
- if (filename.endsWith(".cjs")) {
12796
- return "cjs";
12797
- }
12798
- const { data } = joycon.loadSync(["package.json"], cwd);
12799
- return data && data.type === "module" && /\.m?js$/.test(filename) ? "esm" : "cjs";
12800
12268
  };
12801
- var import_tsconfig_paths = __toModule(require_lib4());
12802
- var noOp = () => {
12803
- };
12804
- function registerTsconfigPaths() {
12805
- const configLoaderResult = (0, import_tsconfig_paths.loadConfig)(process.cwd());
12806
- if (configLoaderResult.resultType === "failed") {
12807
- return noOp;
12808
- }
12809
- const matchPath = (0, import_tsconfig_paths.createMatchPath)(configLoaderResult.absoluteBaseUrl, configLoaderResult.paths, configLoaderResult.mainFields, configLoaderResult.addMatchAll);
12810
- const Module = __require("module");
12811
- const originalResolveFilename = Module._resolveFilename;
12812
- Module._resolveFilename = function(request, _parent) {
12813
- const isCoreModule = _module2.builtinModules.includes(request);
12814
- if (!isCoreModule) {
12815
- const found = matchPath(request);
12816
- if (found) {
12817
- const modifiedArguments = [found, ...[].slice.call(arguments, 1)];
12818
- return originalResolveFilename.apply(this, modifiedArguments);
12819
- }
12820
- }
12821
- return originalResolveFilename.apply(this, arguments);
12822
- };
12823
- return () => {
12824
- Module._resolveFilename = originalResolveFilename;
12825
- };
12826
- }
12827
- var _debug = require_src2();
12828
- var _debug2 = _interopRequireDefault2(_debug);
12829
- var debug = _debug2.default.call(void 0, "esbuild-register");
12830
- var IMPORT_META_URL_VARIABLE_NAME = "__esbuild_register_import_meta_url__";
12831
- var map = {};
12832
- function installSourceMapSupport() {
12833
- if (_process2.default.setSourceMapsEnabled) {
12834
- ;
12835
- _process2.default.setSourceMapsEnabled(true);
12836
- } else {
12837
- import_source_map_support.default.install({
12838
- handleUncaughtExceptions: false,
12839
- environment: "node",
12840
- retrieveSourceMap(file) {
12841
- if (map[file]) {
12842
- return {
12843
- url: file,
12844
- map: map[file]
12845
- };
12269
+ squashPgScheme = (json) => {
12270
+ const mappedTables = Object.fromEntries(
12271
+ Object.entries(json.tables).map((it) => {
12272
+ const squashedIndexes = mapValues(it[1].indexes, (index4) => {
12273
+ return PgSquasher.squashIdx(index4);
12274
+ });
12275
+ const squashedFKs = mapValues(it[1].foreignKeys, (fk4) => {
12276
+ return PgSquasher.squashFK(fk4);
12277
+ });
12278
+ const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => {
12279
+ return PgSquasher.squashPK(pk);
12280
+ });
12281
+ const squashedUniqueConstraints = mapValues(
12282
+ it[1].uniqueConstraints,
12283
+ (unq) => {
12284
+ return PgSquasher.squashUnique(unq);
12846
12285
  }
12847
- return null;
12848
- }
12849
- });
12850
- }
12851
- }
12852
- function patchCommonJsLoader(compile) {
12853
- const extensions = _module3.default.Module._extensions;
12854
- const jsHandler = extensions[".js"];
12855
- extensions[".js"] = function(module2, filename) {
12856
- try {
12857
- return jsHandler.call(this, module2, filename);
12858
- } catch (error2) {
12859
- if (error2.code !== "ERR_REQUIRE_ESM") {
12860
- throw error2;
12861
- }
12862
- let content = _fs3.default.readFileSync(filename, "utf8");
12863
- content = compile(content, filename, "cjs");
12864
- module2._compile(content, filename);
12865
- }
12866
- };
12867
- return () => {
12868
- extensions[".js"] = jsHandler;
12286
+ );
12287
+ return [
12288
+ it[0],
12289
+ {
12290
+ name: it[1].name,
12291
+ schema: it[1].schema,
12292
+ columns: it[1].columns,
12293
+ indexes: squashedIndexes,
12294
+ foreignKeys: squashedFKs,
12295
+ compositePrimaryKeys: squashedPKs,
12296
+ uniqueConstraints: squashedUniqueConstraints
12297
+ }
12298
+ ];
12299
+ })
12300
+ );
12301
+ return {
12302
+ version: "5",
12303
+ dialect: json.dialect,
12304
+ tables: mappedTables,
12305
+ enums: json.enums,
12306
+ schemas: json.schemas
12869
12307
  };
12870
- }
12871
- var FILE_LOADERS = {
12872
- ".js": "js",
12873
- ".jsx": "jsx",
12874
- ".ts": "ts",
12875
- ".tsx": "tsx",
12876
- ".mjs": "js",
12877
- ".mts": "ts",
12878
- ".cts": "ts"
12879
12308
  };
12880
- var DEFAULT_EXTENSIONS = Object.keys(FILE_LOADERS);
12881
- var getLoader = (filename) => FILE_LOADERS[_path2.extname.call(void 0, filename)];
12882
- function register(esbuildOptions = {}) {
12883
- const {
12884
- extensions = DEFAULT_EXTENSIONS,
12885
- hookIgnoreNodeModules = true,
12886
- hookMatcher,
12887
- ...overrides
12888
- } = esbuildOptions;
12889
- const compile = function compile2(code, filename, format) {
12890
- const define = {
12891
- "import.meta.url": IMPORT_META_URL_VARIABLE_NAME,
12892
- ...overrides.define
12893
- };
12894
- const banner = `const ${IMPORT_META_URL_VARIABLE_NAME} = require('url').pathToFileURL(__filename).href;${overrides.banner || ""}`;
12895
- if (code.includes(banner)) {
12896
- return code;
12897
- }
12898
- const dir = _path2.dirname.call(void 0, filename);
12899
- const options = getOptions(dir);
12900
- format = format != null ? format : inferPackageFormat(dir, filename);
12901
- const result = _esbuild.transformSync.call(void 0, code, {
12902
- sourcefile: filename,
12903
- loader: getLoader(filename),
12904
- sourcemap: "both",
12905
- target: options.target,
12906
- jsxFactory: options.jsxFactory,
12907
- jsxFragment: options.jsxFragment,
12908
- format,
12909
- define,
12910
- banner,
12911
- ...overrides
12309
+ dryPg = pgSchema.parse({
12310
+ version: snapshotVersion,
12311
+ dialect: "pg",
12312
+ id: originUUID,
12313
+ prevId: "",
12314
+ tables: {},
12315
+ enums: {},
12316
+ schemas: {},
12317
+ _meta: {
12318
+ schemas: {},
12319
+ tables: {},
12320
+ columns: {}
12321
+ }
12322
+ });
12323
+ }
12324
+ });
12325
+
12326
+ // src/serializer/sqliteSchema.ts
12327
+ var index2, fk2, compositePK2, column2, tableV32, uniqueConstraint2, table2, dialect4, schemaHash2, schemaInternalV3, schemaInternalV4, latestVersion, schemaInternal, schemaV3, schemaV4, schema2, tableSquashed2, schemaSquashed, SQLiteSquasher, squashSqliteScheme, drySQLite, sqliteSchema, backwardCompatibleSqliteSchema;
12328
+ var init_sqliteSchema = __esm({
12329
+ "src/serializer/sqliteSchema.ts"() {
12330
+ init_global();
12331
+ init_lib();
12332
+ index2 = objectType({
12333
+ name: stringType(),
12334
+ columns: stringType().array(),
12335
+ where: stringType().optional(),
12336
+ isUnique: booleanType()
12337
+ }).strict();
12338
+ fk2 = objectType({
12339
+ name: stringType(),
12340
+ tableFrom: stringType(),
12341
+ columnsFrom: stringType().array(),
12342
+ tableTo: stringType(),
12343
+ columnsTo: stringType().array(),
12344
+ onUpdate: stringType().optional(),
12345
+ onDelete: stringType().optional()
12346
+ }).strict();
12347
+ compositePK2 = objectType({
12348
+ columns: stringType().array(),
12349
+ name: stringType().optional()
12350
+ }).strict();
12351
+ column2 = objectType({
12352
+ name: stringType(),
12353
+ type: stringType(),
12354
+ primaryKey: booleanType(),
12355
+ notNull: booleanType(),
12356
+ autoincrement: booleanType().optional(),
12357
+ default: anyType().optional()
12358
+ }).strict();
12359
+ tableV32 = objectType({
12360
+ name: stringType(),
12361
+ columns: recordType(stringType(), column2),
12362
+ indexes: recordType(stringType(), index2),
12363
+ foreignKeys: recordType(stringType(), fk2)
12364
+ }).strict();
12365
+ uniqueConstraint2 = objectType({
12366
+ name: stringType(),
12367
+ columns: stringType().array()
12368
+ }).strict();
12369
+ table2 = objectType({
12370
+ name: stringType(),
12371
+ columns: recordType(stringType(), column2),
12372
+ indexes: recordType(stringType(), index2),
12373
+ foreignKeys: recordType(stringType(), fk2),
12374
+ compositePrimaryKeys: recordType(stringType(), compositePK2),
12375
+ uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
12376
+ }).strict();
12377
+ dialect4 = enumType(["sqlite"]);
12378
+ schemaHash2 = objectType({
12379
+ id: stringType(),
12380
+ prevId: stringType()
12381
+ }).strict();
12382
+ schemaInternalV3 = objectType({
12383
+ version: literalType("3"),
12384
+ dialect: dialect4,
12385
+ tables: recordType(stringType(), tableV32),
12386
+ enums: objectType({})
12387
+ }).strict();
12388
+ schemaInternalV4 = objectType({
12389
+ version: literalType("4"),
12390
+ dialect: dialect4,
12391
+ tables: recordType(stringType(), table2),
12392
+ enums: objectType({})
12393
+ }).strict();
12394
+ latestVersion = literalType("5");
12395
+ schemaInternal = objectType({
12396
+ version: latestVersion,
12397
+ dialect: dialect4,
12398
+ tables: recordType(stringType(), table2),
12399
+ enums: objectType({}),
12400
+ _meta: objectType({
12401
+ tables: recordType(stringType(), stringType()),
12402
+ columns: recordType(stringType(), stringType())
12403
+ })
12404
+ }).strict();
12405
+ schemaV3 = schemaInternalV3.merge(schemaHash2).strict();
12406
+ schemaV4 = schemaInternalV4.merge(schemaHash2).strict();
12407
+ schema2 = schemaInternal.merge(schemaHash2).strict();
12408
+ tableSquashed2 = objectType({
12409
+ name: stringType(),
12410
+ columns: recordType(stringType(), column2),
12411
+ indexes: recordType(stringType(), stringType()),
12412
+ foreignKeys: recordType(stringType(), stringType()),
12413
+ compositePrimaryKeys: recordType(stringType(), stringType()),
12414
+ uniqueConstraints: recordType(stringType(), stringType()).default({})
12415
+ }).strict();
12416
+ schemaSquashed = objectType({
12417
+ version: latestVersion,
12418
+ dialect: dialect4,
12419
+ tables: recordType(stringType(), tableSquashed2),
12420
+ enums: anyType()
12421
+ }).strict();
12422
+ SQLiteSquasher = {
12423
+ squashIdx: (idx) => {
12424
+ index2.parse(idx);
12425
+ return `${idx.name};${idx.columns.join(",")};${idx.isUnique};${idx.where ?? ""}`;
12426
+ },
12427
+ unsquashIdx: (input) => {
12428
+ const [name, columnsString, isUnique, where] = input.split(";");
12429
+ const result = index2.parse({
12430
+ name,
12431
+ columns: columnsString.split(","),
12432
+ isUnique: isUnique === "true",
12433
+ where: where ?? void 0
12912
12434
  });
12913
- const js = result.code;
12914
- debug("compiled %s", filename);
12915
- debug("%s", js);
12916
- const warnings = result.warnings;
12917
- if (warnings && warnings.length > 0) {
12918
- for (const warning of warnings) {
12919
- console.log(warning.location);
12920
- console.log(warning.text);
12921
- }
12922
- }
12923
- if (format === "esm")
12924
- return js;
12925
- return removeNodePrefix(js);
12926
- };
12927
- const revert = (0, import_pirates.addHook)(compile, {
12928
- exts: extensions,
12929
- ignoreNodeModules: hookIgnoreNodeModules,
12930
- matcher: hookMatcher
12931
- });
12932
- installSourceMapSupport();
12933
- const unpatchCommonJsLoader = patchCommonJsLoader(compile);
12934
- const unregisterTsconfigPaths = registerTsconfigPaths();
12435
+ return result;
12436
+ },
12437
+ squashUnique: (unq) => {
12438
+ return `${unq.name};${unq.columns.join(",")}`;
12439
+ },
12440
+ unsquashUnique: (unq) => {
12441
+ const [name, columns] = unq.split(";");
12442
+ return { name, columns: columns.split(",") };
12443
+ },
12444
+ squashFK: (fk4) => {
12445
+ return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""}`;
12446
+ },
12447
+ unsquashFK: (input) => {
12448
+ const [
12449
+ name,
12450
+ tableFrom,
12451
+ columnsFromStr,
12452
+ tableTo,
12453
+ columnsToStr,
12454
+ onUpdate,
12455
+ onDelete
12456
+ ] = input.split(";");
12457
+ const result = fk2.parse({
12458
+ name,
12459
+ tableFrom,
12460
+ columnsFrom: columnsFromStr.split(","),
12461
+ tableTo,
12462
+ columnsTo: columnsToStr.split(","),
12463
+ onUpdate,
12464
+ onDelete
12465
+ });
12466
+ return result;
12467
+ },
12468
+ squashPK: (pk) => {
12469
+ return pk.columns.join(",");
12470
+ },
12471
+ unsquashPK: (pk) => {
12472
+ return pk.split(",");
12473
+ }
12474
+ };
12475
+ squashSqliteScheme = (json) => {
12476
+ const mappedTables = Object.fromEntries(
12477
+ Object.entries(json.tables).map((it) => {
12478
+ const squashedIndexes = mapValues(it[1].indexes, (index4) => {
12479
+ return SQLiteSquasher.squashIdx(index4);
12480
+ });
12481
+ const squashedFKs = mapValues(it[1].foreignKeys, (fk4) => {
12482
+ return SQLiteSquasher.squashFK(fk4);
12483
+ });
12484
+ const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => {
12485
+ return SQLiteSquasher.squashPK(pk);
12486
+ });
12487
+ const squashedUniqueConstraints = mapValues(it[1].uniqueConstraints, (unq) => {
12488
+ return SQLiteSquasher.squashUnique(unq);
12489
+ });
12490
+ return [
12491
+ it[0],
12492
+ {
12493
+ name: it[1].name,
12494
+ columns: it[1].columns,
12495
+ indexes: squashedIndexes,
12496
+ foreignKeys: squashedFKs,
12497
+ compositePrimaryKeys: squashedPKs,
12498
+ uniqueConstraints: squashedUniqueConstraints
12499
+ }
12500
+ ];
12501
+ })
12502
+ );
12935
12503
  return {
12936
- unregister() {
12937
- revert();
12938
- unpatchCommonJsLoader();
12939
- unregisterTsconfigPaths();
12940
- }
12504
+ version: "5",
12505
+ dialect: json.dialect,
12506
+ tables: mappedTables,
12507
+ enums: json.enums
12941
12508
  };
12942
- }
12943
- exports.register = register;
12509
+ };
12510
+ drySQLite = schema2.parse({
12511
+ version: snapshotVersion,
12512
+ dialect: "sqlite",
12513
+ id: originUUID,
12514
+ prevId: "",
12515
+ tables: {},
12516
+ enums: {},
12517
+ _meta: {
12518
+ tables: {},
12519
+ columns: {}
12520
+ }
12521
+ });
12522
+ sqliteSchema = schema2;
12523
+ backwardCompatibleSqliteSchema = unionType([schemaV3, schemaV4, schema2]);
12944
12524
  }
12945
12525
  });
12946
12526
 
12947
- // src/cli/commands/utils.ts
12948
- var import_hanji2, assertES5, safeRegister;
12949
- var init_utils = __esm({
12950
- "src/cli/commands/utils.ts"() {
12951
- "use strict";
12952
- init_serializer();
12953
- init_source();
12954
- init_views();
12955
- import_hanji2 = __toESM(require_hanji());
12956
- init_outputs();
12527
+ // src/serializer/mysqlSchema.ts
12528
+ var index3, fk3, column3, tableV33, compositePK3, uniqueConstraint3, tableV42, table3, dialect5, schemaHash3, schemaInternalV32, schemaInternalV42, kitInternals2, schemaInternal2, schemaV32, schemaV42, schema3, tableSquashedV42, tableSquashed3, schemaSquashed2, schemaSquashedV4, MySqlSquasher, squashMysqlScheme, mysqlSchema, backwardCompatibleMysqlSchema, dryMySql;
12529
+ var init_mysqlSchema = __esm({
12530
+ "src/serializer/mysqlSchema.ts"() {
12957
12531
  init_global();
12958
- init_mysql();
12959
- init_pg();
12960
- init_sqlite();
12961
- init_common();
12962
- assertES5 = async (unregister) => {
12963
- try {
12964
- init_es5();
12965
- } catch (e) {
12966
- if ("errors" in e && Array.isArray(e.errors) && e.errors.length > 0) {
12967
- const es5Error = e.errors.filter(
12968
- (it) => {
12969
- var _a;
12970
- return (_a = it.text) == null ? void 0 : _a.includes(`("es5") is not supported yet`);
12971
- }
12972
- ).length > 0;
12973
- if (es5Error) {
12974
- console.log(
12975
- error(
12976
- `Please change compilerOptions.target from 'es5' to 'es6' or above in your tsconfig.json`
12977
- )
12978
- );
12979
- process.exit(1);
12980
- }
12981
- }
12982
- console.error(e);
12983
- process.exit(1);
12984
- }
12985
- };
12986
- safeRegister = async () => {
12987
- const { register } = await Promise.resolve().then(() => __toESM(require_node2()));
12988
- let res;
12989
- try {
12990
- res = register({
12991
- format: "cjs",
12992
- loader: "ts"
12993
- });
12994
- } catch {
12995
- res = {
12996
- unregister: () => {
12997
- }
12532
+ init_lib();
12533
+ index3 = objectType({
12534
+ name: stringType(),
12535
+ columns: stringType().array(),
12536
+ isUnique: booleanType(),
12537
+ using: enumType(["btree", "hash"]).optional(),
12538
+ algorithm: enumType(["default", "inplace", "copy"]).optional(),
12539
+ lock: enumType(["default", "none", "shared", "exclusive"]).optional()
12540
+ }).strict();
12541
+ fk3 = objectType({
12542
+ name: stringType(),
12543
+ tableFrom: stringType(),
12544
+ columnsFrom: stringType().array(),
12545
+ tableTo: stringType(),
12546
+ columnsTo: stringType().array(),
12547
+ onUpdate: stringType().optional(),
12548
+ onDelete: stringType().optional()
12549
+ }).strict();
12550
+ column3 = objectType({
12551
+ name: stringType(),
12552
+ type: stringType(),
12553
+ primaryKey: booleanType(),
12554
+ notNull: booleanType(),
12555
+ autoincrement: booleanType().optional(),
12556
+ default: anyType().optional(),
12557
+ onUpdate: anyType().optional()
12558
+ }).strict();
12559
+ tableV33 = objectType({
12560
+ name: stringType(),
12561
+ columns: recordType(stringType(), column3),
12562
+ indexes: recordType(stringType(), index3),
12563
+ foreignKeys: recordType(stringType(), fk3)
12564
+ }).strict();
12565
+ compositePK3 = objectType({
12566
+ name: stringType(),
12567
+ columns: stringType().array()
12568
+ }).strict();
12569
+ uniqueConstraint3 = objectType({
12570
+ name: stringType(),
12571
+ columns: stringType().array()
12572
+ }).strict();
12573
+ tableV42 = objectType({
12574
+ name: stringType(),
12575
+ schema: stringType().optional(),
12576
+ columns: recordType(stringType(), column3),
12577
+ indexes: recordType(stringType(), index3),
12578
+ foreignKeys: recordType(stringType(), fk3)
12579
+ }).strict();
12580
+ table3 = objectType({
12581
+ name: stringType(),
12582
+ schema: stringType().optional(),
12583
+ columns: recordType(stringType(), column3),
12584
+ indexes: recordType(stringType(), index3),
12585
+ foreignKeys: recordType(stringType(), fk3),
12586
+ compositePrimaryKeys: recordType(stringType(), compositePK3),
12587
+ uniqueConstraints: recordType(stringType(), uniqueConstraint3).default({})
12588
+ }).strict();
12589
+ dialect5 = literalType("mysql");
12590
+ schemaHash3 = objectType({
12591
+ id: stringType(),
12592
+ prevId: stringType()
12593
+ });
12594
+ schemaInternalV32 = objectType({
12595
+ version: literalType("3"),
12596
+ dialect: dialect5,
12597
+ tables: recordType(stringType(), tableV33)
12598
+ }).strict();
12599
+ schemaInternalV42 = objectType({
12600
+ version: literalType("4"),
12601
+ dialect: dialect5,
12602
+ tables: recordType(stringType(), tableV42),
12603
+ schemas: recordType(stringType(), stringType())
12604
+ }).strict();
12605
+ kitInternals2 = objectType({
12606
+ tables: recordType(
12607
+ stringType(),
12608
+ objectType({
12609
+ columns: recordType(
12610
+ stringType(),
12611
+ objectType({ isDefaultAnExpression: booleanType().optional() }).optional()
12612
+ )
12613
+ }).optional()
12614
+ )
12615
+ }).optional();
12616
+ schemaInternal2 = objectType({
12617
+ version: literalType("5"),
12618
+ dialect: dialect5,
12619
+ tables: recordType(stringType(), table3),
12620
+ schemas: recordType(stringType(), stringType()),
12621
+ _meta: objectType({
12622
+ schemas: recordType(stringType(), stringType()),
12623
+ tables: recordType(stringType(), stringType()),
12624
+ columns: recordType(stringType(), stringType())
12625
+ }),
12626
+ internal: kitInternals2
12627
+ }).strict();
12628
+ schemaV32 = schemaInternalV32.merge(schemaHash3);
12629
+ schemaV42 = schemaInternalV42.merge(schemaHash3);
12630
+ schema3 = schemaInternal2.merge(schemaHash3);
12631
+ tableSquashedV42 = objectType({
12632
+ name: stringType(),
12633
+ schema: stringType().optional(),
12634
+ columns: recordType(stringType(), column3),
12635
+ indexes: recordType(stringType(), stringType()),
12636
+ foreignKeys: recordType(stringType(), stringType())
12637
+ }).strict();
12638
+ tableSquashed3 = objectType({
12639
+ name: stringType(),
12640
+ schema: stringType().optional(),
12641
+ columns: recordType(stringType(), column3),
12642
+ indexes: recordType(stringType(), stringType()),
12643
+ foreignKeys: recordType(stringType(), stringType()),
12644
+ compositePrimaryKeys: recordType(stringType(), stringType()),
12645
+ uniqueConstraints: recordType(stringType(), stringType()).default({})
12646
+ }).strict();
12647
+ schemaSquashed2 = objectType({
12648
+ version: literalType("5"),
12649
+ dialect: dialect5,
12650
+ tables: recordType(stringType(), tableSquashed3),
12651
+ schemas: recordType(stringType(), stringType())
12652
+ }).strict();
12653
+ schemaSquashedV4 = objectType({
12654
+ version: literalType("4"),
12655
+ dialect: dialect5,
12656
+ tables: recordType(stringType(), tableSquashedV42),
12657
+ schemas: recordType(stringType(), stringType())
12658
+ }).strict();
12659
+ MySqlSquasher = {
12660
+ squashIdx: (idx) => {
12661
+ index3.parse(idx);
12662
+ return `${idx.name};${idx.columns.join(",")};${idx.isUnique};${idx.using ?? ""};${idx.algorithm ?? ""};${idx.lock ?? ""}`;
12663
+ },
12664
+ unsquashIdx: (input) => {
12665
+ const [name, columnsString, isUnique, using, algorithm, lock] = input.split(";");
12666
+ const destructed = {
12667
+ name,
12668
+ columns: columnsString.split(","),
12669
+ isUnique: isUnique === "true",
12670
+ using: using ? using : void 0,
12671
+ algorithm: algorithm ? algorithm : void 0,
12672
+ lock: lock ? lock : void 0
12998
12673
  };
12674
+ return index3.parse(destructed);
12675
+ },
12676
+ squashPK: (pk) => {
12677
+ return `${pk.name};${pk.columns.join(",")}`;
12678
+ },
12679
+ unsquashPK: (pk) => {
12680
+ const splitted = pk.split(";");
12681
+ return { name: splitted[0], columns: splitted[1].split(",") };
12682
+ },
12683
+ squashUnique: (unq) => {
12684
+ return `${unq.name};${unq.columns.join(",")}`;
12685
+ },
12686
+ unsquashUnique: (unq) => {
12687
+ const [name, columns] = unq.split(";");
12688
+ return { name, columns: columns.split(",") };
12689
+ },
12690
+ squashFK: (fk4) => {
12691
+ return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""}`;
12692
+ },
12693
+ unsquashFK: (input) => {
12694
+ const [
12695
+ name,
12696
+ tableFrom,
12697
+ columnsFromStr,
12698
+ tableTo,
12699
+ columnsToStr,
12700
+ onUpdate,
12701
+ onDelete
12702
+ ] = input.split(";");
12703
+ const result = fk3.parse({
12704
+ name,
12705
+ tableFrom,
12706
+ columnsFrom: columnsFromStr.split(","),
12707
+ tableTo,
12708
+ columnsTo: columnsToStr.split(","),
12709
+ onUpdate,
12710
+ onDelete
12711
+ });
12712
+ return result;
12999
12713
  }
13000
- await assertES5(res.unregister);
13001
- return res;
13002
12714
  };
13003
- }
13004
- });
13005
-
13006
- // src/serializer/pgImports.ts
13007
- var pgImports_exports = {};
13008
- __export(pgImports_exports, {
13009
- prepareFromExports: () => prepareFromExports3,
13010
- prepareFromPgImports: () => prepareFromPgImports
13011
- });
13012
- import {
13013
- PgTable,
13014
- PgSchema as PgSchema2,
13015
- isPgEnum
13016
- } from "drizzle-orm/pg-core";
13017
- import { is as is6 } from "drizzle-orm";
13018
- var prepareFromExports3, prepareFromPgImports;
13019
- var init_pgImports = __esm({
13020
- "src/serializer/pgImports.ts"() {
13021
- "use strict";
13022
- init_utils();
13023
- prepareFromExports3 = (exports) => {
13024
- const tables = [];
13025
- const enums = [];
13026
- const schemas = [];
13027
- const i0values = Object.values(exports);
13028
- i0values.forEach((t) => {
13029
- if (isPgEnum(t)) {
13030
- enums.push(t);
13031
- return;
13032
- }
13033
- if (is6(t, PgTable)) {
13034
- tables.push(t);
13035
- }
13036
- if (is6(t, PgSchema2)) {
13037
- schemas.push(t);
13038
- }
13039
- });
13040
- return { tables, enums, schemas };
12715
+ squashMysqlScheme = (json) => {
12716
+ const mappedTables = Object.fromEntries(
12717
+ Object.entries(json.tables).map((it) => {
12718
+ const squashedIndexes = mapValues(it[1].indexes, (index4) => {
12719
+ return MySqlSquasher.squashIdx(index4);
12720
+ });
12721
+ const squashedFKs = mapValues(it[1].foreignKeys, (fk4) => {
12722
+ return MySqlSquasher.squashFK(fk4);
12723
+ });
12724
+ const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => {
12725
+ return MySqlSquasher.squashPK(pk);
12726
+ });
12727
+ const squashedUniqueConstraints = mapValues(
12728
+ it[1].uniqueConstraints,
12729
+ (unq) => {
12730
+ return MySqlSquasher.squashUnique(unq);
12731
+ }
12732
+ );
12733
+ return [
12734
+ it[0],
12735
+ {
12736
+ name: it[1].name,
12737
+ schema: it[1].schema,
12738
+ columns: it[1].columns,
12739
+ indexes: squashedIndexes,
12740
+ foreignKeys: squashedFKs,
12741
+ compositePrimaryKeys: squashedPKs,
12742
+ uniqueConstraints: squashedUniqueConstraints
12743
+ }
12744
+ ];
12745
+ })
12746
+ );
12747
+ return {
12748
+ version: "5",
12749
+ dialect: json.dialect,
12750
+ tables: mappedTables,
12751
+ schemas: json.schemas
12752
+ };
13041
12753
  };
13042
- prepareFromPgImports = async (imports) => {
13043
- let tables = [];
13044
- let enums = [];
13045
- let schemas = [];
13046
- const { unregister } = await safeRegister();
13047
- for (let i = 0; i < imports.length; i++) {
13048
- const it = imports[i];
13049
- const i0 = __require(`${it}`);
13050
- const prepared = prepareFromExports3(i0);
13051
- tables.push(...prepared.tables);
13052
- enums.push(...prepared.enums);
13053
- schemas.push(...prepared.schemas);
12754
+ mysqlSchema = schema3;
12755
+ backwardCompatibleMysqlSchema = unionType([
12756
+ schemaV32,
12757
+ schemaV42,
12758
+ schema3
12759
+ ]);
12760
+ dryMySql = mysqlSchema.parse({
12761
+ version: snapshotVersion,
12762
+ dialect: "mysql",
12763
+ id: originUUID,
12764
+ prevId: "",
12765
+ tables: {},
12766
+ schemas: {},
12767
+ _meta: {
12768
+ schemas: {},
12769
+ tables: {},
12770
+ columns: {}
13054
12771
  }
13055
- unregister();
13056
- return { tables: Array.from(new Set(tables)), enums, schemas };
13057
- };
12772
+ });
13058
12773
  }
13059
12774
  });
13060
12775
 
@@ -13064,7 +12779,6 @@ import { randomUUID } from "crypto";
13064
12779
  var prepareMySqlDbPushSnapshot, prepareSQLiteDbPushSnapshot, preparePgDbPushSnapshot, prepareMySqlMigrationSnapshot, prepareSqliteMigrationSnapshot, fillPgSnapshot, preparePgMigrationSnapshot, preparePrevSnapshot;
13065
12780
  var init_migrationPreparator = __esm({
13066
12781
  "src/migrationPreparator.ts"() {
13067
- "use strict";
13068
12782
  init_serializer();
13069
12783
  init_pgSchema();
13070
12784
  init_sqliteSchema();
@@ -13073,18 +12787,18 @@ var init_migrationPreparator = __esm({
13073
12787
  const serialized = await serializeMySql(schemaPath);
13074
12788
  const id = randomUUID();
13075
12789
  const idPrev = prev.id;
13076
- const { version, dialect: dialect7, ...rest } = serialized;
13077
- const result = { version, dialect: dialect7, id, prevId: idPrev, ...rest };
12790
+ const { version, dialect: dialect6, ...rest } = serialized;
12791
+ const result = { version, dialect: dialect6, id, prevId: idPrev, ...rest };
13078
12792
  return { prev, cur: result };
13079
12793
  };
13080
12794
  prepareSQLiteDbPushSnapshot = async (prev, schemaPath) => {
13081
12795
  const serialized = await serializeSQLite(schemaPath);
13082
12796
  const id = randomUUID();
13083
12797
  const idPrev = prev.id;
13084
- const { version, dialect: dialect7, ...rest } = serialized;
12798
+ const { version, dialect: dialect6, ...rest } = serialized;
13085
12799
  const result = {
13086
12800
  version,
13087
- dialect: dialect7,
12801
+ dialect: dialect6,
13088
12802
  id,
13089
12803
  prevId: idPrev,
13090
12804
  ...rest
@@ -13095,8 +12809,8 @@ var init_migrationPreparator = __esm({
13095
12809
  const serialized = await serializePg(schemaPath, schemaFilter);
13096
12810
  const id = randomUUID();
13097
12811
  const idPrev = prev.id;
13098
- const { version, dialect: dialect7, ...rest } = serialized;
13099
- const result = { version, dialect: dialect7, id, prevId: idPrev, ...rest };
12812
+ const { version, dialect: dialect6, ...rest } = serialized;
12813
+ const result = { version, dialect: dialect6, id, prevId: idPrev, ...rest };
13100
12814
  return { prev, cur: result };
13101
12815
  };
13102
12816
  prepareMySqlMigrationSnapshot = async (migrationFolders, schemaPath) => {
@@ -13106,8 +12820,8 @@ var init_migrationPreparator = __esm({
13106
12820
  const serialized = await serializeMySql(schemaPath);
13107
12821
  const id = randomUUID();
13108
12822
  const idPrev = prevSnapshot.id;
13109
- const { version, dialect: dialect7, ...rest } = serialized;
13110
- const result = { version, dialect: dialect7, id, prevId: idPrev, ...rest };
12823
+ const { version, dialect: dialect6, ...rest } = serialized;
12824
+ const result = { version, dialect: dialect6, id, prevId: idPrev, ...rest };
13111
12825
  const { id: _ignoredId, prevId: _ignoredPrevId, ...prevRest } = prevSnapshot;
13112
12826
  const custom = {
13113
12827
  id,
@@ -13123,10 +12837,10 @@ var init_migrationPreparator = __esm({
13123
12837
  const serialized = await serializeSQLite(schemaPath);
13124
12838
  const id = randomUUID();
13125
12839
  const idPrev = prevSnapshot.id;
13126
- const { version, dialect: dialect7, ...rest } = serialized;
12840
+ const { version, dialect: dialect6, ...rest } = serialized;
13127
12841
  const result = {
13128
12842
  version,
13129
- dialect: dialect7,
12843
+ dialect: dialect6,
13130
12844
  id,
13131
12845
  prevId: idPrev,
13132
12846
  ...rest
@@ -13151,7 +12865,7 @@ var init_migrationPreparator = __esm({
13151
12865
  const serialized = await serializePg(schemaPath);
13152
12866
  const id = randomUUID();
13153
12867
  const idPrev = prevSnapshot.id;
13154
- const result = { id, prevId: idPrev, ...serialized };
12868
+ const result = fillPgSnapshot({ serialized, id, idPrev });
13155
12869
  const { id: _ignoredId, prevId: _ignoredPrevId, ...prevRest } = prevSnapshot;
13156
12870
  const custom = fillPgSnapshot({ serialized: prevRest, id, idPrev });
13157
12871
  return { prev: prevSnapshot, cur: result, custom };
@@ -13459,7 +13173,6 @@ function applyJsonDiff(json1, json2) {
13459
13173
  var findAlternationsInTable, alternationsInColumn;
13460
13174
  var init_jsonDiffer = __esm({
13461
13175
  "src/jsonDiffer.js"() {
13462
- "use strict";
13463
13176
  "use-strict";
13464
13177
  findAlternationsInTable = (table4, tableSchema) => {
13465
13178
  const columns = table4.columns ?? {};
@@ -13631,21 +13344,20 @@ var init_jsonDiffer = __esm({
13631
13344
  var preparePgCreateTableJson, prepareMySqlCreateTableJson, prepareSQLiteCreateTable, prepareDropTableJson, prepareRenameTableJson, prepareCreateEnumJson, prepareAddValuesToEnumJson, prepareCreateSchemasJson, prepareRenameSchemasJson, prepareDeleteSchemasJson, prepareRenameColumns, prepareAlterTableColumnsJson, _prepareDropColumns, _prepareAddColumns, _prepareSQLiteAddColumns, _prepareAlterColumns, prepareCreateIndexesJson, prepareCreateReferencesJson, prepareDropReferencesJson, prepareAlterReferencesJson, prepareDropIndexesJson, prepareAddCompositePrimaryKeySqlite, prepareDeleteCompositePrimaryKeySqlite, prepareAlterCompositePrimaryKeySqlite, prepareAddCompositePrimaryKeyPg, prepareDeleteCompositePrimaryKeyPg, prepareAlterCompositePrimaryKeyPg, prepareAddUniqueConstraintPg, prepareDeleteUniqueConstraintPg, prepareAddCompositePrimaryKeyMySql, prepareDeleteCompositePrimaryKeyMySql, prepareAlterCompositePrimaryKeyMySql;
13632
13345
  var init_jsonStatements = __esm({
13633
13346
  "src/jsonStatements.ts"() {
13634
- "use strict";
13635
13347
  init_mysqlSchema();
13636
13348
  init_pgSchema();
13637
13349
  init_sqliteSchema();
13638
13350
  preparePgCreateTableJson = (table4, json2) => {
13639
13351
  const { name, schema: schema4, columns, compositePrimaryKeys, uniqueConstraints } = table4;
13640
- const tableKey = `${schema4 || "public"}.${name}`;
13641
- const compositePkName = Object.values(compositePrimaryKeys).length > 0 ? json2.tables[tableKey].compositePrimaryKeys[`${PgSquasher.unsquashPK(Object.values(compositePrimaryKeys)[0]).name}`].name : "";
13642
13352
  return {
13643
13353
  type: "create_table",
13644
13354
  tableName: name,
13645
13355
  schema: schema4,
13646
13356
  columns: Object.values(columns),
13647
13357
  compositePKs: Object.values(compositePrimaryKeys),
13648
- compositePkName,
13358
+ compositePkName: Object.values(compositePrimaryKeys).length > 0 ? json2.tables[name].compositePrimaryKeys[`${PgSquasher.unsquashPK(
13359
+ Object.values(compositePrimaryKeys)[0]
13360
+ ).name}`].name : "",
13649
13361
  uniqueConstraints: Object.values(uniqueConstraints)
13650
13362
  };
13651
13363
  };
@@ -13744,12 +13456,11 @@ var init_jsonStatements = __esm({
13744
13456
  };
13745
13457
  });
13746
13458
  };
13747
- prepareAlterTableColumnsJson = (tableName, schema4, deleted, added, altered, addedFk, json2, dialect7) => {
13459
+ prepareAlterTableColumnsJson = (tableName, schema4, deleted, added, altered, addedFk, json2, dialect6) => {
13748
13460
  const addColumns = [];
13749
13461
  const dropColumns = _prepareDropColumns(tableName, schema4, deleted);
13750
- const tableKey = `${schema4 || "public"}.${tableName}`;
13751
- const alterColumns = _prepareAlterColumns(tableKey, schema4, altered, json2);
13752
- if (dialect7 === "sqlite") {
13462
+ const alterColumns = _prepareAlterColumns(tableName, schema4, altered, json2);
13463
+ if (dialect6 === "sqlite") {
13753
13464
  let jsonCreateFKStatements = Object.values(addedFk);
13754
13465
  const sqliteAddColumns = _prepareSQLiteAddColumns(
13755
13466
  tableName,
@@ -13798,22 +13509,19 @@ var init_jsonStatements = __esm({
13798
13509
  };
13799
13510
  });
13800
13511
  };
13801
- _prepareAlterColumns = (tableKey, schema4, columns, json2) => {
13512
+ _prepareAlterColumns = (tableName, schema4, columns, json2) => {
13802
13513
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
13803
13514
  let statements = [];
13804
13515
  let dropPkStatements = [];
13805
13516
  let setPkStatements = [];
13806
13517
  for (const column4 of columns) {
13807
13518
  const columnName = typeof column4.name !== "string" ? column4.name.new : column4.name;
13808
- const table4 = json2.tables[tableKey];
13809
- const tableName = table4.name;
13810
- const snapshotColumn = table4.columns[columnName];
13811
- const columnType = snapshotColumn.type;
13812
- const columnDefault = snapshotColumn.default;
13813
- const columnOnUpdate = "onUpdate" in snapshotColumn ? snapshotColumn.onUpdate : void 0;
13814
- const columnNotNull = table4.columns[columnName].notNull;
13815
- const columnAutoIncrement = "autoincrement" in snapshotColumn ? snapshotColumn.autoincrement ?? false : false;
13816
- const columnPk = table4.columns[columnName].primaryKey;
13519
+ const columnType = json2.tables[tableName].columns[columnName].type;
13520
+ const columnDefault = json2.tables[tableName].columns[columnName].default;
13521
+ const columnOnUpdate = json2.tables[tableName].columns[columnName].onUpdate;
13522
+ const columnNotNull = json2.tables[tableName].columns[columnName].notNull;
13523
+ const columnAutoIncrement = json2.tables[tableName].columns[columnName].autoincrement;
13524
+ const columnPk = json2.tables[tableName].columns[columnName].primaryKey;
13817
13525
  if (((_a = column4.autoincrement) == null ? void 0 : _a.type) === "added") {
13818
13526
  statements.push({
13819
13527
  type: "alter_table_alter_column_set_autoincrement",
@@ -13860,14 +13568,13 @@ var init_jsonStatements = __esm({
13860
13568
  }
13861
13569
  for (const column4 of columns) {
13862
13570
  const columnName = typeof column4.name !== "string" ? column4.name.new : column4.name;
13863
- const tableName = json2.tables[tableKey].name;
13864
- const columnType = json2.tables[tableKey].columns[columnName].type;
13865
- const columnDefault = json2.tables[tableKey].columns[columnName].default;
13866
- const columnOnUpdate = json2.tables[tableKey].columns[columnName].onUpdate;
13867
- const columnNotNull = json2.tables[tableKey].columns[columnName].notNull;
13868
- const columnAutoIncrement = json2.tables[tableKey].columns[columnName].autoincrement;
13869
- const columnPk = json2.tables[tableKey].columns[columnName].primaryKey;
13870
- const compositePk = json2.tables[tableKey].compositePrimaryKeys[`${tableName}_${columnName}`];
13571
+ const columnType = json2.tables[tableName].columns[columnName].type;
13572
+ const columnDefault = json2.tables[tableName].columns[columnName].default;
13573
+ const columnOnUpdate = json2.tables[tableName].columns[columnName].onUpdate;
13574
+ const columnNotNull = json2.tables[tableName].columns[columnName].notNull;
13575
+ const columnAutoIncrement = json2.tables[tableName].columns[columnName].autoincrement;
13576
+ const columnPk = json2.tables[tableName].columns[columnName].primaryKey;
13577
+ const compositePk = json2.tables[tableName].compositePrimaryKeys[`${tableName}_${columnName}`];
13871
13578
  if (typeof column4.name !== "string") {
13872
13579
  statements.push({
13873
13580
  type: "alter_table_rename_column",
@@ -14218,7 +13925,6 @@ var init_jsonStatements = __esm({
14218
13925
  var prepareMigrationMetadata, adjectives, heroes;
14219
13926
  var init_words = __esm({
14220
13927
  "src/utils/words.ts"() {
14221
- "use strict";
14222
13928
  prepareMigrationMetadata = (idx) => {
14223
13929
  const prefix = idx.toFixed(0).padStart(4, "0");
14224
13930
  const suffix = `${adjectives.random()}_${heroes.random()}`;
@@ -15539,7 +15245,6 @@ var init_words = __esm({
15539
15245
  // src/cli/commands/pgUp.ts
15540
15246
  var init_pgUp = __esm({
15541
15247
  "src/cli/commands/pgUp.ts"() {
15542
- "use strict";
15543
15248
  init_source();
15544
15249
  init_global();
15545
15250
  init_pgSchema();
@@ -15550,7 +15255,6 @@ var init_pgUp = __esm({
15550
15255
  // src/cli/commands/mysqlUp.ts
15551
15256
  var init_mysqlUp = __esm({
15552
15257
  "src/cli/commands/mysqlUp.ts"() {
15553
- "use strict";
15554
15258
  init_source();
15555
15259
  init_mysqlSchema();
15556
15260
  init_utils2();
@@ -15560,7 +15264,6 @@ var init_mysqlUp = __esm({
15560
15264
  // src/cli/commands/upFolders.ts
15561
15265
  var init_upFolders = __esm({
15562
15266
  "src/cli/commands/upFolders.ts"() {
15563
- "use strict";
15564
15267
  init_jsonDiffer();
15565
15268
  init_mysqlSchema();
15566
15269
  init_sqliteSchema();
@@ -15582,10 +15285,9 @@ import {
15582
15285
  writeFileSync
15583
15286
  } from "fs";
15584
15287
  import { join } from "path";
15585
- var assertV1OutFolder, dryJournal, prepareOutFolder, validatorForDialect, validateWithReport, prepareMigrationFolder, prepareMigrationMeta, schemaRenameKey, tableRenameKey, columnRenameKey;
15288
+ var assertV1OutFolder, dryJournal, prepareOutFolder2, validatorForDialect, validateWithReport, prepareMigrationFolder, prepareMigrationMeta, schemaRenameKey, tableRenameKey, columnRenameKey;
15586
15289
  var init_utils2 = __esm({
15587
15290
  "src/utils.ts"() {
15588
- "use strict";
15589
15291
  init_views();
15590
15292
  init_mysqlSchema();
15591
15293
  init_pgSchema();
@@ -15594,7 +15296,7 @@ var init_utils2 = __esm({
15594
15296
  init_global();
15595
15297
  init_upFolders();
15596
15298
  init_snapshotsDiffer();
15597
- assertV1OutFolder = (out) => {
15299
+ assertV1OutFolder = (out, dialect6) => {
15598
15300
  if (!existsSync(out))
15599
15301
  return;
15600
15302
  const oldMigrationFolders = readdirSync(out).filter(
@@ -15603,43 +15305,43 @@ var init_utils2 = __esm({
15603
15305
  if (oldMigrationFolders.length > 0) {
15604
15306
  console.log(
15605
15307
  `Your migrations folder format is outdated, please run ${source_default.green.bold(
15606
- `drizzle-kit up`
15308
+ `drizzle-kit up:${dialect6}`
15607
15309
  )}`
15608
15310
  );
15609
15311
  process.exit(1);
15610
15312
  }
15611
15313
  };
15612
- dryJournal = (dialect7) => {
15314
+ dryJournal = (dialect6) => {
15613
15315
  return {
15614
15316
  version: snapshotVersion,
15615
- dialect: dialect7,
15317
+ dialect: dialect6,
15616
15318
  entries: []
15617
15319
  };
15618
15320
  };
15619
- prepareOutFolder = (out, dialect7) => {
15321
+ prepareOutFolder2 = (out, dialect6) => {
15620
15322
  const meta = join(out, "meta");
15621
15323
  const journalPath = join(meta, "_journal.json");
15622
15324
  if (!existsSync(join(out, "meta"))) {
15623
15325
  mkdirSync(meta, { recursive: true });
15624
- writeFileSync(journalPath, JSON.stringify(dryJournal(dialect7)));
15326
+ writeFileSync(journalPath, JSON.stringify(dryJournal(dialect6)));
15625
15327
  }
15626
15328
  const journal = JSON.parse(readFileSync(journalPath).toString());
15627
15329
  const snapshots = readdirSync(meta).filter((it) => !it.startsWith("_")).map((it) => join(meta, it));
15628
15330
  snapshots.sort();
15629
15331
  return { meta, snapshots, journal };
15630
15332
  };
15631
- validatorForDialect = (dialect7) => {
15632
- switch (dialect7) {
15333
+ validatorForDialect = (dialect6) => {
15334
+ switch (dialect6) {
15633
15335
  case "pg":
15634
- return { validator: backwardCompatiblePgSchema, version: 6 };
15336
+ return { validator: backwardCompatiblePgSchema, version: 5 };
15635
15337
  case "sqlite":
15636
- return { validator: backwardCompatibleSqliteSchema, version: 6 };
15338
+ return { validator: backwardCompatibleSqliteSchema, version: 5 };
15637
15339
  case "mysql":
15638
15340
  return { validator: backwardCompatibleMysqlSchema, version: 5 };
15639
15341
  }
15640
15342
  };
15641
- validateWithReport = (snapshots, dialect7) => {
15642
- const { validator, version } = validatorForDialect(dialect7);
15343
+ validateWithReport = (snapshots, dialect6) => {
15344
+ const { validator, version } = validatorForDialect(dialect6);
15643
15345
  const result = snapshots.reduce(
15644
15346
  (accum, it) => {
15645
15347
  const raw = JSON.parse(readFileSync(`./${it}`).toString());
@@ -15680,14 +15382,14 @@ var init_utils2 = __esm({
15680
15382
  );
15681
15383
  return result;
15682
15384
  };
15683
- prepareMigrationFolder = (outFolder = "drizzle", dialect7) => {
15684
- const { snapshots, journal } = prepareOutFolder(outFolder, dialect7);
15685
- const report = validateWithReport(snapshots, dialect7);
15385
+ prepareMigrationFolder = (outFolder = "drizzle", dialect6) => {
15386
+ const { snapshots, journal } = prepareOutFolder2(outFolder, dialect6);
15387
+ const report = validateWithReport(snapshots, dialect6);
15686
15388
  if (report.nonLatest.length > 0) {
15687
15389
  console.log(
15688
15390
  report.nonLatest.map((it) => {
15689
15391
  return `${it}/snapshot.json is not of the latest version`;
15690
- }).concat(`Run ${source_default.green.bold(`drizzle-kit up`)}`).join("\n")
15392
+ }).concat(`Run ${source_default.green.bold(`drizzle-kit up:${dialect6}`)}`).join("\n")
15691
15393
  );
15692
15394
  process.exit(0);
15693
15395
  }
@@ -15756,7 +15458,6 @@ var init_utils2 = __esm({
15756
15458
  var makeChanged, makeSelfOrChanged, makePatched, makeSelfOrPatched, valueFromSelfOrPatchedNew, columnSchema, alteredColumnSchema, enumSchema2, changedEnumSchema, tableScheme, alteredTableScheme, diffResultScheme, applySnapshotsDiff;
15757
15459
  var init_snapshotsDiffer = __esm({
15758
15460
  "src/snapshotsDiffer.ts"() {
15759
- "use strict";
15760
15461
  init_sqlgenerator();
15761
15462
  init_lib();
15762
15463
  init_jsonDiffer();
@@ -15764,7 +15465,6 @@ var init_snapshotsDiffer = __esm({
15764
15465
  init_utils2();
15765
15466
  init_sqliteSchema();
15766
15467
  init_mysqlSchema();
15767
- init_global();
15768
15468
  makeChanged = (schema4) => {
15769
15469
  return objectType({
15770
15470
  type: enumType(["changed"]),
@@ -15803,7 +15503,7 @@ var init_snapshotsDiffer = __esm({
15803
15503
  return unionType([
15804
15504
  objectType({
15805
15505
  type: literalType("none"),
15806
- value: schema4
15506
+ value: schema4.optional()
15807
15507
  }),
15808
15508
  objectType({
15809
15509
  type: literalType("added"),
@@ -15925,9 +15625,10 @@ var init_snapshotsDiffer = __esm({
15925
15625
  addedSchemas: stringType().array(),
15926
15626
  deletedSchemas: stringType().array()
15927
15627
  }).strict();
15928
- applySnapshotsDiff = async (json1, json2, dialect7, schemasResolver, tablesResolver, columnsResolver, prevFull, curFull) => {
15628
+ applySnapshotsDiff = async (json1, json2, dialect6, schemasResolver, tablesResolver, columnsResolver, prevFull, curFull) => {
15929
15629
  var _a, _b;
15930
- if (dialect7 === "mysql") {
15630
+ let diffResult;
15631
+ if (dialect6 === "mysql") {
15931
15632
  for (const tableName in json1.tables) {
15932
15633
  const table4 = json1.tables[tableName];
15933
15634
  for (const indexName3 in table4.indexes) {
@@ -15954,26 +15655,13 @@ var init_snapshotsDiffer = __esm({
15954
15655
  }
15955
15656
  }
15956
15657
  }
15658
+ diffResult = applyJsonDiff(json1, json2);
15957
15659
  }
15958
- const diffResult = applyJsonDiff(json1, json2);
15660
+ diffResult = applyJsonDiff(json1, json2);
15959
15661
  if (Object.keys(diffResult).length === 0) {
15960
15662
  return { statements: [], sqlStatements: [], _meta: void 0 };
15961
15663
  }
15962
15664
  const typedResult = diffResultScheme.parse(diffResult);
15963
- typedResult.alteredTablesWithColumns = typedResult.alteredTablesWithColumns.map((it) => {
15964
- let schemaToTrim;
15965
- if (it.schema.type === "none") {
15966
- schemaToTrim = it.schema.value || "public";
15967
- } else if (it.schema.type === "deleted") {
15968
- schemaToTrim = it.schema.value;
15969
- } else if (it.schema.type === "added") {
15970
- schemaToTrim = "public";
15971
- } else {
15972
- schemaToTrim = it.schema.old;
15973
- }
15974
- it.name = it.name.substring(schemaToTrim.length + 1);
15975
- return it;
15976
- });
15977
15665
  const {
15978
15666
  created: createdSchemas,
15979
15667
  deleted: deletedSchemas,
@@ -16065,9 +15753,9 @@ var init_snapshotsDiffer = __esm({
16065
15753
  let addedColumns = [];
16066
15754
  for (const addedPkName of Object.keys(it.addedCompositePKs)) {
16067
15755
  const addedPkColumns = it.addedCompositePKs[addedPkName];
16068
- if (dialect7 === "sqlite") {
15756
+ if (dialect6 === "sqlite") {
16069
15757
  addedColumns = SQLiteSquasher.unsquashPK(addedPkColumns);
16070
- } else if (dialect7 === "mysql") {
15758
+ } else if (dialect6 === "mysql") {
16071
15759
  addedColumns = MySqlSquasher.unsquashPK(addedPkColumns).columns;
16072
15760
  } else {
16073
15761
  addedColumns = SQLiteSquasher.unsquashPK(addedPkColumns);
@@ -16076,9 +15764,9 @@ var init_snapshotsDiffer = __esm({
16076
15764
  let deletedColumns = [];
16077
15765
  for (const deletedPkName of Object.keys(it.deletedCompositePKs)) {
16078
15766
  const deletedPkColumns = it.deletedCompositePKs[deletedPkName];
16079
- if (dialect7 === "sqlite") {
15767
+ if (dialect6 === "sqlite") {
16080
15768
  deletedColumns = SQLiteSquasher.unsquashPK(deletedPkColumns);
16081
- } else if (dialect7 === "mysql") {
15769
+ } else if (dialect6 === "mysql") {
16082
15770
  deletedColumns = MySqlSquasher.unsquashPK(deletedPkColumns).columns;
16083
15771
  } else {
16084
15772
  deletedColumns = SQLiteSquasher.unsquashPK(deletedPkColumns);
@@ -16088,7 +15776,7 @@ var init_snapshotsDiffer = __esm({
16088
15776
  let addedCompositePKs = [];
16089
15777
  let deletedCompositePKs = [];
16090
15778
  let alteredCompositePKs = [];
16091
- if (dialect7 === "sqlite") {
15779
+ if (dialect6 === "sqlite") {
16092
15780
  if (doPerformDeleteAndCreate) {
16093
15781
  addedCompositePKs = prepareAddCompositePrimaryKeySqlite(
16094
15782
  it.name,
@@ -16103,7 +15791,7 @@ var init_snapshotsDiffer = __esm({
16103
15791
  it.name,
16104
15792
  it.alteredCompositePKs
16105
15793
  );
16106
- } else if (dialect7 === "pg") {
15794
+ } else if (dialect6 === "pg") {
16107
15795
  if (doPerformDeleteAndCreate) {
16108
15796
  addedCompositePKs = prepareAddCompositePrimaryKeyPg(
16109
15797
  it.name,
@@ -16125,7 +15813,7 @@ var init_snapshotsDiffer = __esm({
16125
15813
  prevFull,
16126
15814
  curFull
16127
15815
  );
16128
- } else if (dialect7 === "mysql") {
15816
+ } else {
16129
15817
  addedCompositePKs = prepareAddCompositePrimaryKeyMySql(
16130
15818
  it.name,
16131
15819
  it.addedCompositePKs,
@@ -16143,8 +15831,6 @@ var init_snapshotsDiffer = __esm({
16143
15831
  prevFull,
16144
15832
  curFull
16145
15833
  );
16146
- } else {
16147
- assertUnreachable(dialect7);
16148
15834
  }
16149
15835
  let addedUniqueConstraints = [];
16150
15836
  let deletedUniqueConstraints = [];
@@ -16227,7 +15913,7 @@ var init_snapshotsDiffer = __esm({
16227
15913
  it.altered,
16228
15914
  it.addedForeignKeys,
16229
15915
  json2,
16230
- dialect7
15916
+ dialect6
16231
15917
  );
16232
15918
  }).flat().reduce(
16233
15919
  (res, it) => {
@@ -16304,7 +15990,7 @@ var init_snapshotsDiffer = __esm({
16304
15990
  const jsonAlterEnumsWithAddedValues = ((_b = typedResult.alteredEnums) == null ? void 0 : _b.map((it) => {
16305
15991
  return prepareAddValuesToEnumJson(it.name, it.addedValues);
16306
15992
  }).flat()) ?? [];
16307
- if (dialect7 === "mysql") {
15993
+ if (dialect6 === "mysql") {
16308
15994
  createdSchemas.push(...renamedSchemas.map((it) => it.to));
16309
15995
  deletedSchemas.push(...renamedSchemas.map((it) => it.from));
16310
15996
  renamedSchemas.splice(0, renamedSchemas.length);
@@ -16328,25 +16014,23 @@ var init_snapshotsDiffer = __esm({
16328
16014
  jsonStatements.push(...renameSchemas);
16329
16015
  jsonStatements.push(...createEnums);
16330
16016
  jsonStatements.push(...jsonAlterEnumsWithAddedValues);
16331
- if (dialect7 === "sqlite") {
16017
+ if (dialect6 === "sqlite") {
16332
16018
  jsonStatements.push(...jsonSQLiteCreateTables);
16333
- } else if (dialect7 === "pg") {
16019
+ } else if (dialect6 === "pg") {
16334
16020
  const jsonPgCreateTables = created.map((it) => {
16335
16021
  return preparePgCreateTableJson(it, curFull);
16336
16022
  });
16337
16023
  jsonStatements.push(...jsonPgCreateTables);
16338
- } else if (dialect7 === "mysql") {
16024
+ } else {
16339
16025
  const jsonMySqlCreateTables = created.map((it) => {
16340
16026
  return prepareMySqlCreateTableJson(it, curFull);
16341
16027
  });
16342
16028
  jsonStatements.push(...jsonMySqlCreateTables);
16343
- } else {
16344
- assertUnreachable(dialect7);
16345
16029
  }
16346
16030
  jsonStatements.push(...jsonDropTables);
16347
16031
  jsonStatements.push(...jsonRenameTables);
16348
16032
  jsonStatements.push(...jsonRenameColumnsStatements);
16349
- if (dialect7 !== "mysql") {
16033
+ if (dialect6 !== "mysql") {
16350
16034
  jsonStatements.push(...jsonDeletedUniqueConstraints);
16351
16035
  }
16352
16036
  jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
@@ -16354,7 +16038,7 @@ var init_snapshotsDiffer = __esm({
16354
16038
  jsonStatements.push(...jsonDeletedCompositePKs);
16355
16039
  jsonStatements.push(...jsonTableAlternations.alterColumns);
16356
16040
  jsonStatements.push(...jsonAddedCompositePKs);
16357
- if (dialect7 === "mysql") {
16041
+ if (dialect6 === "mysql") {
16358
16042
  jsonStatements.push(...jsonAddedUniqueConstraints);
16359
16043
  jsonStatements.push(...jsonDeletedUniqueConstraints);
16360
16044
  }
@@ -16363,10 +16047,10 @@ var init_snapshotsDiffer = __esm({
16363
16047
  jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
16364
16048
  jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
16365
16049
  jsonStatements.push(...jsonTableAlternations.dropColumns);
16366
- if (dialect7 !== "sqlite")
16050
+ if (dialect6 !== "sqlite")
16367
16051
  jsonStatements.push(...jsonCreateReferences);
16368
16052
  jsonStatements.push(...jsonAlteredCompositePKs);
16369
- if (dialect7 !== "mysql") {
16053
+ if (dialect6 !== "mysql") {
16370
16054
  jsonStatements.push(...jsonAddedUniqueConstraints);
16371
16055
  }
16372
16056
  jsonStatements.push(...jsonAlteredUniqueConstraints);
@@ -16374,7 +16058,7 @@ var init_snapshotsDiffer = __esm({
16374
16058
  jsonStatements.push(...filteredJsonSetNewTableSchemas);
16375
16059
  jsonStatements.push(...jsonRemoveTableFromSchemas);
16376
16060
  jsonStatements.push(...dropSchemas);
16377
- const sqlStatements = fromJson(jsonStatements, dialect7);
16061
+ const sqlStatements = fromJson(jsonStatements, dialect6);
16378
16062
  const uniqueSqlStatements = [];
16379
16063
  sqlStatements.forEach((ss) => {
16380
16064
  if (!uniqueSqlStatements.includes(ss)) {
@@ -16411,7 +16095,6 @@ import path2, { join as join2 } from "path";
16411
16095
  var import_hanji4, prepareAndMigratePg, prepareMySQLPush, prepareSQLitePush, preparePgPush, prepareAndMigrateMySql, prepareAndMigrateSqlite, prepareSQL, promptColumnsConflicts, promptTablesConflict, promptSchemasConflict, BREAKPOINT, writeResult, embeddedMigrations, prepareSnapshotFolderName, two;
16412
16096
  var init_migrate = __esm({
16413
16097
  "src/cli/commands/migrate.ts"() {
16414
- "use strict";
16415
16098
  init_migrationPreparator();
16416
16099
  init_snapshotsDiffer();
16417
16100
  import_hanji4 = __toESM(require_hanji());
@@ -16427,7 +16110,7 @@ var init_migrate = __esm({
16427
16110
  const outFolder = config.out;
16428
16111
  const schemaPath = config.schema;
16429
16112
  try {
16430
- assertV1OutFolder(outFolder);
16113
+ assertV1OutFolder(outFolder, "pg");
16431
16114
  const { snapshots, journal } = prepareMigrationFolder(outFolder, "pg");
16432
16115
  const { prev, cur, custom } = await preparePgMigrationSnapshot(
16433
16116
  snapshots,
@@ -16487,56 +16170,66 @@ var init_migrate = __esm({
16487
16170
  return { sqlStatements, statements, validatedCur, validatedPrev };
16488
16171
  } catch (e) {
16489
16172
  console.error(e);
16490
- process.exit(1);
16491
16173
  }
16492
16174
  };
16493
16175
  prepareSQLitePush = async (config, snapshot) => {
16494
16176
  const schemaPath = config.schema;
16495
- const { prev, cur } = await prepareSQLiteDbPushSnapshot(snapshot, schemaPath);
16496
- const validatedPrev = sqliteSchema.parse(prev);
16497
- const validatedCur = sqliteSchema.parse(cur);
16498
- const squashedPrev = squashSqliteScheme(validatedPrev);
16499
- const squashedCur = squashSqliteScheme(validatedCur);
16500
- const { sqlStatements, statements, _meta } = await prepareSQL(
16501
- squashedPrev,
16502
- squashedCur,
16503
- "sqlite",
16504
- validatedPrev,
16505
- validatedCur
16506
- );
16507
- return {
16508
- sqlStatements,
16509
- statements,
16510
- squashedPrev,
16511
- squashedCur,
16512
- meta: _meta
16513
- };
16177
+ try {
16178
+ const { prev, cur } = await prepareSQLiteDbPushSnapshot(
16179
+ snapshot,
16180
+ schemaPath
16181
+ );
16182
+ const validatedPrev = sqliteSchema.parse(prev);
16183
+ const validatedCur = sqliteSchema.parse(cur);
16184
+ const squashedPrev = squashSqliteScheme(validatedPrev);
16185
+ const squashedCur = squashSqliteScheme(validatedCur);
16186
+ const { sqlStatements, statements, _meta } = await prepareSQL(
16187
+ squashedPrev,
16188
+ squashedCur,
16189
+ "sqlite",
16190
+ validatedPrev,
16191
+ validatedCur
16192
+ );
16193
+ return {
16194
+ sqlStatements,
16195
+ statements,
16196
+ squashedPrev,
16197
+ squashedCur,
16198
+ meta: _meta
16199
+ };
16200
+ } catch (e) {
16201
+ console.error(e);
16202
+ }
16514
16203
  };
16515
16204
  preparePgPush = async (config, snapshot, schemaFilter) => {
16516
16205
  const schemaPath = config.schema;
16517
- const { prev, cur } = await preparePgDbPushSnapshot(
16518
- snapshot,
16519
- schemaPath,
16520
- schemaFilter
16521
- );
16522
- const validatedPrev = pgSchema.parse(prev);
16523
- const validatedCur = pgSchema.parse(cur);
16524
- const squashedPrev = squashPgScheme(validatedPrev);
16525
- const squashedCur = squashPgScheme(validatedCur);
16526
- const { sqlStatements, statements } = await prepareSQL(
16527
- squashedPrev,
16528
- squashedCur,
16529
- "pg",
16530
- validatedPrev,
16531
- validatedCur
16532
- );
16533
- return { sqlStatements, statements, squashedPrev, squashedCur };
16206
+ try {
16207
+ const { prev, cur } = await preparePgDbPushSnapshot(
16208
+ snapshot,
16209
+ schemaPath,
16210
+ schemaFilter
16211
+ );
16212
+ const validatedPrev = pgSchema.parse(prev);
16213
+ const validatedCur = pgSchema.parse(cur);
16214
+ const squashedPrev = squashPgScheme(validatedPrev);
16215
+ const squashedCur = squashPgScheme(validatedCur);
16216
+ const { sqlStatements, statements } = await prepareSQL(
16217
+ squashedPrev,
16218
+ squashedCur,
16219
+ "pg",
16220
+ validatedPrev,
16221
+ validatedCur
16222
+ );
16223
+ return { sqlStatements, statements, squashedPrev, squashedCur };
16224
+ } catch (e) {
16225
+ console.error(e);
16226
+ }
16534
16227
  };
16535
16228
  prepareAndMigrateMySql = async (config) => {
16536
16229
  const outFolder = config.out;
16537
16230
  const schemaPath = config.schema;
16538
16231
  try {
16539
- assertV1OutFolder(outFolder);
16232
+ assertV1OutFolder(outFolder, "mysql");
16540
16233
  const { snapshots, journal } = prepareMigrationFolder(outFolder, "mysql");
16541
16234
  const { prev, cur, custom } = await prepareMySqlMigrationSnapshot(
16542
16235
  snapshots,
@@ -16580,7 +16273,7 @@ var init_migrate = __esm({
16580
16273
  const outFolder = config.out;
16581
16274
  const schemaPath = config.schema;
16582
16275
  try {
16583
- assertV1OutFolder(outFolder);
16276
+ assertV1OutFolder(outFolder, "sqlite");
16584
16277
  const { snapshots, journal } = prepareMigrationFolder(outFolder, "sqlite");
16585
16278
  const { prev, cur, custom } = await prepareSqliteMigrationSnapshot(
16586
16279
  snapshots,
@@ -16605,9 +16298,7 @@ var init_migrate = __esm({
16605
16298
  const { sqlStatements, _meta } = await prepareSQL(
16606
16299
  squashedPrev,
16607
16300
  squashedCur,
16608
- "sqlite",
16609
- validatedPrev,
16610
- validatedCur
16301
+ "sqlite"
16611
16302
  );
16612
16303
  writeResult({
16613
16304
  cur,
@@ -16622,7 +16313,7 @@ var init_migrate = __esm({
16622
16313
  console.error(e);
16623
16314
  }
16624
16315
  };
16625
- prepareSQL = async (prev, cur, dialect7, prevFull, curFull) => {
16316
+ prepareSQL = async (prev, cur, dialect6, prevFull, curFull) => {
16626
16317
  const schemasResolver = async (input) => {
16627
16318
  try {
16628
16319
  const { created, deleted, renamed } = await promptSchemasConflict(
@@ -16664,7 +16355,7 @@ var init_migrate = __esm({
16664
16355
  return await applySnapshotsDiff(
16665
16356
  prev,
16666
16357
  cur,
16667
- dialect7,
16358
+ dialect6,
16668
16359
  schemasResolver,
16669
16360
  tablesResolver,
16670
16361
  columnsResolver,
@@ -16906,7 +16597,6 @@ ${sql2}
16906
16597
  var pgNativeTypes, isPgNativeType, Convertor, PgCreateTableConvertor, MySqlCreateTableConvertor, SQLiteCreateTableConvertor, PgAlterTableAddUniqueConstraintConvertor, PgAlterTableDropUniqueConstraintConvertor, MySQLAlterTableAddUniqueConstraintConvertor, MySQLAlterTableDropUniqueConstraintConvertor, SQLiteAlterTableAddUniqueConstraintConvertor, SQLiteAlterTableDropUniqueConstraintConvertor, CreateTypeEnumConvertor, AlterTypeAddValueConvertor, PgDropTableConvertor, MySQLDropTableConvertor, SQLiteDropTableConvertor, PgRenameTableConvertor, SqliteRenameTableConvertor, MySqlRenameTableConvertor, PgAlterTableRenameColumnConvertor, MySqlAlterTableRenameColumnConvertor, SQLiteAlterTableRenameColumnConvertor, PgAlterTableDropColumnConvertor, MySqlAlterTableDropColumnConvertor, SQLiteAlterTableDropColumnConvertor, PgAlterTableAddColumnConvertor, MySqlAlterTableAddColumnConvertor, SQLiteAlterTableAddColumnConvertor, PgAlterTableAlterColumnSetTypeConvertor, SQLiteAlterTableAlterColumnSetTypeConvertor, PgAlterTableAlterColumnSetDefaultConvertor, SqliteAlterTableAlterColumnSetDefaultConvertor, PgAlterTableAlterColumnDropDefaultConvertor, MySqlAlterTableAddPk, MySqlAlterTableDropPk, MySqlModifyColumn, SqliteAlterTableAlterColumnDropDefaultConvertor, PgAlterTableCreateCompositePrimaryKeyConvertor, PgAlterTableDeleteCompositePrimaryKeyConvertor, PgAlterTableAlterCompositePrimaryKeyConvertor, MySqlAlterTableCreateCompositePrimaryKeyConvertor, MySqlAlterTableDeleteCompositePrimaryKeyConvertor, MySqlAlterTableAlterCompositePrimaryKeyConvertor, SqliteAlterTableCreateCompositePrimaryKeyConvertor, SqliteAlterTableDeleteCompositePrimaryKeyConvertor, SqliteAlterTableAlterCompositePrimaryKeyConvertor, PgAlterTableAlterColumnSetPrimaryKeyConvertor, PgAlterTableAlterColumnDropPrimaryKeyConvertor, PgAlterTableAlterColumnSetNotNullConvertor, SqliteAlterTableAlterColumnSetNotNullConvertor, SqliteAlterTableAlterColumnSetAutoincrementConvertor, SqliteAlterTableAlterColumnDropAutoincrementConvertor, PgAlterTableAlterColumnDropNotNullConvertor, SqliteAlterTableAlterColumnDropNotNullConvertor, PgCreateForeignKeyConvertor, SqliteCreateForeignKeyConvertor, MySqlCreateForeignKeyConvertor, PgAlterForeignKeyConvertor, SqliteAlterForeignKeyConvertor, PgDeleteForeignKeyConvertor, SqliteDeleteForeignKeyConvertor, MySqlDeleteForeignKeyConvertor, CreatePgIndexConvertor, CreateMySqlIndexConvertor, CreateSqliteIndexConvertor, PgDropIndexConvertor, PgCreateSchemaConvertor, PgRenameSchemaConvertor, PgDropSchemaConvertor, PgAlterTableSetSchemaConvertor, PgAlterTableSetNewSchemaConvertor, PgAlterTableRemoveFromSchemaConvertor, SqliteDropIndexConvertor, MysqlCreateSchemaConvertor, MysqlDropSchemaConvertor, MysqlAlterTableSetSchemaConvertor, MysqlAlterTableSetNewSchemaConvertor, MysqlAlterTableRemoveFromSchemaConvertor, MySqlDropIndexConvertor, convertors, fromJson;
16907
16598
  var init_sqlgenerator = __esm({
16908
16599
  "src/sqlgenerator.ts"() {
16909
- "use strict";
16910
16600
  init_migrate();
16911
16601
  init_mysqlSchema();
16912
16602
  init_pgSchema();
@@ -16961,8 +16651,8 @@ var init_sqlgenerator = __esm({
16961
16651
  Convertor = class {
16962
16652
  };
16963
16653
  PgCreateTableConvertor = class extends Convertor {
16964
- can(statement, dialect7) {
16965
- return statement.type === "create_table" && dialect7 === "pg";
16654
+ can(statement, dialect6) {
16655
+ return statement.type === "create_table" && dialect6 === "pg";
16966
16656
  }
16967
16657
  convert(st) {
16968
16658
  const { tableName, schema: schema4, columns, compositePKs, uniqueConstraints } = st;
@@ -17000,8 +16690,8 @@ var init_sqlgenerator = __esm({
17000
16690
  }
17001
16691
  };
17002
16692
  MySqlCreateTableConvertor = class extends Convertor {
17003
- can(statement, dialect7) {
17004
- return statement.type === "create_table" && dialect7 === "mysql";
16693
+ can(statement, dialect6) {
16694
+ return statement.type === "create_table" && dialect6 === "mysql";
17005
16695
  }
17006
16696
  convert(st) {
17007
16697
  const { tableName, columns, schema: schema4, compositePKs, uniqueConstraints } = st;
@@ -17039,8 +16729,8 @@ var init_sqlgenerator = __esm({
17039
16729
  }
17040
16730
  };
17041
16731
  SQLiteCreateTableConvertor = class extends Convertor {
17042
- can(statement, dialect7) {
17043
- return statement.type === "sqlite_create_table" && dialect7 === "sqlite";
16732
+ can(statement, dialect6) {
16733
+ return statement.type === "sqlite_create_table" && dialect6 === "sqlite";
17044
16734
  }
17045
16735
  convert(st) {
17046
16736
  const {
@@ -17102,8 +16792,8 @@ var init_sqlgenerator = __esm({
17102
16792
  }
17103
16793
  };
17104
16794
  PgAlterTableAddUniqueConstraintConvertor = class extends Convertor {
17105
- can(statement, dialect7) {
17106
- return statement.type === "create_unique_constraint" && dialect7 === "pg";
16795
+ can(statement, dialect6) {
16796
+ return statement.type === "create_unique_constraint" && dialect6 === "pg";
17107
16797
  }
17108
16798
  convert(statement) {
17109
16799
  const unsquashed = PgSquasher.unsquashUnique(statement.data);
@@ -17112,8 +16802,8 @@ var init_sqlgenerator = __esm({
17112
16802
  }
17113
16803
  };
17114
16804
  PgAlterTableDropUniqueConstraintConvertor = class extends Convertor {
17115
- can(statement, dialect7) {
17116
- return statement.type === "delete_unique_constraint" && dialect7 === "pg";
16805
+ can(statement, dialect6) {
16806
+ return statement.type === "delete_unique_constraint" && dialect6 === "pg";
17117
16807
  }
17118
16808
  convert(statement) {
17119
16809
  const unsquashed = PgSquasher.unsquashUnique(statement.data);
@@ -17122,8 +16812,8 @@ var init_sqlgenerator = __esm({
17122
16812
  }
17123
16813
  };
17124
16814
  MySQLAlterTableAddUniqueConstraintConvertor = class extends Convertor {
17125
- can(statement, dialect7) {
17126
- return statement.type === "create_unique_constraint" && dialect7 === "mysql";
16815
+ can(statement, dialect6) {
16816
+ return statement.type === "create_unique_constraint" && dialect6 === "mysql";
17127
16817
  }
17128
16818
  convert(statement) {
17129
16819
  const unsquashed = MySqlSquasher.unsquashUnique(statement.data);
@@ -17132,8 +16822,8 @@ var init_sqlgenerator = __esm({
17132
16822
  }
17133
16823
  };
17134
16824
  MySQLAlterTableDropUniqueConstraintConvertor = class extends Convertor {
17135
- can(statement, dialect7) {
17136
- return statement.type === "delete_unique_constraint" && dialect7 === "mysql";
16825
+ can(statement, dialect6) {
16826
+ return statement.type === "delete_unique_constraint" && dialect6 === "mysql";
17137
16827
  }
17138
16828
  convert(statement) {
17139
16829
  const unsquashed = MySqlSquasher.unsquashUnique(statement.data);
@@ -17142,8 +16832,8 @@ var init_sqlgenerator = __esm({
17142
16832
  }
17143
16833
  };
17144
16834
  SQLiteAlterTableAddUniqueConstraintConvertor = class extends Convertor {
17145
- can(statement, dialect7) {
17146
- return statement.type === "create_unique_constraint" && dialect7 === "sqlite";
16835
+ can(statement, dialect6) {
16836
+ return statement.type === "create_unique_constraint" && dialect6 === "sqlite";
17147
16837
  }
17148
16838
  convert(statement) {
17149
16839
  return `/*
@@ -17155,8 +16845,8 @@ var init_sqlgenerator = __esm({
17155
16845
  }
17156
16846
  };
17157
16847
  SQLiteAlterTableDropUniqueConstraintConvertor = class extends Convertor {
17158
- can(statement, dialect7) {
17159
- return statement.type === "delete_unique_constraint" && dialect7 === "sqlite";
16848
+ can(statement, dialect6) {
16849
+ return statement.type === "delete_unique_constraint" && dialect6 === "sqlite";
17160
16850
  }
17161
16851
  convert(statement) {
17162
16852
  return `/*
@@ -17199,8 +16889,8 @@ var init_sqlgenerator = __esm({
17199
16889
  }
17200
16890
  };
17201
16891
  PgDropTableConvertor = class extends Convertor {
17202
- can(statement, dialect7) {
17203
- return statement.type === "drop_table" && dialect7 === "pg";
16892
+ can(statement, dialect6) {
16893
+ return statement.type === "drop_table" && dialect6 === "pg";
17204
16894
  }
17205
16895
  convert(statement) {
17206
16896
  const { tableName, schema: schema4 } = statement;
@@ -17209,8 +16899,8 @@ var init_sqlgenerator = __esm({
17209
16899
  }
17210
16900
  };
17211
16901
  MySQLDropTableConvertor = class extends Convertor {
17212
- can(statement, dialect7) {
17213
- return statement.type === "drop_table" && dialect7 === "mysql";
16902
+ can(statement, dialect6) {
16903
+ return statement.type === "drop_table" && dialect6 === "mysql";
17214
16904
  }
17215
16905
  convert(statement) {
17216
16906
  const { tableName } = statement;
@@ -17218,8 +16908,8 @@ var init_sqlgenerator = __esm({
17218
16908
  }
17219
16909
  };
17220
16910
  SQLiteDropTableConvertor = class extends Convertor {
17221
- can(statement, dialect7) {
17222
- return statement.type === "drop_table" && dialect7 === "sqlite";
16911
+ can(statement, dialect6) {
16912
+ return statement.type === "drop_table" && dialect6 === "sqlite";
17223
16913
  }
17224
16914
  convert(statement) {
17225
16915
  const { tableName } = statement;
@@ -17227,8 +16917,8 @@ var init_sqlgenerator = __esm({
17227
16917
  }
17228
16918
  };
17229
16919
  PgRenameTableConvertor = class extends Convertor {
17230
- can(statement, dialect7) {
17231
- return statement.type === "rename_table" && dialect7 === "pg";
16920
+ can(statement, dialect6) {
16921
+ return statement.type === "rename_table" && dialect6 === "pg";
17232
16922
  }
17233
16923
  convert(statement) {
17234
16924
  const { tableNameFrom, tableNameTo, toSchema, fromSchema } = statement;
@@ -17238,8 +16928,8 @@ var init_sqlgenerator = __esm({
17238
16928
  }
17239
16929
  };
17240
16930
  SqliteRenameTableConvertor = class extends Convertor {
17241
- can(statement, dialect7) {
17242
- return statement.type === "rename_table" && dialect7 === "sqlite";
16931
+ can(statement, dialect6) {
16932
+ return statement.type === "rename_table" && dialect6 === "sqlite";
17243
16933
  }
17244
16934
  convert(statement) {
17245
16935
  const { tableNameFrom, tableNameTo } = statement;
@@ -17247,8 +16937,8 @@ var init_sqlgenerator = __esm({
17247
16937
  }
17248
16938
  };
17249
16939
  MySqlRenameTableConvertor = class extends Convertor {
17250
- can(statement, dialect7) {
17251
- return statement.type === "rename_table" && dialect7 === "mysql";
16940
+ can(statement, dialect6) {
16941
+ return statement.type === "rename_table" && dialect6 === "mysql";
17252
16942
  }
17253
16943
  convert(statement) {
17254
16944
  const { tableNameFrom, tableNameTo, fromSchema, toSchema } = statement;
@@ -17258,8 +16948,8 @@ var init_sqlgenerator = __esm({
17258
16948
  }
17259
16949
  };
17260
16950
  PgAlterTableRenameColumnConvertor = class extends Convertor {
17261
- can(statement, dialect7) {
17262
- return statement.type === "alter_table_rename_column" && dialect7 === "pg";
16951
+ can(statement, dialect6) {
16952
+ return statement.type === "alter_table_rename_column" && dialect6 === "pg";
17263
16953
  }
17264
16954
  convert(statement) {
17265
16955
  const { tableName, oldColumnName, newColumnName, schema: schema4 } = statement;
@@ -17268,8 +16958,8 @@ var init_sqlgenerator = __esm({
17268
16958
  }
17269
16959
  };
17270
16960
  MySqlAlterTableRenameColumnConvertor = class extends Convertor {
17271
- can(statement, dialect7) {
17272
- return statement.type === "alter_table_rename_column" && dialect7 === "mysql";
16961
+ can(statement, dialect6) {
16962
+ return statement.type === "alter_table_rename_column" && dialect6 === "mysql";
17273
16963
  }
17274
16964
  convert(statement) {
17275
16965
  const { tableName, oldColumnName, newColumnName } = statement;
@@ -17277,8 +16967,8 @@ var init_sqlgenerator = __esm({
17277
16967
  }
17278
16968
  };
17279
16969
  SQLiteAlterTableRenameColumnConvertor = class extends Convertor {
17280
- can(statement, dialect7) {
17281
- return statement.type === "alter_table_rename_column" && dialect7 === "sqlite";
16970
+ can(statement, dialect6) {
16971
+ return statement.type === "alter_table_rename_column" && dialect6 === "sqlite";
17282
16972
  }
17283
16973
  convert(statement) {
17284
16974
  const { tableName, oldColumnName, newColumnName } = statement;
@@ -17286,8 +16976,8 @@ var init_sqlgenerator = __esm({
17286
16976
  }
17287
16977
  };
17288
16978
  PgAlterTableDropColumnConvertor = class extends Convertor {
17289
- can(statement, dialect7) {
17290
- return statement.type === "alter_table_drop_column" && dialect7 === "pg";
16979
+ can(statement, dialect6) {
16980
+ return statement.type === "alter_table_drop_column" && dialect6 === "pg";
17291
16981
  }
17292
16982
  convert(statement) {
17293
16983
  const { tableName, columnName, schema: schema4 } = statement;
@@ -17296,8 +16986,8 @@ var init_sqlgenerator = __esm({
17296
16986
  }
17297
16987
  };
17298
16988
  MySqlAlterTableDropColumnConvertor = class extends Convertor {
17299
- can(statement, dialect7) {
17300
- return statement.type === "alter_table_drop_column" && dialect7 === "mysql";
16989
+ can(statement, dialect6) {
16990
+ return statement.type === "alter_table_drop_column" && dialect6 === "mysql";
17301
16991
  }
17302
16992
  convert(statement) {
17303
16993
  const { tableName, columnName } = statement;
@@ -17305,8 +16995,8 @@ var init_sqlgenerator = __esm({
17305
16995
  }
17306
16996
  };
17307
16997
  SQLiteAlterTableDropColumnConvertor = class extends Convertor {
17308
- can(statement, dialect7) {
17309
- return statement.type === "alter_table_drop_column" && dialect7 === "sqlite";
16998
+ can(statement, dialect6) {
16999
+ return statement.type === "alter_table_drop_column" && dialect6 === "sqlite";
17310
17000
  }
17311
17001
  convert(statement) {
17312
17002
  const { tableName, columnName } = statement;
@@ -17314,8 +17004,8 @@ var init_sqlgenerator = __esm({
17314
17004
  }
17315
17005
  };
17316
17006
  PgAlterTableAddColumnConvertor = class extends Convertor {
17317
- can(statement, dialect7) {
17318
- return statement.type === "alter_table_add_column" && dialect7 === "pg";
17007
+ can(statement, dialect6) {
17008
+ return statement.type === "alter_table_add_column" && dialect6 === "pg";
17319
17009
  }
17320
17010
  convert(statement) {
17321
17011
  const { tableName, column: column4, schema: schema4 } = statement;
@@ -17328,8 +17018,8 @@ var init_sqlgenerator = __esm({
17328
17018
  }
17329
17019
  };
17330
17020
  MySqlAlterTableAddColumnConvertor = class extends Convertor {
17331
- can(statement, dialect7) {
17332
- return statement.type === "alter_table_add_column" && dialect7 === "mysql";
17021
+ can(statement, dialect6) {
17022
+ return statement.type === "alter_table_add_column" && dialect6 === "mysql";
17333
17023
  }
17334
17024
  convert(statement) {
17335
17025
  const { tableName, column: column4 } = statement;
@@ -17343,8 +17033,8 @@ var init_sqlgenerator = __esm({
17343
17033
  }
17344
17034
  };
17345
17035
  SQLiteAlterTableAddColumnConvertor = class extends Convertor {
17346
- can(statement, dialect7) {
17347
- return statement.type === "sqlite_alter_table_add_column" && dialect7 === "sqlite";
17036
+ can(statement, dialect6) {
17037
+ return statement.type === "sqlite_alter_table_add_column" && dialect6 === "sqlite";
17348
17038
  }
17349
17039
  convert(statement) {
17350
17040
  const { tableName, column: column4, referenceData } = statement;
@@ -17358,8 +17048,8 @@ var init_sqlgenerator = __esm({
17358
17048
  }
17359
17049
  };
17360
17050
  PgAlterTableAlterColumnSetTypeConvertor = class extends Convertor {
17361
- can(statement, dialect7) {
17362
- return statement.type === "alter_table_alter_column_set_type" && dialect7 === "pg";
17051
+ can(statement, dialect6) {
17052
+ return statement.type === "alter_table_alter_column_set_type" && dialect6 === "pg";
17363
17053
  }
17364
17054
  convert(statement) {
17365
17055
  const { tableName, columnName, newDataType, schema: schema4 } = statement;
@@ -17368,8 +17058,8 @@ var init_sqlgenerator = __esm({
17368
17058
  }
17369
17059
  };
17370
17060
  SQLiteAlterTableAlterColumnSetTypeConvertor = class extends Convertor {
17371
- can(statement, dialect7) {
17372
- return statement.type === "alter_table_alter_column_set_type" && dialect7 === "sqlite";
17061
+ can(statement, dialect6) {
17062
+ return statement.type === "alter_table_alter_column_set_type" && dialect6 === "sqlite";
17373
17063
  }
17374
17064
  convert(statement) {
17375
17065
  return `/*
@@ -17383,8 +17073,8 @@ var init_sqlgenerator = __esm({
17383
17073
  }
17384
17074
  };
17385
17075
  PgAlterTableAlterColumnSetDefaultConvertor = class extends Convertor {
17386
- can(statement, dialect7) {
17387
- return statement.type === "alter_table_alter_column_set_default" && dialect7 === "pg";
17076
+ can(statement, dialect6) {
17077
+ return statement.type === "alter_table_alter_column_set_default" && dialect6 === "pg";
17388
17078
  }
17389
17079
  convert(statement) {
17390
17080
  const { tableName, columnName, schema: schema4 } = statement;
@@ -17393,8 +17083,8 @@ var init_sqlgenerator = __esm({
17393
17083
  }
17394
17084
  };
17395
17085
  SqliteAlterTableAlterColumnSetDefaultConvertor = class extends Convertor {
17396
- can(statement, dialect7) {
17397
- return statement.type === "alter_table_alter_column_set_default" && dialect7 === "sqlite";
17086
+ can(statement, dialect6) {
17087
+ return statement.type === "alter_table_alter_column_set_default" && dialect6 === "sqlite";
17398
17088
  }
17399
17089
  convert(statement) {
17400
17090
  return `/*
@@ -17408,8 +17098,8 @@ var init_sqlgenerator = __esm({
17408
17098
  }
17409
17099
  };
17410
17100
  PgAlterTableAlterColumnDropDefaultConvertor = class extends Convertor {
17411
- can(statement, dialect7) {
17412
- return statement.type === "alter_table_alter_column_drop_default" && dialect7 === "pg";
17101
+ can(statement, dialect6) {
17102
+ return statement.type === "alter_table_alter_column_drop_default" && dialect6 === "pg";
17413
17103
  }
17414
17104
  convert(statement) {
17415
17105
  const { tableName, columnName, schema: schema4 } = statement;
@@ -17418,24 +17108,24 @@ var init_sqlgenerator = __esm({
17418
17108
  }
17419
17109
  };
17420
17110
  MySqlAlterTableAddPk = class extends Convertor {
17421
- can(statement, dialect7) {
17422
- return statement.type === "alter_table_alter_column_set_pk" && dialect7 === "mysql";
17111
+ can(statement, dialect6) {
17112
+ return statement.type === "alter_table_alter_column_set_pk" && dialect6 === "mysql";
17423
17113
  }
17424
17114
  convert(statement) {
17425
17115
  return `ALTER TABLE \`${statement.tableName}\` ADD PRIMARY KEY (\`${statement.columnName}\`);`;
17426
17116
  }
17427
17117
  };
17428
17118
  MySqlAlterTableDropPk = class extends Convertor {
17429
- can(statement, dialect7) {
17430
- return statement.type === "alter_table_alter_column_drop_pk" && dialect7 === "mysql";
17119
+ can(statement, dialect6) {
17120
+ return statement.type === "alter_table_alter_column_drop_pk" && dialect6 === "mysql";
17431
17121
  }
17432
17122
  convert(statement) {
17433
17123
  return `ALTER TABLE \`${statement.tableName}\` DROP PRIMARY KEY`;
17434
17124
  }
17435
17125
  };
17436
17126
  MySqlModifyColumn = class extends Convertor {
17437
- can(statement, dialect7) {
17438
- 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") && dialect7 === "mysql";
17127
+ can(statement, dialect6) {
17128
+ 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") && dialect6 === "mysql";
17439
17129
  }
17440
17130
  convert(statement) {
17441
17131
  const { tableName, columnName } = statement;
@@ -17505,8 +17195,8 @@ var init_sqlgenerator = __esm({
17505
17195
  }
17506
17196
  };
17507
17197
  SqliteAlterTableAlterColumnDropDefaultConvertor = class extends Convertor {
17508
- can(statement, dialect7) {
17509
- return statement.type === "alter_table_alter_column_drop_default" && dialect7 === "sqlite";
17198
+ can(statement, dialect6) {
17199
+ return statement.type === "alter_table_alter_column_drop_default" && dialect6 === "sqlite";
17510
17200
  }
17511
17201
  convert(statement) {
17512
17202
  return `/*
@@ -17520,8 +17210,8 @@ var init_sqlgenerator = __esm({
17520
17210
  }
17521
17211
  };
17522
17212
  PgAlterTableCreateCompositePrimaryKeyConvertor = class extends Convertor {
17523
- can(statement, dialect7) {
17524
- return statement.type === "create_composite_pk" && dialect7 === "pg";
17213
+ can(statement, dialect6) {
17214
+ return statement.type === "create_composite_pk" && dialect6 === "pg";
17525
17215
  }
17526
17216
  convert(statement) {
17527
17217
  const { name, columns } = PgSquasher.unsquashPK(statement.data);
@@ -17530,8 +17220,8 @@ var init_sqlgenerator = __esm({
17530
17220
  }
17531
17221
  };
17532
17222
  PgAlterTableDeleteCompositePrimaryKeyConvertor = class extends Convertor {
17533
- can(statement, dialect7) {
17534
- return statement.type === "delete_composite_pk" && dialect7 === "pg";
17223
+ can(statement, dialect6) {
17224
+ return statement.type === "delete_composite_pk" && dialect6 === "pg";
17535
17225
  }
17536
17226
  convert(statement) {
17537
17227
  const { name, columns } = PgSquasher.unsquashPK(statement.data);
@@ -17540,8 +17230,8 @@ var init_sqlgenerator = __esm({
17540
17230
  }
17541
17231
  };
17542
17232
  PgAlterTableAlterCompositePrimaryKeyConvertor = class extends Convertor {
17543
- can(statement, dialect7) {
17544
- return statement.type === "alter_composite_pk" && dialect7 === "pg";
17233
+ can(statement, dialect6) {
17234
+ return statement.type === "alter_composite_pk" && dialect6 === "pg";
17545
17235
  }
17546
17236
  convert(statement) {
17547
17237
  const { name, columns } = PgSquasher.unsquashPK(statement.old);
@@ -17554,8 +17244,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17554
17244
  }
17555
17245
  };
17556
17246
  MySqlAlterTableCreateCompositePrimaryKeyConvertor = class extends Convertor {
17557
- can(statement, dialect7) {
17558
- return statement.type === "create_composite_pk" && dialect7 === "mysql";
17247
+ can(statement, dialect6) {
17248
+ return statement.type === "create_composite_pk" && dialect6 === "mysql";
17559
17249
  }
17560
17250
  convert(statement) {
17561
17251
  const { name, columns } = MySqlSquasher.unsquashPK(statement.data);
@@ -17563,8 +17253,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17563
17253
  }
17564
17254
  };
17565
17255
  MySqlAlterTableDeleteCompositePrimaryKeyConvertor = class extends Convertor {
17566
- can(statement, dialect7) {
17567
- return statement.type === "delete_composite_pk" && dialect7 === "mysql";
17256
+ can(statement, dialect6) {
17257
+ return statement.type === "delete_composite_pk" && dialect6 === "mysql";
17568
17258
  }
17569
17259
  convert(statement) {
17570
17260
  const { name, columns } = MySqlSquasher.unsquashPK(statement.data);
@@ -17572,8 +17262,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17572
17262
  }
17573
17263
  };
17574
17264
  MySqlAlterTableAlterCompositePrimaryKeyConvertor = class extends Convertor {
17575
- can(statement, dialect7) {
17576
- return statement.type === "alter_composite_pk" && dialect7 === "mysql";
17265
+ can(statement, dialect6) {
17266
+ return statement.type === "alter_composite_pk" && dialect6 === "mysql";
17577
17267
  }
17578
17268
  convert(statement) {
17579
17269
  const { name, columns } = MySqlSquasher.unsquashPK(statement.old);
@@ -17584,8 +17274,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17584
17274
  }
17585
17275
  };
17586
17276
  SqliteAlterTableCreateCompositePrimaryKeyConvertor = class extends Convertor {
17587
- can(statement, dialect7) {
17588
- return statement.type === "create_composite_pk" && dialect7 === "sqlite";
17277
+ can(statement, dialect6) {
17278
+ return statement.type === "create_composite_pk" && dialect6 === "sqlite";
17589
17279
  }
17590
17280
  convert(statement) {
17591
17281
  let msg = "/*\n";
@@ -17611,8 +17301,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17611
17301
  }
17612
17302
  };
17613
17303
  SqliteAlterTableDeleteCompositePrimaryKeyConvertor = class extends Convertor {
17614
- can(statement, dialect7) {
17615
- return statement.type === "delete_composite_pk" && dialect7 === "sqlite";
17304
+ can(statement, dialect6) {
17305
+ return statement.type === "delete_composite_pk" && dialect6 === "sqlite";
17616
17306
  }
17617
17307
  convert(statement) {
17618
17308
  let msg = "/*\n";
@@ -17638,8 +17328,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17638
17328
  }
17639
17329
  };
17640
17330
  SqliteAlterTableAlterCompositePrimaryKeyConvertor = class extends Convertor {
17641
- can(statement, dialect7) {
17642
- return statement.type === "alter_composite_pk" && dialect7 === "sqlite";
17331
+ can(statement, dialect6) {
17332
+ return statement.type === "alter_composite_pk" && dialect6 === "sqlite";
17643
17333
  }
17644
17334
  convert(statement) {
17645
17335
  let msg = "/*\n";
@@ -17663,8 +17353,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17663
17353
  }
17664
17354
  };
17665
17355
  PgAlterTableAlterColumnSetPrimaryKeyConvertor = class extends Convertor {
17666
- can(statement, dialect7) {
17667
- return statement.type === "alter_table_alter_column_set_pk" && dialect7 === "pg";
17356
+ can(statement, dialect6) {
17357
+ return statement.type === "alter_table_alter_column_set_pk" && dialect6 === "pg";
17668
17358
  }
17669
17359
  convert(statement) {
17670
17360
  const { tableName, columnName } = statement;
@@ -17673,8 +17363,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17673
17363
  }
17674
17364
  };
17675
17365
  PgAlterTableAlterColumnDropPrimaryKeyConvertor = class extends Convertor {
17676
- can(statement, dialect7) {
17677
- return statement.type === "alter_table_alter_column_drop_pk" && dialect7 === "pg";
17366
+ can(statement, dialect6) {
17367
+ return statement.type === "alter_table_alter_column_drop_pk" && dialect6 === "pg";
17678
17368
  }
17679
17369
  convert(statement) {
17680
17370
  const { tableName, columnName, schema: schema4 } = statement;
@@ -17697,8 +17387,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17697
17387
  }
17698
17388
  };
17699
17389
  PgAlterTableAlterColumnSetNotNullConvertor = class extends Convertor {
17700
- can(statement, dialect7) {
17701
- return statement.type === "alter_table_alter_column_set_notnull" && dialect7 === "pg";
17390
+ can(statement, dialect6) {
17391
+ return statement.type === "alter_table_alter_column_set_notnull" && dialect6 === "pg";
17702
17392
  }
17703
17393
  convert(statement) {
17704
17394
  const { tableName, columnName } = statement;
@@ -17707,8 +17397,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17707
17397
  }
17708
17398
  };
17709
17399
  SqliteAlterTableAlterColumnSetNotNullConvertor = class extends Convertor {
17710
- can(statement, dialect7) {
17711
- return statement.type === "alter_table_alter_column_set_notnull" && dialect7 === "sqlite";
17400
+ can(statement, dialect6) {
17401
+ return statement.type === "alter_table_alter_column_set_notnull" && dialect6 === "sqlite";
17712
17402
  }
17713
17403
  convert(statement) {
17714
17404
  return `/*
@@ -17722,8 +17412,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17722
17412
  }
17723
17413
  };
17724
17414
  SqliteAlterTableAlterColumnSetAutoincrementConvertor = class extends Convertor {
17725
- can(statement, dialect7) {
17726
- return statement.type === "alter_table_alter_column_set_autoincrement" && dialect7 === "sqlite";
17415
+ can(statement, dialect6) {
17416
+ return statement.type === "alter_table_alter_column_set_autoincrement" && dialect6 === "sqlite";
17727
17417
  }
17728
17418
  convert(statement) {
17729
17419
  return `/*
@@ -17737,8 +17427,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17737
17427
  }
17738
17428
  };
17739
17429
  SqliteAlterTableAlterColumnDropAutoincrementConvertor = class extends Convertor {
17740
- can(statement, dialect7) {
17741
- return statement.type === "alter_table_alter_column_drop_autoincrement" && dialect7 === "sqlite";
17430
+ can(statement, dialect6) {
17431
+ return statement.type === "alter_table_alter_column_drop_autoincrement" && dialect6 === "sqlite";
17742
17432
  }
17743
17433
  convert(statement) {
17744
17434
  return `/*
@@ -17752,8 +17442,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17752
17442
  }
17753
17443
  };
17754
17444
  PgAlterTableAlterColumnDropNotNullConvertor = class extends Convertor {
17755
- can(statement, dialect7) {
17756
- return statement.type === "alter_table_alter_column_drop_notnull" && dialect7 === "pg";
17445
+ can(statement, dialect6) {
17446
+ return statement.type === "alter_table_alter_column_drop_notnull" && dialect6 === "pg";
17757
17447
  }
17758
17448
  convert(statement) {
17759
17449
  const { tableName, columnName } = statement;
@@ -17762,8 +17452,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17762
17452
  }
17763
17453
  };
17764
17454
  SqliteAlterTableAlterColumnDropNotNullConvertor = class extends Convertor {
17765
- can(statement, dialect7) {
17766
- return statement.type === "alter_table_alter_column_drop_notnull" && dialect7 === "sqlite";
17455
+ can(statement, dialect6) {
17456
+ return statement.type === "alter_table_alter_column_drop_notnull" && dialect6 === "sqlite";
17767
17457
  }
17768
17458
  convert(statement) {
17769
17459
  return `/*
@@ -17777,8 +17467,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17777
17467
  }
17778
17468
  };
17779
17469
  PgCreateForeignKeyConvertor = class extends Convertor {
17780
- can(statement, dialect7) {
17781
- return statement.type === "create_reference" && dialect7 === "pg";
17470
+ can(statement, dialect6) {
17471
+ return statement.type === "create_reference" && dialect6 === "pg";
17782
17472
  }
17783
17473
  convert(statement) {
17784
17474
  const {
@@ -17807,8 +17497,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17807
17497
  }
17808
17498
  };
17809
17499
  SqliteCreateForeignKeyConvertor = class extends Convertor {
17810
- can(statement, dialect7) {
17811
- return statement.type === "create_reference" && dialect7 === "sqlite";
17500
+ can(statement, dialect6) {
17501
+ return statement.type === "create_reference" && dialect6 === "sqlite";
17812
17502
  }
17813
17503
  convert(statement) {
17814
17504
  return `/*
@@ -17821,8 +17511,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17821
17511
  }
17822
17512
  };
17823
17513
  MySqlCreateForeignKeyConvertor = class extends Convertor {
17824
- can(statement, dialect7) {
17825
- return statement.type === "create_reference" && dialect7 === "mysql";
17514
+ can(statement, dialect6) {
17515
+ return statement.type === "create_reference" && dialect6 === "mysql";
17826
17516
  }
17827
17517
  convert(statement) {
17828
17518
  const {
@@ -17842,8 +17532,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17842
17532
  }
17843
17533
  };
17844
17534
  PgAlterForeignKeyConvertor = class extends Convertor {
17845
- can(statement, dialect7) {
17846
- return statement.type === "alter_reference" && dialect7 === "pg";
17535
+ can(statement, dialect6) {
17536
+ return statement.type === "alter_reference" && dialect6 === "pg";
17847
17537
  }
17848
17538
  convert(statement) {
17849
17539
  const newFk = PgSquasher.unsquashFK(statement.data);
@@ -17867,8 +17557,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17867
17557
  }
17868
17558
  };
17869
17559
  SqliteAlterForeignKeyConvertor = class extends Convertor {
17870
- can(statement, dialect7) {
17871
- return statement.type === "alter_reference" && dialect7 === "sqlite";
17560
+ can(statement, dialect6) {
17561
+ return statement.type === "alter_reference" && dialect6 === "sqlite";
17872
17562
  }
17873
17563
  convert(statement) {
17874
17564
  return `/*
@@ -17881,8 +17571,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17881
17571
  }
17882
17572
  };
17883
17573
  PgDeleteForeignKeyConvertor = class extends Convertor {
17884
- can(statement, dialect7) {
17885
- return statement.type === "delete_reference" && dialect7 === "pg";
17574
+ can(statement, dialect6) {
17575
+ return statement.type === "delete_reference" && dialect6 === "pg";
17886
17576
  }
17887
17577
  convert(statement) {
17888
17578
  const tableFrom = statement.tableName;
@@ -17893,8 +17583,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17893
17583
  }
17894
17584
  };
17895
17585
  SqliteDeleteForeignKeyConvertor = class extends Convertor {
17896
- can(statement, dialect7) {
17897
- return statement.type === "delete_reference" && dialect7 === "sqlite";
17586
+ can(statement, dialect6) {
17587
+ return statement.type === "delete_reference" && dialect6 === "sqlite";
17898
17588
  }
17899
17589
  convert(statement) {
17900
17590
  return `/*
@@ -17907,8 +17597,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17907
17597
  }
17908
17598
  };
17909
17599
  MySqlDeleteForeignKeyConvertor = class extends Convertor {
17910
- can(statement, dialect7) {
17911
- return statement.type === "delete_reference" && dialect7 === "mysql";
17600
+ can(statement, dialect6) {
17601
+ return statement.type === "delete_reference" && dialect6 === "mysql";
17912
17602
  }
17913
17603
  convert(statement) {
17914
17604
  const tableFrom = statement.tableName;
@@ -17918,8 +17608,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17918
17608
  }
17919
17609
  };
17920
17610
  CreatePgIndexConvertor = class extends Convertor {
17921
- can(statement, dialect7) {
17922
- return statement.type === "create_index" && dialect7 === "pg";
17611
+ can(statement, dialect6) {
17612
+ return statement.type === "create_index" && dialect6 === "pg";
17923
17613
  }
17924
17614
  convert(statement) {
17925
17615
  const { name, columns, isUnique } = PgSquasher.unsquashIdx(statement.data);
@@ -17930,8 +17620,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17930
17620
  }
17931
17621
  };
17932
17622
  CreateMySqlIndexConvertor = class extends Convertor {
17933
- can(statement, dialect7) {
17934
- return statement.type === "create_index" && dialect7 === "mysql";
17623
+ can(statement, dialect6) {
17624
+ return statement.type === "create_index" && dialect6 === "mysql";
17935
17625
  }
17936
17626
  convert(statement) {
17937
17627
  const { name, columns, isUnique } = MySqlSquasher.unsquashIdx(
@@ -17943,8 +17633,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17943
17633
  }
17944
17634
  };
17945
17635
  CreateSqliteIndexConvertor = class extends Convertor {
17946
- can(statement, dialect7) {
17947
- return statement.type === "create_index" && dialect7 === "sqlite";
17636
+ can(statement, dialect6) {
17637
+ return statement.type === "create_index" && dialect6 === "sqlite";
17948
17638
  }
17949
17639
  convert(statement) {
17950
17640
  const { name, columns, isUnique, where } = SQLiteSquasher.unsquashIdx(
@@ -17957,8 +17647,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17957
17647
  }
17958
17648
  };
17959
17649
  PgDropIndexConvertor = class extends Convertor {
17960
- can(statement, dialect7) {
17961
- return statement.type === "drop_index" && dialect7 === "pg";
17650
+ can(statement, dialect6) {
17651
+ return statement.type === "drop_index" && dialect6 === "pg";
17962
17652
  }
17963
17653
  convert(statement) {
17964
17654
  const { name } = PgSquasher.unsquashIdx(statement.data);
@@ -17966,8 +17656,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17966
17656
  }
17967
17657
  };
17968
17658
  PgCreateSchemaConvertor = class extends Convertor {
17969
- can(statement, dialect7) {
17970
- return statement.type === "create_schema" && dialect7 === "pg";
17659
+ can(statement, dialect6) {
17660
+ return statement.type === "create_schema" && dialect6 === "pg";
17971
17661
  }
17972
17662
  convert(statement) {
17973
17663
  const { name } = statement;
@@ -17976,8 +17666,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17976
17666
  }
17977
17667
  };
17978
17668
  PgRenameSchemaConvertor = class extends Convertor {
17979
- can(statement, dialect7) {
17980
- return statement.type === "rename_schema" && dialect7 === "pg";
17669
+ can(statement, dialect6) {
17670
+ return statement.type === "rename_schema" && dialect6 === "pg";
17981
17671
  }
17982
17672
  convert(statement) {
17983
17673
  const { from, to } = statement;
@@ -17986,8 +17676,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17986
17676
  }
17987
17677
  };
17988
17678
  PgDropSchemaConvertor = class extends Convertor {
17989
- can(statement, dialect7) {
17990
- return statement.type === "drop_schema" && dialect7 === "pg";
17679
+ can(statement, dialect6) {
17680
+ return statement.type === "drop_schema" && dialect6 === "pg";
17991
17681
  }
17992
17682
  convert(statement) {
17993
17683
  const { name } = statement;
@@ -17996,8 +17686,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17996
17686
  }
17997
17687
  };
17998
17688
  PgAlterTableSetSchemaConvertor = class extends Convertor {
17999
- can(statement, dialect7) {
18000
- return statement.type === "alter_table_set_schema" && dialect7 === "pg";
17689
+ can(statement, dialect6) {
17690
+ return statement.type === "alter_table_set_schema" && dialect6 === "pg";
18001
17691
  }
18002
17692
  convert(statement) {
18003
17693
  const { tableName, schema: schema4 } = statement;
@@ -18006,8 +17696,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
18006
17696
  }
18007
17697
  };
18008
17698
  PgAlterTableSetNewSchemaConvertor = class extends Convertor {
18009
- can(statement, dialect7) {
18010
- return statement.type === "alter_table_set_new_schema" && dialect7 === "pg";
17699
+ can(statement, dialect6) {
17700
+ return statement.type === "alter_table_set_new_schema" && dialect6 === "pg";
18011
17701
  }
18012
17702
  convert(statement) {
18013
17703
  const { tableName, to, from } = statement;
@@ -18017,8 +17707,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
18017
17707
  }
18018
17708
  };
18019
17709
  PgAlterTableRemoveFromSchemaConvertor = class extends Convertor {
18020
- can(statement, dialect7) {
18021
- return statement.type === "alter_table_remove_from_schema" && dialect7 === "pg";
17710
+ can(statement, dialect6) {
17711
+ return statement.type === "alter_table_remove_from_schema" && dialect6 === "pg";
18022
17712
  }
18023
17713
  convert(statement) {
18024
17714
  const { tableName, schema: schema4 } = statement;
@@ -18028,8 +17718,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
18028
17718
  }
18029
17719
  };
18030
17720
  SqliteDropIndexConvertor = class extends Convertor {
18031
- can(statement, dialect7) {
18032
- return statement.type === "drop_index" && dialect7 === "sqlite";
17721
+ can(statement, dialect6) {
17722
+ return statement.type === "drop_index" && dialect6 === "sqlite";
18033
17723
  }
18034
17724
  convert(statement) {
18035
17725
  const { name } = PgSquasher.unsquashIdx(statement.data);
@@ -18037,8 +17727,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
18037
17727
  }
18038
17728
  };
18039
17729
  MysqlCreateSchemaConvertor = class extends Convertor {
18040
- can(statement, dialect7) {
18041
- return statement.type === "create_schema" && dialect7 === "mysql";
17730
+ can(statement, dialect6) {
17731
+ return statement.type === "create_schema" && dialect6 === "mysql";
18042
17732
  }
18043
17733
  convert(statement) {
18044
17734
  const { name } = statement;
@@ -18047,8 +17737,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
18047
17737
  }
18048
17738
  };
18049
17739
  MysqlDropSchemaConvertor = class extends Convertor {
18050
- can(statement, dialect7) {
18051
- return statement.type === "drop_schema" && dialect7 === "mysql";
17740
+ can(statement, dialect6) {
17741
+ return statement.type === "drop_schema" && dialect6 === "mysql";
18052
17742
  }
18053
17743
  convert(statement) {
18054
17744
  const { name } = statement;
@@ -18057,8 +17747,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
18057
17747
  }
18058
17748
  };
18059
17749
  MysqlAlterTableSetSchemaConvertor = class extends Convertor {
18060
- can(statement, dialect7) {
18061
- return statement.type === "alter_table_set_schema" && dialect7 === "mysql";
17750
+ can(statement, dialect6) {
17751
+ return statement.type === "alter_table_set_schema" && dialect6 === "mysql";
18062
17752
  }
18063
17753
  convert(statement) {
18064
17754
  const { tableName, schema: schema4 } = statement;
@@ -18069,8 +17759,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
18069
17759
  }
18070
17760
  };
18071
17761
  MysqlAlterTableSetNewSchemaConvertor = class extends Convertor {
18072
- can(statement, dialect7) {
18073
- return statement.type === "alter_table_set_new_schema" && dialect7 === "mysql";
17762
+ can(statement, dialect6) {
17763
+ return statement.type === "alter_table_set_new_schema" && dialect6 === "mysql";
18074
17764
  }
18075
17765
  convert(statement) {
18076
17766
  const { tableName, to, from } = statement;
@@ -18081,8 +17771,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
18081
17771
  }
18082
17772
  };
18083
17773
  MysqlAlterTableRemoveFromSchemaConvertor = class extends Convertor {
18084
- can(statement, dialect7) {
18085
- return statement.type === "alter_table_remove_from_schema" && dialect7 === "mysql";
17774
+ can(statement, dialect6) {
17775
+ return statement.type === "alter_table_remove_from_schema" && dialect6 === "mysql";
18086
17776
  }
18087
17777
  convert(statement) {
18088
17778
  const { tableName, schema: schema4 } = statement;
@@ -18093,8 +17783,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
18093
17783
  }
18094
17784
  };
18095
17785
  MySqlDropIndexConvertor = class extends Convertor {
18096
- can(statement, dialect7) {
18097
- return statement.type === "drop_index" && dialect7 === "mysql";
17786
+ can(statement, dialect6) {
17787
+ return statement.type === "drop_index" && dialect6 === "mysql";
18098
17788
  }
18099
17789
  convert(statement) {
18100
17790
  const tableName = typeof statement.schema === "undefined" ? `\`${statement.tableName}\`` : `\`${statement.schema}\`.\`${statement.tableName}\``;
@@ -18180,10 +17870,10 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
18180
17870
  convertors.push(new MySqlAlterTableCreateCompositePrimaryKeyConvertor());
18181
17871
  convertors.push(new MySqlAlterTableAddPk());
18182
17872
  convertors.push(new MySqlAlterTableAlterCompositePrimaryKeyConvertor());
18183
- fromJson = (statements, dialect7) => {
17873
+ fromJson = (statements, dialect6) => {
18184
17874
  const result = statements.map((statement) => {
18185
17875
  const filtered = convertors.filter((it) => {
18186
- return it.can(statement, dialect7);
17876
+ return it.can(statement, dialect6);
18187
17877
  });
18188
17878
  const convertor = filtered.length === 1 ? filtered[0] : void 0;
18189
17879
  if (!convertor) {
@@ -18224,7 +17914,6 @@ drop type __venum;
18224
17914
  var import_hanji5, Select;
18225
17915
  var init_selector_ui = __esm({
18226
17916
  "src/cli/selector-ui.ts"() {
18227
- "use strict";
18228
17917
  init_source();
18229
17918
  import_hanji5 = __toESM(require_hanji());
18230
17919
  Select = class extends import_hanji5.Prompt {
@@ -34827,7 +34516,6 @@ import { sql } from "drizzle-orm";
34827
34516
  var DrizzleDbClient, DrizzleORMPgClient, DrizzleORMMySQLClient, DrizzleORMSQLiteClient, BetterSqlite, MySQL2Client, TursoSqlite, PgPostgres;
34828
34517
  var init_drivers = __esm({
34829
34518
  "src/drivers/index.ts"() {
34830
- "use strict";
34831
34519
  DrizzleDbClient = class {
34832
34520
  constructor(db) {
34833
34521
  this.db = db;
@@ -34908,7 +34596,6 @@ __export(mysqlPushUtils_exports, {
34908
34596
  var import_hanji9, filterStatements, logSuggestionsAndReturn2;
34909
34597
  var init_mysqlPushUtils = __esm({
34910
34598
  "src/cli/commands/mysqlPushUtils.ts"() {
34911
- "use strict";
34912
34599
  init_source();
34913
34600
  import_hanji9 = __toESM(require_hanji());
34914
34601
  init_mysqlSchema();
@@ -35277,7 +34964,7 @@ String.prototype.camelCase = function() {
35277
34964
  return camelCase(String(this));
35278
34965
  };
35279
34966
  String.prototype.concatIf = function(it, condition) {
35280
- return condition ? `${this}${it}` : String(this);
34967
+ return condition ? `${this}${it}` : this;
35281
34968
  };
35282
34969
  Array.prototype.random = function() {
35283
34970
  return this[~~(Math.random() * this.length)];