drizzle-kit 0.17.5 → 0.17.6-4805b4b

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/index.d.ts +14 -0
  2. package/index.js +20226 -19033
  3. package/package.json +9 -5
  4. package/utils.js +696 -641
package/utils.js CHANGED
@@ -28,6 +28,508 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  ));
29
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
30
 
31
+ // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/ansi-styles/index.js
32
+ function assembleStyles() {
33
+ const codes = /* @__PURE__ */ new Map();
34
+ for (const [groupName, group] of Object.entries(styles)) {
35
+ for (const [styleName, style] of Object.entries(group)) {
36
+ styles[styleName] = {
37
+ open: `\x1B[${style[0]}m`,
38
+ close: `\x1B[${style[1]}m`
39
+ };
40
+ group[styleName] = styles[styleName];
41
+ codes.set(style[0], style[1]);
42
+ }
43
+ Object.defineProperty(styles, groupName, {
44
+ value: group,
45
+ enumerable: false
46
+ });
47
+ }
48
+ Object.defineProperty(styles, "codes", {
49
+ value: codes,
50
+ enumerable: false
51
+ });
52
+ styles.color.close = "\x1B[39m";
53
+ styles.bgColor.close = "\x1B[49m";
54
+ styles.color.ansi = wrapAnsi16();
55
+ styles.color.ansi256 = wrapAnsi256();
56
+ styles.color.ansi16m = wrapAnsi16m();
57
+ styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
58
+ styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
59
+ styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
60
+ Object.defineProperties(styles, {
61
+ rgbToAnsi256: {
62
+ value(red, green, blue) {
63
+ if (red === green && green === blue) {
64
+ if (red < 8) {
65
+ return 16;
66
+ }
67
+ if (red > 248) {
68
+ return 231;
69
+ }
70
+ return Math.round((red - 8) / 247 * 24) + 232;
71
+ }
72
+ return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
73
+ },
74
+ enumerable: false
75
+ },
76
+ hexToRgb: {
77
+ value(hex) {
78
+ const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
79
+ if (!matches) {
80
+ return [0, 0, 0];
81
+ }
82
+ let [colorString] = matches;
83
+ if (colorString.length === 3) {
84
+ colorString = [...colorString].map((character) => character + character).join("");
85
+ }
86
+ const integer = Number.parseInt(colorString, 16);
87
+ return [
88
+ integer >> 16 & 255,
89
+ integer >> 8 & 255,
90
+ integer & 255
91
+ ];
92
+ },
93
+ enumerable: false
94
+ },
95
+ hexToAnsi256: {
96
+ value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
97
+ enumerable: false
98
+ },
99
+ ansi256ToAnsi: {
100
+ value(code) {
101
+ if (code < 8) {
102
+ return 30 + code;
103
+ }
104
+ if (code < 16) {
105
+ return 90 + (code - 8);
106
+ }
107
+ let red;
108
+ let green;
109
+ let blue;
110
+ if (code >= 232) {
111
+ red = ((code - 232) * 10 + 8) / 255;
112
+ green = red;
113
+ blue = red;
114
+ } else {
115
+ code -= 16;
116
+ const remainder = code % 36;
117
+ red = Math.floor(code / 36) / 5;
118
+ green = Math.floor(remainder / 6) / 5;
119
+ blue = remainder % 6 / 5;
120
+ }
121
+ const value = Math.max(red, green, blue) * 2;
122
+ if (value === 0) {
123
+ return 30;
124
+ }
125
+ let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
126
+ if (value === 2) {
127
+ result += 60;
128
+ }
129
+ return result;
130
+ },
131
+ enumerable: false
132
+ },
133
+ rgbToAnsi: {
134
+ value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
135
+ enumerable: false
136
+ },
137
+ hexToAnsi: {
138
+ value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
139
+ enumerable: false
140
+ }
141
+ });
142
+ return styles;
143
+ }
144
+ var ANSI_BACKGROUND_OFFSET, wrapAnsi16, wrapAnsi256, wrapAnsi16m, styles, modifierNames, foregroundColorNames, backgroundColorNames, colorNames, ansiStyles, ansi_styles_default;
145
+ var init_ansi_styles = __esm({
146
+ "node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/ansi-styles/index.js"() {
147
+ ANSI_BACKGROUND_OFFSET = 10;
148
+ wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
149
+ wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
150
+ wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
151
+ styles = {
152
+ modifier: {
153
+ reset: [0, 0],
154
+ bold: [1, 22],
155
+ dim: [2, 22],
156
+ italic: [3, 23],
157
+ underline: [4, 24],
158
+ overline: [53, 55],
159
+ inverse: [7, 27],
160
+ hidden: [8, 28],
161
+ strikethrough: [9, 29]
162
+ },
163
+ color: {
164
+ black: [30, 39],
165
+ red: [31, 39],
166
+ green: [32, 39],
167
+ yellow: [33, 39],
168
+ blue: [34, 39],
169
+ magenta: [35, 39],
170
+ cyan: [36, 39],
171
+ white: [37, 39],
172
+ blackBright: [90, 39],
173
+ gray: [90, 39],
174
+ grey: [90, 39],
175
+ redBright: [91, 39],
176
+ greenBright: [92, 39],
177
+ yellowBright: [93, 39],
178
+ blueBright: [94, 39],
179
+ magentaBright: [95, 39],
180
+ cyanBright: [96, 39],
181
+ whiteBright: [97, 39]
182
+ },
183
+ bgColor: {
184
+ bgBlack: [40, 49],
185
+ bgRed: [41, 49],
186
+ bgGreen: [42, 49],
187
+ bgYellow: [43, 49],
188
+ bgBlue: [44, 49],
189
+ bgMagenta: [45, 49],
190
+ bgCyan: [46, 49],
191
+ bgWhite: [47, 49],
192
+ bgBlackBright: [100, 49],
193
+ bgGray: [100, 49],
194
+ bgGrey: [100, 49],
195
+ bgRedBright: [101, 49],
196
+ bgGreenBright: [102, 49],
197
+ bgYellowBright: [103, 49],
198
+ bgBlueBright: [104, 49],
199
+ bgMagentaBright: [105, 49],
200
+ bgCyanBright: [106, 49],
201
+ bgWhiteBright: [107, 49]
202
+ }
203
+ };
204
+ modifierNames = Object.keys(styles.modifier);
205
+ foregroundColorNames = Object.keys(styles.color);
206
+ backgroundColorNames = Object.keys(styles.bgColor);
207
+ colorNames = [...foregroundColorNames, ...backgroundColorNames];
208
+ ansiStyles = assembleStyles();
209
+ ansi_styles_default = ansiStyles;
210
+ }
211
+ });
212
+
213
+ // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/supports-color/index.js
214
+ function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : import_node_process.default.argv) {
215
+ const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
216
+ const position = argv.indexOf(prefix + flag);
217
+ const terminatorPosition = argv.indexOf("--");
218
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
219
+ }
220
+ function envForceColor() {
221
+ if ("FORCE_COLOR" in env) {
222
+ if (env.FORCE_COLOR === "true") {
223
+ return 1;
224
+ }
225
+ if (env.FORCE_COLOR === "false") {
226
+ return 0;
227
+ }
228
+ return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
229
+ }
230
+ }
231
+ function translateLevel(level) {
232
+ if (level === 0) {
233
+ return false;
234
+ }
235
+ return {
236
+ level,
237
+ hasBasic: true,
238
+ has256: level >= 2,
239
+ has16m: level >= 3
240
+ };
241
+ }
242
+ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
243
+ const noFlagForceColor = envForceColor();
244
+ if (noFlagForceColor !== void 0) {
245
+ flagForceColor = noFlagForceColor;
246
+ }
247
+ const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
248
+ if (forceColor === 0) {
249
+ return 0;
250
+ }
251
+ if (sniffFlags) {
252
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
253
+ return 3;
254
+ }
255
+ if (hasFlag("color=256")) {
256
+ return 2;
257
+ }
258
+ }
259
+ if ("TF_BUILD" in env && "AGENT_NAME" in env) {
260
+ return 1;
261
+ }
262
+ if (haveStream && !streamIsTTY && forceColor === void 0) {
263
+ return 0;
264
+ }
265
+ const min = forceColor || 0;
266
+ if (env.TERM === "dumb") {
267
+ return min;
268
+ }
269
+ if (import_node_process.default.platform === "win32") {
270
+ const osRelease = import_node_os.default.release().split(".");
271
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
272
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
273
+ }
274
+ return 1;
275
+ }
276
+ if ("CI" in env) {
277
+ if ("GITHUB_ACTIONS" in env) {
278
+ return 3;
279
+ }
280
+ if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
281
+ return 1;
282
+ }
283
+ return min;
284
+ }
285
+ if ("TEAMCITY_VERSION" in env) {
286
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
287
+ }
288
+ if (env.COLORTERM === "truecolor") {
289
+ return 3;
290
+ }
291
+ if (env.TERM === "xterm-kitty") {
292
+ return 3;
293
+ }
294
+ if ("TERM_PROGRAM" in env) {
295
+ const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
296
+ switch (env.TERM_PROGRAM) {
297
+ case "iTerm.app": {
298
+ return version >= 3 ? 3 : 2;
299
+ }
300
+ case "Apple_Terminal": {
301
+ return 2;
302
+ }
303
+ }
304
+ }
305
+ if (/-256(color)?$/i.test(env.TERM)) {
306
+ return 2;
307
+ }
308
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
309
+ return 1;
310
+ }
311
+ if ("COLORTERM" in env) {
312
+ return 1;
313
+ }
314
+ return min;
315
+ }
316
+ function createSupportsColor(stream, options = {}) {
317
+ const level = _supportsColor(stream, {
318
+ streamIsTTY: stream && stream.isTTY,
319
+ ...options
320
+ });
321
+ return translateLevel(level);
322
+ }
323
+ var import_node_process, import_node_os, import_node_tty, env, flagForceColor, supportsColor, supports_color_default;
324
+ var init_supports_color = __esm({
325
+ "node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/supports-color/index.js"() {
326
+ import_node_process = __toESM(require("process"), 1);
327
+ import_node_os = __toESM(require("os"), 1);
328
+ import_node_tty = __toESM(require("tty"), 1);
329
+ ({ env } = import_node_process.default);
330
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
331
+ flagForceColor = 0;
332
+ } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
333
+ flagForceColor = 1;
334
+ }
335
+ supportsColor = {
336
+ stdout: createSupportsColor({ isTTY: import_node_tty.default.isatty(1) }),
337
+ stderr: createSupportsColor({ isTTY: import_node_tty.default.isatty(2) })
338
+ };
339
+ supports_color_default = supportsColor;
340
+ }
341
+ });
342
+
343
+ // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/utilities.js
344
+ function stringReplaceAll(string, substring, replacer) {
345
+ let index4 = string.indexOf(substring);
346
+ if (index4 === -1) {
347
+ return string;
348
+ }
349
+ const substringLength = substring.length;
350
+ let endIndex = 0;
351
+ let returnValue = "";
352
+ do {
353
+ returnValue += string.slice(endIndex, index4) + substring + replacer;
354
+ endIndex = index4 + substringLength;
355
+ index4 = string.indexOf(substring, endIndex);
356
+ } while (index4 !== -1);
357
+ returnValue += string.slice(endIndex);
358
+ return returnValue;
359
+ }
360
+ function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index4) {
361
+ let endIndex = 0;
362
+ let returnValue = "";
363
+ do {
364
+ const gotCR = string[index4 - 1] === "\r";
365
+ returnValue += string.slice(endIndex, gotCR ? index4 - 1 : index4) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
366
+ endIndex = index4 + 1;
367
+ index4 = string.indexOf("\n", endIndex);
368
+ } while (index4 !== -1);
369
+ returnValue += string.slice(endIndex);
370
+ return returnValue;
371
+ }
372
+ var init_utilities = __esm({
373
+ "node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/utilities.js"() {
374
+ }
375
+ });
376
+
377
+ // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/index.js
378
+ function createChalk(options) {
379
+ return chalkFactory(options);
380
+ }
381
+ var stdoutColor, stderrColor, GENERATOR, STYLER, IS_EMPTY, levelMapping, styles2, applyOptions, chalkFactory, getModelAnsi, usedModels, proto, createStyler, createBuilder, applyStyle, chalk, chalkStderr, source_default;
382
+ var init_source = __esm({
383
+ "node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/index.js"() {
384
+ init_ansi_styles();
385
+ init_supports_color();
386
+ init_utilities();
387
+ init_ansi_styles();
388
+ ({ stdout: stdoutColor, stderr: stderrColor } = supports_color_default);
389
+ GENERATOR = Symbol("GENERATOR");
390
+ STYLER = Symbol("STYLER");
391
+ IS_EMPTY = Symbol("IS_EMPTY");
392
+ levelMapping = [
393
+ "ansi",
394
+ "ansi",
395
+ "ansi256",
396
+ "ansi16m"
397
+ ];
398
+ styles2 = /* @__PURE__ */ Object.create(null);
399
+ applyOptions = (object, options = {}) => {
400
+ if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
401
+ throw new Error("The `level` option should be an integer from 0 to 3");
402
+ }
403
+ const colorLevel = stdoutColor ? stdoutColor.level : 0;
404
+ object.level = options.level === void 0 ? colorLevel : options.level;
405
+ };
406
+ chalkFactory = (options) => {
407
+ const chalk2 = (...strings) => strings.join(" ");
408
+ applyOptions(chalk2, options);
409
+ Object.setPrototypeOf(chalk2, createChalk.prototype);
410
+ return chalk2;
411
+ };
412
+ Object.setPrototypeOf(createChalk.prototype, Function.prototype);
413
+ for (const [styleName, style] of Object.entries(ansi_styles_default)) {
414
+ styles2[styleName] = {
415
+ get() {
416
+ const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
417
+ Object.defineProperty(this, styleName, { value: builder });
418
+ return builder;
419
+ }
420
+ };
421
+ }
422
+ styles2.visible = {
423
+ get() {
424
+ const builder = createBuilder(this, this[STYLER], true);
425
+ Object.defineProperty(this, "visible", { value: builder });
426
+ return builder;
427
+ }
428
+ };
429
+ getModelAnsi = (model, level, type, ...arguments_) => {
430
+ if (model === "rgb") {
431
+ if (level === "ansi16m") {
432
+ return ansi_styles_default[type].ansi16m(...arguments_);
433
+ }
434
+ if (level === "ansi256") {
435
+ return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
436
+ }
437
+ return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
438
+ }
439
+ if (model === "hex") {
440
+ return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
441
+ }
442
+ return ansi_styles_default[type][model](...arguments_);
443
+ };
444
+ usedModels = ["rgb", "hex", "ansi256"];
445
+ for (const model of usedModels) {
446
+ styles2[model] = {
447
+ get() {
448
+ const { level } = this;
449
+ return function(...arguments_) {
450
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
451
+ return createBuilder(this, styler, this[IS_EMPTY]);
452
+ };
453
+ }
454
+ };
455
+ const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
456
+ styles2[bgModel] = {
457
+ get() {
458
+ const { level } = this;
459
+ return function(...arguments_) {
460
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
461
+ return createBuilder(this, styler, this[IS_EMPTY]);
462
+ };
463
+ }
464
+ };
465
+ }
466
+ proto = Object.defineProperties(() => {
467
+ }, {
468
+ ...styles2,
469
+ level: {
470
+ enumerable: true,
471
+ get() {
472
+ return this[GENERATOR].level;
473
+ },
474
+ set(level) {
475
+ this[GENERATOR].level = level;
476
+ }
477
+ }
478
+ });
479
+ createStyler = (open, close, parent) => {
480
+ let openAll;
481
+ let closeAll;
482
+ if (parent === void 0) {
483
+ openAll = open;
484
+ closeAll = close;
485
+ } else {
486
+ openAll = parent.openAll + open;
487
+ closeAll = close + parent.closeAll;
488
+ }
489
+ return {
490
+ open,
491
+ close,
492
+ openAll,
493
+ closeAll,
494
+ parent
495
+ };
496
+ };
497
+ createBuilder = (self2, _styler, _isEmpty) => {
498
+ const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
499
+ Object.setPrototypeOf(builder, proto);
500
+ builder[GENERATOR] = self2;
501
+ builder[STYLER] = _styler;
502
+ builder[IS_EMPTY] = _isEmpty;
503
+ return builder;
504
+ };
505
+ applyStyle = (self2, string) => {
506
+ if (self2.level <= 0 || !string) {
507
+ return self2[IS_EMPTY] ? "" : string;
508
+ }
509
+ let styler = self2[STYLER];
510
+ if (styler === void 0) {
511
+ return string;
512
+ }
513
+ const { openAll, closeAll } = styler;
514
+ if (string.includes("\x1B")) {
515
+ while (styler !== void 0) {
516
+ string = stringReplaceAll(string, styler.close, styler.open);
517
+ styler = styler.parent;
518
+ }
519
+ }
520
+ const lfIndex = string.indexOf("\n");
521
+ if (lfIndex !== -1) {
522
+ string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
523
+ }
524
+ return openAll + string + closeAll;
525
+ };
526
+ Object.defineProperties(createChalk.prototype, styles2);
527
+ chalk = createChalk();
528
+ chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
529
+ source_default = chalk;
530
+ }
531
+ });
532
+
31
533
  // node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/readline.js
