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.js CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
2
  var __create = Object.create;
4
3
  var __defProp = Object.defineProperty;
5
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -1079,7 +1078,6 @@ var require_hanji = __commonJS({
1079
1078
  var import_hanji, info, error, schema, isRenamePromptItem, ResolveColumnSelect, ResolveTableSelect, ResolveSchemasSelect;
1080
1079
  var init_views = __esm({
1081
1080
  "src/cli/views.ts"() {
1082
- "use strict";
1083
1081
  init_source();
1084
1082
  import_hanji = __toESM(require_hanji());
1085
1083
  info = (msg, greyMsg = "") => {
@@ -1101,7 +1099,7 @@ var init_views = __esm({
1101
1099
  )}`;
1102
1100
  }).join("\n");
1103
1101
  msg += "\n";
1104
- const enums = Object.values("enums" in schema4 ? schema4["enums"] || {} : {});
1102
+ const enums = Object.values(schema4["enums"] || {});
1105
1103
  if (enums.length > 0) {
1106
1104
  msg += "\n";
1107
1105
  msg += source_default.bold(`${enums.length} enums
@@ -1116,7 +1114,7 @@ var init_views = __esm({
1116
1114
  return msg;
1117
1115
  };
1118
1116
  isRenamePromptItem = (item) => {
1119
- return "from" in item && "to" in item;
1117
+ return item["from"] && item["to"];
1120
1118
  };
1121
1119
  ResolveColumnSelect = class extends import_hanji.Prompt {
1122
1120
  constructor(tableName, base, data) {
@@ -1264,7 +1262,6 @@ __export(mysqlImports_exports, {
1264
1262
  var import_mysql_core, import_drizzle_orm, prepareFromExports, prepareFromMySqlImports;
1265
1263
  var init_mysqlImports = __esm({
1266
1264
  "src/serializer/mysqlImports.ts"() {
1267
- "use strict";
1268
1265
  import_mysql_core = require("drizzle-orm/mysql-core");
1269
1266
  import_drizzle_orm = require("drizzle-orm");
1270
1267
  init_utils();
@@ -1306,7 +1303,6 @@ var init_mysqlImports = __esm({
1306
1303
  var withStyle;
1307
1304
  var init_outputs = __esm({
1308
1305
  "src/cli/validations/outputs.ts"() {
1309
- "use strict";
1310
1306
  init_source();
1311
1307
  withStyle = {
1312
1308
  error: (str) => `${source_default.red(`${source_default.white.bgRed(" Invalid input ")} ${str}`)}`,
@@ -1345,7 +1341,6 @@ function clearDefaults(defaultValue, collate) {
1345
1341
  var import_mysql_core2, import_drizzle_orm2, import_mysql_core3, import_drizzle_orm3, dialect, indexName, generateMySqlSnapshot, fromDatabase;
1346
1342
  var init_mysqlSerializer = __esm({
1347
1343
  "src/serializer/mysqlSerializer.ts"() {
1348
- "use strict";
1349
1344
  import_mysql_core2 = require("drizzle-orm/mysql-core");
1350
1345
  import_drizzle_orm2 = require("drizzle-orm");
1351
1346
  import_mysql_core3 = require("drizzle-orm/mysql-core");
@@ -1561,8 +1556,7 @@ We have encountered a collision between the index name on columns ${source_defau
1561
1556
  lock: value.config.lock
1562
1557
  };
1563
1558
  });
1564
- const tableKey = `${schema4 || "public"}.${tableName}`;
1565
- result[tableKey] = {
1559
+ result[tableName] = {
1566
1560
  name: tableName,
1567
1561
  schema: schema4,
1568
1562
  columns: columnsObject,
@@ -1576,7 +1570,7 @@ We have encountered a collision between the index name on columns ${source_defau
1576
1570
  mysqlSchemas.map((it) => [it.schemaName, it.schemaName])
1577
1571
  );
1578
1572
  return {
1579
- version: "6",
1573
+ version: "5",
1580
1574
  dialect: "mysql",
1581
1575
  tables: result,
1582
1576
  schemas,
@@ -1831,7 +1825,7 @@ We have encountered a collision between the index name on columns ${source_defau
1831
1825
  }
1832
1826
  const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
1833
1827
  return {
1834
- version: "6",
1828
+ version: "5",
1835
1829
  dialect: "mysql",
1836
1830
  tables: result,
1837
1831
  schemas: schemasObject,
@@ -1856,7 +1850,6 @@ __export(pgSerializer_exports, {
1856
1850
  var import_pg_core, import_pg_core2, import_drizzle_orm4, dialect2, indexName2, generatePgSnapshot, trimChar, fromDatabase2, columnToDefault, defaultForColumn;
1857
1851
  var init_pgSerializer = __esm({
1858
1852
  "src/serializer/pgSerializer.ts"() {
1859
- "use strict";
1860
1853
  import_pg_core = require("drizzle-orm/pg-core");
1861
1854
  import_pg_core2 = require("drizzle-orm/pg-core");
1862
1855
  import_drizzle_orm4 = require("drizzle-orm");
@@ -2047,8 +2040,7 @@ ${withStyle.errorWarning(
2047
2040
  isUnique: value.config.unique ?? false
2048
2041
  };
2049
2042
  });
2050
- const tableKey = `${schema4 ?? "public"}.${tableName}`;
2051
- result[tableKey] = {
2043
+ result[tableName] = {
2052
2044
  name: tableName,
2053
2045
  schema: schema4 ?? "",
2054
2046
  columns: columnsObject,
@@ -2077,7 +2069,7 @@ ${withStyle.errorWarning(
2077
2069
  }).map((it) => [it.schemaName, it.schemaName])
2078
2070
  );
2079
2071
  return {
2080
- version: "6",
2072
+ version: "5",
2081
2073
  dialect: "pg",
2082
2074
  tables: result,
2083
2075
  enums: enumsToReturn,
@@ -2098,7 +2090,7 @@ ${withStyle.errorWarning(
2098
2090
  --end;
2099
2091
  return start > 0 || end < str.length ? str.substring(start, end) : str.toString();
2100
2092
  };
2101
- fromDatabase2 = async (db, tablesFilter = () => true, schemaFilters, progressCallback) => {
2093
+ fromDatabase2 = async (db, tablesFilter = (table4) => true, schemaFilters, progressCallback) => {
2102
2094
  const result = {};
2103
2095
  const internals = { tables: {} };
2104
2096
  const where = schemaFilters.map((t) => `table_schema = '${t}'`).join(" or ");
@@ -2425,7 +2417,7 @@ ${withStyle.errorWarning(
2425
2417
  }
2426
2418
  const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
2427
2419
  return {
2428
- version: "6",
2420
+ version: "5",
2429
2421
  dialect: "pg",
2430
2422
  tables: result,
2431
2423
  enums: enumsToReturn,
@@ -2506,7 +2498,6 @@ __export(sqliteImports_exports, {
2506
2498
  var import_sqlite_core, import_drizzle_orm5, prepareFromExports2, prepareFromSqliteImports;
2507
2499
  var init_sqliteImports = __esm({
2508
2500
  "src/serializer/sqliteImports.ts"() {
2509
- "use strict";
2510
2501
  import_sqlite_core = require("drizzle-orm/sqlite-core");
2511
2502
  import_drizzle_orm5 = require("drizzle-orm");
2512
2503
  init_utils();
@@ -2582,7 +2573,6 @@ function mapSqlToSqliteType(sqlType) {
2582
2573
  var import_drizzle_orm6, import_sqlite_core2, dialect3, generateSqliteSnapshot, fromDatabase3;
2583
2574
  var init_sqliteSerializer = __esm({
2584
2575
  "src/serializer/sqliteSerializer.ts"() {
2585
- "use strict";
2586
2576
  import_drizzle_orm6 = require("drizzle-orm");
2587
2577
  import_sqlite_core2 = require("drizzle-orm/sqlite-core");
2588
2578
  init_serializer();
@@ -2955,7 +2945,6 @@ WHERE
2955
2945
  var import_fs, import_path, glob, sqlToStr, serializeMySql, serializePg, serializeSQLite, prepareFilenames;
2956
2946
  var init_serializer = __esm({
2957
2947
  "src/serializer/index.ts"() {
2958
- "use strict";
2959
2948
  import_fs = __toESM(require("fs"));
2960
2949
  import_path = __toESM(require("path"));
2961
2950
  glob = __toESM(require("glob"));
@@ -3025,26 +3014,6 @@ ${filenames.join("\n")}
3025
3014
  }
3026
3015
  });
3027
3016
 
3028
- // src/global.ts
3029
- function assertUnreachable(x) {
3030
- throw new Error("Didn't expect to get here");
3031
- }
3032
- var originUUID, snapshotVersion, mapValues;
3033
- var init_global = __esm({
3034
- "src/global.ts"() {
3035
- "use strict";
3036
- originUUID = "00000000-0000-0000-0000-000000000000";
3037
- snapshotVersion = "6";
3038
- mapValues = (obj, map) => {
3039
- const result = Object.keys(obj).reduce(function(result2, key) {
3040
- result2[key] = map(obj[key]);
3041
- return result2;
3042
- }, {});
3043
- return result;
3044
- };
3045
- }
3046
- });
3047
-
3048
3017
  // node_modules/.pnpm/zod@3.20.2/node_modules/zod/lib/index.mjs
3049
3018
  function getErrorMap() {
3050
3019
  return overrideErrorMap;
@@ -6191,1250 +6160,132 @@ var init_lib = __esm({
6191
6160
  }
6192
6161
  });
6193
6162
 
6194
- // src/serializer/mysqlSchema.ts
6195
- 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;
6196
- var init_mysqlSchema = __esm({
6197
- "src/serializer/mysqlSchema.ts"() {
6198
- "use strict";
6199
- init_global();
6200
- init_lib();
6201
- index = objectType({
6202
- name: stringType(),
6203
- columns: stringType().array(),
6204
- isUnique: booleanType(),
6205
- using: enumType(["btree", "hash"]).optional(),
6206
- algorithm: enumType(["default", "inplace", "copy"]).optional(),
6207
- lock: enumType(["default", "none", "shared", "exclusive"]).optional()
6208
- }).strict();
6209
- fk = objectType({
6210
- name: stringType(),
6211
- tableFrom: stringType(),
6212
- columnsFrom: stringType().array(),
6213
- tableTo: stringType(),
6214
- columnsTo: stringType().array(),
6215
- onUpdate: stringType().optional(),
6216
- onDelete: stringType().optional()
6217
- }).strict();
6218
- column = objectType({
6219
- name: stringType(),
6220
- type: stringType(),
6221
- primaryKey: booleanType(),
6222
- notNull: booleanType(),
6223
- autoincrement: booleanType().optional(),
6224
- default: anyType().optional(),
6225
- onUpdate: anyType().optional()
6226
- }).strict();
6227
- tableV3 = objectType({
6228
- name: stringType(),
6229
- columns: recordType(stringType(), column),
6230
- indexes: recordType(stringType(), index),
6231
- foreignKeys: recordType(stringType(), fk)
6232
- }).strict();
6233
- compositePK = objectType({
6234
- name: stringType(),
6235
- columns: stringType().array()
6236
- }).strict();
6237
- uniqueConstraint = objectType({
6238
- name: stringType(),
6239
- columns: stringType().array()
6240
- }).strict();
6241
- tableV4 = objectType({
6242
- name: stringType(),
6243
- schema: stringType().optional(),
6244
- columns: recordType(stringType(), column),
6245
- indexes: recordType(stringType(), index),
6246
- foreignKeys: recordType(stringType(), fk)
6247
- }).strict();
6248
- table = objectType({
6249
- name: stringType(),
6250
- schema: stringType().optional(),
6251
- columns: recordType(stringType(), column),
6252
- indexes: recordType(stringType(), index),
6253
- foreignKeys: recordType(stringType(), fk),
6254
- compositePrimaryKeys: recordType(stringType(), compositePK),
6255
- uniqueConstraints: recordType(stringType(), uniqueConstraint).default({})
6256
- }).strict();
6257
- kitInternals = objectType({
6258
- tables: recordType(
6259
- stringType(),
6260
- objectType({
6261
- columns: recordType(
6262
- stringType(),
6263
- objectType({ isDefaultAnExpression: booleanType().optional() }).optional()
6264
- )
6265
- }).optional()
6266
- )
6267
- }).optional();
6268
- dialect4 = literalType("mysql");
6269
- schemaHash = objectType({
6270
- id: stringType(),
6271
- prevId: stringType()
6272
- });
6273
- schemaInternalV3 = objectType({
6274
- version: literalType("3"),
6275
- dialect: dialect4,
6276
- tables: recordType(stringType(), tableV3)
6277
- }).strict();
6278
- schemaInternalV4 = objectType({
6279
- version: literalType("4"),
6280
- dialect: dialect4,
6281
- tables: recordType(stringType(), tableV4),
6282
- schemas: recordType(stringType(), stringType())
6283
- }).strict();
6284
- schemaInternalV5 = objectType({
6285
- version: literalType("5"),
6286
- dialect: dialect4,
6287
- tables: recordType(stringType(), table),
6288
- schemas: recordType(stringType(), stringType()),
6289
- _meta: objectType({
6290
- schemas: recordType(stringType(), stringType()),
6291
- tables: recordType(stringType(), stringType()),
6292
- columns: recordType(stringType(), stringType())
6293
- }),
6294
- internal: kitInternals
6295
- }).strict();
6296
- schemaInternalV6 = objectType({
6297
- version: literalType("6"),
6298
- dialect: dialect4,
6299
- tables: recordType(stringType(), table),
6300
- schemas: recordType(stringType(), stringType()),
6301
- _meta: objectType({
6302
- schemas: recordType(stringType(), stringType()),
6303
- tables: recordType(stringType(), stringType()),
6304
- columns: recordType(stringType(), stringType())
6305
- }),
6306
- internal: kitInternals
6307
- }).strict();
6308
- schemaInternal = objectType({
6309
- version: literalType("6"),
6310
- dialect: dialect4,
6311
- tables: recordType(stringType(), table),
6312
- schemas: recordType(stringType(), stringType()),
6313
- _meta: objectType({
6314
- schemas: recordType(stringType(), stringType()),
6315
- tables: recordType(stringType(), stringType()),
6316
- columns: recordType(stringType(), stringType())
6317
- }),
6318
- internal: kitInternals
6319
- }).strict();
6320
- schemaV3 = schemaInternalV3.merge(schemaHash);
6321
- schemaV4 = schemaInternalV4.merge(schemaHash);
6322
- schemaV5 = schemaInternalV5.merge(schemaHash);
6323
- schema2 = schemaInternal.merge(schemaHash);
6324
- tableSquashedV4 = objectType({
6325
- name: stringType(),
6326
- schema: stringType().optional(),
6327
- columns: recordType(stringType(), column),
6328
- indexes: recordType(stringType(), stringType()),
6329
- foreignKeys: recordType(stringType(), stringType())
6330
- }).strict();
6331
- tableSquashed = objectType({
6332
- name: stringType(),
6333
- schema: stringType().optional(),
6334
- columns: recordType(stringType(), column),
6335
- indexes: recordType(stringType(), stringType()),
6336
- foreignKeys: recordType(stringType(), stringType()),
6337
- compositePrimaryKeys: recordType(stringType(), stringType()),
6338
- uniqueConstraints: recordType(stringType(), stringType()).default({})
6339
- }).strict();
6340
- schemaSquashed = objectType({
6341
- version: literalType("5"),
6342
- dialect: dialect4,
6343
- tables: recordType(stringType(), tableSquashed),
6344
- schemas: recordType(stringType(), stringType())
6345
- }).strict();
6346
- schemaSquashedV4 = objectType({
6347
- version: literalType("4"),
6348
- dialect: dialect4,
6349
- tables: recordType(stringType(), tableSquashedV4),
6350
- schemas: recordType(stringType(), stringType())
6351
- }).strict();
6352
- MySqlSquasher = {
6353
- squashIdx: (idx) => {
6354
- index.parse(idx);
6355
- return `${idx.name};${idx.columns.join(",")};${idx.isUnique};${idx.using ?? ""};${idx.algorithm ?? ""};${idx.lock ?? ""}`;
6356
- },
6357
- unsquashIdx: (input) => {
6358
- const [name, columnsString, isUnique, using, algorithm, lock] = input.split(";");
6359
- const destructed = {
6360
- name,
6361
- columns: columnsString.split(","),
6362
- isUnique: isUnique === "true",
6363
- using: using ? using : void 0,
6364
- algorithm: algorithm ? algorithm : void 0,
6365
- lock: lock ? lock : void 0
6366
- };
6367
- return index.parse(destructed);
6368
- },
6369
- squashPK: (pk) => {
6370
- return `${pk.name};${pk.columns.join(",")}`;
6371
- },
6372
- unsquashPK: (pk) => {
6373
- const splitted = pk.split(";");
6374
- return { name: splitted[0], columns: splitted[1].split(",") };
6375
- },
6376
- squashUnique: (unq) => {
6377
- return `${unq.name};${unq.columns.join(",")}`;
6378
- },
6379
- unsquashUnique: (unq) => {
6380
- const [name, columns] = unq.split(";");
6381
- return { name, columns: columns.split(",") };
6382
- },
6383
- squashFK: (fk4) => {
6384
- return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""}`;
6385
- },
6386
- unsquashFK: (input) => {
6387
- const [
6388
- name,
6389
- tableFrom,
6390
- columnsFromStr,
6391
- tableTo,
6392
- columnsToStr,
6393
- onUpdate,
6394
- onDelete
6395
- ] = input.split(";");
6396
- const result = fk.parse({
6397
- name,
6398
- tableFrom,
6399
- columnsFrom: columnsFromStr.split(","),
6400
- tableTo,
6401
- columnsTo: columnsToStr.split(","),
6402
- onUpdate,
6403
- onDelete
6404
- });
6405
- return result;
6163
+ // src/cli/commands/_es5.ts
6164
+ var es5_exports = {};
6165
+ __export(es5_exports, {
6166
+ default: () => es5_default
6167
+ });
6168
+ var _, es5_default;
6169
+ var init_es5 = __esm({
6170
+ "src/cli/commands/_es5.ts"() {
6171
+ _ = "";
6172
+ es5_default = _;
6173
+ }
6174
+ });
6175
+
6176
+ // node_modules/.pnpm/ms@2.1.2/node_modules/ms/index.js
6177
+ var require_ms = __commonJS({
6178
+ "node_modules/.pnpm/ms@2.1.2/node_modules/ms/index.js"(exports, module2) {
6179
+ var s = 1e3;
6180
+ var m = s * 60;
6181
+ var h = m * 60;
6182
+ var d = h * 24;
6183
+ var w = d * 7;
6184
+ var y = d * 365.25;
6185
+ module2.exports = function(val, options) {
6186
+ options = options || {};
6187
+ var type = typeof val;
6188
+ if (type === "string" && val.length > 0) {
6189
+ return parse(val);
6190
+ } else if (type === "number" && isFinite(val)) {
6191
+ return options.long ? fmtLong(val) : fmtShort(val);
6406
6192
  }
6407
- };
6408
- squashMysqlScheme = (json) => {
6409
- const mappedTables = Object.fromEntries(
6410
- Object.entries(json.tables).map((it) => {
6411
- const squashedIndexes = mapValues(it[1].indexes, (index4) => {
6412
- return MySqlSquasher.squashIdx(index4);
6413
- });
6414
- const squashedFKs = mapValues(it[1].foreignKeys, (fk4) => {
6415
- return MySqlSquasher.squashFK(fk4);
6416
- });
6417
- const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => {
6418
- return MySqlSquasher.squashPK(pk);
6419
- });
6420
- const squashedUniqueConstraints = mapValues(
6421
- it[1].uniqueConstraints,
6422
- (unq) => {
6423
- return MySqlSquasher.squashUnique(unq);
6424
- }
6425
- );
6426
- return [
6427
- it[0],
6428
- {
6429
- name: it[1].name,
6430
- schema: it[1].schema,
6431
- columns: it[1].columns,
6432
- indexes: squashedIndexes,
6433
- foreignKeys: squashedFKs,
6434
- compositePrimaryKeys: squashedPKs,
6435
- uniqueConstraints: squashedUniqueConstraints
6436
- }
6437
- ];
6438
- })
6193
+ throw new Error(
6194
+ "val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
6439
6195
  );
6440
- return {
6441
- version: "5",
6442
- dialect: json.dialect,
6443
- tables: mappedTables,
6444
- schemas: json.schemas
6445
- };
6446
6196
  };
6447
- mysqlSchema = schema2;
6448
- mysqlSchemaV5 = schemaV5;
6449
- mysqlSchemaSquashed = schemaSquashed;
6450
- backwardCompatibleMysqlSchema = unionType([mysqlSchemaV5, schema2]);
6451
- dryMySql = mysqlSchema.parse({
6452
- version: snapshotVersion,
6453
- dialect: "mysql",
6454
- id: originUUID,
6455
- prevId: "",
6456
- tables: {},
6457
- schemas: {},
6458
- _meta: {
6459
- schemas: {},
6460
- tables: {},
6461
- columns: {}
6197
+ function parse(str) {
6198
+ str = String(str);
6199
+ if (str.length > 100) {
6200
+ return;
6462
6201
  }
6463
- });
6464
- }
6465
- });
6466
-
6467
- // src/serializer/pgSchema.ts
6468
- 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;
6469
- var init_pgSchema = __esm({
6470
- "src/serializer/pgSchema.ts"() {
6471
- "use strict";
6472
- init_global();
6473
- init_lib();
6474
- indexV2 = objectType({
6475
- name: stringType(),
6476
- columns: recordType(
6477
- stringType(),
6478
- objectType({
6479
- name: stringType()
6480
- })
6481
- ),
6482
- isUnique: booleanType()
6483
- }).strict();
6484
- columnV2 = objectType({
6485
- name: stringType(),
6486
- type: stringType(),
6487
- primaryKey: booleanType(),
6488
- notNull: booleanType(),
6489
- default: anyType().optional(),
6490
- references: stringType().optional()
6491
- }).strict();
6492
- tableV2 = objectType({
6493
- name: stringType(),
6494
- columns: recordType(stringType(), columnV2),
6495
- indexes: recordType(stringType(), indexV2)
6496
- }).strict();
6497
- enumSchema = objectType({
6498
- name: stringType(),
6499
- values: recordType(stringType(), stringType())
6500
- }).strict();
6501
- pgSchemaV2 = objectType({
6502
- version: literalType("2"),
6503
- tables: recordType(stringType(), tableV2),
6504
- enums: recordType(stringType(), enumSchema)
6505
- }).strict();
6506
- references = objectType({
6507
- foreignKeyName: stringType(),
6508
- table: stringType(),
6509
- column: stringType(),
6510
- onDelete: stringType().optional(),
6511
- onUpdate: stringType().optional()
6512
- }).strict();
6513
- columnV1 = objectType({
6514
- name: stringType(),
6515
- type: stringType(),
6516
- primaryKey: booleanType(),
6517
- notNull: booleanType(),
6518
- default: anyType().optional(),
6519
- references: references.optional()
6520
- }).strict();
6521
- tableV1 = objectType({
6522
- name: stringType(),
6523
- columns: recordType(stringType(), columnV1),
6524
- indexes: recordType(stringType(), indexV2)
6525
- }).strict();
6526
- pgSchemaV1 = objectType({
6527
- version: literalType("1"),
6528
- tables: recordType(stringType(), tableV1),
6529
- enums: recordType(stringType(), enumSchema)
6530
- }).strict();
6531
- index2 = objectType({
6532
- name: stringType(),
6533
- columns: stringType().array(),
6534
- isUnique: booleanType()
6535
- }).strict();
6536
- fk2 = objectType({
6537
- name: stringType(),
6538
- tableFrom: stringType(),
6539
- columnsFrom: stringType().array(),
6540
- tableTo: stringType(),
6541
- schemaTo: stringType().optional(),
6542
- columnsTo: stringType().array(),
6543
- onUpdate: stringType().optional(),
6544
- onDelete: stringType().optional()
6545
- }).strict();
6546
- column2 = objectType({
6547
- name: stringType(),
6548
- type: stringType(),
6549
- primaryKey: booleanType(),
6550
- notNull: booleanType(),
6551
- default: anyType().optional(),
6552
- isUnique: anyType().optional(),
6553
- uniqueName: stringType().optional(),
6554
- nullsNotDistinct: booleanType().optional()
6555
- }).strict();
6556
- tableV32 = objectType({
6557
- name: stringType(),
6558
- columns: recordType(stringType(), column2),
6559
- indexes: recordType(stringType(), index2),
6560
- foreignKeys: recordType(stringType(), fk2)
6561
- }).strict();
6562
- compositePK2 = objectType({
6563
- name: stringType(),
6564
- columns: stringType().array()
6565
- }).strict();
6566
- uniqueConstraint2 = objectType({
6567
- name: stringType(),
6568
- columns: stringType().array(),
6569
- nullsNotDistinct: booleanType()
6570
- }).strict();
6571
- tableV42 = objectType({
6572
- name: stringType(),
6573
- schema: stringType(),
6574
- columns: recordType(stringType(), column2),
6575
- indexes: recordType(stringType(), index2),
6576
- foreignKeys: recordType(stringType(), fk2)
6577
- }).strict();
6578
- table2 = objectType({
6579
- name: stringType(),
6580
- schema: stringType(),
6581
- columns: recordType(stringType(), column2),
6582
- indexes: recordType(stringType(), index2),
6583
- foreignKeys: recordType(stringType(), fk2),
6584
- compositePrimaryKeys: recordType(stringType(), compositePK2),
6585
- uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
6586
- }).strict();
6587
- schemaHash2 = objectType({
6588
- id: stringType(),
6589
- prevId: stringType()
6590
- });
6591
- kitInternals2 = objectType({
6592
- tables: recordType(
6593
- stringType(),
6594
- objectType({
6595
- columns: recordType(
6596
- stringType(),
6597
- objectType({
6598
- isArray: booleanType().optional(),
6599
- dimensions: numberType().optional(),
6600
- rawType: stringType().optional()
6601
- }).optional()
6602
- )
6603
- }).optional()
6604
- )
6605
- }).optional();
6606
- pgSchemaInternalV3 = objectType({
6607
- version: literalType("3"),
6608
- dialect: literalType("pg"),
6609
- tables: recordType(stringType(), tableV32),
6610
- enums: recordType(stringType(), enumSchema)
6611
- }).strict();
6612
- pgSchemaInternalV4 = objectType({
6613
- version: literalType("4"),
6614
- dialect: literalType("pg"),
6615
- tables: recordType(stringType(), tableV42),
6616
- enums: recordType(stringType(), enumSchema),
6617
- schemas: recordType(stringType(), stringType())
6618
- }).strict();
6619
- pgSchemaInternalV5 = objectType({
6620
- version: literalType("5"),
6621
- dialect: literalType("pg"),
6622
- tables: recordType(stringType(), table2),
6623
- enums: recordType(stringType(), enumSchema),
6624
- schemas: recordType(stringType(), stringType()),
6625
- _meta: objectType({
6626
- schemas: recordType(stringType(), stringType()),
6627
- tables: recordType(stringType(), stringType()),
6628
- columns: recordType(stringType(), stringType())
6629
- }),
6630
- internal: kitInternals2
6631
- }).strict();
6632
- pgSchemaExternal = objectType({
6633
- version: literalType("5"),
6634
- dialect: literalType("pg"),
6635
- tables: arrayType(table2),
6636
- enums: arrayType(enumSchema),
6637
- schemas: arrayType(objectType({ name: stringType() })),
6638
- _meta: objectType({
6639
- schemas: recordType(stringType(), stringType()),
6640
- tables: recordType(stringType(), stringType()),
6641
- columns: recordType(stringType(), stringType())
6642
- })
6643
- }).strict();
6644
- pgSchemaInternal = objectType({
6645
- version: literalType("6"),
6646
- dialect: literalType("pg"),
6647
- tables: recordType(stringType(), table2),
6648
- enums: recordType(stringType(), enumSchema),
6649
- schemas: recordType(stringType(), stringType()),
6650
- _meta: objectType({
6651
- schemas: recordType(stringType(), stringType()),
6652
- tables: recordType(stringType(), stringType()),
6653
- columns: recordType(stringType(), stringType())
6654
- }),
6655
- internal: kitInternals2
6656
- }).strict();
6657
- tableSquashed2 = objectType({
6658
- name: stringType(),
6659
- schema: stringType(),
6660
- columns: recordType(stringType(), column2),
6661
- indexes: recordType(stringType(), stringType()),
6662
- foreignKeys: recordType(stringType(), stringType()),
6663
- compositePrimaryKeys: recordType(stringType(), stringType()),
6664
- uniqueConstraints: recordType(stringType(), stringType())
6665
- }).strict();
6666
- tableSquashedV42 = objectType({
6667
- name: stringType(),
6668
- schema: stringType(),
6669
- columns: recordType(stringType(), column2),
6670
- indexes: recordType(stringType(), stringType()),
6671
- foreignKeys: recordType(stringType(), stringType())
6672
- }).strict();
6673
- pgSchemaSquashedV4 = objectType({
6674
- version: literalType("4"),
6675
- dialect: enumType(["pg"]),
6676
- tables: recordType(stringType(), tableSquashedV42),
6677
- enums: recordType(stringType(), enumSchema),
6678
- schemas: recordType(stringType(), stringType())
6679
- }).strict();
6680
- pgSchemaSquashed = objectType({
6681
- version: literalType("6"),
6682
- dialect: enumType(["pg"]),
6683
- tables: recordType(stringType(), tableSquashed2),
6684
- enums: recordType(stringType(), enumSchema),
6685
- schemas: recordType(stringType(), stringType())
6686
- }).strict();
6687
- pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash2);
6688
- pgSchemaV4 = pgSchemaInternalV4.merge(schemaHash2);
6689
- pgSchemaV5 = pgSchemaInternalV5.merge(schemaHash2);
6690
- pgSchema = pgSchemaInternal.merge(schemaHash2);
6691
- backwardCompatiblePgSchema = unionType([pgSchemaV5, pgSchema]);
6692
- PgSquasher = {
6693
- squashIdx: (idx) => {
6694
- index2.parse(idx);
6695
- return `${idx.name};${idx.columns.join(",")};${idx.isUnique}`;
6696
- },
6697
- unsquashIdx: (input) => {
6698
- const [name, columnsString, isUnique] = input.split(";");
6699
- const result = index2.parse({
6700
- name,
6701
- columns: columnsString.split(","),
6702
- isUnique: isUnique === "true"
6703
- });
6704
- return result;
6705
- },
6706
- squashFK: (fk4) => {
6707
- return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""};${fk4.schemaTo ?? ""}`;
6708
- },
6709
- squashPK: (pk) => {
6710
- return `${pk.columns.join(",")};${pk.name}`;
6711
- },
6712
- unsquashPK: (pk) => {
6713
- const splitted = pk.split(";");
6714
- return { name: splitted[1], columns: splitted[0].split(",") };
6715
- },
6716
- squashUnique: (unq) => {
6717
- return `${unq.name};${unq.columns.join(",")};${unq.nullsNotDistinct}`;
6718
- },
6719
- unsquashUnique: (unq) => {
6720
- const [name, columns, nullsNotDistinct] = unq.split(";");
6721
- return {
6722
- name,
6723
- columns: columns.split(","),
6724
- nullsNotDistinct: nullsNotDistinct === "true"
6725
- };
6726
- },
6727
- unsquashFK: (input) => {
6728
- const [
6729
- name,
6730
- tableFrom,
6731
- columnsFromStr,
6732
- tableTo,
6733
- columnsToStr,
6734
- onUpdate,
6735
- onDelete,
6736
- schemaTo
6737
- ] = input.split(";");
6738
- const result = fk2.parse({
6739
- name,
6740
- tableFrom,
6741
- columnsFrom: columnsFromStr.split(","),
6742
- schemaTo,
6743
- tableTo,
6744
- columnsTo: columnsToStr.split(","),
6745
- onUpdate,
6746
- onDelete
6747
- });
6748
- return result;
6749
- }
6750
- };
6751
- squashPgScheme = (json) => {
6752
- const mappedTables = Object.fromEntries(
6753
- Object.entries(json.tables).map((it) => {
6754
- const squashedIndexes = mapValues(it[1].indexes, (index4) => {
6755
- return PgSquasher.squashIdx(index4);
6756
- });
6757
- const squashedFKs = mapValues(it[1].foreignKeys, (fk4) => {
6758
- return PgSquasher.squashFK(fk4);
6759
- });
6760
- const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => {
6761
- return PgSquasher.squashPK(pk);
6762
- });
6763
- const squashedUniqueConstraints = mapValues(
6764
- it[1].uniqueConstraints,
6765
- (unq) => {
6766
- return PgSquasher.squashUnique(unq);
6767
- }
6768
- );
6769
- return [
6770
- it[0],
6771
- {
6772
- name: it[1].name,
6773
- schema: it[1].schema,
6774
- columns: it[1].columns,
6775
- indexes: squashedIndexes,
6776
- foreignKeys: squashedFKs,
6777
- compositePrimaryKeys: squashedPKs,
6778
- uniqueConstraints: squashedUniqueConstraints
6779
- }
6780
- ];
6781
- })
6782
- );
6783
- return {
6784
- version: "6",
6785
- dialect: json.dialect,
6786
- tables: mappedTables,
6787
- enums: json.enums,
6788
- schemas: json.schemas
6789
- };
6790
- };
6791
- dryPg = pgSchema.parse({
6792
- version: snapshotVersion,
6793
- dialect: "pg",
6794
- id: originUUID,
6795
- prevId: "",
6796
- tables: {},
6797
- enums: {},
6798
- schemas: {},
6799
- _meta: {
6800
- schemas: {},
6801
- tables: {},
6802
- columns: {}
6803
- }
6804
- });
6805
- }
6806
- });
6807
-
6808
- // src/serializer/sqliteSchema.ts
6809
- 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;
6810
- var init_sqliteSchema = __esm({
6811
- "src/serializer/sqliteSchema.ts"() {
6812
- "use strict";
6813
- init_global();
6814
- init_lib();
6815
- index3 = objectType({
6816
- name: stringType(),
6817
- columns: stringType().array(),
6818
- where: stringType().optional(),
6819
- isUnique: booleanType()
6820
- }).strict();
6821
- fk3 = objectType({
6822
- name: stringType(),
6823
- tableFrom: stringType(),
6824
- columnsFrom: stringType().array(),
6825
- tableTo: stringType(),
6826
- columnsTo: stringType().array(),
6827
- onUpdate: stringType().optional(),
6828
- onDelete: stringType().optional()
6829
- }).strict();
6830
- compositePK3 = objectType({
6831
- columns: stringType().array(),
6832
- name: stringType().optional()
6833
- }).strict();
6834
- column3 = objectType({
6835
- name: stringType(),
6836
- type: stringType(),
6837
- primaryKey: booleanType(),
6838
- notNull: booleanType(),
6839
- autoincrement: booleanType().optional(),
6840
- default: anyType().optional()
6841
- }).strict();
6842
- tableV33 = objectType({
6843
- name: stringType(),
6844
- columns: recordType(stringType(), column3),
6845
- indexes: recordType(stringType(), index3),
6846
- foreignKeys: recordType(stringType(), fk3)
6847
- }).strict();
6848
- uniqueConstraint3 = objectType({
6849
- name: stringType(),
6850
- columns: stringType().array()
6851
- }).strict();
6852
- table3 = objectType({
6853
- name: stringType(),
6854
- columns: recordType(stringType(), column3),
6855
- indexes: recordType(stringType(), index3),
6856
- foreignKeys: recordType(stringType(), fk3),
6857
- compositePrimaryKeys: recordType(stringType(), compositePK3),
6858
- uniqueConstraints: recordType(stringType(), uniqueConstraint3).default({})
6859
- }).strict();
6860
- dialect5 = enumType(["sqlite"]);
6861
- schemaHash3 = objectType({
6862
- id: stringType(),
6863
- prevId: stringType()
6864
- }).strict();
6865
- schemaInternalV32 = objectType({
6866
- version: literalType("3"),
6867
- dialect: dialect5,
6868
- tables: recordType(stringType(), tableV33),
6869
- enums: objectType({})
6870
- }).strict();
6871
- schemaInternalV42 = objectType({
6872
- version: literalType("4"),
6873
- dialect: dialect5,
6874
- tables: recordType(stringType(), table3),
6875
- enums: objectType({})
6876
- }).strict();
6877
- latestVersion = literalType("5");
6878
- schemaInternal2 = objectType({
6879
- version: latestVersion,
6880
- dialect: dialect5,
6881
- tables: recordType(stringType(), table3),
6882
- enums: objectType({}),
6883
- _meta: objectType({
6884
- tables: recordType(stringType(), stringType()),
6885
- columns: recordType(stringType(), stringType())
6886
- })
6887
- }).strict();
6888
- schemaV32 = schemaInternalV32.merge(schemaHash3).strict();
6889
- schemaV42 = schemaInternalV42.merge(schemaHash3).strict();
6890
- schema3 = schemaInternal2.merge(schemaHash3).strict();
6891
- tableSquashed3 = objectType({
6892
- name: stringType(),
6893
- columns: recordType(stringType(), column3),
6894
- indexes: recordType(stringType(), stringType()),
6895
- foreignKeys: recordType(stringType(), stringType()),
6896
- compositePrimaryKeys: recordType(stringType(), stringType()),
6897
- uniqueConstraints: recordType(stringType(), stringType()).default({})
6898
- }).strict();
6899
- schemaSquashed2 = objectType({
6900
- version: latestVersion,
6901
- dialect: dialect5,
6902
- tables: recordType(stringType(), tableSquashed3),
6903
- enums: anyType()
6904
- }).strict();
6905
- SQLiteSquasher = {
6906
- squashIdx: (idx) => {
6907
- index3.parse(idx);
6908
- return `${idx.name};${idx.columns.join(",")};${idx.isUnique};${idx.where ?? ""}`;
6909
- },
6910
- unsquashIdx: (input) => {
6911
- const [name, columnsString, isUnique, where] = input.split(";");
6912
- const result = index3.parse({
6913
- name,
6914
- columns: columnsString.split(","),
6915
- isUnique: isUnique === "true",
6916
- where: where ?? void 0
6917
- });
6918
- return result;
6919
- },
6920
- squashUnique: (unq) => {
6921
- return `${unq.name};${unq.columns.join(",")}`;
6922
- },
6923
- unsquashUnique: (unq) => {
6924
- const [name, columns] = unq.split(";");
6925
- return { name, columns: columns.split(",") };
6926
- },
6927
- squashFK: (fk4) => {
6928
- return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""}`;
6929
- },
6930
- unsquashFK: (input) => {
6931
- const [
6932
- name,
6933
- tableFrom,
6934
- columnsFromStr,
6935
- tableTo,
6936
- columnsToStr,
6937
- onUpdate,
6938
- onDelete
6939
- ] = input.split(";");
6940
- const result = fk3.parse({
6941
- name,
6942
- tableFrom,
6943
- columnsFrom: columnsFromStr.split(","),
6944
- tableTo,
6945
- columnsTo: columnsToStr.split(","),
6946
- onUpdate,
6947
- onDelete
6948
- });
6949
- return result;
6950
- },
6951
- squashPK: (pk) => {
6952
- return pk.columns.join(",");
6953
- },
6954
- unsquashPK: (pk) => {
6955
- return pk.split(",");
6956
- }
6957
- };
6958
- squashSqliteScheme = (json) => {
6959
- const mappedTables = Object.fromEntries(
6960
- Object.entries(json.tables).map((it) => {
6961
- const squashedIndexes = mapValues(it[1].indexes, (index4) => {
6962
- return SQLiteSquasher.squashIdx(index4);
6963
- });
6964
- const squashedFKs = mapValues(it[1].foreignKeys, (fk4) => {
6965
- return SQLiteSquasher.squashFK(fk4);
6966
- });
6967
- const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => {
6968
- return SQLiteSquasher.squashPK(pk);
6969
- });
6970
- const squashedUniqueConstraints = mapValues(
6971
- it[1].uniqueConstraints,
6972
- (unq) => {
6973
- return SQLiteSquasher.squashUnique(unq);
6974
- }
6975
- );
6976
- return [
6977
- it[0],
6978
- {
6979
- name: it[1].name,
6980
- columns: it[1].columns,
6981
- indexes: squashedIndexes,
6982
- foreignKeys: squashedFKs,
6983
- compositePrimaryKeys: squashedPKs,
6984
- uniqueConstraints: squashedUniqueConstraints
6985
- }
6986
- ];
6987
- })
6988
- );
6989
- return {
6990
- version: "5",
6991
- dialect: json.dialect,
6992
- tables: mappedTables,
6993
- enums: json.enums
6994
- };
6995
- };
6996
- drySQLite = schema3.parse({
6997
- version: "5",
6998
- dialect: "sqlite",
6999
- id: originUUID,
7000
- prevId: "",
7001
- tables: {},
7002
- enums: {},
7003
- _meta: {
7004
- tables: {},
7005
- columns: {}
7006
- }
7007
- });
7008
- sqliteSchema = schema3;
7009
- SQLiteSchemaSquashed = schemaSquashed2;
7010
- backwardCompatibleSqliteSchema = schema3;
7011
- }
7012
- });
7013
-
7014
- // src/schemaValidator.ts
7015
- var dialect6, commonSquashedSchema, commonSchema;
7016
- var init_schemaValidator = __esm({
7017
- "src/schemaValidator.ts"() {
7018
- "use strict";
7019
- init_lib();
7020
- init_mysqlSchema();
7021
- init_pgSchema();
7022
- init_sqliteSchema();
7023
- dialect6 = enumType(["pg", "mysql", "sqlite"]);
7024
- commonSquashedSchema = unionType([
7025
- pgSchemaSquashed,
7026
- mysqlSchemaSquashed,
7027
- SQLiteSchemaSquashed
7028
- ]);
7029
- commonSchema = unionType([
7030
- pgSchema,
7031
- mysqlSchema,
7032
- sqliteSchema
7033
- ]);
7034
- }
7035
- });
7036
-
7037
- // src/cli/validations/common.ts
7038
- var driver, configCommonSchema, introspectCasing, configIntrospectSchema, configIntrospectCliSchema, configGenerateSchema, configPushSchema, mysqlConnectionSchema, mySqlCliConfigSchema;
7039
- var init_common = __esm({
7040
- "src/cli/validations/common.ts"() {
7041
- "use strict";
7042
- init_outputs();
7043
- init_lib();
7044
- init_schemaValidator();
7045
- driver = unionType([
7046
- literalType("better-sqlite"),
7047
- literalType("turso"),
7048
- literalType("libsql"),
7049
- literalType("d1"),
7050
- literalType("expo"),
7051
- literalType("pg"),
7052
- literalType("mysql2")
7053
- ]);
7054
- configCommonSchema = objectType({
7055
- dialect: dialect6,
7056
- schema: unionType([stringType(), stringType().array()]),
7057
- out: stringType().optional(),
7058
- breakpoints: booleanType().default(true),
7059
- driver: driver.optional(),
7060
- tablesFilter: unionType([stringType(), stringType().array()]).optional(),
7061
- schemaFilter: unionType([stringType(), stringType().array()]).default(["public"])
7062
- });
7063
- introspectCasing = objectType({
7064
- casing: unionType([literalType("camel"), literalType("preserve")]).default("camel")
7065
- }).default({ casing: "camel" });
7066
- configIntrospectSchema = objectType({
7067
- schema: unionType([stringType(), stringType().array()]).optional(),
7068
- out: stringType().optional().default("./drizzle"),
7069
- breakpoints: booleanType().default(true),
7070
- tablesFilter: unionType([stringType(), stringType().array()]).optional(),
7071
- schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
7072
- introspect: introspectCasing
7073
- });
7074
- configIntrospectCliSchema = objectType({
7075
- schema: unionType([stringType(), stringType().array()]).optional(),
7076
- out: stringType().optional().default("./drizzle"),
7077
- breakpoints: booleanType().default(true),
7078
- tablesFilter: unionType([stringType(), stringType().array()]).optional(),
7079
- schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
7080
- introspectCasing: unionType([literalType("camel"), literalType("preserve")]).default(
7081
- "camel"
7082
- )
7083
- });
7084
- configGenerateSchema = objectType({
7085
- schema: unionType([stringType(), stringType().array()]),
7086
- out: stringType().optional().default("./drizzle"),
7087
- breakpoints: booleanType().default(true)
7088
- });
7089
- configPushSchema = objectType({
7090
- dialect: dialect6,
7091
- schema: unionType([stringType(), stringType().array()]),
7092
- tablesFilter: unionType([stringType(), stringType().array()]).optional(),
7093
- schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
7094
- verbose: booleanType().default(false),
7095
- strict: booleanType().default(false)
7096
- });
7097
- mysqlConnectionSchema = unionType([
7098
- objectType({
7099
- host: stringType(),
7100
- port: coerce.number().optional(),
7101
- user: stringType().default("mysql"),
7102
- password: stringType().optional(),
7103
- database: stringType()
7104
- // ssl: boolean().optional(),
7105
- }),
7106
- objectType({
7107
- connectionString: stringType()
7108
- }),
7109
- objectType({})
7110
- ]);
7111
- mySqlCliConfigSchema = intersectionType(
7112
- configCommonSchema,
7113
- mysqlConnectionSchema
7114
- );
7115
- }
7116
- });
7117
-
7118
- // src/cli/validations/mysql.ts
7119
- var mysqlConnectionCli, mysql2credentials, mysqlConnectionConfig, mysqlConfigIntrospectSchema, mysqlCliIntrospectParams, mysqlCliPushParams, mysqlConfigPushParams;
7120
- var init_mysql = __esm({
7121
- "src/cli/validations/mysql.ts"() {
7122
- "use strict";
7123
- init_lib();
7124
- init_utils();
7125
- init_common();
7126
- init_common();
7127
- init_outputs();
7128
- mysqlConnectionCli = unionType([
7129
- objectType({
7130
- driver: literalType("mysql2"),
7131
- host: stringType(),
7132
- port: coerce.number().optional(),
7133
- user: stringType().default("mysql"),
7134
- password: stringType().optional(),
7135
- database: stringType()
7136
- }),
7137
- objectType({
7138
- driver: literalType("mysql2"),
7139
- uri: stringType()
7140
- // TODO: change docs
7141
- })
7142
- ]);
7143
- mysql2credentials = unionType([
7144
- objectType({
7145
- host: stringType(),
7146
- port: coerce.number().optional(),
7147
- user: stringType().default("mysql"),
7148
- password: stringType().optional(),
7149
- database: stringType()
7150
- }),
7151
- objectType({
7152
- uri: stringType()
7153
- // TODO: change docs
7154
- })
7155
- ]);
7156
- mysqlConnectionConfig = objectType({
7157
- driver: literalType("mysql2"),
7158
- dbCredentials: mysql2credentials
7159
- });
7160
- mysqlConfigIntrospectSchema = intersectionType(
7161
- configIntrospectSchema,
7162
- mysqlConnectionConfig
7163
- );
7164
- mysqlCliIntrospectParams = intersectionType(
7165
- configIntrospectCliSchema,
7166
- mysqlConnectionCli
7167
- );
7168
- mysqlCliPushParams = intersectionType(
7169
- configPushSchema,
7170
- mysqlConnectionCli
7171
- );
7172
- mysqlConfigPushParams = intersectionType(
7173
- configPushSchema,
7174
- mysqlConnectionConfig
7175
- );
7176
- }
7177
- });
7178
-
7179
- // src/cli/validations/pg.ts
7180
- var pgConnectionCli, pgConnectionConfig, pgConfigIntrospectSchema, pgCliIntrospectParams, pgCliPushParams, pgConfigPushParams;
7181
- var init_pg = __esm({
7182
- "src/cli/validations/pg.ts"() {
7183
- "use strict";
7184
- init_lib();
7185
- init_utils();
7186
- init_common();
7187
- init_common();
7188
- init_outputs();
7189
- pgConnectionCli = unionType([
7190
- objectType({
7191
- driver: literalType("pg"),
7192
- host: stringType(),
7193
- port: coerce.number().optional(),
7194
- user: stringType().default("postgres"),
7195
- password: stringType().optional(),
7196
- database: stringType(),
7197
- ssl: coerce.boolean().optional(),
7198
- type: literalType("params").default("params")
7199
- }),
7200
- objectType({
7201
- driver: literalType("pg"),
7202
- connectionString: stringType(),
7203
- type: literalType("url").default("url")
7204
- })
7205
- ]);
7206
- pgConnectionConfig = unionType([
7207
- objectType({
7208
- driver: literalType("pg"),
7209
- dbCredentials: objectType({
7210
- host: stringType(),
7211
- port: coerce.number().optional(),
7212
- user: stringType().default("postgres"),
7213
- password: stringType().optional(),
7214
- database: stringType(),
7215
- ssl: coerce.boolean().optional(),
7216
- type: literalType("params").default("params").optional()
7217
- })
7218
- }),
7219
- objectType({
7220
- driver: literalType("pg"),
7221
- dbCredentials: objectType({
7222
- connectionString: stringType(),
7223
- type: literalType("url").default("url").optional()
7224
- })
7225
- })
7226
- ]);
7227
- pgConfigIntrospectSchema = intersectionType(
7228
- configIntrospectSchema,
7229
- pgConnectionConfig
7230
- );
7231
- pgCliIntrospectParams = intersectionType(
7232
- configIntrospectCliSchema,
7233
- pgConnectionCli
7234
- );
7235
- pgCliPushParams = intersectionType(
7236
- configPushSchema,
7237
- pgConnectionCli
7238
- );
7239
- pgConfigPushParams = intersectionType(
7240
- configPushSchema,
7241
- pgConnectionConfig
7242
- );
7243
- }
7244
- });
7245
-
7246
- // src/cli/validations/sqlite.ts
7247
- var sqliteConnectionCli, sqliteConnectionSchema, sqliteCliConfigSchema, sqliteCliIntrospectParams, sqliteCliPushParams, sqliteConfigPushParams;
7248
- var init_sqlite = __esm({
7249
- "src/cli/validations/sqlite.ts"() {
7250
- "use strict";
7251
- init_lib();
7252
- init_utils();
7253
- init_common();
7254
- init_common();
7255
- init_outputs();
7256
- sqliteConnectionCli = unionType([
7257
- objectType({
7258
- driver: literalType("turso"),
7259
- url: stringType(),
7260
- authToken: stringType()
7261
- }),
7262
- objectType({
7263
- driver: literalType("better-sqlite"),
7264
- url: stringType()
7265
- }),
7266
- objectType({
7267
- driver: literalType("libsql"),
7268
- url: stringType()
7269
- })
7270
- ]);
7271
- sqliteConnectionSchema = unionType([
7272
- objectType({
7273
- driver: literalType("turso"),
7274
- dbCredentials: objectType({
7275
- url: stringType(),
7276
- authToken: stringType().optional()
7277
- })
7278
- }),
7279
- objectType({
7280
- driver: literalType("libsql"),
7281
- dbCredentials: objectType({
7282
- url: stringType()
7283
- })
7284
- }),
7285
- objectType({
7286
- driver: literalType("better-sqlite"),
7287
- dbCredentials: objectType({
7288
- url: stringType()
7289
- })
7290
- })
7291
- ]);
7292
- sqliteCliConfigSchema = intersectionType(
7293
- configIntrospectSchema,
7294
- sqliteConnectionSchema
7295
- );
7296
- sqliteCliIntrospectParams = intersectionType(
7297
- configIntrospectCliSchema,
7298
- sqliteConnectionCli
7299
- );
7300
- sqliteCliPushParams = intersectionType(
7301
- configPushSchema,
7302
- sqliteConnectionCli
7303
- );
7304
- sqliteConfigPushParams = intersectionType(
7305
- configPushSchema,
7306
- sqliteConnectionSchema
7307
- );
7308
- }
7309
- });
7310
-
7311
- // src/cli/commands/_es5.ts
7312
- var es5_exports = {};
7313
- __export(es5_exports, {
7314
- default: () => es5_default
7315
- });
7316
- var _, es5_default;
7317
- var init_es5 = __esm({
7318
- "src/cli/commands/_es5.ts"() {
7319
- "use strict";
7320
- _ = "";
7321
- es5_default = _;
7322
- }
7323
- });
7324
-
7325
- // node_modules/.pnpm/ms@2.1.2/node_modules/ms/index.js
7326
- var require_ms = __commonJS({
7327
- "node_modules/.pnpm/ms@2.1.2/node_modules/ms/index.js"(exports, module2) {
7328
- var s = 1e3;
7329
- var m = s * 60;
7330
- var h = m * 60;
7331
- var d = h * 24;
7332
- var w = d * 7;
7333
- var y = d * 365.25;
7334
- module2.exports = function(val, options) {
7335
- options = options || {};
7336
- var type = typeof val;
7337
- if (type === "string" && val.length > 0) {
7338
- return parse(val);
7339
- } else if (type === "number" && isFinite(val)) {
7340
- return options.long ? fmtLong(val) : fmtShort(val);
7341
- }
7342
- throw new Error(
7343
- "val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
7344
- );
7345
- };
7346
- function parse(str) {
7347
- str = String(str);
7348
- if (str.length > 100) {
7349
- return;
7350
- }
7351
- 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(
7352
- str
7353
- );
7354
- if (!match2) {
7355
- return;
7356
- }
7357
- var n = parseFloat(match2[1]);
7358
- var type = (match2[2] || "ms").toLowerCase();
7359
- switch (type) {
7360
- case "years":
7361
- case "year":
7362
- case "yrs":
7363
- case "yr":
7364
- case "y":
7365
- return n * y;
7366
- case "weeks":
7367
- case "week":
7368
- case "w":
7369
- return n * w;
7370
- case "days":
7371
- case "day":
7372
- case "d":
7373
- return n * d;
7374
- case "hours":
7375
- case "hour":
7376
- case "hrs":
7377
- case "hr":
7378
- case "h":
7379
- return n * h;
7380
- case "minutes":
7381
- case "minute":
7382
- case "mins":
7383
- case "min":
7384
- case "m":
7385
- return n * m;
7386
- case "seconds":
7387
- case "second":
7388
- case "secs":
7389
- case "sec":
7390
- case "s":
7391
- return n * s;
7392
- case "milliseconds":
7393
- case "millisecond":
7394
- case "msecs":
7395
- case "msec":
7396
- case "ms":
7397
- return n;
7398
- default:
7399
- return void 0;
7400
- }
7401
- }
7402
- function fmtShort(ms) {
7403
- var msAbs = Math.abs(ms);
7404
- if (msAbs >= d) {
7405
- return Math.round(ms / d) + "d";
7406
- }
7407
- if (msAbs >= h) {
7408
- return Math.round(ms / h) + "h";
7409
- }
7410
- if (msAbs >= m) {
7411
- return Math.round(ms / m) + "m";
7412
- }
7413
- if (msAbs >= s) {
7414
- return Math.round(ms / s) + "s";
7415
- }
7416
- return ms + "ms";
7417
- }
7418
- function fmtLong(ms) {
7419
- var msAbs = Math.abs(ms);
7420
- if (msAbs >= d) {
7421
- return plural(ms, msAbs, d, "day");
7422
- }
7423
- if (msAbs >= h) {
7424
- return plural(ms, msAbs, h, "hour");
7425
- }
7426
- if (msAbs >= m) {
7427
- return plural(ms, msAbs, m, "minute");
7428
- }
7429
- if (msAbs >= s) {
7430
- return plural(ms, msAbs, s, "second");
7431
- }
7432
- return ms + " ms";
7433
- }
7434
- function plural(ms, msAbs, n, name) {
7435
- var isPlural = msAbs >= n * 1.5;
7436
- return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
7437
- }
6202
+ 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(
6203
+ str
6204
+ );
6205
+ if (!match2) {
6206
+ return;
6207
+ }
6208
+ var n = parseFloat(match2[1]);
6209
+ var type = (match2[2] || "ms").toLowerCase();
6210
+ switch (type) {
6211
+ case "years":
6212
+ case "year":
6213
+ case "yrs":
6214
+ case "yr":
6215
+ case "y":
6216
+ return n * y;
6217
+ case "weeks":
6218
+ case "week":
6219
+ case "w":
6220
+ return n * w;
6221
+ case "days":
6222
+ case "day":
6223
+ case "d":
6224
+ return n * d;
6225
+ case "hours":
6226
+ case "hour":
6227
+ case "hrs":
6228
+ case "hr":
6229
+ case "h":
6230
+ return n * h;
6231
+ case "minutes":
6232
+ case "minute":
6233
+ case "mins":
6234
+ case "min":
6235
+ case "m":
6236
+ return n * m;
6237
+ case "seconds":
6238
+ case "second":
6239
+ case "secs":
6240
+ case "sec":
6241
+ case "s":
6242
+ return n * s;
6243
+ case "milliseconds":
6244
+ case "millisecond":
6245
+ case "msecs":
6246
+ case "msec":
6247
+ case "ms":
6248
+ return n;
6249
+ default:
6250
+ return void 0;
6251
+ }
6252
+ }
6253
+ function fmtShort(ms) {
6254
+ var msAbs = Math.abs(ms);
6255
+ if (msAbs >= d) {
6256
+ return Math.round(ms / d) + "d";
6257
+ }
6258
+ if (msAbs >= h) {
6259
+ return Math.round(ms / h) + "h";
6260
+ }
6261
+ if (msAbs >= m) {
6262
+ return Math.round(ms / m) + "m";
6263
+ }
6264
+ if (msAbs >= s) {
6265
+ return Math.round(ms / s) + "s";
6266
+ }
6267
+ return ms + "ms";
6268
+ }
6269
+ function fmtLong(ms) {
6270
+ var msAbs = Math.abs(ms);
6271
+ if (msAbs >= d) {
6272
+ return plural(ms, msAbs, d, "day");
6273
+ }
6274
+ if (msAbs >= h) {
6275
+ return plural(ms, msAbs, h, "hour");
6276
+ }
6277
+ if (msAbs >= m) {
6278
+ return plural(ms, msAbs, m, "minute");
6279
+ }
6280
+ if (msAbs >= s) {
6281
+ return plural(ms, msAbs, s, "second");
6282
+ }
6283
+ return ms + " ms";
6284
+ }
6285
+ function plural(ms, msAbs, n, name) {
6286
+ var isPlural = msAbs >= n * 1.5;
6287
+ return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
6288
+ }
7438
6289
  }
7439
6290
  });
7440
6291
 
@@ -12759,281 +11610,1144 @@ var require_node2 = __commonJS({
12759
11610
  return jsoncParse(content);
12760
11611
  }
12761
11612
  });
12762
- var getOptions = (cwd) => {
12763
- var _a, _b, _c, _d;
12764
- const { data, path: path3 } = joycon.loadSync(["tsconfig.json", "jsconfig.json"], cwd);
12765
- if (path3 && data) {
11613
+ var getOptions = (cwd) => {
11614
+ var _a, _b, _c, _d;
11615
+ const { data, path: path3 } = joycon.loadSync(["tsconfig.json", "jsconfig.json"], cwd);
11616
+ if (path3 && data) {
11617
+ return {
11618
+ jsxFactory: (_a = data.compilerOptions) == null ? void 0 : _a.jsxFactory,
11619
+ jsxFragment: (_b = data.compilerOptions) == null ? void 0 : _b.jsxFragmentFactory,
11620
+ target: (_d = (_c = data.compilerOptions) == null ? void 0 : _c.target) == null ? void 0 : _d.toLowerCase()
11621
+ };
11622
+ }
11623
+ return {};
11624
+ };
11625
+ var inferPackageFormat = (cwd, filename) => {
11626
+ if (filename.endsWith(".mjs")) {
11627
+ return "esm";
11628
+ }
11629
+ if (filename.endsWith(".cjs")) {
11630
+ return "cjs";
11631
+ }
11632
+ const { data } = joycon.loadSync(["package.json"], cwd);
11633
+ return data && data.type === "module" && /\.m?js$/.test(filename) ? "esm" : "cjs";
11634
+ };
11635
+ var import_tsconfig_paths = __toModule(require_lib4());
11636
+ var noOp = () => {
11637
+ };
11638
+ function registerTsconfigPaths() {
11639
+ const configLoaderResult = (0, import_tsconfig_paths.loadConfig)(process.cwd());
11640
+ if (configLoaderResult.resultType === "failed") {
11641
+ return noOp;
11642
+ }
11643
+ const matchPath = (0, import_tsconfig_paths.createMatchPath)(configLoaderResult.absoluteBaseUrl, configLoaderResult.paths, configLoaderResult.mainFields, configLoaderResult.addMatchAll);
11644
+ const Module = require("module");
11645
+ const originalResolveFilename = Module._resolveFilename;
11646
+ Module._resolveFilename = function(request, _parent) {
11647
+ const isCoreModule = _module2.builtinModules.includes(request);
11648
+ if (!isCoreModule) {
11649
+ const found = matchPath(request);
11650
+ if (found) {
11651
+ const modifiedArguments = [found, ...[].slice.call(arguments, 1)];
11652
+ return originalResolveFilename.apply(this, modifiedArguments);
11653
+ }
11654
+ }
11655
+ return originalResolveFilename.apply(this, arguments);
11656
+ };
11657
+ return () => {
11658
+ Module._resolveFilename = originalResolveFilename;
11659
+ };
11660
+ }
11661
+ var _debug = require_src2();
11662
+ var _debug2 = _interopRequireDefault2(_debug);
11663
+ var debug = _debug2.default.call(void 0, "esbuild-register");
11664
+ var IMPORT_META_URL_VARIABLE_NAME = "__esbuild_register_import_meta_url__";
11665
+ var map = {};
11666
+ function installSourceMapSupport() {
11667
+ if (_process2.default.setSourceMapsEnabled) {
11668
+ ;
11669
+ _process2.default.setSourceMapsEnabled(true);
11670
+ } else {
11671
+ import_source_map_support.default.install({
11672
+ handleUncaughtExceptions: false,
11673
+ environment: "node",
11674
+ retrieveSourceMap(file) {
11675
+ if (map[file]) {
11676
+ return {
11677
+ url: file,
11678
+ map: map[file]
11679
+ };
11680
+ }
11681
+ return null;
11682
+ }
11683
+ });
11684
+ }
11685
+ }
11686
+ function patchCommonJsLoader(compile) {
11687
+ const extensions = _module3.default.Module._extensions;
11688
+ const jsHandler = extensions[".js"];
11689
+ extensions[".js"] = function(module22, filename) {
11690
+ try {
11691
+ return jsHandler.call(this, module22, filename);
11692
+ } catch (error2) {
11693
+ if (error2.code !== "ERR_REQUIRE_ESM") {
11694
+ throw error2;
11695
+ }
11696
+ let content = _fs3.default.readFileSync(filename, "utf8");
11697
+ content = compile(content, filename, "cjs");
11698
+ module22._compile(content, filename);
11699
+ }
11700
+ };
11701
+ return () => {
11702
+ extensions[".js"] = jsHandler;
11703
+ };
11704
+ }
11705
+ var FILE_LOADERS = {
11706
+ ".js": "js",
11707
+ ".jsx": "jsx",
11708
+ ".ts": "ts",
11709
+ ".tsx": "tsx",
11710
+ ".mjs": "js",
11711
+ ".mts": "ts",
11712
+ ".cts": "ts"
11713
+ };
11714
+ var DEFAULT_EXTENSIONS = Object.keys(FILE_LOADERS);
11715
+ var getLoader = (filename) => FILE_LOADERS[_path2.extname.call(void 0, filename)];
11716
+ function register(esbuildOptions = {}) {
11717
+ const {
11718
+ extensions = DEFAULT_EXTENSIONS,
11719
+ hookIgnoreNodeModules = true,
11720
+ hookMatcher,
11721
+ ...overrides
11722
+ } = esbuildOptions;
11723
+ const compile = function compile2(code, filename, format) {
11724
+ const define = {
11725
+ "import.meta.url": IMPORT_META_URL_VARIABLE_NAME,
11726
+ ...overrides.define
11727
+ };
11728
+ const banner = `const ${IMPORT_META_URL_VARIABLE_NAME} = require('url').pathToFileURL(__filename).href;${overrides.banner || ""}`;
11729
+ if (code.includes(banner)) {
11730
+ return code;
11731
+ }
11732
+ const dir = _path2.dirname.call(void 0, filename);
11733
+ const options = getOptions(dir);
11734
+ format = format != null ? format : inferPackageFormat(dir, filename);
11735
+ const result = _esbuild.transformSync.call(void 0, code, {
11736
+ sourcefile: filename,
11737
+ loader: getLoader(filename),
11738
+ sourcemap: "both",
11739
+ target: options.target,
11740
+ jsxFactory: options.jsxFactory,
11741
+ jsxFragment: options.jsxFragment,
11742
+ format,
11743
+ define,
11744
+ banner,
11745
+ ...overrides
11746
+ });
11747
+ const js = result.code;
11748
+ debug("compiled %s", filename);
11749
+ debug("%s", js);
11750
+ const warnings = result.warnings;
11751
+ if (warnings && warnings.length > 0) {
11752
+ for (const warning of warnings) {
11753
+ console.log(warning.location);
11754
+ console.log(warning.text);
11755
+ }
11756
+ }
11757
+ if (format === "esm")
11758
+ return js;
11759
+ return removeNodePrefix(js);
11760
+ };
11761
+ const revert = (0, import_pirates.addHook)(compile, {
11762
+ exts: extensions,
11763
+ ignoreNodeModules: hookIgnoreNodeModules,
11764
+ matcher: hookMatcher
11765
+ });
11766
+ installSourceMapSupport();
11767
+ const unpatchCommonJsLoader = patchCommonJsLoader(compile);
11768
+ const unregisterTsconfigPaths = registerTsconfigPaths();
11769
+ return {
11770
+ unregister() {
11771
+ revert();
11772
+ unpatchCommonJsLoader();
11773
+ unregisterTsconfigPaths();
11774
+ }
11775
+ };
11776
+ }
11777
+ exports.register = register;
11778
+ }
11779
+ });
11780
+
11781
+ // src/cli/commands/utils.ts
11782
+ var import_hanji2, assertES5, safeRegister, driver, configCommonSchema, introspectCasing, configIntrospectSchema, configIntrospectCliSchema, configGenerateSchema, configPushSchema, mysqlConnectionSchema, mySqlCliConfigSchema, mySqlIntrospectConfigSchema;
11783
+ var init_utils = __esm({
11784
+ "src/cli/commands/utils.ts"() {
11785
+ init_serializer();
11786
+ init_lib();
11787
+ init_source();
11788
+ init_views();
11789
+ import_hanji2 = __toESM(require_hanji());
11790
+ assertES5 = async (unregister) => {
11791
+ try {
11792
+ init_es5();
11793
+ } catch (e) {
11794
+ if ("errors" in e && Array.isArray(e.errors) && e.errors.length > 0) {
11795
+ const es5Error = e.errors.filter(
11796
+ (it) => {
11797
+ var _a;
11798
+ return (_a = it.text) == null ? void 0 : _a.includes(`("es5") is not supported yet`);
11799
+ }
11800
+ ).length > 0;
11801
+ if (es5Error) {
11802
+ console.log(
11803
+ error(
11804
+ `Please change compilerOptions.target from 'es5' to 'es6' or above in your tsconfig.json`
11805
+ )
11806
+ );
11807
+ process.exit(1);
11808
+ }
11809
+ }
11810
+ console.error(e);
11811
+ process.exit(1);
11812
+ }
11813
+ };
11814
+ safeRegister = async () => {
11815
+ const { register } = await Promise.resolve().then(() => __toESM(require_node2()));
11816
+ let res;
11817
+ try {
11818
+ res = register({
11819
+ format: "cjs",
11820
+ loader: "ts"
11821
+ });
11822
+ } catch {
11823
+ res = {
11824
+ unregister: () => {
11825
+ }
11826
+ };
11827
+ }
11828
+ await assertES5(res.unregister);
11829
+ return res;
11830
+ };
11831
+ driver = unionType([
11832
+ literalType("better-sqlite"),
11833
+ literalType("turso"),
11834
+ literalType("libsql"),
11835
+ literalType("d1"),
11836
+ literalType("expo"),
11837
+ literalType("pg"),
11838
+ literalType("mysql2")
11839
+ ]);
11840
+ configCommonSchema = objectType({
11841
+ schema: unionType([stringType(), stringType().array()]),
11842
+ out: stringType().optional(),
11843
+ breakpoints: booleanType().default(true),
11844
+ driver: driver.optional(),
11845
+ tablesFilter: unionType([stringType(), stringType().array()]).optional(),
11846
+ schemaFilter: unionType([stringType(), stringType().array()]).default(["public"])
11847
+ });
11848
+ introspectCasing = objectType({
11849
+ casing: unionType([literalType("camel"), literalType("preserve")]).default("camel")
11850
+ }).default({ casing: "camel" });
11851
+ configIntrospectSchema = objectType({
11852
+ schema: unionType([stringType(), stringType().array()]).optional(),
11853
+ out: stringType().optional().default("./drizzle"),
11854
+ breakpoints: booleanType().default(true),
11855
+ tablesFilter: unionType([stringType(), stringType().array()]).optional(),
11856
+ schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
11857
+ introspect: introspectCasing
11858
+ });
11859
+ configIntrospectCliSchema = objectType({
11860
+ schema: unionType([stringType(), stringType().array()]).optional(),
11861
+ out: stringType().optional().default("./drizzle"),
11862
+ breakpoints: booleanType().default(true),
11863
+ tablesFilter: unionType([stringType(), stringType().array()]).optional(),
11864
+ schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
11865
+ introspectCasing: unionType([literalType("camel"), literalType("preserve")]).default(
11866
+ "camel"
11867
+ )
11868
+ });
11869
+ configGenerateSchema = objectType({
11870
+ schema: unionType([stringType(), stringType().array()]),
11871
+ out: stringType().optional().default("./drizzle"),
11872
+ breakpoints: booleanType().default(true)
11873
+ });
11874
+ configPushSchema = objectType({
11875
+ schema: unionType([stringType(), stringType().array()]),
11876
+ tablesFilter: unionType([stringType(), stringType().array()]).optional(),
11877
+ schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
11878
+ verbose: booleanType().default(false),
11879
+ strict: booleanType().default(false)
11880
+ });
11881
+ mysqlConnectionSchema = unionType([
11882
+ objectType({
11883
+ host: stringType(),
11884
+ port: coerce.number().optional(),
11885
+ user: stringType().default("mysql"),
11886
+ password: stringType().optional(),
11887
+ database: stringType()
11888
+ // ssl: boolean().optional(),
11889
+ }),
11890
+ objectType({
11891
+ connectionString: stringType()
11892
+ }),
11893
+ objectType({})
11894
+ ]);
11895
+ mySqlCliConfigSchema = intersectionType(
11896
+ configCommonSchema,
11897
+ mysqlConnectionSchema
11898
+ );
11899
+ mySqlIntrospectConfigSchema = intersectionType(
11900
+ configIntrospectSchema,
11901
+ mysqlConnectionSchema
11902
+ );
11903
+ }
11904
+ });
11905
+
11906
+ // src/serializer/pgImports.ts
11907
+ var pgImports_exports = {};
11908
+ __export(pgImports_exports, {
11909
+ prepareFromExports: () => prepareFromExports3,
11910
+ prepareFromPgImports: () => prepareFromPgImports
11911
+ });
11912
+ var import_pg_core3, import_drizzle_orm7, prepareFromExports3, prepareFromPgImports;
11913
+ var init_pgImports = __esm({
11914
+ "src/serializer/pgImports.ts"() {
11915
+ import_pg_core3 = require("drizzle-orm/pg-core");
11916
+ import_drizzle_orm7 = require("drizzle-orm");
11917
+ init_utils();
11918
+ prepareFromExports3 = (exports) => {
11919
+ const tables = [];
11920
+ const enums = [];
11921
+ const schemas = [];
11922
+ const i0values = Object.values(exports);
11923
+ i0values.forEach((t) => {
11924
+ if ((0, import_pg_core3.isPgEnum)(t)) {
11925
+ enums.push(t);
11926
+ return;
11927
+ }
11928
+ if ((0, import_drizzle_orm7.is)(t, import_pg_core3.PgTable)) {
11929
+ tables.push(t);
11930
+ }
11931
+ if ((0, import_drizzle_orm7.is)(t, import_pg_core3.PgSchema)) {
11932
+ schemas.push(t);
11933
+ }
11934
+ });
11935
+ return { tables, enums, schemas };
11936
+ };
11937
+ prepareFromPgImports = async (imports) => {
11938
+ let tables = [];
11939
+ let enums = [];
11940
+ let schemas = [];
11941
+ const { unregister } = await safeRegister();
11942
+ for (let i = 0; i < imports.length; i++) {
11943
+ const it = imports[i];
11944
+ const i0 = require(`${it}`);
11945
+ const prepared = prepareFromExports3(i0);
11946
+ tables.push(...prepared.tables);
11947
+ enums.push(...prepared.enums);
11948
+ schemas.push(...prepared.schemas);
11949
+ }
11950
+ unregister();
11951
+ return { tables: Array.from(new Set(tables)), enums, schemas };
11952
+ };
11953
+ }
11954
+ });
11955
+
11956
+ // src/global.ts
11957
+ var originUUID, snapshotVersion, mapValues;
11958
+ var init_global = __esm({
11959
+ "src/global.ts"() {
11960
+ originUUID = "00000000-0000-0000-0000-000000000000";
11961
+ snapshotVersion = "5";
11962
+ mapValues = (obj, map) => {
11963
+ const result = Object.keys(obj).reduce(function(result2, key) {
11964
+ result2[key] = map(obj[key]);
11965
+ return result2;
11966
+ }, {});
11967
+ return result;
11968
+ };
11969
+ }
11970
+ });
11971
+
11972
+ // src/serializer/pgSchema.ts
11973
+ 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;
11974
+ var init_pgSchema = __esm({
11975
+ "src/serializer/pgSchema.ts"() {
11976
+ init_global();
11977
+ init_lib();
11978
+ indexV2 = objectType({
11979
+ name: stringType(),
11980
+ columns: recordType(
11981
+ stringType(),
11982
+ objectType({
11983
+ name: stringType()
11984
+ })
11985
+ ),
11986
+ isUnique: booleanType()
11987
+ }).strict();
11988
+ columnV2 = objectType({
11989
+ name: stringType(),
11990
+ type: stringType(),
11991
+ primaryKey: booleanType(),
11992
+ notNull: booleanType(),
11993
+ default: anyType().optional(),
11994
+ references: stringType().optional()
11995
+ }).strict();
11996
+ tableV2 = objectType({
11997
+ name: stringType(),
11998
+ columns: recordType(stringType(), columnV2),
11999
+ indexes: recordType(stringType(), indexV2)
12000
+ }).strict();
12001
+ enumSchema = objectType({
12002
+ name: stringType(),
12003
+ values: recordType(stringType(), stringType())
12004
+ }).strict();
12005
+ pgSchemaV2 = objectType({
12006
+ version: literalType("2"),
12007
+ tables: recordType(stringType(), tableV2),
12008
+ enums: recordType(stringType(), enumSchema)
12009
+ }).strict();
12010
+ references = objectType({
12011
+ foreignKeyName: stringType(),
12012
+ table: stringType(),
12013
+ column: stringType(),
12014
+ onDelete: stringType().optional(),
12015
+ onUpdate: stringType().optional()
12016
+ }).strict();
12017
+ columnV1 = objectType({
12018
+ name: stringType(),
12019
+ type: stringType(),
12020
+ primaryKey: booleanType(),
12021
+ notNull: booleanType(),
12022
+ default: anyType().optional(),
12023
+ references: references.optional()
12024
+ }).strict();
12025
+ tableV1 = objectType({
12026
+ name: stringType(),
12027
+ columns: recordType(stringType(), columnV1),
12028
+ indexes: recordType(stringType(), indexV2)
12029
+ }).strict();
12030
+ pgSchemaV1 = objectType({
12031
+ version: literalType("1"),
12032
+ tables: recordType(stringType(), tableV1),
12033
+ enums: recordType(stringType(), enumSchema)
12034
+ }).strict();
12035
+ index = objectType({
12036
+ name: stringType(),
12037
+ columns: stringType().array(),
12038
+ isUnique: booleanType()
12039
+ }).strict();
12040
+ fk = objectType({
12041
+ name: stringType(),
12042
+ tableFrom: stringType(),
12043
+ columnsFrom: stringType().array(),
12044
+ tableTo: stringType(),
12045
+ schemaTo: stringType().optional(),
12046
+ columnsTo: stringType().array(),
12047
+ onUpdate: stringType().optional(),
12048
+ onDelete: stringType().optional()
12049
+ }).strict();
12050
+ column = objectType({
12051
+ name: stringType(),
12052
+ type: stringType(),
12053
+ primaryKey: booleanType(),
12054
+ notNull: booleanType(),
12055
+ default: anyType().optional(),
12056
+ isUnique: anyType().optional(),
12057
+ uniqueName: stringType().optional(),
12058
+ nullsNotDistinct: booleanType().optional()
12059
+ }).strict();
12060
+ tableV3 = objectType({
12061
+ name: stringType(),
12062
+ columns: recordType(stringType(), column),
12063
+ indexes: recordType(stringType(), index),
12064
+ foreignKeys: recordType(stringType(), fk)
12065
+ }).strict();
12066
+ compositePK = objectType({
12067
+ name: stringType(),
12068
+ columns: stringType().array()
12069
+ }).strict();
12070
+ uniqueConstraint = objectType({
12071
+ name: stringType(),
12072
+ columns: stringType().array(),
12073
+ nullsNotDistinct: booleanType()
12074
+ }).strict();
12075
+ tableV4 = objectType({
12076
+ name: stringType(),
12077
+ schema: stringType(),
12078
+ columns: recordType(stringType(), column),
12079
+ indexes: recordType(stringType(), index),
12080
+ foreignKeys: recordType(stringType(), fk)
12081
+ }).strict();
12082
+ table = objectType({
12083
+ name: stringType(),
12084
+ schema: stringType(),
12085
+ columns: recordType(stringType(), column),
12086
+ indexes: recordType(stringType(), index),
12087
+ foreignKeys: recordType(stringType(), fk),
12088
+ compositePrimaryKeys: recordType(stringType(), compositePK),
12089
+ uniqueConstraints: recordType(stringType(), uniqueConstraint).default({})
12090
+ }).strict();
12091
+ schemaHash = objectType({
12092
+ id: stringType(),
12093
+ prevId: stringType()
12094
+ });
12095
+ pgSchemaInternalV3 = objectType({
12096
+ version: literalType("3"),
12097
+ dialect: literalType("pg"),
12098
+ tables: recordType(stringType(), tableV3),
12099
+ enums: recordType(stringType(), enumSchema)
12100
+ }).strict();
12101
+ pgSchemaInternalV4 = objectType({
12102
+ version: literalType("4"),
12103
+ dialect: literalType("pg"),
12104
+ tables: recordType(stringType(), tableV4),
12105
+ enums: recordType(stringType(), enumSchema),
12106
+ schemas: recordType(stringType(), stringType())
12107
+ }).strict();
12108
+ pgSchemaExternal = objectType({
12109
+ version: literalType("5"),
12110
+ dialect: literalType("pg"),
12111
+ tables: arrayType(table),
12112
+ enums: arrayType(enumSchema),
12113
+ schemas: arrayType(objectType({ name: stringType() })),
12114
+ _meta: objectType({
12115
+ schemas: recordType(stringType(), stringType()),
12116
+ tables: recordType(stringType(), stringType()),
12117
+ columns: recordType(stringType(), stringType())
12118
+ })
12119
+ }).strict();
12120
+ kitInternals = objectType({
12121
+ tables: recordType(
12122
+ stringType(),
12123
+ objectType({
12124
+ columns: recordType(
12125
+ stringType(),
12126
+ objectType({
12127
+ isArray: booleanType().optional(),
12128
+ dimensions: numberType().optional(),
12129
+ rawType: stringType().optional()
12130
+ }).optional()
12131
+ )
12132
+ }).optional()
12133
+ )
12134
+ }).optional();
12135
+ pgSchemaInternal = objectType({
12136
+ version: literalType("5"),
12137
+ dialect: literalType("pg"),
12138
+ tables: recordType(stringType(), table),
12139
+ enums: recordType(stringType(), enumSchema),
12140
+ schemas: recordType(stringType(), stringType()),
12141
+ _meta: objectType({
12142
+ schemas: recordType(stringType(), stringType()),
12143
+ tables: recordType(stringType(), stringType()),
12144
+ columns: recordType(stringType(), stringType())
12145
+ }),
12146
+ internal: kitInternals
12147
+ }).strict();
12148
+ tableSquashed = objectType({
12149
+ name: stringType(),
12150
+ schema: stringType(),
12151
+ columns: recordType(stringType(), column),
12152
+ indexes: recordType(stringType(), stringType()),
12153
+ foreignKeys: recordType(stringType(), stringType()),
12154
+ compositePrimaryKeys: recordType(stringType(), stringType()),
12155
+ uniqueConstraints: recordType(stringType(), stringType())
12156
+ }).strict();
12157
+ tableSquashedV4 = objectType({
12158
+ name: stringType(),
12159
+ schema: stringType(),
12160
+ columns: recordType(stringType(), column),
12161
+ indexes: recordType(stringType(), stringType()),
12162
+ foreignKeys: recordType(stringType(), stringType())
12163
+ }).strict();
12164
+ pgSchemaSquashedV4 = objectType({
12165
+ version: literalType("4"),
12166
+ dialect: enumType(["pg"]),
12167
+ tables: recordType(stringType(), tableSquashedV4),
12168
+ enums: recordType(stringType(), enumSchema),
12169
+ schemas: recordType(stringType(), stringType())
12170
+ }).strict();
12171
+ pgSchemaSquashed = objectType({
12172
+ version: literalType("5"),
12173
+ dialect: enumType(["pg"]),
12174
+ tables: recordType(stringType(), tableSquashed),
12175
+ enums: recordType(stringType(), enumSchema),
12176
+ schemas: recordType(stringType(), stringType())
12177
+ }).strict();
12178
+ pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash);
12179
+ pgSchemaV4 = pgSchemaInternalV4.merge(schemaHash);
12180
+ pgSchema = pgSchemaInternal.merge(schemaHash);
12181
+ backwardCompatiblePgSchema = unionType([
12182
+ pgSchemaV1,
12183
+ pgSchemaV2,
12184
+ pgSchemaV3,
12185
+ pgSchemaV4,
12186
+ pgSchema
12187
+ ]);
12188
+ PgSquasher = {
12189
+ squashIdx: (idx) => {
12190
+ index.parse(idx);
12191
+ return `${idx.name};${idx.columns.join(",")};${idx.isUnique}`;
12192
+ },
12193
+ unsquashIdx: (input) => {
12194
+ const [name, columnsString, isUnique] = input.split(";");
12195
+ const result = index.parse({
12196
+ name,
12197
+ columns: columnsString.split(","),
12198
+ isUnique: isUnique === "true"
12199
+ });
12200
+ return result;
12201
+ },
12202
+ squashFK: (fk4) => {
12203
+ return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""};${fk4.schemaTo ?? ""}`;
12204
+ },
12205
+ squashPK: (pk) => {
12206
+ return `${pk.columns.join(",")};${pk.name}`;
12207
+ },
12208
+ unsquashPK: (pk) => {
12209
+ const splitted = pk.split(";");
12210
+ return { name: splitted[1], columns: splitted[0].split(",") };
12211
+ },
12212
+ squashUnique: (unq) => {
12213
+ return `${unq.name};${unq.columns.join(",")};${unq.nullsNotDistinct}`;
12214
+ },
12215
+ unsquashUnique: (unq) => {
12216
+ const [name, columns, nullsNotDistinct] = unq.split(";");
12766
12217
  return {
12767
- jsxFactory: (_a = data.compilerOptions) == null ? void 0 : _a.jsxFactory,
12768
- jsxFragment: (_b = data.compilerOptions) == null ? void 0 : _b.jsxFragmentFactory,
12769
- target: (_d = (_c = data.compilerOptions) == null ? void 0 : _c.target) == null ? void 0 : _d.toLowerCase()
12218
+ name,
12219
+ columns: columns.split(","),
12220
+ nullsNotDistinct: nullsNotDistinct === "true"
12770
12221
  };
12222
+ },
12223
+ unsquashFK: (input) => {
12224
+ const [
12225
+ name,
12226
+ tableFrom,
12227
+ columnsFromStr,
12228
+ tableTo,
12229
+ columnsToStr,
12230
+ onUpdate,
12231
+ onDelete,
12232
+ schemaTo
12233
+ ] = input.split(";");
12234
+ const result = fk.parse({
12235
+ name,
12236
+ tableFrom,
12237
+ columnsFrom: columnsFromStr.split(","),
12238
+ schemaTo,
12239
+ tableTo,
12240
+ columnsTo: columnsToStr.split(","),
12241
+ onUpdate,
12242
+ onDelete
12243
+ });
12244
+ return result;
12771
12245
  }
12772
- return {};
12773
- };
12774
- var inferPackageFormat = (cwd, filename) => {
12775
- if (filename.endsWith(".mjs")) {
12776
- return "esm";
12777
- }
12778
- if (filename.endsWith(".cjs")) {
12779
- return "cjs";
12780
- }
12781
- const { data } = joycon.loadSync(["package.json"], cwd);
12782
- return data && data.type === "module" && /\.m?js$/.test(filename) ? "esm" : "cjs";
12783
12246
  };
12784
- var import_tsconfig_paths = __toModule(require_lib4());
12785
- var noOp = () => {
12786
- };
12787
- function registerTsconfigPaths() {
12788
- const configLoaderResult = (0, import_tsconfig_paths.loadConfig)(process.cwd());
12789
- if (configLoaderResult.resultType === "failed") {
12790
- return noOp;
12791
- }
12792
- const matchPath = (0, import_tsconfig_paths.createMatchPath)(configLoaderResult.absoluteBaseUrl, configLoaderResult.paths, configLoaderResult.mainFields, configLoaderResult.addMatchAll);
12793
- const Module = require("module");
12794
- const originalResolveFilename = Module._resolveFilename;
12795
- Module._resolveFilename = function(request, _parent) {
12796
- const isCoreModule = _module2.builtinModules.includes(request);
12797
- if (!isCoreModule) {
12798
- const found = matchPath(request);
12799
- if (found) {
12800
- const modifiedArguments = [found, ...[].slice.call(arguments, 1)];
12801
- return originalResolveFilename.apply(this, modifiedArguments);
12802
- }
12803
- }
12804
- return originalResolveFilename.apply(this, arguments);
12805
- };
12806
- return () => {
12807
- Module._resolveFilename = originalResolveFilename;
12808
- };
12809
- }
12810
- var _debug = require_src2();
12811
- var _debug2 = _interopRequireDefault2(_debug);
12812
- var debug = _debug2.default.call(void 0, "esbuild-register");
12813
- var IMPORT_META_URL_VARIABLE_NAME = "__esbuild_register_import_meta_url__";
12814
- var map = {};
12815
- function installSourceMapSupport() {
12816
- if (_process2.default.setSourceMapsEnabled) {
12817
- ;
12818
- _process2.default.setSourceMapsEnabled(true);
12819
- } else {
12820
- import_source_map_support.default.install({
12821
- handleUncaughtExceptions: false,
12822
- environment: "node",
12823
- retrieveSourceMap(file) {
12824
- if (map[file]) {
12825
- return {
12826
- url: file,
12827
- map: map[file]
12828
- };
12247
+ squashPgScheme = (json) => {
12248
+ const mappedTables = Object.fromEntries(
12249
+ Object.entries(json.tables).map((it) => {
12250
+ const squashedIndexes = mapValues(it[1].indexes, (index4) => {
12251
+ return PgSquasher.squashIdx(index4);
12252
+ });
12253
+ const squashedFKs = mapValues(it[1].foreignKeys, (fk4) => {
12254
+ return PgSquasher.squashFK(fk4);
12255
+ });
12256
+ const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => {
12257
+ return PgSquasher.squashPK(pk);
12258
+ });
12259
+ const squashedUniqueConstraints = mapValues(
12260
+ it[1].uniqueConstraints,
12261
+ (unq) => {
12262
+ return PgSquasher.squashUnique(unq);
12829
12263
  }
12830
- return null;
12831
- }
12832
- });
12833
- }
12834
- }
12835
- function patchCommonJsLoader(compile) {
12836
- const extensions = _module3.default.Module._extensions;
12837
- const jsHandler = extensions[".js"];
12838
- extensions[".js"] = function(module22, filename) {
12839
- try {
12840
- return jsHandler.call(this, module22, filename);
12841
- } catch (error2) {
12842
- if (error2.code !== "ERR_REQUIRE_ESM") {
12843
- throw error2;
12844
- }
12845
- let content = _fs3.default.readFileSync(filename, "utf8");
12846
- content = compile(content, filename, "cjs");
12847
- module22._compile(content, filename);
12848
- }
12849
- };
12850
- return () => {
12851
- extensions[".js"] = jsHandler;
12264
+ );
12265
+ return [
12266
+ it[0],
12267
+ {
12268
+ name: it[1].name,
12269
+ schema: it[1].schema,
12270
+ columns: it[1].columns,
12271
+ indexes: squashedIndexes,
12272
+ foreignKeys: squashedFKs,
12273
+ compositePrimaryKeys: squashedPKs,
12274
+ uniqueConstraints: squashedUniqueConstraints
12275
+ }
12276
+ ];
12277
+ })
12278
+ );
12279
+ return {
12280
+ version: "5",
12281
+ dialect: json.dialect,
12282
+ tables: mappedTables,
12283
+ enums: json.enums,
12284
+ schemas: json.schemas
12852
12285
  };
12853
- }
12854
- var FILE_LOADERS = {
12855
- ".js": "js",
12856
- ".jsx": "jsx",
12857
- ".ts": "ts",
12858
- ".tsx": "tsx",
12859
- ".mjs": "js",
12860
- ".mts": "ts",
12861
- ".cts": "ts"
12862
12286
  };
12863
- var DEFAULT_EXTENSIONS = Object.keys(FILE_LOADERS);
12864
- var getLoader = (filename) => FILE_LOADERS[_path2.extname.call(void 0, filename)];
12865
- function register(esbuildOptions = {}) {
12866
- const {
12867
- extensions = DEFAULT_EXTENSIONS,
12868
- hookIgnoreNodeModules = true,
12869
- hookMatcher,
12870
- ...overrides
12871
- } = esbuildOptions;
12872
- const compile = function compile2(code, filename, format) {
12873
- const define = {
12874
- "import.meta.url": IMPORT_META_URL_VARIABLE_NAME,
12875
- ...overrides.define
12876
- };
12877
- const banner = `const ${IMPORT_META_URL_VARIABLE_NAME} = require('url').pathToFileURL(__filename).href;${overrides.banner || ""}`;
12878
- if (code.includes(banner)) {
12879
- return code;
12880
- }
12881
- const dir = _path2.dirname.call(void 0, filename);
12882
- const options = getOptions(dir);
12883
- format = format != null ? format : inferPackageFormat(dir, filename);
12884
- const result = _esbuild.transformSync.call(void 0, code, {
12885
- sourcefile: filename,
12886
- loader: getLoader(filename),
12887
- sourcemap: "both",
12888
- target: options.target,
12889
- jsxFactory: options.jsxFactory,
12890
- jsxFragment: options.jsxFragment,
12891
- format,
12892
- define,
12893
- banner,
12894
- ...overrides
12287
+ dryPg = pgSchema.parse({
12288
+ version: snapshotVersion,
12289
+ dialect: "pg",
12290
+ id: originUUID,
12291
+ prevId: "",
12292
+ tables: {},
12293
+ enums: {},
12294
+ schemas: {},
12295
+ _meta: {
12296
+ schemas: {},
12297
+ tables: {},
12298
+ columns: {}
12299
+ }
12300
+ });
12301
+ }
12302
+ });
12303
+
12304
+ // src/serializer/sqliteSchema.ts
12305
+ var index2, fk2, compositePK2, column2, tableV32, uniqueConstraint2, table2, dialect4, schemaHash2, schemaInternalV3, schemaInternalV4, latestVersion, schemaInternal, schemaV3, schemaV4, schema2, tableSquashed2, schemaSquashed, SQLiteSquasher, squashSqliteScheme, drySQLite, sqliteSchema, backwardCompatibleSqliteSchema;
12306
+ var init_sqliteSchema = __esm({
12307
+ "src/serializer/sqliteSchema.ts"() {
12308
+ init_global();
12309
+ init_lib();
12310
+ index2 = objectType({
12311
+ name: stringType(),
12312
+ columns: stringType().array(),
12313
+ where: stringType().optional(),
12314
+ isUnique: booleanType()
12315
+ }).strict();
12316
+ fk2 = objectType({
12317
+ name: stringType(),
12318
+ tableFrom: stringType(),
12319
+ columnsFrom: stringType().array(),
12320
+ tableTo: stringType(),
12321
+ columnsTo: stringType().array(),
12322
+ onUpdate: stringType().optional(),
12323
+ onDelete: stringType().optional()
12324
+ }).strict();
12325
+ compositePK2 = objectType({
12326
+ columns: stringType().array(),
12327
+ name: stringType().optional()
12328
+ }).strict();
12329
+ column2 = objectType({
12330
+ name: stringType(),
12331
+ type: stringType(),
12332
+ primaryKey: booleanType(),
12333
+ notNull: booleanType(),
12334
+ autoincrement: booleanType().optional(),
12335
+ default: anyType().optional()
12336
+ }).strict();
12337
+ tableV32 = objectType({
12338
+ name: stringType(),
12339
+ columns: recordType(stringType(), column2),
12340
+ indexes: recordType(stringType(), index2),
12341
+ foreignKeys: recordType(stringType(), fk2)
12342
+ }).strict();
12343
+ uniqueConstraint2 = objectType({
12344
+ name: stringType(),
12345
+ columns: stringType().array()
12346
+ }).strict();
12347
+ table2 = objectType({
12348
+ name: stringType(),
12349
+ columns: recordType(stringType(), column2),
12350
+ indexes: recordType(stringType(), index2),
12351
+ foreignKeys: recordType(stringType(), fk2),
12352
+ compositePrimaryKeys: recordType(stringType(), compositePK2),
12353
+ uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
12354
+ }).strict();
12355
+ dialect4 = enumType(["sqlite"]);
12356
+ schemaHash2 = objectType({
12357
+ id: stringType(),
12358
+ prevId: stringType()
12359
+ }).strict();
12360
+ schemaInternalV3 = objectType({
12361
+ version: literalType("3"),
12362
+ dialect: dialect4,
12363
+ tables: recordType(stringType(), tableV32),
12364
+ enums: objectType({})
12365
+ }).strict();
12366
+ schemaInternalV4 = objectType({
12367
+ version: literalType("4"),
12368
+ dialect: dialect4,
12369
+ tables: recordType(stringType(), table2),
12370
+ enums: objectType({})
12371
+ }).strict();
12372
+ latestVersion = literalType("5");
12373
+ schemaInternal = objectType({
12374
+ version: latestVersion,
12375
+ dialect: dialect4,
12376
+ tables: recordType(stringType(), table2),
12377
+ enums: objectType({}),
12378
+ _meta: objectType({
12379
+ tables: recordType(stringType(), stringType()),
12380
+ columns: recordType(stringType(), stringType())
12381
+ })
12382
+ }).strict();
12383
+ schemaV3 = schemaInternalV3.merge(schemaHash2).strict();
12384
+ schemaV4 = schemaInternalV4.merge(schemaHash2).strict();
12385
+ schema2 = schemaInternal.merge(schemaHash2).strict();
12386
+ tableSquashed2 = objectType({
12387
+ name: stringType(),
12388
+ columns: recordType(stringType(), column2),
12389
+ indexes: recordType(stringType(), stringType()),
12390
+ foreignKeys: recordType(stringType(), stringType()),
12391
+ compositePrimaryKeys: recordType(stringType(), stringType()),
12392
+ uniqueConstraints: recordType(stringType(), stringType()).default({})
12393
+ }).strict();
12394
+ schemaSquashed = objectType({
12395
+ version: latestVersion,
12396
+ dialect: dialect4,
12397
+ tables: recordType(stringType(), tableSquashed2),
12398
+ enums: anyType()
12399
+ }).strict();
12400
+ SQLiteSquasher = {
12401
+ squashIdx: (idx) => {
12402
+ index2.parse(idx);
12403
+ return `${idx.name};${idx.columns.join(",")};${idx.isUnique};${idx.where ?? ""}`;
12404
+ },
12405
+ unsquashIdx: (input) => {
12406
+ const [name, columnsString, isUnique, where] = input.split(";");
12407
+ const result = index2.parse({
12408
+ name,
12409
+ columns: columnsString.split(","),
12410
+ isUnique: isUnique === "true",
12411
+ where: where ?? void 0
12895
12412
  });
12896
- const js = result.code;
12897
- debug("compiled %s", filename);
12898
- debug("%s", js);
12899
- const warnings = result.warnings;
12900
- if (warnings && warnings.length > 0) {
12901
- for (const warning of warnings) {
12902
- console.log(warning.location);
12903
- console.log(warning.text);
12904
- }
12905
- }
12906
- if (format === "esm")
12907
- return js;
12908
- return removeNodePrefix(js);
12909
- };
12910
- const revert = (0, import_pirates.addHook)(compile, {
12911
- exts: extensions,
12912
- ignoreNodeModules: hookIgnoreNodeModules,
12913
- matcher: hookMatcher
12914
- });
12915
- installSourceMapSupport();
12916
- const unpatchCommonJsLoader = patchCommonJsLoader(compile);
12917
- const unregisterTsconfigPaths = registerTsconfigPaths();
12413
+ return result;
12414
+ },
12415
+ squashUnique: (unq) => {
12416
+ return `${unq.name};${unq.columns.join(",")}`;
12417
+ },
12418
+ unsquashUnique: (unq) => {
12419
+ const [name, columns] = unq.split(";");
12420
+ return { name, columns: columns.split(",") };
12421
+ },
12422
+ squashFK: (fk4) => {
12423
+ return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""}`;
12424
+ },
12425
+ unsquashFK: (input) => {
12426
+ const [
12427
+ name,
12428
+ tableFrom,
12429
+ columnsFromStr,
12430
+ tableTo,
12431
+ columnsToStr,
12432
+ onUpdate,
12433
+ onDelete
12434
+ ] = input.split(";");
12435
+ const result = fk2.parse({
12436
+ name,
12437
+ tableFrom,
12438
+ columnsFrom: columnsFromStr.split(","),
12439
+ tableTo,
12440
+ columnsTo: columnsToStr.split(","),
12441
+ onUpdate,
12442
+ onDelete
12443
+ });
12444
+ return result;
12445
+ },
12446
+ squashPK: (pk) => {
12447
+ return pk.columns.join(",");
12448
+ },
12449
+ unsquashPK: (pk) => {
12450
+ return pk.split(",");
12451
+ }
12452
+ };
12453
+ squashSqliteScheme = (json) => {
12454
+ const mappedTables = Object.fromEntries(
12455
+ Object.entries(json.tables).map((it) => {
12456
+ const squashedIndexes = mapValues(it[1].indexes, (index4) => {
12457
+ return SQLiteSquasher.squashIdx(index4);
12458
+ });
12459
+ const squashedFKs = mapValues(it[1].foreignKeys, (fk4) => {
12460
+ return SQLiteSquasher.squashFK(fk4);
12461
+ });
12462
+ const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => {
12463
+ return SQLiteSquasher.squashPK(pk);
12464
+ });
12465
+ const squashedUniqueConstraints = mapValues(it[1].uniqueConstraints, (unq) => {
12466
+ return SQLiteSquasher.squashUnique(unq);
12467
+ });
12468
+ return [
12469
+ it[0],
12470
+ {
12471
+ name: it[1].name,
12472
+ columns: it[1].columns,
12473
+ indexes: squashedIndexes,
12474
+ foreignKeys: squashedFKs,
12475
+ compositePrimaryKeys: squashedPKs,
12476
+ uniqueConstraints: squashedUniqueConstraints
12477
+ }
12478
+ ];
12479
+ })
12480
+ );
12918
12481
  return {
12919
- unregister() {
12920
- revert();
12921
- unpatchCommonJsLoader();
12922
- unregisterTsconfigPaths();
12923
- }
12482
+ version: "5",
12483
+ dialect: json.dialect,
12484
+ tables: mappedTables,
12485
+ enums: json.enums
12924
12486
  };
12925
- }
12926
- exports.register = register;
12487
+ };
12488
+ drySQLite = schema2.parse({
12489
+ version: snapshotVersion,
12490
+ dialect: "sqlite",
12491
+ id: originUUID,
12492
+ prevId: "",
12493
+ tables: {},
12494
+ enums: {},
12495
+ _meta: {
12496
+ tables: {},
12497
+ columns: {}
12498
+ }
12499
+ });
12500
+ sqliteSchema = schema2;
12501
+ backwardCompatibleSqliteSchema = unionType([schemaV3, schemaV4, schema2]);
12927
12502
  }
12928
12503
  });
12929
12504
 
12930
- // src/cli/commands/utils.ts
12931
- var import_hanji2, assertES5, safeRegister;
12932
- var init_utils = __esm({
12933
- "src/cli/commands/utils.ts"() {
12934
- "use strict";
12935
- init_serializer();
12936
- init_source();
12937
- init_views();
12938
- import_hanji2 = __toESM(require_hanji());
12939
- init_outputs();
12505
+ // src/serializer/mysqlSchema.ts
12506
+ 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;
12507
+ var init_mysqlSchema = __esm({
12508
+ "src/serializer/mysqlSchema.ts"() {
12940
12509
  init_global();
12941
- init_mysql();
12942
- init_pg();
12943
- init_sqlite();
12944
- init_common();
12945
- assertES5 = async (unregister) => {
12946
- try {
12947
- init_es5();
12948
- } catch (e) {
12949
- if ("errors" in e && Array.isArray(e.errors) && e.errors.length > 0) {
12950
- const es5Error = e.errors.filter(
12951
- (it) => {
12952
- var _a;
12953
- return (_a = it.text) == null ? void 0 : _a.includes(`("es5") is not supported yet`);
12954
- }
12955
- ).length > 0;
12956
- if (es5Error) {
12957
- console.log(
12958
- error(
12959
- `Please change compilerOptions.target from 'es5' to 'es6' or above in your tsconfig.json`
12960
- )
12961
- );
12962
- process.exit(1);
12963
- }
12964
- }
12965
- console.error(e);
12966
- process.exit(1);
12967
- }
12968
- };
12969
- safeRegister = async () => {
12970
- const { register } = await Promise.resolve().then(() => __toESM(require_node2()));
12971
- let res;
12972
- try {
12973
- res = register({
12974
- format: "cjs",
12975
- loader: "ts"
12976
- });
12977
- } catch {
12978
- res = {
12979
- unregister: () => {
12980
- }
12510
+ init_lib();
12511
+ index3 = objectType({
12512
+ name: stringType(),
12513
+ columns: stringType().array(),
12514
+ isUnique: booleanType(),
12515
+ using: enumType(["btree", "hash"]).optional(),
12516
+ algorithm: enumType(["default", "inplace", "copy"]).optional(),
12517
+ lock: enumType(["default", "none", "shared", "exclusive"]).optional()
12518
+ }).strict();
12519
+ fk3 = objectType({
12520
+ name: stringType(),
12521
+ tableFrom: stringType(),
12522
+ columnsFrom: stringType().array(),
12523
+ tableTo: stringType(),
12524
+ columnsTo: stringType().array(),
12525
+ onUpdate: stringType().optional(),
12526
+ onDelete: stringType().optional()
12527
+ }).strict();
12528
+ column3 = objectType({
12529
+ name: stringType(),
12530
+ type: stringType(),
12531
+ primaryKey: booleanType(),
12532
+ notNull: booleanType(),
12533
+ autoincrement: booleanType().optional(),
12534
+ default: anyType().optional(),
12535
+ onUpdate: anyType().optional()
12536
+ }).strict();
12537
+ tableV33 = objectType({
12538
+ name: stringType(),
12539
+ columns: recordType(stringType(), column3),
12540
+ indexes: recordType(stringType(), index3),
12541
+ foreignKeys: recordType(stringType(), fk3)
12542
+ }).strict();
12543
+ compositePK3 = objectType({
12544
+ name: stringType(),
12545
+ columns: stringType().array()
12546
+ }).strict();
12547
+ uniqueConstraint3 = objectType({
12548
+ name: stringType(),
12549
+ columns: stringType().array()
12550
+ }).strict();
12551
+ tableV42 = objectType({
12552
+ name: stringType(),
12553
+ schema: stringType().optional(),
12554
+ columns: recordType(stringType(), column3),
12555
+ indexes: recordType(stringType(), index3),
12556
+ foreignKeys: recordType(stringType(), fk3)
12557
+ }).strict();
12558
+ table3 = objectType({
12559
+ name: stringType(),
12560
+ schema: stringType().optional(),
12561
+ columns: recordType(stringType(), column3),
12562
+ indexes: recordType(stringType(), index3),
12563
+ foreignKeys: recordType(stringType(), fk3),
12564
+ compositePrimaryKeys: recordType(stringType(), compositePK3),
12565
+ uniqueConstraints: recordType(stringType(), uniqueConstraint3).default({})
12566
+ }).strict();
12567
+ dialect5 = literalType("mysql");
12568
+ schemaHash3 = objectType({
12569
+ id: stringType(),
12570
+ prevId: stringType()
12571
+ });
12572
+ schemaInternalV32 = objectType({
12573
+ version: literalType("3"),
12574
+ dialect: dialect5,
12575
+ tables: recordType(stringType(), tableV33)
12576
+ }).strict();
12577
+ schemaInternalV42 = objectType({
12578
+ version: literalType("4"),
12579
+ dialect: dialect5,
12580
+ tables: recordType(stringType(), tableV42),
12581
+ schemas: recordType(stringType(), stringType())
12582
+ }).strict();
12583
+ kitInternals2 = objectType({
12584
+ tables: recordType(
12585
+ stringType(),
12586
+ objectType({
12587
+ columns: recordType(
12588
+ stringType(),
12589
+ objectType({ isDefaultAnExpression: booleanType().optional() }).optional()
12590
+ )
12591
+ }).optional()
12592
+ )
12593
+ }).optional();
12594
+ schemaInternal2 = objectType({
12595
+ version: literalType("5"),
12596
+ dialect: dialect5,
12597
+ tables: recordType(stringType(), table3),
12598
+ schemas: recordType(stringType(), stringType()),
12599
+ _meta: objectType({
12600
+ schemas: recordType(stringType(), stringType()),
12601
+ tables: recordType(stringType(), stringType()),
12602
+ columns: recordType(stringType(), stringType())
12603
+ }),
12604
+ internal: kitInternals2
12605
+ }).strict();
12606
+ schemaV32 = schemaInternalV32.merge(schemaHash3);
12607
+ schemaV42 = schemaInternalV42.merge(schemaHash3);
12608
+ schema3 = schemaInternal2.merge(schemaHash3);
12609
+ tableSquashedV42 = objectType({
12610
+ name: stringType(),
12611
+ schema: stringType().optional(),
12612
+ columns: recordType(stringType(), column3),
12613
+ indexes: recordType(stringType(), stringType()),
12614
+ foreignKeys: recordType(stringType(), stringType())
12615
+ }).strict();
12616
+ tableSquashed3 = objectType({
12617
+ name: stringType(),
12618
+ schema: stringType().optional(),
12619
+ columns: recordType(stringType(), column3),
12620
+ indexes: recordType(stringType(), stringType()),
12621
+ foreignKeys: recordType(stringType(), stringType()),
12622
+ compositePrimaryKeys: recordType(stringType(), stringType()),
12623
+ uniqueConstraints: recordType(stringType(), stringType()).default({})
12624
+ }).strict();
12625
+ schemaSquashed2 = objectType({
12626
+ version: literalType("5"),
12627
+ dialect: dialect5,
12628
+ tables: recordType(stringType(), tableSquashed3),
12629
+ schemas: recordType(stringType(), stringType())
12630
+ }).strict();
12631
+ schemaSquashedV4 = objectType({
12632
+ version: literalType("4"),
12633
+ dialect: dialect5,
12634
+ tables: recordType(stringType(), tableSquashedV42),
12635
+ schemas: recordType(stringType(), stringType())
12636
+ }).strict();
12637
+ MySqlSquasher = {
12638
+ squashIdx: (idx) => {
12639
+ index3.parse(idx);
12640
+ return `${idx.name};${idx.columns.join(",")};${idx.isUnique};${idx.using ?? ""};${idx.algorithm ?? ""};${idx.lock ?? ""}`;
12641
+ },
12642
+ unsquashIdx: (input) => {
12643
+ const [name, columnsString, isUnique, using, algorithm, lock] = input.split(";");
12644
+ const destructed = {
12645
+ name,
12646
+ columns: columnsString.split(","),
12647
+ isUnique: isUnique === "true",
12648
+ using: using ? using : void 0,
12649
+ algorithm: algorithm ? algorithm : void 0,
12650
+ lock: lock ? lock : void 0
12981
12651
  };
12652
+ return index3.parse(destructed);
12653
+ },
12654
+ squashPK: (pk) => {
12655
+ return `${pk.name};${pk.columns.join(",")}`;
12656
+ },
12657
+ unsquashPK: (pk) => {
12658
+ const splitted = pk.split(";");
12659
+ return { name: splitted[0], columns: splitted[1].split(",") };
12660
+ },
12661
+ squashUnique: (unq) => {
12662
+ return `${unq.name};${unq.columns.join(",")}`;
12663
+ },
12664
+ unsquashUnique: (unq) => {
12665
+ const [name, columns] = unq.split(";");
12666
+ return { name, columns: columns.split(",") };
12667
+ },
12668
+ squashFK: (fk4) => {
12669
+ return `${fk4.name};${fk4.tableFrom};${fk4.columnsFrom.join(",")};${fk4.tableTo};${fk4.columnsTo.join(",")};${fk4.onUpdate ?? ""};${fk4.onDelete ?? ""}`;
12670
+ },
12671
+ unsquashFK: (input) => {
12672
+ const [
12673
+ name,
12674
+ tableFrom,
12675
+ columnsFromStr,
12676
+ tableTo,
12677
+ columnsToStr,
12678
+ onUpdate,
12679
+ onDelete
12680
+ ] = input.split(";");
12681
+ const result = fk3.parse({
12682
+ name,
12683
+ tableFrom,
12684
+ columnsFrom: columnsFromStr.split(","),
12685
+ tableTo,
12686
+ columnsTo: columnsToStr.split(","),
12687
+ onUpdate,
12688
+ onDelete
12689
+ });
12690
+ return result;
12982
12691
  }
12983
- await assertES5(res.unregister);
12984
- return res;
12985
12692
  };
12986
- }
12987
- });
12988
-
12989
- // src/serializer/pgImports.ts
12990
- var pgImports_exports = {};
12991
- __export(pgImports_exports, {
12992
- prepareFromExports: () => prepareFromExports3,
12993
- prepareFromPgImports: () => prepareFromPgImports
12994
- });
12995
- var import_pg_core3, import_drizzle_orm7, prepareFromExports3, prepareFromPgImports;
12996
- var init_pgImports = __esm({
12997
- "src/serializer/pgImports.ts"() {
12998
- "use strict";
12999
- import_pg_core3 = require("drizzle-orm/pg-core");
13000
- import_drizzle_orm7 = require("drizzle-orm");
13001
- init_utils();
13002
- prepareFromExports3 = (exports) => {
13003
- const tables = [];
13004
- const enums = [];
13005
- const schemas = [];
13006
- const i0values = Object.values(exports);
13007
- i0values.forEach((t) => {
13008
- if ((0, import_pg_core3.isPgEnum)(t)) {
13009
- enums.push(t);
13010
- return;
13011
- }
13012
- if ((0, import_drizzle_orm7.is)(t, import_pg_core3.PgTable)) {
13013
- tables.push(t);
13014
- }
13015
- if ((0, import_drizzle_orm7.is)(t, import_pg_core3.PgSchema)) {
13016
- schemas.push(t);
13017
- }
13018
- });
13019
- return { tables, enums, schemas };
12693
+ squashMysqlScheme = (json) => {
12694
+ const mappedTables = Object.fromEntries(
12695
+ Object.entries(json.tables).map((it) => {
12696
+ const squashedIndexes = mapValues(it[1].indexes, (index4) => {
12697
+ return MySqlSquasher.squashIdx(index4);
12698
+ });
12699
+ const squashedFKs = mapValues(it[1].foreignKeys, (fk4) => {
12700
+ return MySqlSquasher.squashFK(fk4);
12701
+ });
12702
+ const squashedPKs = mapValues(it[1].compositePrimaryKeys, (pk) => {
12703
+ return MySqlSquasher.squashPK(pk);
12704
+ });
12705
+ const squashedUniqueConstraints = mapValues(
12706
+ it[1].uniqueConstraints,
12707
+ (unq) => {
12708
+ return MySqlSquasher.squashUnique(unq);
12709
+ }
12710
+ );
12711
+ return [
12712
+ it[0],
12713
+ {
12714
+ name: it[1].name,
12715
+ schema: it[1].schema,
12716
+ columns: it[1].columns,
12717
+ indexes: squashedIndexes,
12718
+ foreignKeys: squashedFKs,
12719
+ compositePrimaryKeys: squashedPKs,
12720
+ uniqueConstraints: squashedUniqueConstraints
12721
+ }
12722
+ ];
12723
+ })
12724
+ );
12725
+ return {
12726
+ version: "5",
12727
+ dialect: json.dialect,
12728
+ tables: mappedTables,
12729
+ schemas: json.schemas
12730
+ };
13020
12731
  };
13021
- prepareFromPgImports = async (imports) => {
13022
- let tables = [];
13023
- let enums = [];
13024
- let schemas = [];
13025
- const { unregister } = await safeRegister();
13026
- for (let i = 0; i < imports.length; i++) {
13027
- const it = imports[i];
13028
- const i0 = require(`${it}`);
13029
- const prepared = prepareFromExports3(i0);
13030
- tables.push(...prepared.tables);
13031
- enums.push(...prepared.enums);
13032
- schemas.push(...prepared.schemas);
12732
+ mysqlSchema = schema3;
12733
+ backwardCompatibleMysqlSchema = unionType([
12734
+ schemaV32,
12735
+ schemaV42,
12736
+ schema3
12737
+ ]);
12738
+ dryMySql = mysqlSchema.parse({
12739
+ version: snapshotVersion,
12740
+ dialect: "mysql",
12741
+ id: originUUID,
12742
+ prevId: "",
12743
+ tables: {},
12744
+ schemas: {},
12745
+ _meta: {
12746
+ schemas: {},
12747
+ tables: {},
12748
+ columns: {}
13033
12749
  }
13034
- unregister();
13035
- return { tables: Array.from(new Set(tables)), enums, schemas };
13036
- };
12750
+ });
13037
12751
  }
13038
12752
  });
13039
12753
 
@@ -13041,7 +12755,6 @@ var init_pgImports = __esm({
13041
12755
  var import_fs2, import_crypto, prepareMySqlDbPushSnapshot, prepareSQLiteDbPushSnapshot, preparePgDbPushSnapshot, prepareMySqlMigrationSnapshot, prepareSqliteMigrationSnapshot, fillPgSnapshot, preparePgMigrationSnapshot, preparePrevSnapshot;
13042
12756
  var init_migrationPreparator = __esm({
13043
12757
  "src/migrationPreparator.ts"() {
13044
- "use strict";
13045
12758
  import_fs2 = __toESM(require("fs"));
13046
12759
  import_crypto = require("crypto");
13047
12760
  init_serializer();
@@ -13052,18 +12765,18 @@ var init_migrationPreparator = __esm({
13052
12765
  const serialized = await serializeMySql(schemaPath);
13053
12766
  const id = (0, import_crypto.randomUUID)();
13054
12767
  const idPrev = prev.id;
13055
- const { version, dialect: dialect7, ...rest } = serialized;
13056
- const result = { version, dialect: dialect7, id, prevId: idPrev, ...rest };
12768
+ const { version, dialect: dialect6, ...rest } = serialized;
12769
+ const result = { version, dialect: dialect6, id, prevId: idPrev, ...rest };
13057
12770
  return { prev, cur: result };
13058
12771
  };
13059
12772
  prepareSQLiteDbPushSnapshot = async (prev, schemaPath) => {
13060
12773
  const serialized = await serializeSQLite(schemaPath);
13061
12774
  const id = (0, import_crypto.randomUUID)();
13062
12775
  const idPrev = prev.id;
13063
- const { version, dialect: dialect7, ...rest } = serialized;
12776
+ const { version, dialect: dialect6, ...rest } = serialized;
13064
12777
  const result = {
13065
12778
  version,
13066
- dialect: dialect7,
12779
+ dialect: dialect6,
13067
12780
  id,
13068
12781
  prevId: idPrev,
13069
12782
  ...rest
@@ -13074,8 +12787,8 @@ var init_migrationPreparator = __esm({
13074
12787
  const serialized = await serializePg(schemaPath, schemaFilter);
13075
12788
  const id = (0, import_crypto.randomUUID)();
13076
12789
  const idPrev = prev.id;
13077
- const { version, dialect: dialect7, ...rest } = serialized;
13078
- 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 };
13079
12792
  return { prev, cur: result };
13080
12793
  };
13081
12794
  prepareMySqlMigrationSnapshot = async (migrationFolders, schemaPath) => {
@@ -13085,8 +12798,8 @@ var init_migrationPreparator = __esm({
13085
12798
  const serialized = await serializeMySql(schemaPath);
13086
12799
  const id = (0, import_crypto.randomUUID)();
13087
12800
  const idPrev = prevSnapshot.id;
13088
- const { version, dialect: dialect7, ...rest } = serialized;
13089
- const result = { version, dialect: dialect7, id, prevId: idPrev, ...rest };
12801
+ const { version, dialect: dialect6, ...rest } = serialized;
12802
+ const result = { version, dialect: dialect6, id, prevId: idPrev, ...rest };
13090
12803
  const { id: _ignoredId, prevId: _ignoredPrevId, ...prevRest } = prevSnapshot;
13091
12804
  const custom = {
13092
12805
  id,
@@ -13102,10 +12815,10 @@ var init_migrationPreparator = __esm({
13102
12815
  const serialized = await serializeSQLite(schemaPath);
13103
12816
  const id = (0, import_crypto.randomUUID)();
13104
12817
  const idPrev = prevSnapshot.id;
13105
- const { version, dialect: dialect7, ...rest } = serialized;
12818
+ const { version, dialect: dialect6, ...rest } = serialized;
13106
12819
  const result = {
13107
12820
  version,
13108
- dialect: dialect7,
12821
+ dialect: dialect6,
13109
12822
  id,
13110
12823
  prevId: idPrev,
13111
12824
  ...rest
@@ -13130,7 +12843,7 @@ var init_migrationPreparator = __esm({
13130
12843
  const serialized = await serializePg(schemaPath);
13131
12844
  const id = (0, import_crypto.randomUUID)();
13132
12845
  const idPrev = prevSnapshot.id;
13133
- const result = { id, prevId: idPrev, ...serialized };
12846
+ const result = fillPgSnapshot({ serialized, id, idPrev });
13134
12847
  const { id: _ignoredId, prevId: _ignoredPrevId, ...prevRest } = prevSnapshot;
13135
12848
  const custom = fillPgSnapshot({ serialized: prevRest, id, idPrev });
13136
12849
  return { prev: prevSnapshot, cur: result, custom };
@@ -13437,7 +13150,6 @@ function applyJsonDiff(json1, json2) {
13437
13150
  var import_json_diff, findAlternationsInTable, alternationsInColumn;
13438
13151
  var init_jsonDiffer = __esm({
13439
13152
  "src/jsonDiffer.js"() {
13440
- "use strict";
13441
13153
  "use-strict";
13442
13154
  import_json_diff = require("json-diff");
13443
13155
  findAlternationsInTable = (table4, tableSchema) => {
@@ -13610,21 +13322,20 @@ var init_jsonDiffer = __esm({
13610
13322
  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;
13611
13323
  var init_jsonStatements = __esm({
13612
13324
  "src/jsonStatements.ts"() {
13613
- "use strict";
13614
13325
  init_mysqlSchema();
13615
13326
  init_pgSchema();
13616
13327
  init_sqliteSchema();
13617
13328
  preparePgCreateTableJson = (table4, json2) => {
13618
13329
  const { name, schema: schema4, columns, compositePrimaryKeys, uniqueConstraints } = table4;
13619
- const tableKey = `${schema4 || "public"}.${name}`;
13620
- const compositePkName = Object.values(compositePrimaryKeys).length > 0 ? json2.tables[tableKey].compositePrimaryKeys[`${PgSquasher.unsquashPK(Object.values(compositePrimaryKeys)[0]).name}`].name : "";
13621
13330
  return {
13622
13331
  type: "create_table",
13623
13332
  tableName: name,
13624
13333
  schema: schema4,
13625
13334
  columns: Object.values(columns),
13626
13335
  compositePKs: Object.values(compositePrimaryKeys),
13627
- compositePkName,
13336
+ compositePkName: Object.values(compositePrimaryKeys).length > 0 ? json2.tables[name].compositePrimaryKeys[`${PgSquasher.unsquashPK(
13337
+ Object.values(compositePrimaryKeys)[0]
13338
+ ).name}`].name : "",
13628
13339
  uniqueConstraints: Object.values(uniqueConstraints)
13629
13340
  };
13630
13341
  };
@@ -13723,12 +13434,11 @@ var init_jsonStatements = __esm({
13723
13434
  };
13724
13435
  });
13725
13436
  };
13726
- prepareAlterTableColumnsJson = (tableName, schema4, deleted, added, altered, addedFk, json2, dialect7) => {
13437
+ prepareAlterTableColumnsJson = (tableName, schema4, deleted, added, altered, addedFk, json2, dialect6) => {
13727
13438
  const addColumns = [];
13728
13439
  const dropColumns = _prepareDropColumns(tableName, schema4, deleted);
13729
- const tableKey = `${schema4 || "public"}.${tableName}`;
13730
- const alterColumns = _prepareAlterColumns(tableKey, schema4, altered, json2);
13731
- if (dialect7 === "sqlite") {
13440
+ const alterColumns = _prepareAlterColumns(tableName, schema4, altered, json2);
13441
+ if (dialect6 === "sqlite") {
13732
13442
  let jsonCreateFKStatements = Object.values(addedFk);
13733
13443
  const sqliteAddColumns = _prepareSQLiteAddColumns(
13734
13444
  tableName,
@@ -13777,22 +13487,19 @@ var init_jsonStatements = __esm({
13777
13487
  };
13778
13488
  });
13779
13489
  };
13780
- _prepareAlterColumns = (tableKey, schema4, columns, json2) => {
13490
+ _prepareAlterColumns = (tableName, schema4, columns, json2) => {
13781
13491
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
13782
13492
  let statements = [];
13783
13493
  let dropPkStatements = [];
13784
13494
  let setPkStatements = [];
13785
13495
  for (const column4 of columns) {
13786
13496
  const columnName = typeof column4.name !== "string" ? column4.name.new : column4.name;
13787
- const table4 = json2.tables[tableKey];
13788
- const tableName = table4.name;
13789
- const snapshotColumn = table4.columns[columnName];
13790
- const columnType = snapshotColumn.type;
13791
- const columnDefault = snapshotColumn.default;
13792
- const columnOnUpdate = "onUpdate" in snapshotColumn ? snapshotColumn.onUpdate : void 0;
13793
- const columnNotNull = table4.columns[columnName].notNull;
13794
- const columnAutoIncrement = "autoincrement" in snapshotColumn ? snapshotColumn.autoincrement ?? false : false;
13795
- const columnPk = table4.columns[columnName].primaryKey;
13497
+ const columnType = json2.tables[tableName].columns[columnName].type;
13498
+ const columnDefault = json2.tables[tableName].columns[columnName].default;
13499
+ const columnOnUpdate = json2.tables[tableName].columns[columnName].onUpdate;
13500
+ const columnNotNull = json2.tables[tableName].columns[columnName].notNull;
13501
+ const columnAutoIncrement = json2.tables[tableName].columns[columnName].autoincrement;
13502
+ const columnPk = json2.tables[tableName].columns[columnName].primaryKey;
13796
13503
  if (((_a = column4.autoincrement) == null ? void 0 : _a.type) === "added") {
13797
13504
  statements.push({
13798
13505
  type: "alter_table_alter_column_set_autoincrement",
@@ -13839,14 +13546,13 @@ var init_jsonStatements = __esm({
13839
13546
  }
13840
13547
  for (const column4 of columns) {
13841
13548
  const columnName = typeof column4.name !== "string" ? column4.name.new : column4.name;
13842
- const tableName = json2.tables[tableKey].name;
13843
- const columnType = json2.tables[tableKey].columns[columnName].type;
13844
- const columnDefault = json2.tables[tableKey].columns[columnName].default;
13845
- const columnOnUpdate = json2.tables[tableKey].columns[columnName].onUpdate;
13846
- const columnNotNull = json2.tables[tableKey].columns[columnName].notNull;
13847
- const columnAutoIncrement = json2.tables[tableKey].columns[columnName].autoincrement;
13848
- const columnPk = json2.tables[tableKey].columns[columnName].primaryKey;
13849
- const compositePk = json2.tables[tableKey].compositePrimaryKeys[`${tableName}_${columnName}`];
13549
+ const columnType = json2.tables[tableName].columns[columnName].type;
13550
+ const columnDefault = json2.tables[tableName].columns[columnName].default;
13551
+ const columnOnUpdate = json2.tables[tableName].columns[columnName].onUpdate;
13552
+ const columnNotNull = json2.tables[tableName].columns[columnName].notNull;
13553
+ const columnAutoIncrement = json2.tables[tableName].columns[columnName].autoincrement;
13554
+ const columnPk = json2.tables[tableName].columns[columnName].primaryKey;
13555
+ const compositePk = json2.tables[tableName].compositePrimaryKeys[`${tableName}_${columnName}`];
13850
13556
  if (typeof column4.name !== "string") {
13851
13557
  statements.push({
13852
13558
  type: "alter_table_rename_column",
@@ -14197,7 +13903,6 @@ var init_jsonStatements = __esm({
14197
13903
  var prepareMigrationMetadata, adjectives, heroes;
14198
13904
  var init_words = __esm({
14199
13905
  "src/utils/words.ts"() {
14200
- "use strict";
14201
13906
  prepareMigrationMetadata = (idx) => {
14202
13907
  const prefix = idx.toFixed(0).padStart(4, "0");
14203
13908
  const suffix = `${adjectives.random()}_${heroes.random()}`;
@@ -15518,7 +15223,6 @@ var init_words = __esm({
15518
15223
  // src/cli/commands/pgUp.ts
15519
15224
  var init_pgUp = __esm({
15520
15225
  "src/cli/commands/pgUp.ts"() {
15521
- "use strict";
15522
15226
  init_source();
15523
15227
  init_global();
15524
15228
  init_pgSchema();
@@ -15529,7 +15233,6 @@ var init_pgUp = __esm({
15529
15233
  // src/cli/commands/mysqlUp.ts
15530
15234
  var init_mysqlUp = __esm({
15531
15235
  "src/cli/commands/mysqlUp.ts"() {
15532
- "use strict";
15533
15236
  init_source();
15534
15237
  init_mysqlSchema();
15535
15238
  init_utils2();
@@ -15539,7 +15242,6 @@ var init_mysqlUp = __esm({
15539
15242
  // src/cli/commands/upFolders.ts
15540
15243
  var init_upFolders = __esm({
15541
15244
  "src/cli/commands/upFolders.ts"() {
15542
- "use strict";
15543
15245
  init_jsonDiffer();
15544
15246
  init_mysqlSchema();
15545
15247
  init_sqliteSchema();
@@ -15553,10 +15255,9 @@ var init_upFolders = __esm({
15553
15255
  });
15554
15256
 
15555
15257
  // src/utils.ts
15556
- var import_fs3, import_path2, assertV1OutFolder, dryJournal, prepareOutFolder, validatorForDialect, validateWithReport, prepareMigrationFolder, prepareMigrationMeta, schemaRenameKey, tableRenameKey, columnRenameKey;
15258
+ var import_fs3, import_path2, assertV1OutFolder, dryJournal, prepareOutFolder2, validatorForDialect, validateWithReport, prepareMigrationFolder, prepareMigrationMeta, schemaRenameKey, tableRenameKey, columnRenameKey;
15557
15259
  var init_utils2 = __esm({
15558
15260
  "src/utils.ts"() {
15559
- "use strict";
15560
15261
  import_fs3 = require("fs");
15561
15262
  init_views();
15562
15263
  init_mysqlSchema();
@@ -15567,7 +15268,7 @@ var init_utils2 = __esm({
15567
15268
  init_global();
15568
15269
  init_upFolders();
15569
15270
  init_snapshotsDiffer();
15570
- assertV1OutFolder = (out) => {
15271
+ assertV1OutFolder = (out, dialect6) => {
15571
15272
  if (!(0, import_fs3.existsSync)(out))
15572
15273
  return;
15573
15274
  const oldMigrationFolders = (0, import_fs3.readdirSync)(out).filter(
@@ -15576,43 +15277,43 @@ var init_utils2 = __esm({
15576
15277
  if (oldMigrationFolders.length > 0) {
15577
15278
  console.log(
15578
15279
  `Your migrations folder format is outdated, please run ${source_default.green.bold(
15579
- `drizzle-kit up`
15280
+ `drizzle-kit up:${dialect6}`
15580
15281
  )}`
15581
15282
  );
15582
15283
  process.exit(1);
15583
15284
  }
15584
15285
  };
15585
- dryJournal = (dialect7) => {
15286
+ dryJournal = (dialect6) => {
15586
15287
  return {
15587
15288
  version: snapshotVersion,
15588
- dialect: dialect7,
15289
+ dialect: dialect6,
15589
15290
  entries: []
15590
15291
  };
15591
15292
  };
15592
- prepareOutFolder = (out, dialect7) => {
15293
+ prepareOutFolder2 = (out, dialect6) => {
15593
15294
  const meta = (0, import_path2.join)(out, "meta");
15594
15295
  const journalPath = (0, import_path2.join)(meta, "_journal.json");
15595
15296
  if (!(0, import_fs3.existsSync)((0, import_path2.join)(out, "meta"))) {
15596
15297
  (0, import_fs3.mkdirSync)(meta, { recursive: true });
15597
- (0, import_fs3.writeFileSync)(journalPath, JSON.stringify(dryJournal(dialect7)));
15298
+ (0, import_fs3.writeFileSync)(journalPath, JSON.stringify(dryJournal(dialect6)));
15598
15299
  }
15599
15300
  const journal = JSON.parse((0, import_fs3.readFileSync)(journalPath).toString());
15600
15301
  const snapshots = (0, import_fs3.readdirSync)(meta).filter((it) => !it.startsWith("_")).map((it) => (0, import_path2.join)(meta, it));
15601
15302
  snapshots.sort();
15602
15303
  return { meta, snapshots, journal };
15603
15304
  };
15604
- validatorForDialect = (dialect7) => {
15605
- switch (dialect7) {
15305
+ validatorForDialect = (dialect6) => {
15306
+ switch (dialect6) {
15606
15307
  case "pg":
15607
- return { validator: backwardCompatiblePgSchema, version: 6 };
15308
+ return { validator: backwardCompatiblePgSchema, version: 5 };
15608
15309
  case "sqlite":
15609
- return { validator: backwardCompatibleSqliteSchema, version: 6 };
15310
+ return { validator: backwardCompatibleSqliteSchema, version: 5 };
15610
15311
  case "mysql":
15611
15312
  return { validator: backwardCompatibleMysqlSchema, version: 5 };
15612
15313
  }
15613
15314
  };
15614
- validateWithReport = (snapshots, dialect7) => {
15615
- const { validator, version } = validatorForDialect(dialect7);
15315
+ validateWithReport = (snapshots, dialect6) => {
15316
+ const { validator, version } = validatorForDialect(dialect6);
15616
15317
  const result = snapshots.reduce(
15617
15318
  (accum, it) => {
15618
15319
  const raw = JSON.parse((0, import_fs3.readFileSync)(`./${it}`).toString());
@@ -15653,14 +15354,14 @@ var init_utils2 = __esm({
15653
15354
  );
15654
15355
  return result;
15655
15356
  };
15656
- prepareMigrationFolder = (outFolder = "drizzle", dialect7) => {
15657
- const { snapshots, journal } = prepareOutFolder(outFolder, dialect7);
15658
- const report = validateWithReport(snapshots, dialect7);
15357
+ prepareMigrationFolder = (outFolder = "drizzle", dialect6) => {
15358
+ const { snapshots, journal } = prepareOutFolder2(outFolder, dialect6);
15359
+ const report = validateWithReport(snapshots, dialect6);
15659
15360
  if (report.nonLatest.length > 0) {
15660
15361
  console.log(
15661
15362
  report.nonLatest.map((it) => {
15662
15363
  return `${it}/snapshot.json is not of the latest version`;
15663
- }).concat(`Run ${source_default.green.bold(`drizzle-kit up`)}`).join("\n")
15364
+ }).concat(`Run ${source_default.green.bold(`drizzle-kit up:${dialect6}`)}`).join("\n")
15664
15365
  );
15665
15366
  process.exit(0);
15666
15367
  }
@@ -15729,7 +15430,6 @@ var init_utils2 = __esm({
15729
15430
  var makeChanged, makeSelfOrChanged, makePatched, makeSelfOrPatched, valueFromSelfOrPatchedNew, columnSchema, alteredColumnSchema, enumSchema2, changedEnumSchema, tableScheme, alteredTableScheme, diffResultScheme, applySnapshotsDiff;
15730
15431
  var init_snapshotsDiffer = __esm({
15731
15432
  "src/snapshotsDiffer.ts"() {
15732
- "use strict";
15733
15433
  init_sqlgenerator();
15734
15434
  init_lib();
15735
15435
  init_jsonDiffer();
@@ -15737,7 +15437,6 @@ var init_snapshotsDiffer = __esm({
15737
15437
  init_utils2();
15738
15438
  init_sqliteSchema();
15739
15439
  init_mysqlSchema();
15740
- init_global();
15741
15440
  makeChanged = (schema4) => {
15742
15441
  return objectType({
15743
15442
  type: enumType(["changed"]),
@@ -15776,7 +15475,7 @@ var init_snapshotsDiffer = __esm({
15776
15475
  return unionType([
15777
15476
  objectType({
15778
15477
  type: literalType("none"),
15779
- value: schema4
15478
+ value: schema4.optional()
15780
15479
  }),
15781
15480
  objectType({
15782
15481
  type: literalType("added"),
@@ -15898,9 +15597,10 @@ var init_snapshotsDiffer = __esm({
15898
15597
  addedSchemas: stringType().array(),
15899
15598
  deletedSchemas: stringType().array()
15900
15599
  }).strict();
15901
- applySnapshotsDiff = async (json1, json2, dialect7, schemasResolver, tablesResolver, columnsResolver, prevFull, curFull) => {
15600
+ applySnapshotsDiff = async (json1, json2, dialect6, schemasResolver, tablesResolver, columnsResolver, prevFull, curFull) => {
15902
15601
  var _a, _b;
15903
- if (dialect7 === "mysql") {
15602
+ let diffResult;
15603
+ if (dialect6 === "mysql") {
15904
15604
  for (const tableName in json1.tables) {
15905
15605
  const table4 = json1.tables[tableName];
15906
15606
  for (const indexName3 in table4.indexes) {
@@ -15927,26 +15627,13 @@ var init_snapshotsDiffer = __esm({
15927
15627
  }
15928
15628
  }
15929
15629
  }
15630
+ diffResult = applyJsonDiff(json1, json2);
15930
15631
  }
15931
- const diffResult = applyJsonDiff(json1, json2);
15632
+ diffResult = applyJsonDiff(json1, json2);
15932
15633
  if (Object.keys(diffResult).length === 0) {
15933
15634
  return { statements: [], sqlStatements: [], _meta: void 0 };
15934
15635
  }
15935
15636
  const typedResult = diffResultScheme.parse(diffResult);
15936
- typedResult.alteredTablesWithColumns = typedResult.alteredTablesWithColumns.map((it) => {
15937
- let schemaToTrim;
15938
- if (it.schema.type === "none") {
15939
- schemaToTrim = it.schema.value || "public";
15940
- } else if (it.schema.type === "deleted") {
15941
- schemaToTrim = it.schema.value;
15942
- } else if (it.schema.type === "added") {
15943
- schemaToTrim = "public";
15944
- } else {
15945
- schemaToTrim = it.schema.old;
15946
- }
15947
- it.name = it.name.substring(schemaToTrim.length + 1);
15948
- return it;
15949
- });
15950
15637
  const {
15951
15638
  created: createdSchemas,
15952
15639
  deleted: deletedSchemas,
@@ -16038,9 +15725,9 @@ var init_snapshotsDiffer = __esm({
16038
15725
  let addedColumns = [];
16039
15726
  for (const addedPkName of Object.keys(it.addedCompositePKs)) {
16040
15727
  const addedPkColumns = it.addedCompositePKs[addedPkName];
16041
- if (dialect7 === "sqlite") {
15728
+ if (dialect6 === "sqlite") {
16042
15729
  addedColumns = SQLiteSquasher.unsquashPK(addedPkColumns);
16043
- } else if (dialect7 === "mysql") {
15730
+ } else if (dialect6 === "mysql") {
16044
15731
  addedColumns = MySqlSquasher.unsquashPK(addedPkColumns).columns;
16045
15732
  } else {
16046
15733
  addedColumns = SQLiteSquasher.unsquashPK(addedPkColumns);
@@ -16049,9 +15736,9 @@ var init_snapshotsDiffer = __esm({
16049
15736
  let deletedColumns = [];
16050
15737
  for (const deletedPkName of Object.keys(it.deletedCompositePKs)) {
16051
15738
  const deletedPkColumns = it.deletedCompositePKs[deletedPkName];
16052
- if (dialect7 === "sqlite") {
15739
+ if (dialect6 === "sqlite") {
16053
15740
  deletedColumns = SQLiteSquasher.unsquashPK(deletedPkColumns);
16054
- } else if (dialect7 === "mysql") {
15741
+ } else if (dialect6 === "mysql") {
16055
15742
  deletedColumns = MySqlSquasher.unsquashPK(deletedPkColumns).columns;
16056
15743
  } else {
16057
15744
  deletedColumns = SQLiteSquasher.unsquashPK(deletedPkColumns);
@@ -16061,7 +15748,7 @@ var init_snapshotsDiffer = __esm({
16061
15748
  let addedCompositePKs = [];
16062
15749
  let deletedCompositePKs = [];
16063
15750
  let alteredCompositePKs = [];
16064
- if (dialect7 === "sqlite") {
15751
+ if (dialect6 === "sqlite") {
16065
15752
  if (doPerformDeleteAndCreate) {
16066
15753
  addedCompositePKs = prepareAddCompositePrimaryKeySqlite(
16067
15754
  it.name,
@@ -16076,7 +15763,7 @@ var init_snapshotsDiffer = __esm({
16076
15763
  it.name,
16077
15764
  it.alteredCompositePKs
16078
15765
  );
16079
- } else if (dialect7 === "pg") {
15766
+ } else if (dialect6 === "pg") {
16080
15767
  if (doPerformDeleteAndCreate) {
16081
15768
  addedCompositePKs = prepareAddCompositePrimaryKeyPg(
16082
15769
  it.name,
@@ -16098,7 +15785,7 @@ var init_snapshotsDiffer = __esm({
16098
15785
  prevFull,
16099
15786
  curFull
16100
15787
  );
16101
- } else if (dialect7 === "mysql") {
15788
+ } else {
16102
15789
  addedCompositePKs = prepareAddCompositePrimaryKeyMySql(
16103
15790
  it.name,
16104
15791
  it.addedCompositePKs,
@@ -16116,8 +15803,6 @@ var init_snapshotsDiffer = __esm({
16116
15803
  prevFull,
16117
15804
  curFull
16118
15805
  );
16119
- } else {
16120
- assertUnreachable(dialect7);
16121
15806
  }
16122
15807
  let addedUniqueConstraints = [];
16123
15808
  let deletedUniqueConstraints = [];
@@ -16200,7 +15885,7 @@ var init_snapshotsDiffer = __esm({
16200
15885
  it.altered,
16201
15886
  it.addedForeignKeys,
16202
15887
  json2,
16203
- dialect7
15888
+ dialect6
16204
15889
  );
16205
15890
  }).flat().reduce(
16206
15891
  (res, it) => {
@@ -16277,7 +15962,7 @@ var init_snapshotsDiffer = __esm({
16277
15962
  const jsonAlterEnumsWithAddedValues = ((_b = typedResult.alteredEnums) == null ? void 0 : _b.map((it) => {
16278
15963
  return prepareAddValuesToEnumJson(it.name, it.addedValues);
16279
15964
  }).flat()) ?? [];
16280
- if (dialect7 === "mysql") {
15965
+ if (dialect6 === "mysql") {
16281
15966
  createdSchemas.push(...renamedSchemas.map((it) => it.to));
16282
15967
  deletedSchemas.push(...renamedSchemas.map((it) => it.from));
16283
15968
  renamedSchemas.splice(0, renamedSchemas.length);
@@ -16301,25 +15986,23 @@ var init_snapshotsDiffer = __esm({
16301
15986
  jsonStatements.push(...renameSchemas);
16302
15987
  jsonStatements.push(...createEnums);
16303
15988
  jsonStatements.push(...jsonAlterEnumsWithAddedValues);
16304
- if (dialect7 === "sqlite") {
15989
+ if (dialect6 === "sqlite") {
16305
15990
  jsonStatements.push(...jsonSQLiteCreateTables);
16306
- } else if (dialect7 === "pg") {
15991
+ } else if (dialect6 === "pg") {
16307
15992
  const jsonPgCreateTables = created.map((it) => {
16308
15993
  return preparePgCreateTableJson(it, curFull);
16309
15994
  });
16310
15995
  jsonStatements.push(...jsonPgCreateTables);
16311
- } else if (dialect7 === "mysql") {
15996
+ } else {
16312
15997
  const jsonMySqlCreateTables = created.map((it) => {
16313
15998
  return prepareMySqlCreateTableJson(it, curFull);
16314
15999
  });
16315
16000
  jsonStatements.push(...jsonMySqlCreateTables);
16316
- } else {
16317
- assertUnreachable(dialect7);
16318
16001
  }
16319
16002
  jsonStatements.push(...jsonDropTables);
16320
16003
  jsonStatements.push(...jsonRenameTables);
16321
16004
  jsonStatements.push(...jsonRenameColumnsStatements);
16322
- if (dialect7 !== "mysql") {
16005
+ if (dialect6 !== "mysql") {
16323
16006
  jsonStatements.push(...jsonDeletedUniqueConstraints);
16324
16007
  }
16325
16008
  jsonStatements.push(...jsonDroppedReferencesForAlteredTables);
@@ -16327,7 +16010,7 @@ var init_snapshotsDiffer = __esm({
16327
16010
  jsonStatements.push(...jsonDeletedCompositePKs);
16328
16011
  jsonStatements.push(...jsonTableAlternations.alterColumns);
16329
16012
  jsonStatements.push(...jsonAddedCompositePKs);
16330
- if (dialect7 === "mysql") {
16013
+ if (dialect6 === "mysql") {
16331
16014
  jsonStatements.push(...jsonAddedUniqueConstraints);
16332
16015
  jsonStatements.push(...jsonDeletedUniqueConstraints);
16333
16016
  }
@@ -16336,10 +16019,10 @@ var init_snapshotsDiffer = __esm({
16336
16019
  jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
16337
16020
  jsonStatements.push(...jsonCreatedReferencesForAlteredTables);
16338
16021
  jsonStatements.push(...jsonTableAlternations.dropColumns);
16339
- if (dialect7 !== "sqlite")
16022
+ if (dialect6 !== "sqlite")
16340
16023
  jsonStatements.push(...jsonCreateReferences);
16341
16024
  jsonStatements.push(...jsonAlteredCompositePKs);
16342
- if (dialect7 !== "mysql") {
16025
+ if (dialect6 !== "mysql") {
16343
16026
  jsonStatements.push(...jsonAddedUniqueConstraints);
16344
16027
  }
16345
16028
  jsonStatements.push(...jsonAlteredUniqueConstraints);
@@ -16347,7 +16030,7 @@ var init_snapshotsDiffer = __esm({
16347
16030
  jsonStatements.push(...filteredJsonSetNewTableSchemas);
16348
16031
  jsonStatements.push(...jsonRemoveTableFromSchemas);
16349
16032
  jsonStatements.push(...dropSchemas);
16350
- const sqlStatements = fromJson(jsonStatements, dialect7);
16033
+ const sqlStatements = fromJson(jsonStatements, dialect6);
16351
16034
  const uniqueSqlStatements = [];
16352
16035
  sqlStatements.forEach((ss) => {
16353
16036
  if (!uniqueSqlStatements.includes(ss)) {
@@ -16382,7 +16065,6 @@ __export(migrate_exports, {
16382
16065
  var import_fs4, import_path3, import_hanji4, prepareAndMigratePg, prepareMySQLPush, prepareSQLitePush, preparePgPush, prepareAndMigrateMySql, prepareAndMigrateSqlite, prepareSQL, promptColumnsConflicts, promptTablesConflict, promptSchemasConflict, BREAKPOINT, writeResult, embeddedMigrations, prepareSnapshotFolderName, two;
16383
16066
  var init_migrate = __esm({
16384
16067
  "src/cli/commands/migrate.ts"() {
16385
- "use strict";
16386
16068
  import_fs4 = __toESM(require("fs"));
16387
16069
  init_migrationPreparator();
16388
16070
  init_snapshotsDiffer();
@@ -16400,7 +16082,7 @@ var init_migrate = __esm({
16400
16082
  const outFolder = config.out;
16401
16083
  const schemaPath = config.schema;
16402
16084
  try {
16403
- assertV1OutFolder(outFolder);
16085
+ assertV1OutFolder(outFolder, "pg");
16404
16086
  const { snapshots, journal } = prepareMigrationFolder(outFolder, "pg");
16405
16087
  const { prev, cur, custom } = await preparePgMigrationSnapshot(
16406
16088
  snapshots,
@@ -16460,56 +16142,66 @@ var init_migrate = __esm({
16460
16142
  return { sqlStatements, statements, validatedCur, validatedPrev };
16461
16143
  } catch (e) {
16462
16144
  console.error(e);
16463
- process.exit(1);
16464
16145
  }
16465
16146
  };
16466
16147
  prepareSQLitePush = async (config, snapshot) => {
16467
16148
  const schemaPath = config.schema;
16468
- const { prev, cur } = await prepareSQLiteDbPushSnapshot(snapshot, schemaPath);
16469
- const validatedPrev = sqliteSchema.parse(prev);
16470
- const validatedCur = sqliteSchema.parse(cur);
16471
- const squashedPrev = squashSqliteScheme(validatedPrev);
16472
- const squashedCur = squashSqliteScheme(validatedCur);
16473
- const { sqlStatements, statements, _meta } = await prepareSQL(
16474
- squashedPrev,
16475
- squashedCur,
16476
- "sqlite",
16477
- validatedPrev,
16478
- validatedCur
16479
- );
16480
- return {
16481
- sqlStatements,
16482
- statements,
16483
- squashedPrev,
16484
- squashedCur,
16485
- meta: _meta
16486
- };
16149
+ try {
16150
+ const { prev, cur } = await prepareSQLiteDbPushSnapshot(
16151
+ snapshot,
16152
+ schemaPath
16153
+ );
16154
+ const validatedPrev = sqliteSchema.parse(prev);
16155
+ const validatedCur = sqliteSchema.parse(cur);
16156
+ const squashedPrev = squashSqliteScheme(validatedPrev);
16157
+ const squashedCur = squashSqliteScheme(validatedCur);
16158
+ const { sqlStatements, statements, _meta } = await prepareSQL(
16159
+ squashedPrev,
16160
+ squashedCur,
16161
+ "sqlite",
16162
+ validatedPrev,
16163
+ validatedCur
16164
+ );
16165
+ return {
16166
+ sqlStatements,
16167
+ statements,
16168
+ squashedPrev,
16169
+ squashedCur,
16170
+ meta: _meta
16171
+ };
16172
+ } catch (e) {
16173
+ console.error(e);
16174
+ }
16487
16175
  };
16488
16176
  preparePgPush = async (config, snapshot, schemaFilter) => {
16489
16177
  const schemaPath = config.schema;
16490
- const { prev, cur } = await preparePgDbPushSnapshot(
16491
- snapshot,
16492
- schemaPath,
16493
- schemaFilter
16494
- );
16495
- const validatedPrev = pgSchema.parse(prev);
16496
- const validatedCur = pgSchema.parse(cur);
16497
- const squashedPrev = squashPgScheme(validatedPrev);
16498
- const squashedCur = squashPgScheme(validatedCur);
16499
- const { sqlStatements, statements } = await prepareSQL(
16500
- squashedPrev,
16501
- squashedCur,
16502
- "pg",
16503
- validatedPrev,
16504
- validatedCur
16505
- );
16506
- return { sqlStatements, statements, squashedPrev, squashedCur };
16178
+ try {
16179
+ const { prev, cur } = await preparePgDbPushSnapshot(
16180
+ snapshot,
16181
+ schemaPath,
16182
+ schemaFilter
16183
+ );
16184
+ const validatedPrev = pgSchema.parse(prev);
16185
+ const validatedCur = pgSchema.parse(cur);
16186
+ const squashedPrev = squashPgScheme(validatedPrev);
16187
+ const squashedCur = squashPgScheme(validatedCur);
16188
+ const { sqlStatements, statements } = await prepareSQL(
16189
+ squashedPrev,
16190
+ squashedCur,
16191
+ "pg",
16192
+ validatedPrev,
16193
+ validatedCur
16194
+ );
16195
+ return { sqlStatements, statements, squashedPrev, squashedCur };
16196
+ } catch (e) {
16197
+ console.error(e);
16198
+ }
16507
16199
  };
16508
16200
  prepareAndMigrateMySql = async (config) => {
16509
16201
  const outFolder = config.out;
16510
16202
  const schemaPath = config.schema;
16511
16203
  try {
16512
- assertV1OutFolder(outFolder);
16204
+ assertV1OutFolder(outFolder, "mysql");
16513
16205
  const { snapshots, journal } = prepareMigrationFolder(outFolder, "mysql");
16514
16206
  const { prev, cur, custom } = await prepareMySqlMigrationSnapshot(
16515
16207
  snapshots,
@@ -16553,7 +16245,7 @@ var init_migrate = __esm({
16553
16245
  const outFolder = config.out;
16554
16246
  const schemaPath = config.schema;
16555
16247
  try {
16556
- assertV1OutFolder(outFolder);
16248
+ assertV1OutFolder(outFolder, "sqlite");
16557
16249
  const { snapshots, journal } = prepareMigrationFolder(outFolder, "sqlite");
16558
16250
  const { prev, cur, custom } = await prepareSqliteMigrationSnapshot(
16559
16251
  snapshots,
@@ -16578,9 +16270,7 @@ var init_migrate = __esm({
16578
16270
  const { sqlStatements, _meta } = await prepareSQL(
16579
16271
  squashedPrev,
16580
16272
  squashedCur,
16581
- "sqlite",
16582
- validatedPrev,
16583
- validatedCur
16273
+ "sqlite"
16584
16274
  );
16585
16275
  writeResult({
16586
16276
  cur,
@@ -16595,7 +16285,7 @@ var init_migrate = __esm({
16595
16285
  console.error(e);
16596
16286
  }
16597
16287
  };
16598
- prepareSQL = async (prev, cur, dialect7, prevFull, curFull) => {
16288
+ prepareSQL = async (prev, cur, dialect6, prevFull, curFull) => {
16599
16289
  const schemasResolver = async (input) => {
16600
16290
  try {
16601
16291
  const { created, deleted, renamed } = await promptSchemasConflict(
@@ -16637,7 +16327,7 @@ var init_migrate = __esm({
16637
16327
  return await applySnapshotsDiff(
16638
16328
  prev,
16639
16329
  cur,
16640
- dialect7,
16330
+ dialect6,
16641
16331
  schemasResolver,
16642
16332
  tablesResolver,
16643
16333
  columnsResolver,
@@ -16879,7 +16569,6 @@ ${sql2}
16879
16569
  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;
16880
16570
  var init_sqlgenerator = __esm({
16881
16571
  "src/sqlgenerator.ts"() {
16882
- "use strict";
16883
16572
  init_migrate();
16884
16573
  init_mysqlSchema();
16885
16574
  init_pgSchema();
@@ -16934,8 +16623,8 @@ var init_sqlgenerator = __esm({
16934
16623
  Convertor = class {
16935
16624
  };
16936
16625
  PgCreateTableConvertor = class extends Convertor {
16937
- can(statement, dialect7) {
16938
- return statement.type === "create_table" && dialect7 === "pg";
16626
+ can(statement, dialect6) {
16627
+ return statement.type === "create_table" && dialect6 === "pg";
16939
16628
  }
16940
16629
  convert(st) {
16941
16630
  const { tableName, schema: schema4, columns, compositePKs, uniqueConstraints } = st;
@@ -16973,8 +16662,8 @@ var init_sqlgenerator = __esm({
16973
16662
  }
16974
16663
  };
16975
16664
  MySqlCreateTableConvertor = class extends Convertor {
16976
- can(statement, dialect7) {
16977
- return statement.type === "create_table" && dialect7 === "mysql";
16665
+ can(statement, dialect6) {
16666
+ return statement.type === "create_table" && dialect6 === "mysql";
16978
16667
  }
16979
16668
  convert(st) {
16980
16669
  const { tableName, columns, schema: schema4, compositePKs, uniqueConstraints } = st;
@@ -17012,8 +16701,8 @@ var init_sqlgenerator = __esm({
17012
16701
  }
17013
16702
  };
17014
16703
  SQLiteCreateTableConvertor = class extends Convertor {
17015
- can(statement, dialect7) {
17016
- return statement.type === "sqlite_create_table" && dialect7 === "sqlite";
16704
+ can(statement, dialect6) {
16705
+ return statement.type === "sqlite_create_table" && dialect6 === "sqlite";
17017
16706
  }
17018
16707
  convert(st) {
17019
16708
  const {
@@ -17075,8 +16764,8 @@ var init_sqlgenerator = __esm({
17075
16764
  }
17076
16765
  };
17077
16766
  PgAlterTableAddUniqueConstraintConvertor = class extends Convertor {
17078
- can(statement, dialect7) {
17079
- return statement.type === "create_unique_constraint" && dialect7 === "pg";
16767
+ can(statement, dialect6) {
16768
+ return statement.type === "create_unique_constraint" && dialect6 === "pg";
17080
16769
  }
17081
16770
  convert(statement) {
17082
16771
  const unsquashed = PgSquasher.unsquashUnique(statement.data);
@@ -17085,8 +16774,8 @@ var init_sqlgenerator = __esm({
17085
16774
  }
17086
16775
  };
17087
16776
  PgAlterTableDropUniqueConstraintConvertor = class extends Convertor {
17088
- can(statement, dialect7) {
17089
- return statement.type === "delete_unique_constraint" && dialect7 === "pg";
16777
+ can(statement, dialect6) {
16778
+ return statement.type === "delete_unique_constraint" && dialect6 === "pg";
17090
16779
  }
17091
16780
  convert(statement) {
17092
16781
  const unsquashed = PgSquasher.unsquashUnique(statement.data);
@@ -17095,8 +16784,8 @@ var init_sqlgenerator = __esm({
17095
16784
  }
17096
16785
  };
17097
16786
  MySQLAlterTableAddUniqueConstraintConvertor = class extends Convertor {
17098
- can(statement, dialect7) {
17099
- return statement.type === "create_unique_constraint" && dialect7 === "mysql";
16787
+ can(statement, dialect6) {
16788
+ return statement.type === "create_unique_constraint" && dialect6 === "mysql";
17100
16789
  }
17101
16790
  convert(statement) {
17102
16791
  const unsquashed = MySqlSquasher.unsquashUnique(statement.data);
@@ -17105,8 +16794,8 @@ var init_sqlgenerator = __esm({
17105
16794
  }
17106
16795
  };
17107
16796
  MySQLAlterTableDropUniqueConstraintConvertor = class extends Convertor {
17108
- can(statement, dialect7) {
17109
- return statement.type === "delete_unique_constraint" && dialect7 === "mysql";
16797
+ can(statement, dialect6) {
16798
+ return statement.type === "delete_unique_constraint" && dialect6 === "mysql";
17110
16799
  }
17111
16800
  convert(statement) {
17112
16801
  const unsquashed = MySqlSquasher.unsquashUnique(statement.data);
@@ -17115,8 +16804,8 @@ var init_sqlgenerator = __esm({
17115
16804
  }
17116
16805
  };
17117
16806
  SQLiteAlterTableAddUniqueConstraintConvertor = class extends Convertor {
17118
- can(statement, dialect7) {
17119
- return statement.type === "create_unique_constraint" && dialect7 === "sqlite";
16807
+ can(statement, dialect6) {
16808
+ return statement.type === "create_unique_constraint" && dialect6 === "sqlite";
17120
16809
  }
17121
16810
  convert(statement) {
17122
16811
  return `/*
@@ -17128,8 +16817,8 @@ var init_sqlgenerator = __esm({
17128
16817
  }
17129
16818
  };
17130
16819
  SQLiteAlterTableDropUniqueConstraintConvertor = class extends Convertor {
17131
- can(statement, dialect7) {
17132
- return statement.type === "delete_unique_constraint" && dialect7 === "sqlite";
16820
+ can(statement, dialect6) {
16821
+ return statement.type === "delete_unique_constraint" && dialect6 === "sqlite";
17133
16822
  }
17134
16823
  convert(statement) {
17135
16824
  return `/*
@@ -17172,8 +16861,8 @@ var init_sqlgenerator = __esm({
17172
16861
  }
17173
16862
  };
17174
16863
  PgDropTableConvertor = class extends Convertor {
17175
- can(statement, dialect7) {
17176
- return statement.type === "drop_table" && dialect7 === "pg";
16864
+ can(statement, dialect6) {
16865
+ return statement.type === "drop_table" && dialect6 === "pg";
17177
16866
  }
17178
16867
  convert(statement) {
17179
16868
  const { tableName, schema: schema4 } = statement;
@@ -17182,8 +16871,8 @@ var init_sqlgenerator = __esm({
17182
16871
  }
17183
16872
  };
17184
16873
  MySQLDropTableConvertor = class extends Convertor {
17185
- can(statement, dialect7) {
17186
- return statement.type === "drop_table" && dialect7 === "mysql";
16874
+ can(statement, dialect6) {
16875
+ return statement.type === "drop_table" && dialect6 === "mysql";
17187
16876
  }
17188
16877
  convert(statement) {
17189
16878
  const { tableName } = statement;
@@ -17191,8 +16880,8 @@ var init_sqlgenerator = __esm({
17191
16880
  }
17192
16881
  };
17193
16882
  SQLiteDropTableConvertor = class extends Convertor {
17194
- can(statement, dialect7) {
17195
- return statement.type === "drop_table" && dialect7 === "sqlite";
16883
+ can(statement, dialect6) {
16884
+ return statement.type === "drop_table" && dialect6 === "sqlite";
17196
16885
  }
17197
16886
  convert(statement) {
17198
16887
  const { tableName } = statement;
@@ -17200,8 +16889,8 @@ var init_sqlgenerator = __esm({
17200
16889
  }
17201
16890
  };
17202
16891
  PgRenameTableConvertor = class extends Convertor {
17203
- can(statement, dialect7) {
17204
- return statement.type === "rename_table" && dialect7 === "pg";
16892
+ can(statement, dialect6) {
16893
+ return statement.type === "rename_table" && dialect6 === "pg";
17205
16894
  }
17206
16895
  convert(statement) {
17207
16896
  const { tableNameFrom, tableNameTo, toSchema, fromSchema } = statement;
@@ -17211,8 +16900,8 @@ var init_sqlgenerator = __esm({
17211
16900
  }
17212
16901
  };
17213
16902
  SqliteRenameTableConvertor = class extends Convertor {
17214
- can(statement, dialect7) {
17215
- return statement.type === "rename_table" && dialect7 === "sqlite";
16903
+ can(statement, dialect6) {
16904
+ return statement.type === "rename_table" && dialect6 === "sqlite";
17216
16905
  }
17217
16906
  convert(statement) {
17218
16907
  const { tableNameFrom, tableNameTo } = statement;
@@ -17220,8 +16909,8 @@ var init_sqlgenerator = __esm({
17220
16909
  }
17221
16910
  };
17222
16911
  MySqlRenameTableConvertor = class extends Convertor {
17223
- can(statement, dialect7) {
17224
- return statement.type === "rename_table" && dialect7 === "mysql";
16912
+ can(statement, dialect6) {
16913
+ return statement.type === "rename_table" && dialect6 === "mysql";
17225
16914
  }
17226
16915
  convert(statement) {
17227
16916
  const { tableNameFrom, tableNameTo, fromSchema, toSchema } = statement;
@@ -17231,8 +16920,8 @@ var init_sqlgenerator = __esm({
17231
16920
  }
17232
16921
  };
17233
16922
  PgAlterTableRenameColumnConvertor = class extends Convertor {
17234
- can(statement, dialect7) {
17235
- return statement.type === "alter_table_rename_column" && dialect7 === "pg";
16923
+ can(statement, dialect6) {
16924
+ return statement.type === "alter_table_rename_column" && dialect6 === "pg";
17236
16925
  }
17237
16926
  convert(statement) {
17238
16927
  const { tableName, oldColumnName, newColumnName, schema: schema4 } = statement;
@@ -17241,8 +16930,8 @@ var init_sqlgenerator = __esm({
17241
16930
  }
17242
16931
  };
17243
16932
  MySqlAlterTableRenameColumnConvertor = class extends Convertor {
17244
- can(statement, dialect7) {
17245
- return statement.type === "alter_table_rename_column" && dialect7 === "mysql";
16933
+ can(statement, dialect6) {
16934
+ return statement.type === "alter_table_rename_column" && dialect6 === "mysql";
17246
16935
  }
17247
16936
  convert(statement) {
17248
16937
  const { tableName, oldColumnName, newColumnName } = statement;
@@ -17250,8 +16939,8 @@ var init_sqlgenerator = __esm({
17250
16939
  }
17251
16940
  };
17252
16941
  SQLiteAlterTableRenameColumnConvertor = class extends Convertor {
17253
- can(statement, dialect7) {
17254
- return statement.type === "alter_table_rename_column" && dialect7 === "sqlite";
16942
+ can(statement, dialect6) {
16943
+ return statement.type === "alter_table_rename_column" && dialect6 === "sqlite";
17255
16944
  }
17256
16945
  convert(statement) {
17257
16946
  const { tableName, oldColumnName, newColumnName } = statement;
@@ -17259,8 +16948,8 @@ var init_sqlgenerator = __esm({
17259
16948
  }
17260
16949
  };
17261
16950
  PgAlterTableDropColumnConvertor = class extends Convertor {
17262
- can(statement, dialect7) {
17263
- return statement.type === "alter_table_drop_column" && dialect7 === "pg";
16951
+ can(statement, dialect6) {
16952
+ return statement.type === "alter_table_drop_column" && dialect6 === "pg";
17264
16953
  }
17265
16954
  convert(statement) {
17266
16955
  const { tableName, columnName, schema: schema4 } = statement;
@@ -17269,8 +16958,8 @@ var init_sqlgenerator = __esm({
17269
16958
  }
17270
16959
  };
17271
16960
  MySqlAlterTableDropColumnConvertor = class extends Convertor {
17272
- can(statement, dialect7) {
17273
- return statement.type === "alter_table_drop_column" && dialect7 === "mysql";
16961
+ can(statement, dialect6) {
16962
+ return statement.type === "alter_table_drop_column" && dialect6 === "mysql";
17274
16963
  }
17275
16964
  convert(statement) {
17276
16965
  const { tableName, columnName } = statement;
@@ -17278,8 +16967,8 @@ var init_sqlgenerator = __esm({
17278
16967
  }
17279
16968
  };
17280
16969
  SQLiteAlterTableDropColumnConvertor = class extends Convertor {
17281
- can(statement, dialect7) {
17282
- return statement.type === "alter_table_drop_column" && dialect7 === "sqlite";
16970
+ can(statement, dialect6) {
16971
+ return statement.type === "alter_table_drop_column" && dialect6 === "sqlite";
17283
16972
  }
17284
16973
  convert(statement) {
17285
16974
  const { tableName, columnName } = statement;
@@ -17287,8 +16976,8 @@ var init_sqlgenerator = __esm({
17287
16976
  }
17288
16977
  };
17289
16978
  PgAlterTableAddColumnConvertor = class extends Convertor {
17290
- can(statement, dialect7) {
17291
- return statement.type === "alter_table_add_column" && dialect7 === "pg";
16979
+ can(statement, dialect6) {
16980
+ return statement.type === "alter_table_add_column" && dialect6 === "pg";
17292
16981
  }
17293
16982
  convert(statement) {
17294
16983
  const { tableName, column: column4, schema: schema4 } = statement;
@@ -17301,8 +16990,8 @@ var init_sqlgenerator = __esm({
17301
16990
  }
17302
16991
  };
17303
16992
  MySqlAlterTableAddColumnConvertor = class extends Convertor {
17304
- can(statement, dialect7) {
17305
- return statement.type === "alter_table_add_column" && dialect7 === "mysql";
16993
+ can(statement, dialect6) {
16994
+ return statement.type === "alter_table_add_column" && dialect6 === "mysql";
17306
16995
  }
17307
16996
  convert(statement) {
17308
16997
  const { tableName, column: column4 } = statement;
@@ -17316,8 +17005,8 @@ var init_sqlgenerator = __esm({
17316
17005
  }
17317
17006
  };
17318
17007
  SQLiteAlterTableAddColumnConvertor = class extends Convertor {
17319
- can(statement, dialect7) {
17320
- return statement.type === "sqlite_alter_table_add_column" && dialect7 === "sqlite";
17008
+ can(statement, dialect6) {
17009
+ return statement.type === "sqlite_alter_table_add_column" && dialect6 === "sqlite";
17321
17010
  }
17322
17011
  convert(statement) {
17323
17012
  const { tableName, column: column4, referenceData } = statement;
@@ -17331,8 +17020,8 @@ var init_sqlgenerator = __esm({
17331
17020
  }
17332
17021
  };
17333
17022
  PgAlterTableAlterColumnSetTypeConvertor = class extends Convertor {
17334
- can(statement, dialect7) {
17335
- return statement.type === "alter_table_alter_column_set_type" && dialect7 === "pg";
17023
+ can(statement, dialect6) {
17024
+ return statement.type === "alter_table_alter_column_set_type" && dialect6 === "pg";
17336
17025
  }
17337
17026
  convert(statement) {
17338
17027
  const { tableName, columnName, newDataType, schema: schema4 } = statement;
@@ -17341,8 +17030,8 @@ var init_sqlgenerator = __esm({
17341
17030
  }
17342
17031
  };
17343
17032
  SQLiteAlterTableAlterColumnSetTypeConvertor = class extends Convertor {
17344
- can(statement, dialect7) {
17345
- return statement.type === "alter_table_alter_column_set_type" && dialect7 === "sqlite";
17033
+ can(statement, dialect6) {
17034
+ return statement.type === "alter_table_alter_column_set_type" && dialect6 === "sqlite";
17346
17035
  }
17347
17036
  convert(statement) {
17348
17037
  return `/*
@@ -17356,8 +17045,8 @@ var init_sqlgenerator = __esm({
17356
17045
  }
17357
17046
  };
17358
17047
  PgAlterTableAlterColumnSetDefaultConvertor = class extends Convertor {
17359
- can(statement, dialect7) {
17360
- return statement.type === "alter_table_alter_column_set_default" && dialect7 === "pg";
17048
+ can(statement, dialect6) {
17049
+ return statement.type === "alter_table_alter_column_set_default" && dialect6 === "pg";
17361
17050
  }
17362
17051
  convert(statement) {
17363
17052
  const { tableName, columnName, schema: schema4 } = statement;
@@ -17366,8 +17055,8 @@ var init_sqlgenerator = __esm({
17366
17055
  }
17367
17056
  };
17368
17057
  SqliteAlterTableAlterColumnSetDefaultConvertor = class extends Convertor {
17369
- can(statement, dialect7) {
17370
- return statement.type === "alter_table_alter_column_set_default" && dialect7 === "sqlite";
17058
+ can(statement, dialect6) {
17059
+ return statement.type === "alter_table_alter_column_set_default" && dialect6 === "sqlite";
17371
17060
  }
17372
17061
  convert(statement) {
17373
17062
  return `/*
@@ -17381,8 +17070,8 @@ var init_sqlgenerator = __esm({
17381
17070
  }
17382
17071
  };
17383
17072
  PgAlterTableAlterColumnDropDefaultConvertor = class extends Convertor {
17384
- can(statement, dialect7) {
17385
- return statement.type === "alter_table_alter_column_drop_default" && dialect7 === "pg";
17073
+ can(statement, dialect6) {
17074
+ return statement.type === "alter_table_alter_column_drop_default" && dialect6 === "pg";
17386
17075
  }
17387
17076
  convert(statement) {
17388
17077
  const { tableName, columnName, schema: schema4 } = statement;
@@ -17391,24 +17080,24 @@ var init_sqlgenerator = __esm({
17391
17080
  }
17392
17081
  };
17393
17082
  MySqlAlterTableAddPk = class extends Convertor {
17394
- can(statement, dialect7) {
17395
- return statement.type === "alter_table_alter_column_set_pk" && dialect7 === "mysql";
17083
+ can(statement, dialect6) {
17084
+ return statement.type === "alter_table_alter_column_set_pk" && dialect6 === "mysql";
17396
17085
  }
17397
17086
  convert(statement) {
17398
17087
  return `ALTER TABLE \`${statement.tableName}\` ADD PRIMARY KEY (\`${statement.columnName}\`);`;
17399
17088
  }
17400
17089
  };
17401
17090
  MySqlAlterTableDropPk = class extends Convertor {
17402
- can(statement, dialect7) {
17403
- return statement.type === "alter_table_alter_column_drop_pk" && dialect7 === "mysql";
17091
+ can(statement, dialect6) {
17092
+ return statement.type === "alter_table_alter_column_drop_pk" && dialect6 === "mysql";
17404
17093
  }
17405
17094
  convert(statement) {
17406
17095
  return `ALTER TABLE \`${statement.tableName}\` DROP PRIMARY KEY`;
17407
17096
  }
17408
17097
  };
17409
17098
  MySqlModifyColumn = class extends Convertor {
17410
- can(statement, dialect7) {
17411
- 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";
17099
+ can(statement, dialect6) {
17100
+ 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";
17412
17101
  }
17413
17102
  convert(statement) {
17414
17103
  const { tableName, columnName } = statement;
@@ -17478,8 +17167,8 @@ var init_sqlgenerator = __esm({
17478
17167
  }
17479
17168
  };
17480
17169
  SqliteAlterTableAlterColumnDropDefaultConvertor = class extends Convertor {
17481
- can(statement, dialect7) {
17482
- return statement.type === "alter_table_alter_column_drop_default" && dialect7 === "sqlite";
17170
+ can(statement, dialect6) {
17171
+ return statement.type === "alter_table_alter_column_drop_default" && dialect6 === "sqlite";
17483
17172
  }
17484
17173
  convert(statement) {
17485
17174
  return `/*
@@ -17493,8 +17182,8 @@ var init_sqlgenerator = __esm({
17493
17182
  }
17494
17183
  };
17495
17184
  PgAlterTableCreateCompositePrimaryKeyConvertor = class extends Convertor {
17496
- can(statement, dialect7) {
17497
- return statement.type === "create_composite_pk" && dialect7 === "pg";
17185
+ can(statement, dialect6) {
17186
+ return statement.type === "create_composite_pk" && dialect6 === "pg";
17498
17187
  }
17499
17188
  convert(statement) {
17500
17189
  const { name, columns } = PgSquasher.unsquashPK(statement.data);
@@ -17503,8 +17192,8 @@ var init_sqlgenerator = __esm({
17503
17192
  }
17504
17193
  };
17505
17194
  PgAlterTableDeleteCompositePrimaryKeyConvertor = class extends Convertor {
17506
- can(statement, dialect7) {
17507
- return statement.type === "delete_composite_pk" && dialect7 === "pg";
17195
+ can(statement, dialect6) {
17196
+ return statement.type === "delete_composite_pk" && dialect6 === "pg";
17508
17197
  }
17509
17198
  convert(statement) {
17510
17199
  const { name, columns } = PgSquasher.unsquashPK(statement.data);
@@ -17513,8 +17202,8 @@ var init_sqlgenerator = __esm({
17513
17202
  }
17514
17203
  };
17515
17204
  PgAlterTableAlterCompositePrimaryKeyConvertor = class extends Convertor {
17516
- can(statement, dialect7) {
17517
- return statement.type === "alter_composite_pk" && dialect7 === "pg";
17205
+ can(statement, dialect6) {
17206
+ return statement.type === "alter_composite_pk" && dialect6 === "pg";
17518
17207
  }
17519
17208
  convert(statement) {
17520
17209
  const { name, columns } = PgSquasher.unsquashPK(statement.old);
@@ -17527,8 +17216,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17527
17216
  }
17528
17217
  };
17529
17218
  MySqlAlterTableCreateCompositePrimaryKeyConvertor = class extends Convertor {
17530
- can(statement, dialect7) {
17531
- return statement.type === "create_composite_pk" && dialect7 === "mysql";
17219
+ can(statement, dialect6) {
17220
+ return statement.type === "create_composite_pk" && dialect6 === "mysql";
17532
17221
  }
17533
17222
  convert(statement) {
17534
17223
  const { name, columns } = MySqlSquasher.unsquashPK(statement.data);
@@ -17536,8 +17225,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17536
17225
  }
17537
17226
  };
17538
17227
  MySqlAlterTableDeleteCompositePrimaryKeyConvertor = class extends Convertor {
17539
- can(statement, dialect7) {
17540
- return statement.type === "delete_composite_pk" && dialect7 === "mysql";
17228
+ can(statement, dialect6) {
17229
+ return statement.type === "delete_composite_pk" && dialect6 === "mysql";
17541
17230
  }
17542
17231
  convert(statement) {
17543
17232
  const { name, columns } = MySqlSquasher.unsquashPK(statement.data);
@@ -17545,8 +17234,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17545
17234
  }
17546
17235
  };
17547
17236
  MySqlAlterTableAlterCompositePrimaryKeyConvertor = class extends Convertor {
17548
- can(statement, dialect7) {
17549
- return statement.type === "alter_composite_pk" && dialect7 === "mysql";
17237
+ can(statement, dialect6) {
17238
+ return statement.type === "alter_composite_pk" && dialect6 === "mysql";
17550
17239
  }
17551
17240
  convert(statement) {
17552
17241
  const { name, columns } = MySqlSquasher.unsquashPK(statement.old);
@@ -17557,8 +17246,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17557
17246
  }
17558
17247
  };
17559
17248
  SqliteAlterTableCreateCompositePrimaryKeyConvertor = class extends Convertor {
17560
- can(statement, dialect7) {
17561
- return statement.type === "create_composite_pk" && dialect7 === "sqlite";
17249
+ can(statement, dialect6) {
17250
+ return statement.type === "create_composite_pk" && dialect6 === "sqlite";
17562
17251
  }
17563
17252
  convert(statement) {
17564
17253
  let msg = "/*\n";
@@ -17584,8 +17273,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17584
17273
  }
17585
17274
  };
17586
17275
  SqliteAlterTableDeleteCompositePrimaryKeyConvertor = class extends Convertor {
17587
- can(statement, dialect7) {
17588
- return statement.type === "delete_composite_pk" && dialect7 === "sqlite";
17276
+ can(statement, dialect6) {
17277
+ return statement.type === "delete_composite_pk" && dialect6 === "sqlite";
17589
17278
  }
17590
17279
  convert(statement) {
17591
17280
  let msg = "/*\n";
@@ -17611,8 +17300,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17611
17300
  }
17612
17301
  };
17613
17302
  SqliteAlterTableAlterCompositePrimaryKeyConvertor = class extends Convertor {
17614
- can(statement, dialect7) {
17615
- return statement.type === "alter_composite_pk" && dialect7 === "sqlite";
17303
+ can(statement, dialect6) {
17304
+ return statement.type === "alter_composite_pk" && dialect6 === "sqlite";
17616
17305
  }
17617
17306
  convert(statement) {
17618
17307
  let msg = "/*\n";
@@ -17636,8 +17325,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17636
17325
  }
17637
17326
  };
17638
17327
  PgAlterTableAlterColumnSetPrimaryKeyConvertor = class extends Convertor {
17639
- can(statement, dialect7) {
17640
- return statement.type === "alter_table_alter_column_set_pk" && dialect7 === "pg";
17328
+ can(statement, dialect6) {
17329
+ return statement.type === "alter_table_alter_column_set_pk" && dialect6 === "pg";
17641
17330
  }
17642
17331
  convert(statement) {
17643
17332
  const { tableName, columnName } = statement;
@@ -17646,8 +17335,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17646
17335
  }
17647
17336
  };
17648
17337
  PgAlterTableAlterColumnDropPrimaryKeyConvertor = class extends Convertor {
17649
- can(statement, dialect7) {
17650
- return statement.type === "alter_table_alter_column_drop_pk" && dialect7 === "pg";
17338
+ can(statement, dialect6) {
17339
+ return statement.type === "alter_table_alter_column_drop_pk" && dialect6 === "pg";
17651
17340
  }
17652
17341
  convert(statement) {
17653
17342
  const { tableName, columnName, schema: schema4 } = statement;
@@ -17670,8 +17359,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17670
17359
  }
17671
17360
  };
17672
17361
  PgAlterTableAlterColumnSetNotNullConvertor = class extends Convertor {
17673
- can(statement, dialect7) {
17674
- return statement.type === "alter_table_alter_column_set_notnull" && dialect7 === "pg";
17362
+ can(statement, dialect6) {
17363
+ return statement.type === "alter_table_alter_column_set_notnull" && dialect6 === "pg";
17675
17364
  }
17676
17365
  convert(statement) {
17677
17366
  const { tableName, columnName } = statement;
@@ -17680,8 +17369,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17680
17369
  }
17681
17370
  };
17682
17371
  SqliteAlterTableAlterColumnSetNotNullConvertor = class extends Convertor {
17683
- can(statement, dialect7) {
17684
- return statement.type === "alter_table_alter_column_set_notnull" && dialect7 === "sqlite";
17372
+ can(statement, dialect6) {
17373
+ return statement.type === "alter_table_alter_column_set_notnull" && dialect6 === "sqlite";
17685
17374
  }
17686
17375
  convert(statement) {
17687
17376
  return `/*
@@ -17695,8 +17384,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17695
17384
  }
17696
17385
  };
17697
17386
  SqliteAlterTableAlterColumnSetAutoincrementConvertor = class extends Convertor {
17698
- can(statement, dialect7) {
17699
- return statement.type === "alter_table_alter_column_set_autoincrement" && dialect7 === "sqlite";
17387
+ can(statement, dialect6) {
17388
+ return statement.type === "alter_table_alter_column_set_autoincrement" && dialect6 === "sqlite";
17700
17389
  }
17701
17390
  convert(statement) {
17702
17391
  return `/*
@@ -17710,8 +17399,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17710
17399
  }
17711
17400
  };
17712
17401
  SqliteAlterTableAlterColumnDropAutoincrementConvertor = class extends Convertor {
17713
- can(statement, dialect7) {
17714
- return statement.type === "alter_table_alter_column_drop_autoincrement" && dialect7 === "sqlite";
17402
+ can(statement, dialect6) {
17403
+ return statement.type === "alter_table_alter_column_drop_autoincrement" && dialect6 === "sqlite";
17715
17404
  }
17716
17405
  convert(statement) {
17717
17406
  return `/*
@@ -17725,8 +17414,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17725
17414
  }
17726
17415
  };
17727
17416
  PgAlterTableAlterColumnDropNotNullConvertor = class extends Convertor {
17728
- can(statement, dialect7) {
17729
- return statement.type === "alter_table_alter_column_drop_notnull" && dialect7 === "pg";
17417
+ can(statement, dialect6) {
17418
+ return statement.type === "alter_table_alter_column_drop_notnull" && dialect6 === "pg";
17730
17419
  }
17731
17420
  convert(statement) {
17732
17421
  const { tableName, columnName } = statement;
@@ -17735,8 +17424,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17735
17424
  }
17736
17425
  };
17737
17426
  SqliteAlterTableAlterColumnDropNotNullConvertor = class extends Convertor {
17738
- can(statement, dialect7) {
17739
- return statement.type === "alter_table_alter_column_drop_notnull" && dialect7 === "sqlite";
17427
+ can(statement, dialect6) {
17428
+ return statement.type === "alter_table_alter_column_drop_notnull" && dialect6 === "sqlite";
17740
17429
  }
17741
17430
  convert(statement) {
17742
17431
  return `/*
@@ -17750,8 +17439,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17750
17439
  }
17751
17440
  };
17752
17441
  PgCreateForeignKeyConvertor = class extends Convertor {
17753
- can(statement, dialect7) {
17754
- return statement.type === "create_reference" && dialect7 === "pg";
17442
+ can(statement, dialect6) {
17443
+ return statement.type === "create_reference" && dialect6 === "pg";
17755
17444
  }
17756
17445
  convert(statement) {
17757
17446
  const {
@@ -17780,8 +17469,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17780
17469
  }
17781
17470
  };
17782
17471
  SqliteCreateForeignKeyConvertor = class extends Convertor {
17783
- can(statement, dialect7) {
17784
- return statement.type === "create_reference" && dialect7 === "sqlite";
17472
+ can(statement, dialect6) {
17473
+ return statement.type === "create_reference" && dialect6 === "sqlite";
17785
17474
  }
17786
17475
  convert(statement) {
17787
17476
  return `/*
@@ -17794,8 +17483,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17794
17483
  }
17795
17484
  };
17796
17485
  MySqlCreateForeignKeyConvertor = class extends Convertor {
17797
- can(statement, dialect7) {
17798
- return statement.type === "create_reference" && dialect7 === "mysql";
17486
+ can(statement, dialect6) {
17487
+ return statement.type === "create_reference" && dialect6 === "mysql";
17799
17488
  }
17800
17489
  convert(statement) {
17801
17490
  const {
@@ -17815,8 +17504,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17815
17504
  }
17816
17505
  };
17817
17506
  PgAlterForeignKeyConvertor = class extends Convertor {
17818
- can(statement, dialect7) {
17819
- return statement.type === "alter_reference" && dialect7 === "pg";
17507
+ can(statement, dialect6) {
17508
+ return statement.type === "alter_reference" && dialect6 === "pg";
17820
17509
  }
17821
17510
  convert(statement) {
17822
17511
  const newFk = PgSquasher.unsquashFK(statement.data);
@@ -17840,8 +17529,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17840
17529
  }
17841
17530
  };
17842
17531
  SqliteAlterForeignKeyConvertor = class extends Convertor {
17843
- can(statement, dialect7) {
17844
- return statement.type === "alter_reference" && dialect7 === "sqlite";
17532
+ can(statement, dialect6) {
17533
+ return statement.type === "alter_reference" && dialect6 === "sqlite";
17845
17534
  }
17846
17535
  convert(statement) {
17847
17536
  return `/*
@@ -17854,8 +17543,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17854
17543
  }
17855
17544
  };
17856
17545
  PgDeleteForeignKeyConvertor = class extends Convertor {
17857
- can(statement, dialect7) {
17858
- return statement.type === "delete_reference" && dialect7 === "pg";
17546
+ can(statement, dialect6) {
17547
+ return statement.type === "delete_reference" && dialect6 === "pg";
17859
17548
  }
17860
17549
  convert(statement) {
17861
17550
  const tableFrom = statement.tableName;
@@ -17866,8 +17555,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17866
17555
  }
17867
17556
  };
17868
17557
  SqliteDeleteForeignKeyConvertor = class extends Convertor {
17869
- can(statement, dialect7) {
17870
- return statement.type === "delete_reference" && dialect7 === "sqlite";
17558
+ can(statement, dialect6) {
17559
+ return statement.type === "delete_reference" && dialect6 === "sqlite";
17871
17560
  }
17872
17561
  convert(statement) {
17873
17562
  return `/*
@@ -17880,8 +17569,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17880
17569
  }
17881
17570
  };
17882
17571
  MySqlDeleteForeignKeyConvertor = class extends Convertor {
17883
- can(statement, dialect7) {
17884
- return statement.type === "delete_reference" && dialect7 === "mysql";
17572
+ can(statement, dialect6) {
17573
+ return statement.type === "delete_reference" && dialect6 === "mysql";
17885
17574
  }
17886
17575
  convert(statement) {
17887
17576
  const tableFrom = statement.tableName;
@@ -17891,8 +17580,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17891
17580
  }
17892
17581
  };
17893
17582
  CreatePgIndexConvertor = class extends Convertor {
17894
- can(statement, dialect7) {
17895
- return statement.type === "create_index" && dialect7 === "pg";
17583
+ can(statement, dialect6) {
17584
+ return statement.type === "create_index" && dialect6 === "pg";
17896
17585
  }
17897
17586
  convert(statement) {
17898
17587
  const { name, columns, isUnique } = PgSquasher.unsquashIdx(statement.data);
@@ -17903,8 +17592,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17903
17592
  }
17904
17593
  };
17905
17594
  CreateMySqlIndexConvertor = class extends Convertor {
17906
- can(statement, dialect7) {
17907
- return statement.type === "create_index" && dialect7 === "mysql";
17595
+ can(statement, dialect6) {
17596
+ return statement.type === "create_index" && dialect6 === "mysql";
17908
17597
  }
17909
17598
  convert(statement) {
17910
17599
  const { name, columns, isUnique } = MySqlSquasher.unsquashIdx(
@@ -17916,8 +17605,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17916
17605
  }
17917
17606
  };
17918
17607
  CreateSqliteIndexConvertor = class extends Convertor {
17919
- can(statement, dialect7) {
17920
- return statement.type === "create_index" && dialect7 === "sqlite";
17608
+ can(statement, dialect6) {
17609
+ return statement.type === "create_index" && dialect6 === "sqlite";
17921
17610
  }
17922
17611
  convert(statement) {
17923
17612
  const { name, columns, isUnique, where } = SQLiteSquasher.unsquashIdx(
@@ -17930,8 +17619,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17930
17619
  }
17931
17620
  };
17932
17621
  PgDropIndexConvertor = class extends Convertor {
17933
- can(statement, dialect7) {
17934
- return statement.type === "drop_index" && dialect7 === "pg";
17622
+ can(statement, dialect6) {
17623
+ return statement.type === "drop_index" && dialect6 === "pg";
17935
17624
  }
17936
17625
  convert(statement) {
17937
17626
  const { name } = PgSquasher.unsquashIdx(statement.data);
@@ -17939,8 +17628,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17939
17628
  }
17940
17629
  };
17941
17630
  PgCreateSchemaConvertor = class extends Convertor {
17942
- can(statement, dialect7) {
17943
- return statement.type === "create_schema" && dialect7 === "pg";
17631
+ can(statement, dialect6) {
17632
+ return statement.type === "create_schema" && dialect6 === "pg";
17944
17633
  }
17945
17634
  convert(statement) {
17946
17635
  const { name } = statement;
@@ -17949,8 +17638,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17949
17638
  }
17950
17639
  };
17951
17640
  PgRenameSchemaConvertor = class extends Convertor {
17952
- can(statement, dialect7) {
17953
- return statement.type === "rename_schema" && dialect7 === "pg";
17641
+ can(statement, dialect6) {
17642
+ return statement.type === "rename_schema" && dialect6 === "pg";
17954
17643
  }
17955
17644
  convert(statement) {
17956
17645
  const { from, to } = statement;
@@ -17959,8 +17648,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17959
17648
  }
17960
17649
  };
17961
17650
  PgDropSchemaConvertor = class extends Convertor {
17962
- can(statement, dialect7) {
17963
- return statement.type === "drop_schema" && dialect7 === "pg";
17651
+ can(statement, dialect6) {
17652
+ return statement.type === "drop_schema" && dialect6 === "pg";
17964
17653
  }
17965
17654
  convert(statement) {
17966
17655
  const { name } = statement;
@@ -17969,8 +17658,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17969
17658
  }
17970
17659
  };
17971
17660
  PgAlterTableSetSchemaConvertor = class extends Convertor {
17972
- can(statement, dialect7) {
17973
- return statement.type === "alter_table_set_schema" && dialect7 === "pg";
17661
+ can(statement, dialect6) {
17662
+ return statement.type === "alter_table_set_schema" && dialect6 === "pg";
17974
17663
  }
17975
17664
  convert(statement) {
17976
17665
  const { tableName, schema: schema4 } = statement;
@@ -17979,8 +17668,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17979
17668
  }
17980
17669
  };
17981
17670
  PgAlterTableSetNewSchemaConvertor = class extends Convertor {
17982
- can(statement, dialect7) {
17983
- return statement.type === "alter_table_set_new_schema" && dialect7 === "pg";
17671
+ can(statement, dialect6) {
17672
+ return statement.type === "alter_table_set_new_schema" && dialect6 === "pg";
17984
17673
  }
17985
17674
  convert(statement) {
17986
17675
  const { tableName, to, from } = statement;
@@ -17990,8 +17679,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
17990
17679
  }
17991
17680
  };
17992
17681
  PgAlterTableRemoveFromSchemaConvertor = class extends Convertor {
17993
- can(statement, dialect7) {
17994
- return statement.type === "alter_table_remove_from_schema" && dialect7 === "pg";
17682
+ can(statement, dialect6) {
17683
+ return statement.type === "alter_table_remove_from_schema" && dialect6 === "pg";
17995
17684
  }
17996
17685
  convert(statement) {
17997
17686
  const { tableName, schema: schema4 } = statement;
@@ -18001,8 +17690,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
18001
17690
  }
18002
17691
  };
18003
17692
  SqliteDropIndexConvertor = class extends Convertor {
18004
- can(statement, dialect7) {
18005
- return statement.type === "drop_index" && dialect7 === "sqlite";
17693
+ can(statement, dialect6) {
17694
+ return statement.type === "drop_index" && dialect6 === "sqlite";
18006
17695
  }
18007
17696
  convert(statement) {
18008
17697
  const { name } = PgSquasher.unsquashIdx(statement.data);
@@ -18010,8 +17699,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
18010
17699
  }
18011
17700
  };
18012
17701
  MysqlCreateSchemaConvertor = class extends Convertor {
18013
- can(statement, dialect7) {
18014
- return statement.type === "create_schema" && dialect7 === "mysql";
17702
+ can(statement, dialect6) {
17703
+ return statement.type === "create_schema" && dialect6 === "mysql";
18015
17704
  }
18016
17705
  convert(statement) {
18017
17706
  const { name } = statement;
@@ -18020,8 +17709,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
18020
17709
  }
18021
17710
  };
18022
17711
  MysqlDropSchemaConvertor = class extends Convertor {
18023
- can(statement, dialect7) {
18024
- return statement.type === "drop_schema" && dialect7 === "mysql";
17712
+ can(statement, dialect6) {
17713
+ return statement.type === "drop_schema" && dialect6 === "mysql";
18025
17714
  }
18026
17715
  convert(statement) {
18027
17716
  const { name } = statement;
@@ -18030,8 +17719,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
18030
17719
  }
18031
17720
  };
18032
17721
  MysqlAlterTableSetSchemaConvertor = class extends Convertor {
18033
- can(statement, dialect7) {
18034
- return statement.type === "alter_table_set_schema" && dialect7 === "mysql";
17722
+ can(statement, dialect6) {
17723
+ return statement.type === "alter_table_set_schema" && dialect6 === "mysql";
18035
17724
  }
18036
17725
  convert(statement) {
18037
17726
  const { tableName, schema: schema4 } = statement;
@@ -18042,8 +17731,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
18042
17731
  }
18043
17732
  };
18044
17733
  MysqlAlterTableSetNewSchemaConvertor = class extends Convertor {
18045
- can(statement, dialect7) {
18046
- return statement.type === "alter_table_set_new_schema" && dialect7 === "mysql";
17734
+ can(statement, dialect6) {
17735
+ return statement.type === "alter_table_set_new_schema" && dialect6 === "mysql";
18047
17736
  }
18048
17737
  convert(statement) {
18049
17738
  const { tableName, to, from } = statement;
@@ -18054,8 +17743,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
18054
17743
  }
18055
17744
  };
18056
17745
  MysqlAlterTableRemoveFromSchemaConvertor = class extends Convertor {
18057
- can(statement, dialect7) {
18058
- return statement.type === "alter_table_remove_from_schema" && dialect7 === "mysql";
17746
+ can(statement, dialect6) {
17747
+ return statement.type === "alter_table_remove_from_schema" && dialect6 === "mysql";
18059
17748
  }
18060
17749
  convert(statement) {
18061
17750
  const { tableName, schema: schema4 } = statement;
@@ -18066,8 +17755,8 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
18066
17755
  }
18067
17756
  };
18068
17757
  MySqlDropIndexConvertor = class extends Convertor {
18069
- can(statement, dialect7) {
18070
- return statement.type === "drop_index" && dialect7 === "mysql";
17758
+ can(statement, dialect6) {
17759
+ return statement.type === "drop_index" && dialect6 === "mysql";
18071
17760
  }
18072
17761
  convert(statement) {
18073
17762
  const tableName = typeof statement.schema === "undefined" ? `\`${statement.tableName}\`` : `\`${statement.schema}\`.\`${statement.tableName}\``;
@@ -18153,10 +17842,10 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
18153
17842
  convertors.push(new MySqlAlterTableCreateCompositePrimaryKeyConvertor());
18154
17843
  convertors.push(new MySqlAlterTableAddPk());
18155
17844
  convertors.push(new MySqlAlterTableAlterCompositePrimaryKeyConvertor());
18156
- fromJson = (statements, dialect7) => {
17845
+ fromJson = (statements, dialect6) => {
18157
17846
  const result = statements.map((statement) => {
18158
17847
  const filtered = convertors.filter((it) => {
18159
- return it.can(statement, dialect7);
17848
+ return it.can(statement, dialect6);
18160
17849
  });
18161
17850
  const convertor = filtered.length === 1 ? filtered[0] : void 0;
18162
17851
  if (!convertor) {
@@ -18197,7 +17886,6 @@ drop type __venum;
18197
17886
  var import_hanji5, Select;
18198
17887
  var init_selector_ui = __esm({
18199
17888
  "src/cli/selector-ui.ts"() {
18200
- "use strict";
18201
17889
  init_source();
18202
17890
  import_hanji5 = __toESM(require_hanji());
18203
17891
  Select = class extends import_hanji5.Prompt {
@@ -34799,7 +34487,6 @@ __export(drivers_exports, {
34799
34487
  var import_drizzle_orm9, DrizzleDbClient, DrizzleORMPgClient, DrizzleORMMySQLClient, DrizzleORMSQLiteClient, BetterSqlite, MySQL2Client, TursoSqlite, PgPostgres;
34800
34488
  var init_drivers = __esm({
34801
34489
  "src/drivers/index.ts"() {
34802
- "use strict";
34803
34490
  import_drizzle_orm9 = require("drizzle-orm");
34804
34491
  DrizzleDbClient = class {
34805
34492
  constructor(db) {
@@ -34881,7 +34568,6 @@ __export(mysqlPushUtils_exports, {
34881
34568
  var import_hanji9, filterStatements, logSuggestionsAndReturn2;
34882
34569
  var init_mysqlPushUtils = __esm({
34883
34570
  "src/cli/commands/mysqlPushUtils.ts"() {
34884
- "use strict";
34885
34571
  init_source();
34886
34572
  import_hanji9 = __toESM(require_hanji());
34887
34573
  init_mysqlSchema();
@@ -35258,7 +34944,7 @@ String.prototype.camelCase = function() {
35258
34944
  return camelCase(String(this));
35259
34945
  };
35260
34946
  String.prototype.concatIf = function(it, condition) {
35261
- return condition ? `${this}${it}` : String(this);
34947
+ return condition ? `${this}${it}` : this;
35262
34948
  };
35263
34949
  Array.prototype.random = function() {
35264
34950
  return this[~~(Math.random() * this.length)];