32
534
  var require_readline = __commonJS({
33
535
  "node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/readline.js"(exports) {
@@ -16850,521 +17352,43 @@ var require_glob = __commonJS({
16850
17352
  this.cache[abs] = this.cache[abs] || c;
16851
17353
  if (needDir && c === "FILE")
16852
17354
  return cb();
16853
- return cb(null, c, stat);
16854
- };
16855
- }
16856
- });
16857
-
16858
- // src/serializer/index.ts
16859
- var import_node, import_glob;
16860
- var init_serializer = __esm({
16861
- "src/serializer/index.ts"() {
16862
- import_node = __toESM(require_node2());
16863
- import_glob = __toESM(require_glob());
16864
- }
16865
- });
16866
-
16867
- // src/utils.ts
16868
- var utils_exports = {};
16869
- __export(utils_exports, {
16870
- assertV1OutFolder: () => assertV1OutFolder,
16871
- columnRenameKey: () => columnRenameKey,
16872
- dryJournal: () => dryJournal,
16873
- kloudMeta: () => kloudMeta,
16874
- mapValues: () => mapValues,
16875
- prepareMigrationFolder: () => prepareMigrationFolder,
16876
- prepareMigrationMeta: () => prepareMigrationMeta,
16877
- prepareOutFolder: () => prepareOutFolder2,
16878
- schemaRenameKey: () => schemaRenameKey,
16879
- snapshotsPriorV4: () => snapshotsPriorV4,
16880
- statementsForDiffs: () => statementsForDiffs,
16881
- tableRenameKey: () => tableRenameKey,
16882
- validateWithReport: () => validateWithReport
16883
- });
16884
- module.exports = __toCommonJS(utils_exports);
16885
- var import_fs = require("fs");
16886
-
16887
- // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/ansi-styles/index.js
16888
- var ANSI_BACKGROUND_OFFSET = 10;
16889
- var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
16890
- var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
16891
- var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
16892
- var styles = {
16893
- modifier: {
16894
- reset: [0, 0],
16895
- bold: [1, 22],
16896
- dim: [2, 22],
16897
- italic: [3, 23],
16898
- underline: [4, 24],
16899
- overline: [53, 55],
16900
- inverse: [7, 27],
16901
- hidden: [8, 28],
16902
- strikethrough: [9, 29]
16903
- },
16904
- color: {
16905
- black: [30, 39],
16906
- red: [31, 39],
16907
- green: [32, 39],
16908
- yellow: [33, 39],
16909
- blue: [34, 39],
16910
- magenta: [35, 39],
16911
- cyan: [36, 39],
16912
- white: [37, 39],
16913
- blackBright: [90, 39],
16914
- gray: [90, 39],
16915
- grey: [90, 39],
16916
- redBright: [91, 39],
16917
- greenBright: [92, 39],
16918
- yellowBright: [93, 39],
16919
- blueBright: [94, 39],
16920
- magentaBright: [95, 39],
16921
- cyanBright: [96, 39],
16922
- whiteBright: [97, 39]
16923
- },
16924
- bgColor: {
16925
- bgBlack: [40, 49],
16926
- bgRed: [41, 49],
16927
- bgGreen: [42, 49],
16928
- bgYellow: [43, 49],
16929
- bgBlue: [44, 49],
16930
- bgMagenta: [45, 49],
16931
- bgCyan: [46, 49],
16932
- bgWhite: [47, 49],
16933
- bgBlackBright: [100, 49],
16934
- bgGray: [100, 49],
16935
- bgGrey: [100, 49],
16936
- bgRedBright: [101, 49],
16937
- bgGreenBright: [102, 49],
16938
- bgYellowBright: [103, 49],
16939
- bgBlueBright: [104, 49],
16940
- bgMagentaBright: [105, 49],
16941
- bgCyanBright: [106, 49],
16942
- bgWhiteBright: [107, 49]
16943
- }
16944
- };
16945
- var modifierNames = Object.keys(styles.modifier);
16946
- var foregroundColorNames = Object.keys(styles.color);
16947
- var backgroundColorNames = Object.keys(styles.bgColor);
16948
- var colorNames = [...foregroundColorNames, ...backgroundColorNames];
16949
- function assembleStyles() {
16950
- const codes = /* @__PURE__ */ new Map();
16951
- for (const [groupName, group] of Object.entries(styles)) {
16952
- for (const [styleName, style] of Object.entries(group)) {
16953
- styles[styleName] = {
16954
- open: `\x1B[${style[0]}m`,
16955
- close: `\x1B[${style[1]}m`
16956
- };
16957
- group[styleName] = styles[styleName];
16958
- codes.set(style[0], style[1]);
16959
- }
16960
- Object.defineProperty(styles, groupName, {
16961
- value: group,
16962
- enumerable: false
16963
- });
16964
- }
16965
- Object.defineProperty(styles, "codes", {
16966
- value: codes,
16967
- enumerable: false
16968
- });
16969
- styles.color.close = "\x1B[39m";
16970
- styles.bgColor.close = "\x1B[49m";
16971
- styles.color.ansi = wrapAnsi16();
16972
- styles.color.ansi256 = wrapAnsi256();
16973
- styles.color.ansi16m = wrapAnsi16m();
16974
- styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
16975
- styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
16976
- styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
16977
- Object.defineProperties(styles, {
16978
- rgbToAnsi256: {
16979
- value(red, green, blue) {
16980
- if (red === green && green === blue) {
16981
- if (red < 8) {
16982
- return 16;
16983
- }
16984
- if (red > 248) {
16985
- return 231;
16986
- }
16987
- return Math.round((red - 8) / 247 * 24) + 232;
16988
- }
16989
- return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
16990
- },
16991
- enumerable: false
16992
- },
16993
- hexToRgb: {
16994
- value(hex) {
16995
- const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
16996
- if (!matches) {
16997
- return [0, 0, 0];
16998
- }
16999
- let [colorString] = matches;
17000
- if (colorString.length === 3) {
17001
- colorString = [...colorString].map((character) => character + character).join("");
17002
- }
17003
- const integer = Number.parseInt(colorString, 16);
17004
- return [
17005
- integer >> 16 & 255,
17006
- integer >> 8 & 255,
17007
- integer & 255
17008
- ];
17009
- },
17010
- enumerable: false
17011
- },
17012
- hexToAnsi256: {
17013
- value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
17014
- enumerable: false
17015
- },
17016
- ansi256ToAnsi: {
17017
- value(code) {
17018
- if (code < 8) {
17019
- return 30 + code;
17020
- }
17021
- if (code < 16) {
17022
- return 90 + (code - 8);
17023
- }
17024
- let red;
17025
- let green;
17026
- let blue;
17027
- if (code >= 232) {
17028
- red = ((code - 232) * 10 + 8) / 255;
17029
- green = red;
17030
- blue = red;
17031
- } else {
17032
- code -= 16;
17033
- const remainder = code % 36;
17034
- red = Math.floor(code / 36) / 5;
17035
- green = Math.floor(remainder / 6) / 5;
17036
- blue = remainder % 6 / 5;
17037
- }
17038
- const value = Math.max(red, green, blue) * 2;
17039
- if (value === 0) {
17040
- return 30;
17041
- }
17042
- let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
17043
- if (value === 2) {
17044
- result += 60;
17045
- }
17046
- return result;
17047
- },
17048
- enumerable: false
17049
- },
17050
- rgbToAnsi: {
17051
- value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
17052
- enumerable: false
17053
- },
17054
- hexToAnsi: {
17055
- value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
17056
- enumerable: false
17057
- }
17058
- });
17059
- return styles;
17060
- }
17061
- var ansiStyles = assembleStyles();
17062
- var ansi_styles_default = ansiStyles;
17063
-
17064
- // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/vendor/supports-color/index.js
17065
- var import_node_process = __toESM(require("process"), 1);
17066
- var import_node_os = __toESM(require("os"), 1);
17067
- var import_node_tty = __toESM(require("tty"), 1);
17068
- function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : import_node_process.default.argv) {
17069
- const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
17070
- const position = argv.indexOf(prefix + flag);
17071
- const terminatorPosition = argv.indexOf("--");
17072
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
17073
- }
17074
- var { env } = import_node_process.default;
17075
- var flagForceColor;
17076
- if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
17077
- flagForceColor = 0;
17078
- } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
17079
- flagForceColor = 1;
17080
- }
17081
- function envForceColor() {
17082
- if ("FORCE_COLOR" in env) {
17083
- if (env.FORCE_COLOR === "true") {
17084
- return 1;
17085
- }
17086
- if (env.FORCE_COLOR === "false") {
17087
- return 0;
17088
- }
17089
- return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
17090
- }
17091
- }
17092
- function translateLevel(level) {
17093
- if (level === 0) {
17094
- return false;
17095
- }
17096
- return {
17097
- level,
17098
- hasBasic: true,
17099
- has256: level >= 2,
17100
- has16m: level >= 3
17101
- };
17102
- }
17103
- function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
17104
- const noFlagForceColor = envForceColor();
17105
- if (noFlagForceColor !== void 0) {
17106
- flagForceColor = noFlagForceColor;
17107
- }
17108
- const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
17109
- if (forceColor === 0) {
17110
- return 0;
17111
- }
17112
- if (sniffFlags) {
17113
- if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
17114
- return 3;
17115
- }
17116
- if (hasFlag("color=256")) {
17117
- return 2;
17118
- }
17119
- }
17120
- if ("TF_BUILD" in env && "AGENT_NAME" in env) {
17121
- return 1;
17122
- }
17123
- if (haveStream && !streamIsTTY && forceColor === void 0) {
17124
- return 0;
17125
- }
17126
- const min = forceColor || 0;
17127
- if (env.TERM === "dumb") {
17128
- return min;
17129
- }
17130
- if (import_node_process.default.platform === "win32") {
17131
- const osRelease = import_node_os.default.release().split(".");
17132
- if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
17133
- return Number(osRelease[2]) >= 14931 ? 3 : 2;
17134
- }
17135
- return 1;
17136
- }
17137
- if ("CI" in env) {
17138
- if ("GITHUB_ACTIONS" in env) {
17139
- return 3;
17140
- }
17141
- if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
17142
- return 1;
17143
- }
17144
- return min;
17145
- }
17146
- if ("TEAMCITY_VERSION" in env) {
17147
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
17148
- }
17149
- if (env.COLORTERM === "truecolor") {
17150
- return 3;
17151
- }
17152
- if (env.TERM === "xterm-kitty") {
17153
- return 3;
17154
- }
17155
- if ("TERM_PROGRAM" in env) {
17156
- const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
17157
- switch (env.TERM_PROGRAM) {
17158
- case "iTerm.app": {
17159
- return version >= 3 ? 3 : 2;
17160
- }
17161
- case "Apple_Terminal": {
17162
- return 2;
17163
- }
17164
- }
17165
- }
17166
- if (/-256(color)?$/i.test(env.TERM)) {
17167
- return 2;
17168
- }
17169
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
17170
- return 1;
17171
- }
17172
- if ("COLORTERM" in env) {
17173
- return 1;
17355
+ return cb(null, c, stat);
17356
+ };
17174
17357
  }
17175
- return min;
17176
- }
17177
- function createSupportsColor(stream, options = {}) {
17178
- const level = _supportsColor(stream, {
17179
- streamIsTTY: stream && stream.isTTY,
17180
- ...options
17181
- });
17182
- return translateLevel(level);
17183
- }
17184
- var supportsColor = {
17185
- stdout: createSupportsColor({ isTTY: import_node_tty.default.isatty(1) }),
17186
- stderr: createSupportsColor({ isTTY: import_node_tty.default.isatty(2) })
17187
- };
17188
- var supports_color_default = supportsColor;
17358
+ });
17189
17359
 
17190
- // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/utilities.js
17191
- function stringReplaceAll(string, substring, replacer) {
17192
- let index4 = string.indexOf(substring);
17193
- if (index4 === -1) {
17194
- return string;
17360
+ // src/serializer/index.ts
17361
+ var import_node, import_glob;
17362
+ var init_serializer = __esm({
17363
+ "src/serializer/index.ts"() {
17364
+ import_node = __toESM(require_node2());
17365
+ import_glob = __toESM(require_glob());
17366
+ init_source();
17195
17367
  }
17196
- const substringLength = substring.length;
17197
- let endIndex = 0;
17198
- let returnValue = "";
17199
- do {
17200
- returnValue += string.slice(endIndex, index4) + substring + replacer;
17201
- endIndex = index4 + substringLength;
17202
- index4 = string.indexOf(substring, endIndex);
17203
- } while (index4 !== -1);
17204
- returnValue += string.slice(endIndex);
17205
- return returnValue;
17206
- }
17207
- function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index4) {
17208
- let endIndex = 0;
17209
- let returnValue = "";
17210
- do {
17211
- const gotCR = string[index4 - 1] === "\r";
17212
- returnValue += string.slice(endIndex, gotCR ? index4 - 1 : index4) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
17213
- endIndex = index4 + 1;
17214
- index4 = string.indexOf("\n", endIndex);
17215
- } while (index4 !== -1);
17216
- returnValue += string.slice(endIndex);
17217
- return returnValue;
17218
- }
17368
+ });
17219
17369
 
17220
- // node_modules/.pnpm/chalk@5.2.0/node_modules/chalk/source/index.js
17221
- var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
17222
- var GENERATOR = Symbol("GENERATOR");
17223
- var STYLER = Symbol("STYLER");
17224
- var IS_EMPTY = Symbol("IS_EMPTY");
17225
- var levelMapping = [
17226
- "ansi",
17227
- "ansi",
17228
- "ansi256",
17229
- "ansi16m"
17230
- ];
17231
- var styles2 = /* @__PURE__ */ Object.create(null);
17232
- var applyOptions = (object, options = {}) => {
17233
- if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
17234
- throw new Error("The `level` option should be an integer from 0 to 3");
17235
- }
17236
- const colorLevel = stdoutColor ? stdoutColor.level : 0;
17237
- object.level = options.level === void 0 ? colorLevel : options.level;
17238
- };
17239
- var chalkFactory = (options) => {
17240
- const chalk2 = (...strings) => strings.join(" ");
17241
- applyOptions(chalk2, options);
17242
- Object.setPrototypeOf(chalk2, createChalk.prototype);
17243
- return chalk2;
17244
- };
17245
- function createChalk(options) {
17246
- return chalkFactory(options);
17247
- }
17248
- Object.setPrototypeOf(createChalk.prototype, Function.prototype);
17249
- for (const [styleName, style] of Object.entries(ansi_styles_default)) {
17250
- styles2[styleName] = {
17251
- get() {
17252
- const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
17253
- Object.defineProperty(this, styleName, { value: builder });
17254
- return builder;
17255
- }
17256
- };
17257
- }
17258
- styles2.visible = {
17259
- get() {
17260
- const builder = createBuilder(this, this[STYLER], true);
17261
- Object.defineProperty(this, "visible", { value: builder });
17262
- return builder;
17263
- }
17264
- };
17265
- var getModelAnsi = (model, level, type, ...arguments_) => {
17266
- if (model === "rgb") {
17267
- if (level === "ansi16m") {
17268
- return ansi_styles_default[type].ansi16m(...arguments_);
17269
- }
17270
- if (level === "ansi256") {
17271
- return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
17272
- }
17273
- return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
17274
- }
17275
- if (model === "hex") {
17276
- return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
17277
- }
17278
- return ansi_styles_default[type][model](...arguments_);
17279
- };
17280
- var usedModels = ["rgb", "hex", "ansi256"];
17281
- for (const model of usedModels) {
17282
- styles2[model] = {
17283
- get() {
17284
- const { level } = this;
17285
- return function(...arguments_) {
17286
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
17287
- return createBuilder(this, styler, this[IS_EMPTY]);
17288
- };
17289
- }
17290
- };
17291
- const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
17292
- styles2[bgModel] = {
17293
- get() {
17294
- const { level } = this;
17295
- return function(...arguments_) {
17296
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
17297
- return createBuilder(this, styler, this[IS_EMPTY]);
17298
- };
17299
- }
17300
- };
17301
- }
17302
- var proto = Object.defineProperties(() => {
17303
- }, {
17304
- ...styles2,
17305
- level: {
17306
- enumerable: true,
17307
- get() {
17308
- return this[GENERATOR].level;
17309
- },
17310
- set(level) {
17311
- this[GENERATOR].level = level;
17312
- }
17313
- }
17370
+ // src/utils.ts
17371
+ var utils_exports = {};
17372
+ __export(utils_exports, {
17373
+ assertV1OutFolder: () => assertV1OutFolder,
17374
+ columnRenameKey: () => columnRenameKey,
17375
+ dryJournal: () => dryJournal,
17376
+ kloudMeta: () => kloudMeta,
17377
+ mapValues: () => mapValues,
17378
+ prepareMigrationFolder: () => prepareMigrationFolder,
17379
+ prepareMigrationMeta: () => prepareMigrationMeta,
17380
+ prepareOutFolder: () => prepareOutFolder2,
17381
+ schemaRenameKey: () => schemaRenameKey,
17382
+ snapshotsPriorV4: () => snapshotsPriorV4,
17383
+ statementsForDiffs: () => statementsForDiffs,
17384
+ tableRenameKey: () => tableRenameKey,
17385
+ validateWithReport: () => validateWithReport
17314
17386
  });
17315
- var createStyler = (open, close, parent) => {
17316
- let openAll;
17317
- let closeAll;
17318
- if (parent === void 0) {
17319
- openAll = open;
17320
- closeAll = close;
17321
- } else {
17322
- openAll = parent.openAll + open;
17323
- closeAll = close + parent.closeAll;
17324
- }
17325
- return {
17326
- open,
17327
- close,
17328
- openAll,
17329
- closeAll,
17330
- parent
17331
- };
17332
- };
17333
- var createBuilder = (self2, _styler, _isEmpty) => {
17334
- const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
17335
- Object.setPrototypeOf(builder, proto);
17336
- builder[GENERATOR] = self2;
17337
- builder[STYLER] = _styler;
17338
- builder[IS_EMPTY] = _isEmpty;
17339
- return builder;
17340
- };
17341
- var applyStyle = (self2, string) => {
17342
- if (self2.level <= 0 || !string) {
17343
- return self2[IS_EMPTY] ? "" : string;
17344
- }
17345
- let styler = self2[STYLER];
17346
- if (styler === void 0) {
17347
- return string;
17348
- }
17349
- const { openAll, closeAll } = styler;
17350
- if (string.includes("\x1B")) {
17351
- while (styler !== void 0) {
17352
- string = stringReplaceAll(string, styler.close, styler.open);
17353
- styler = styler.parent;
17354
- }
17355
- }
17356
- const lfIndex = string.indexOf("\n");
17357
- if (lfIndex !== -1) {
17358
- string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
17359
- }
17360
- return openAll + string + closeAll;
17361
- };
17362
- Object.defineProperties(createChalk.prototype, styles2);
17363
- var chalk = createChalk();
17364
- var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
17365
- var source_default = chalk;
17387
+ module.exports = __toCommonJS(utils_exports);
17388
+ var import_fs = require("fs");
17366
17389
 
17367
17390
  // src/cli/views.ts
17391
+ init_source();
17368
17392
  var import_hanji = __toESM(require_hanji());
17369
17393
  var info = (msg, greyMsg = "") => {
17370
17394
  return `${source_default.blue.bold("Info:")} ${msg} ${greyMsg ? source_default.grey(greyMsg) : ""}`.trim();
@@ -21084,6 +21108,7 @@ var drySQLite = schema2.parse({
21084
21108
  var backwardCompatibleSqliteSchema = unionType([schemaV32, schemaV42, schema2]);
21085
21109
 
21086
21110
  // src/utils.ts
21111
+ init_source();
21087
21112
  var import_path = require("path");
21088
21113
 
21089
21114
  // src/jsonDiffer.js
@@ -21270,6 +21295,19 @@ var alternationsInColumn = (column4) => {
21270
21295
  return { ...others, notNull: { type: "deleted", value: it.notNull__deleted } };
21271
21296
  }
21272
21297
  return it;
21298
+ }).map((it) => {
21299
+ if ("primaryKey" in it) {
21300
+ return { ...it, primaryKey: { type: "changed", old: it.primaryKey.__old, new: it.primaryKey.__new } };
21301
+ }
21302
+ if ("primaryKey__added" in it) {
21303
+ const { notNull__added, ...others } = it;
21304
+ return { ...others, primaryKey: { type: "added", value: it.primaryKey__added } };
21305
+ }
21306
+ if ("primaryKey__deleted" in it) {
21307
+ const { notNull__deleted, ...others } = it;
21308
+ return { ...others, primaryKey: { type: "deleted", value: it.primaryKey__deleted } };
21309
+ }
21310
+ return it;
21273
21311
  }).map((it) => {
21274
21312
  if ("onUpdate" in it) {
21275
21313
  return { ...it, onUpdate: { type: "changed", old: it.onUpdate.__old, new: it.onUpdate.__new } };
@@ -21296,19 +21334,6 @@ var alternationsInColumn = (column4) => {
21296
21334
  return { ...others, autoincrement: { type: "deleted", value: it.autoincrement__deleted } };
21297
21335
  }
21298
21336
  return it;
21299
- }).map((it) => {
21300
- if ("primaryKey" in it) {
21301
- return { ...it, primaryKey: { type: "changed", old: it.primaryKey.__old, new: it.primaryKey.__new } };
21302
- }
21303
- if ("primaryKey__added" in it) {
21304
- const { primaryKey__added, ...others } = it;
21305
- return { ...others, primaryKey: { type: "added", value: it.primaryKey__added } };
21306
- }
21307
- if ("primaryKey__deleted" in it) {
21308
- const { primaryKey__deleted, ...others } = it;
21309
- return { ...others, primaryKey: { type: "deleted", value: it.primaryKey__deleted } };
21310
- }
21311
- return it;
21312
21337
  });
21313
21338
  return result[0];
21314
21339
  };
@@ -21318,6 +21343,7 @@ init_serializer();
21318
21343
 
21319
21344
  // src/cli/commands/migrate.ts
21320
21345
  var import_hanji2 = __toESM(require_hanji());
21346
+ init_source();
21321
21347
  var BREAKPOINT = "--> statement-breakpoint\n";
21322
21348
 
21323
21349
  // src/sqlgenerator.ts
@@ -21414,26 +21440,24 @@ var MySqlCreateTableConvertor = class extends Convertor {
21414
21440
  `;
21415
21441
  for (let i = 0; i < columns.length; i++) {
21416
21442
  const column4 = columns[i];
21417
- const primaryKeyStatement = column4.primaryKey ? "PRIMARY KEY" : "";
21418
- const notNullStatement = column4.notNull ? "NOT NULL" : "";
21419
- const defaultStatement = column4.default !== void 0 ? `DEFAULT ${column4.default}` : "";
21420
- const onUpdateStatement = column4.onUpdate ? `ON UPDATE CURRENT_TIMESTAMP` : "";
21421
- const autoincrementStatement = column4.autoincrement ? "AUTO_INCREMENT" : "";
21422
- statement += " " + `\`${column4.name}\` ${column4.type} ${autoincrementStatement} ${primaryKeyStatement} ${notNullStatement} ${defaultStatement} ${onUpdateStatement}`.replace(/ +/g, " ").trim();
21423
- statement += (i === columns.length - 1 ? "" : ",") + "\n";
21443
+ const primaryKeyStatement = column4.primaryKey ? " PRIMARY KEY" : "";
21444
+ const notNullStatement = column4.notNull ? " NOT NULL" : "";
21445
+ const defaultStatement = column4.default !== void 0 ? ` DEFAULT ${column4.default}` : "";
21446
+ const onUpdateStatement = column4.onUpdate ? ` ON UPDATE CURRENT_TIMESTAMP` : "";
21447
+ const autoincrementStatement = column4.autoincrement ? " AUTO_INCREMENT" : "";
21448
+ statement += " " + `\`${column4.name}\` ${column4.type}${autoincrementStatement}${primaryKeyStatement}${notNullStatement}${defaultStatement}${onUpdateStatement}`.trim();
21449
+ statement += i === columns.length - 1 ? "" : ",\n";
21424
21450
  }
21425
- statement += `);`;
21426
- statement += `
21427
- `;
21428
21451
  if (typeof compositePKs !== "undefined" && compositePKs.length > 0) {
21452
+ statement += ",\n";
21429
21453
  const compositePK4 = MySqlSquasher.unsquashPK(compositePKs[0]);
21430
- statement += BREAKPOINT;
21431
- statement += `ALTER TABLE ${tName} ADD PRIMARY KEY(\`${compositePK4.columns.join(
21432
- "`,`"
21433
- )}\`);`;
21454
+ statement += ` PRIMARY KEY(\`${compositePK4.columns.join("`,`")}\`)`;
21434
21455
  statement += `
21435
21456
  `;
21436
21457
  }
21458
+ statement += `);`;
21459
+ statement += `
21460
+ `;
21437
21461
  return statement;
21438
21462
  }
21439
21463
  };
@@ -21524,7 +21548,7 @@ var DropTableConvertor = class extends Convertor {
21524
21548
  }
21525
21549
  convert(statement) {
21526
21550
  const { tableName } = statement;
21527
- return `DROP TABLE ${tableName};`;
21551
+ return `DROP TABLE \`${tableName}\`;`;
21528
21552
  }
21529
21553
  };
21530
21554
  var PgRenameTableConvertor = class extends Convertor {
@@ -21631,12 +21655,13 @@ var MySqlAlterTableAddColumnConvertor = class extends Convertor {
21631
21655
  }
21632
21656
  convert(statement) {
21633
21657
  const { tableName, column: column4 } = statement;
21634
- const { name, type, notNull, primaryKey, autoincrement } = column4;
21635
- const defaultStatement = `${column4.default !== void 0 ? `DEFAULT ${column4.default}` : ""}`;
21636
- const notNullStatement = `${notNull ? "NOT NULL" : ""}`;
21637
- const primaryKeyStatement = `${primaryKey ? "PRIMARY KEY" : ""}`;
21638
- const autoincrementStatement = `${autoincrement ? "AUTO_INCREMENT" : ""}`;
21639
- return `ALTER TABLE \`${tableName}\` ADD \`${name}\` ${type} ${primaryKeyStatement} ${autoincrementStatement} ${defaultStatement} ${notNullStatement}`.replace(/ +/g, " ").trim() + ";";
21658
+ const { name, type, notNull, primaryKey, autoincrement, onUpdate } = column4;
21659
+ const defaultStatement = `${column4.default !== void 0 ? ` DEFAULT ${column4.default}` : ""}`;
21660
+ const notNullStatement = `${notNull ? " NOT NULL" : ""}`;
21661
+ const primaryKeyStatement = `${primaryKey ? " PRIMARY KEY" : ""}`;
21662
+ const autoincrementStatement = `${autoincrement ? " AUTO_INCREMENT" : ""}`;
21663
+ const onUpdateStatement = `${onUpdate ? " ON UPDATE CURRENT_TIMESTAMP" : ""}`;
21664
+ return `ALTER TABLE \`${tableName}\` ADD \`${name}\` ${type}${primaryKeyStatement}${autoincrementStatement}${defaultStatement}${notNullStatement}${onUpdateStatement};`;
21640
21665
  }
21641
21666
  };
21642
21667
  var SQLiteAlterTableAddColumnConvertor = class extends Convertor {
@@ -21711,27 +21736,25 @@ var PgAlterTableAlterColumnDropDefaultConvertor = class extends Convertor {
21711
21736
  return `ALTER TABLE "${tableName}" ALTER COLUMN "${columnName}" DROP DEFAULT;`;
21712
21737
  }
21713
21738
  };
21714
- var MySqlAlterTableAlterColumnSetDefaultConvertor = class extends Convertor {
21739
+ var MySqlAlterTableAddPk = class extends Convertor {
21715
21740
  can(statement, dialect3) {
21716
- return statement.type === "alter_table_alter_column_set_default" && dialect3 === "mysql";
21741
+ return statement.type === "alter_table_alter_column_set_pk" && dialect3 === "mysql";
21717
21742
  }
21718
21743
  convert(statement) {
21719
- const { tableName, columnName } = statement;
21720
- return `ALTER TABLE \`${tableName}\` ALTER COLUMN \`${columnName}\` SET DEFAULT ${statement.newDefaultValue};`;
21744
+ return `ALTER TABLE \`${statement.tableName}\` ADD PRIMARY KEY (\`${statement.columnName}\`);`;
21721
21745
  }
21722
21746
  };
21723
- var MySqlAlterTableAlterColumnDropDefaultConvertor = class extends Convertor {
21747
+ var MySqlAlterTableDropPk = class extends Convertor {
21724
21748
  can(statement, dialect3) {
21725
- return statement.type === "alter_table_alter_column_drop_default" && dialect3 === "mysql";
21749
+ return statement.type === "alter_table_alter_column_drop_pk" && dialect3 === "mysql";
21726
21750
  }
21727
21751
  convert(statement) {
21728
- const { tableName, columnName } = statement;
21729
- return `ALTER TABLE \`${tableName}\` ALTER COLUMN \`${columnName}\` DROP DEFAULT;`;
21752
+ return `ALTER TABLE \`${statement.tableName}\` DROP PRIMARY KEY`;
21730
21753
  }
21731
21754
  };
21732
21755
  var MySqlModifyColumn = class extends Convertor {
21733
21756
  can(statement, dialect3) {
21734
- 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") && dialect3 === "mysql";
21757
+ 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") && dialect3 === "mysql";
21735
21758
  }
21736
21759
  convert(statement) {
21737
21760
  const { tableName, columnName } = statement;
@@ -21740,6 +21763,7 @@ var MySqlModifyColumn = class extends Convertor {
21740
21763
  let columnNotNull = "";
21741
21764
  let columnOnUpdate = "";
21742
21765
  let columnAutoincrement = "";
21766
+ let primaryKey = statement.columnPk ? " PRIMARY KEY" : "";
21743
21767
  if (statement.type === "alter_table_alter_column_drop_notnull") {
21744
21768
  columnType = ` ${statement.newDataType}`;
21745
21769
  columnDefault = statement.columnDefault ? ` DEFAULT ${statement.columnDefault}` : "";
@@ -21769,19 +21793,31 @@ var MySqlModifyColumn = class extends Convertor {
21769
21793
  columnOnUpdate = columnOnUpdate = statement.columnOnUpdate ? ` ON UPDATE CURRENT_TIMESTAMP` : "";
21770
21794
  columnType = ` ${statement.newDataType}`;
21771
21795
  columnDefault = statement.columnDefault ? ` DEFAULT ${statement.columnDefault}` : "";
21772
- columnAutoincrement = "AUTO_INCREMENT";
21796
+ columnAutoincrement = " AUTO_INCREMENT";
21773
21797
  } else if (statement.type === "alter_table_alter_column_drop_autoincrement") {
21774
21798
  columnNotNull = statement.columnNotNull ? ` NOT NULL` : "";
21775
21799
  columnOnUpdate = columnOnUpdate = statement.columnOnUpdate ? ` ON UPDATE CURRENT_TIMESTAMP` : "";
21776
21800
  columnType = ` ${statement.newDataType}`;
21777
21801
  columnDefault = statement.columnDefault ? ` DEFAULT ${statement.columnDefault}` : "";
21778
21802
  columnAutoincrement = "";
21803
+ } else if (statement.type === "alter_table_alter_column_set_default") {
21804
+ columnNotNull = statement.columnNotNull ? ` NOT NULL` : "";
21805
+ columnOnUpdate = columnOnUpdate = statement.columnOnUpdate ? ` ON UPDATE CURRENT_TIMESTAMP` : "";
21806
+ columnType = ` ${statement.newDataType}`;
21807
+ columnDefault = ` DEFAULT ${statement.newDefaultValue}`;
21808
+ columnAutoincrement = statement.columnAutoIncrement ? " AUTO_INCREMENT" : "";
21809
+ } else if (statement.type === "alter_table_alter_column_drop_default") {
21810
+ columnNotNull = statement.columnNotNull ? ` NOT NULL` : "";
21811
+ columnOnUpdate = columnOnUpdate = statement.columnOnUpdate ? ` ON UPDATE CURRENT_TIMESTAMP` : "";
21812
+ columnType = ` ${statement.newDataType}`;
21813
+ columnDefault = "";
21814
+ columnAutoincrement = statement.columnAutoIncrement ? " AUTO_INCREMENT" : "";
21779
21815
  } else {
21780
21816
  columnType = ` ${statement.newDataType}`;
21781
21817
  columnNotNull = statement.columnNotNull ? ` NOT NULL` : "";
21782
21818
  columnOnUpdate = columnOnUpdate = statement.columnOnUpdate ? ` ON UPDATE CURRENT_TIMESTAMP` : "";
21783
21819
  columnDefault = statement.columnDefault ? ` DEFAULT ${statement.columnDefault}` : "";
21784
- columnAutoincrement = statement.columnAutoIncrement ? "AUTO_INCREMENT" : "";
21820
+ columnAutoincrement = statement.columnAutoIncrement ? " AUTO_INCREMENT" : "";
21785
21821
  }
21786
21822
  columnDefault = columnDefault instanceof Date ? columnDefault.toISOString() : columnDefault;
21787
21823
  return `ALTER TABLE \`${tableName}\` MODIFY COLUMN \`${columnName}\`${columnType}${columnAutoincrement}${columnNotNull}${columnDefault}${columnOnUpdate};`;
@@ -21944,7 +21980,7 @@ var SqliteAlterTableAlterCompositePrimaryKeyConvertor = class extends Convertor
21944
21980
  };
21945
21981
  var PgAlterTableAlterColumnSetPrimaryKeyConvertor = class extends Convertor {
21946
21982
  can(statement, dialect3) {
21947
- return statement.type === "alter_table_alter_column_set_primarykey" && dialect3 === "pg";
21983
+ return statement.type === "alter_table_alter_column_set_pk" && dialect3 === "pg";
21948
21984
  }
21949
21985
  convert(statement) {
21950
21986
  const { tableName, columnName } = statement;
@@ -21953,7 +21989,7 @@ var PgAlterTableAlterColumnSetPrimaryKeyConvertor = class extends Convertor {
21953
21989
  };
21954
21990
  var PgAlterTableAlterColumnDropPrimaryKeyConvertor = class extends Convertor {
21955
21991
  can(statement, dialect3) {
21956
- return statement.type === "alter_table_alter_column_drop_primarykey" && dialect3 === "pg";
21992
+ return statement.type === "alter_table_alter_column_drop_pk" && dialect3 === "pg";
21957
21993
  }
21958
21994
  convert(statement) {
21959
21995
  const { tableName, columnName, schema: schema4 } = statement;
@@ -22105,7 +22141,6 @@ var PgAlterForeignKeyConvertor = class extends Convertor {
22105
22141
  sql += " WHEN duplicate_object THEN null;\n";
22106
22142
  sql += "END $$;\n";
22107
22143
  return sql;
22108
- throw new Error("TODO");
22109
22144
  }
22110
22145
  };
22111
22146
  var SqliteAlterForeignKeyConvertor = class extends Convertor {
@@ -22373,8 +22408,6 @@ convertors.push(new PgAlterTableAlterColumnDropNotNullConvertor());
22373
22408
  convertors.push(new PgAlterTableAlterColumnSetDefaultConvertor());
22374
22409
  convertors.push(new PgAlterTableAlterColumnDropDefaultConvertor());
22375
22410
  convertors.push(new MySqlModifyColumn());
22376
- convertors.push(new MySqlAlterTableAlterColumnSetDefaultConvertor());
22377
- convertors.push(new MySqlAlterTableAlterColumnDropDefaultConvertor());
22378
22411
  convertors.push(new PgCreateForeignKeyConvertor());
22379
22412
  convertors.push(new MySqlCreateForeignKeyConvertor());
22380
22413
  convertors.push(new PgAlterForeignKeyConvertor());
@@ -22405,8 +22438,10 @@ convertors.push(new SqliteAlterTableAlterCompositePrimaryKeyConvertor());
22405
22438
  convertors.push(new PgAlterTableCreateCompositePrimaryKeyConvertor());
22406
22439
  convertors.push(new PgAlterTableDeleteCompositePrimaryKeyConvertor());
22407
22440
  convertors.push(new PgAlterTableAlterCompositePrimaryKeyConvertor());
22408
- convertors.push(new MySqlAlterTableCreateCompositePrimaryKeyConvertor());
22409
22441
  convertors.push(new MySqlAlterTableDeleteCompositePrimaryKeyConvertor());
22442
+ convertors.push(new MySqlAlterTableDropPk());
22443
+ convertors.push(new MySqlAlterTableCreateCompositePrimaryKeyConvertor());
22444
+ convertors.push(new MySqlAlterTableAddPk());
22410
22445
  convertors.push(new MySqlAlterTableAlterCompositePrimaryKeyConvertor());
22411
22446
  var fromJson = (statements, dialect3) => {
22412
22447
  const result = statements.map((statement) => {
@@ -22419,7 +22454,7 @@ var fromJson = (statements, dialect3) => {
22419
22454
  return "";
22420
22455
  }
22421
22456
  return convertor.convert(statement);
22422
- });
22457
+ }).filter((it) => it !== "");
22423
22458
  return result;
22424
22459
  };
22425
22460
  https:
@@ -22610,7 +22645,7 @@ var _prepareSQLiteAddColumns = (tableName, columns, referenceData) => {
22610
22645
  });
22611
22646
  };
22612
22647
  var _prepareAlterColumns = (tableName, schema4, columns, json2) => {
22613
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
22648
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
22614
22649
  let statements = [];
22615
22650
  for (const column4 of columns) {
22616
22651
  const columnName = typeof column4.name !== "string" ? column4.name.new : column4.name;
@@ -22619,57 +22654,25 @@ var _prepareAlterColumns = (tableName, schema4, columns, json2) => {
22619
22654
  const columnOnUpdate = json2.tables[tableName].columns[columnName].onUpdate;
22620
22655
  const columnNotNull = json2.tables[tableName].columns[columnName].notNull;
22621
22656
  const columnAutoIncrement = json2.tables[tableName].columns[columnName].autoincrement;
22622
- if (typeof column4.name !== "string") {
22623
- statements.push({
22624
- type: "alter_table_rename_column",
22625
- tableName,
22626
- oldColumnName: column4.name.old,
22627
- newColumnName: column4.name.new,
22628
- schema: schema4
22629
- });
22630
- }
22631
- if (((_a = column4.type) == null ? void 0 : _a.type) === "changed") {
22657
+ const columnPk = json2.tables[tableName].columns[columnName].primaryKey;
22658
+ if (((_a = column4.autoincrement) == null ? void 0 : _a.type) === "added") {
22632
22659
  statements.push({
22633
- type: "alter_table_alter_column_set_type",
22660
+ type: "alter_table_alter_column_set_autoincrement",
22634
22661
  tableName,
22635
22662
  columnName,
22636
- newDataType: column4.type.new,
22637
22663
  schema: schema4,
22664
+ newDataType: columnType,
22638
22665
  columnDefault,
22639
22666
  columnOnUpdate,
22640
22667
  columnNotNull,
22641
- columnAutoIncrement
22642
- });
22643
- }
22644
- if (((_b = column4.default) == null ? void 0 : _b.type) === "added") {
22645
- statements.push({
22646
- type: "alter_table_alter_column_set_default",
22647
- tableName,
22648
- columnName,
22649
- newDefaultValue: column4.default.value,
22650
- schema: schema4
22651
- });
22652
- }
22653
- if (((_c = column4.default) == null ? void 0 : _c.type) === "changed") {
22654
- statements.push({
22655
- type: "alter_table_alter_column_set_default",
22656
- tableName,
22657
- columnName,
22658
- newDefaultValue: column4.default.new,
22659
- schema: schema4
22660
- });
22661
- }
22662
- if (((_d = column4.default) == null ? void 0 : _d.type) === "deleted") {
22663
- statements.push({
22664
- type: "alter_table_alter_column_drop_default",
22665
- tableName,
22666
- columnName,
22667
- schema: schema4
22668
+ columnAutoIncrement,
22669
+ columnPk
22668
22670
  });
22669
22671
  }
22670
- if (((_e = column4.notNull) == null ? void 0 : _e.type) === "added") {
22672
+ if (((_b = column4.autoincrement) == null ? void 0 : _b.type) === "changed") {
22673
+ const type = column4.autoincrement.new ? "alter_table_alter_column_set_autoincrement" : "alter_table_alter_column_drop_autoincrement";
22671
22674
  statements.push({
22672
- type: "alter_table_alter_column_set_notnull",
22675
+ type,
22673
22676
  tableName,
22674
22677
  columnName,
22675
22678
  schema: schema4,
@@ -22677,13 +22680,13 @@ var _prepareAlterColumns = (tableName, schema4, columns, json2) => {
22677
22680
  columnDefault,
22678
22681
  columnOnUpdate,
22679
22682
  columnNotNull,
22680
- columnAutoIncrement
22683
+ columnAutoIncrement,
22684
+ columnPk
22681
22685
  });
22682
22686
  }
22683
- if (((_f = column4.notNull) == null ? void 0 : _f.type) === "changed") {
22684
- const type = column4.notNull.new ? "alter_table_alter_column_set_notnull" : "alter_table_alter_column_drop_notnull";
22687
+ if (((_c = column4.autoincrement) == null ? void 0 : _c.type) === "deleted") {
22685
22688
  statements.push({
22686
- type,
22689
+ type: "alter_table_alter_column_drop_autoincrement",
22687
22690
  tableName,
22688
22691
  columnName,
22689
22692
  schema: schema4,
@@ -22691,65 +22694,94 @@ var _prepareAlterColumns = (tableName, schema4, columns, json2) => {
22691
22694
  columnDefault,
22692
22695
  columnOnUpdate,
22693
22696
  columnNotNull,
22694
- columnAutoIncrement
22697
+ columnAutoIncrement,
22698
+ columnPk
22699
+ });
22700
+ }
22701
+ }
22702
+ for (const column4 of columns) {
22703
+ const columnName = typeof column4.name !== "string" ? column4.name.new : column4.name;
22704
+ const columnType = json2.tables[tableName].columns[columnName].type;
22705
+ const columnDefault = json2.tables[tableName].columns[columnName].default;
22706
+ const columnOnUpdate = json2.tables[tableName].columns[columnName].onUpdate;
22707
+ const columnNotNull = json2.tables[tableName].columns[columnName].notNull;
22708
+ const columnAutoIncrement = json2.tables[tableName].columns[columnName].autoincrement;
22709
+ const columnPk = json2.tables[tableName].columns[columnName].primaryKey;
22710
+ if (typeof column4.name !== "string") {
22711
+ statements.push({
22712
+ type: "alter_table_rename_column",
22713
+ tableName,
22714
+ oldColumnName: column4.name.old,
22715
+ newColumnName: column4.name.new,
22716
+ schema: schema4
22695
22717
  });
22696
22718
  }
22697
- if (((_g = column4.notNull) == null ? void 0 : _g.type) === "deleted") {
22719
+ if (((_d = column4.type) == null ? void 0 : _d.type) === "changed") {
22698
22720
  statements.push({
22699
- type: "alter_table_alter_column_drop_notnull",
22721
+ type: "alter_table_alter_column_set_type",
22700
22722
  tableName,
22701
22723
  columnName,
22724
+ newDataType: column4.type.new,
22702
22725
  schema: schema4,
22703
- newDataType: columnType,
22704
22726
  columnDefault,
22705
22727
  columnOnUpdate,
22706
22728
  columnNotNull,
22707
- columnAutoIncrement
22729
+ columnAutoIncrement,
22730
+ columnPk
22708
22731
  });
22709
22732
  }
22710
- if (((_h = column4.autoincrement) == null ? void 0 : _h.type) === "added") {
22733
+ if (((_e = column4.primaryKey) == null ? void 0 : _e.type) === "deleted" || ((_f = column4.primaryKey) == null ? void 0 : _f.type) === "changed" && !column4.primaryKey.new) {
22711
22734
  statements.push({
22712
- type: "alter_table_alter_column_set_autoincrement",
22735
+ type: "alter_table_alter_column_drop_pk",
22736
+ tableName,
22737
+ columnName
22738
+ });
22739
+ }
22740
+ if (((_g = column4.default) == null ? void 0 : _g.type) === "added") {
22741
+ statements.push({
22742
+ type: "alter_table_alter_column_set_default",
22713
22743
  tableName,
22714
22744
  columnName,
22745
+ newDefaultValue: column4.default.value,
22715
22746
  schema: schema4,
22716
- newDataType: columnType,
22717
- columnDefault,
22718
22747
  columnOnUpdate,
22719
22748
  columnNotNull,
22720
- columnAutoIncrement
22749
+ columnAutoIncrement,
22750
+ newDataType: columnType,
22751
+ columnPk
22721
22752
  });
22722
22753
  }
22723
- if (((_i = column4.autoincrement) == null ? void 0 : _i.type) === "changed") {
22724
- const type = column4.autoincrement.new ? "alter_table_alter_column_set_notnull" : "alter_table_alter_column_drop_notnull";
22754
+ if (((_h = column4.default) == null ? void 0 : _h.type) === "changed") {
22725
22755
  statements.push({
22726
- type,
22756
+ type: "alter_table_alter_column_set_default",
22727
22757
  tableName,
22728
22758
  columnName,
22759
+ newDefaultValue: column4.default.new,
22729
22760
  schema: schema4,
22730
- newDataType: columnType,
22731
- columnDefault,
22732
22761
  columnOnUpdate,
22733
22762
  columnNotNull,
22734
- columnAutoIncrement
22763
+ columnAutoIncrement,
22764
+ newDataType: columnType,
22765
+ columnPk
22735
22766
  });
22736
22767
  }
22737
- if (((_j = column4.autoincrement) == null ? void 0 : _j.type) === "deleted") {
22768
+ if (((_i = column4.default) == null ? void 0 : _i.type) === "deleted") {
22738
22769
  statements.push({
22739
- type: "alter_table_alter_column_drop_autoincrement",
22770
+ type: "alter_table_alter_column_drop_default",
22740
22771
  tableName,
22741
22772
  columnName,
22742
22773
  schema: schema4,
22743
- newDataType: columnType,
22744
22774
  columnDefault,
22745
22775
  columnOnUpdate,
22746
22776
  columnNotNull,
22747
- columnAutoIncrement
22777
+ columnAutoIncrement,
22778
+ newDataType: columnType,
22779
+ columnPk
22748
22780
  });
22749
22781
  }
22750
- if (((_k = column4.primaryKey) == null ? void 0 : _k.type) === "added") {
22782
+ if (((_j = column4.notNull) == null ? void 0 : _j.type) === "added") {
22751
22783
  statements.push({
22752
- type: "alter_table_alter_column_set_primarykey",
22784
+ type: "alter_table_alter_column_set_notnull",
22753
22785
  tableName,
22754
22786
  columnName,
22755
22787
  schema: schema4,
@@ -22757,11 +22789,12 @@ var _prepareAlterColumns = (tableName, schema4, columns, json2) => {
22757
22789
  columnDefault,
22758
22790
  columnOnUpdate,
22759
22791
  columnNotNull,
22760
- columnAutoIncrement
22792
+ columnAutoIncrement,
22793
+ columnPk
22761
22794
  });
22762
22795
  }
22763
- if (((_l = column4.primaryKey) == null ? void 0 : _l.type) === "changed") {
22764
- const type = column4.primaryKey.new ? "alter_table_alter_column_set_primarykey" : "alter_table_alter_column_drop_primarykey";
22796
+ if (((_k = column4.notNull) == null ? void 0 : _k.type) === "changed") {
22797
+ const type = column4.notNull.new ? "alter_table_alter_column_set_notnull" : "alter_table_alter_column_drop_notnull";
22765
22798
  statements.push({
22766
22799
  type,
22767
22800
  tableName,
@@ -22771,12 +22804,13 @@ var _prepareAlterColumns = (tableName, schema4, columns, json2) => {
22771
22804
  columnDefault,
22772
22805
  columnOnUpdate,
22773
22806
  columnNotNull,
22774
- columnAutoIncrement
22807
+ columnAutoIncrement,
22808
+ columnPk
22775
22809
  });
22776
22810
  }
22777
- if (((_m = column4.primaryKey) == null ? void 0 : _m.type) === "deleted") {
22811
+ if (((_l = column4.notNull) == null ? void 0 : _l.type) === "deleted") {
22778
22812
  statements.push({
22779
- type: "alter_table_alter_column_drop_primarykey",
22813
+ type: "alter_table_alter_column_drop_notnull",
22780
22814
  tableName,
22781
22815
  columnName,
22782
22816
  schema: schema4,
@@ -22784,10 +22818,23 @@ var _prepareAlterColumns = (tableName, schema4, columns, json2) => {
22784
22818
  columnDefault,
22785
22819
  columnOnUpdate,
22786
22820
  columnNotNull,
22787
- columnAutoIncrement
22821
+ columnAutoIncrement,
22822
+ columnPk
22788
22823
  });
22789
22824
  }
22790
- if (((_n = column4.onUpdate) == null ? void 0 : _n.type) === "added") {
22825
+ if (((_m = column4.primaryKey) == null ? void 0 : _m.type) === "added" || ((_n = column4.primaryKey) == null ? void 0 : _n.type) === "changed" && column4.primaryKey.new) {
22826
+ const wasAutoincrement = statements.filter(
22827
+ (it) => it.type === "alter_table_alter_column_set_autoincrement"
22828
+ );
22829
+ if (wasAutoincrement.length === 0) {
22830
+ statements.push({
22831
+ type: "alter_table_alter_column_set_pk",
22832
+ tableName,
22833
+ columnName
22834
+ });
22835
+ }
22836
+ }
22837
+ if (((_o = column4.onUpdate) == null ? void 0 : _o.type) === "added") {
22791
22838
  statements.push({
22792
22839
  type: "alter_table_alter_column_set_on_update",
22793
22840
  tableName,
@@ -22797,10 +22844,11 @@ var _prepareAlterColumns = (tableName, schema4, columns, json2) => {
22797
22844
  columnDefault,
22798
22845
  columnOnUpdate,
22799
22846
  columnNotNull,
22800
- columnAutoIncrement
22847
+ columnAutoIncrement,
22848
+ columnPk
22801
22849
  });
22802
22850
  }
22803
- if (((_o = column4.onUpdate) == null ? void 0 : _o.type) === "deleted") {
22851
+ if (((_p = column4.onUpdate) == null ? void 0 : _p.type) === "deleted") {
22804
22852
  statements.push({
22805
22853
  type: "alter_table_alter_column_drop_on_update",
22806
22854
  tableName,
@@ -22810,7 +22858,8 @@ var _prepareAlterColumns = (tableName, schema4, columns, json2) => {
22810
22858
  columnDefault,
22811
22859
  columnOnUpdate,
22812
22860
  columnNotNull,
22813
- columnAutoIncrement
22861
+ columnAutoIncrement,
22862
+ columnPk
22814
22863
  });
22815
22864
  }
22816
22865
  }
@@ -23042,9 +23091,9 @@ var alteredColumnSchema = objectType({
23042
23091
  name: makeSelfOrChanged(stringType()),
23043
23092
  type: makeChanged(stringType()).optional(),
23044
23093
  default: makePatched(anyType()).optional(),
23094
+ primaryKey: makePatched(booleanType()).optional(),
23045
23095
  notNull: makePatched(booleanType()).optional(),
23046
23096
  onUpdate: makePatched(booleanType()).optional(),
23047
- primaryKey: makePatched(booleanType()).optional(),
23048
23097
  autoincrement: makePatched(booleanType()).optional()
23049
23098
  }).strict();
23050
23099
  var enumSchema2 = objectType({
@@ -23375,6 +23424,7 @@ var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesR
23375
23424
  jsonStatements.push(...jsonDropTables);
23376
23425
  jsonStatements.push(...jsonRenameTables);
23377
23426
  jsonStatements.push(...jsonRenameColumnsStatements);
23427
+ jsonStatements.push(...jsonDeletedCompositePKs);
23378
23428
  jsonStatements.push(...jsonTableAlternations.alterColumns);
23379
23429
  jsonStatements.push(...jsonTableAlternations.createColumns);
23380
23430
  jsonStatements.push(...jsonAlterReferencesForAlteredTables);
@@ -23384,7 +23434,6 @@ var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesR
23384
23434
  jsonStatements.push(...jsonDropIndexesForAllAlteredTables);
23385
23435
  jsonStatements.push(...jsonCreateIndexesForCreatedTables);
23386
23436
  jsonStatements.push(...jsonCreateIndexesForAllAlteredTables);
23387
- jsonStatements.push(...jsonDeletedCompositePKs);
23388
23437
  jsonStatements.push(...jsonAddedCompositePKs);
23389
23438
  jsonStatements.push(...jsonAlteredCompositePKs);
23390
23439
  jsonStatements.push(...jsonSetTableSchemas);
@@ -23406,6 +23455,12 @@ var applySnapshotsDiff = async (json1, json2, dialect3, schemasResolver, tablesR
23406
23455
  };
23407
23456
  };
23408
23457
 
23458
+ // src/cli/commands/pgUp.ts
23459
+ init_source();
23460
+
23461
+ // src/cli/commands/mysqlUp.ts
23462
+ init_source();
23463
+
23409
23464
  // src/cli/commands/upFolders.ts
23410
23465
  var resolveSchemas = (missingSchemas, newSchemas, predicate) => {
23411
23466
  try {