drizzle-kit 0.21.2-f3756f2 → 0.21.3

Sign up to get free protection for your applications and to get access to all the features.
package/utils-studio.js CHANGED
@@ -33,6 +33,516 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
33
33
  ));
34
34
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
35
 
36
+ // node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/ansi-styles/index.js
37
+ function assembleStyles() {
38
+ const codes = /* @__PURE__ */ new Map();
39
+ for (const [groupName, group] of Object.entries(styles)) {
40
+ for (const [styleName, style] of Object.entries(group)) {
41
+ styles[styleName] = {
42
+ open: `\x1B[${style[0]}m`,
43
+ close: `\x1B[${style[1]}m`
44
+ };
45
+ group[styleName] = styles[styleName];
46
+ codes.set(style[0], style[1]);
47
+ }
48
+ Object.defineProperty(styles, groupName, {
49
+ value: group,
50
+ enumerable: false
51
+ });
52
+ }
53
+ Object.defineProperty(styles, "codes", {
54
+ value: codes,
55
+ enumerable: false
56
+ });
57
+ styles.color.close = "\x1B[39m";
58
+ styles.bgColor.close = "\x1B[49m";
59
+ styles.color.ansi = wrapAnsi16();
60
+ styles.color.ansi256 = wrapAnsi256();
61
+ styles.color.ansi16m = wrapAnsi16m();
62
+ styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
63
+ styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
64
+ styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
65
+ Object.defineProperties(styles, {
66
+ rgbToAnsi256: {
67
+ value(red, green, blue) {
68
+ if (red === green && green === blue) {
69
+ if (red < 8) {
70
+ return 16;
71
+ }
72
+ if (red > 248) {
73
+ return 231;
74
+ }
75
+ return Math.round((red - 8) / 247 * 24) + 232;
76
+ }
77
+ return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
78
+ },
79
+ enumerable: false
80
+ },
81
+ hexToRgb: {
82
+ value(hex) {
83
+ const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
84
+ if (!matches) {
85
+ return [0, 0, 0];
86
+ }
87
+ let [colorString] = matches;
88
+ if (colorString.length === 3) {
89
+ colorString = [...colorString].map((character) => character + character).join("");
90
+ }
91
+ const integer = Number.parseInt(colorString, 16);
92
+ return [
93
+ /* eslint-disable no-bitwise */
94
+ integer >> 16 & 255,
95
+ integer >> 8 & 255,
96
+ integer & 255
97
+ /* eslint-enable no-bitwise */
98
+ ];
99
+ },
100
+ enumerable: false
101
+ },
102
+ hexToAnsi256: {
103
+ value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
104
+ enumerable: false
105
+ },
106
+ ansi256ToAnsi: {
107
+ value(code) {
108
+ if (code < 8) {
109
+ return 30 + code;
110
+ }
111
+ if (code < 16) {
112
+ return 90 + (code - 8);
113
+ }
114
+ let red;
115
+ let green;
116
+ let blue;
117
+ if (code >= 232) {
118
+ red = ((code - 232) * 10 + 8) / 255;
119
+ green = red;
120
+ blue = red;
121
+ } else {
122
+ code -= 16;
123
+ const remainder = code % 36;
124
+ red = Math.floor(code / 36) / 5;
125
+ green = Math.floor(remainder / 6) / 5;
126
+ blue = remainder % 6 / 5;
127
+ }
128
+ const value = Math.max(red, green, blue) * 2;
129
+ if (value === 0) {
130
+ return 30;
131
+ }
132
+ let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
133
+ if (value === 2) {
134
+ result += 60;
135
+ }
136
+ return result;
137
+ },
138
+ enumerable: false
139
+ },
140
+ rgbToAnsi: {
141
+ value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
142
+ enumerable: false
143
+ },
144
+ hexToAnsi: {
145
+ value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
146
+ enumerable: false
147
+ }
148
+ });
149
+ return styles;
150
+ }
151
+ var ANSI_BACKGROUND_OFFSET, wrapAnsi16, wrapAnsi256, wrapAnsi16m, styles, modifierNames, foregroundColorNames, backgroundColorNames, colorNames, ansiStyles, ansi_styles_default;
152
+ var init_ansi_styles = __esm({
153
+ "node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/ansi-styles/index.js"() {
154
+ ANSI_BACKGROUND_OFFSET = 10;
155
+ wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
156
+ wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
157
+ wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
158
+ styles = {
159
+ modifier: {
160
+ reset: [0, 0],
161
+ // 21 isn't widely supported and 22 does the same thing
162
+ bold: [1, 22],
163
+ dim: [2, 22],
164
+ italic: [3, 23],
165
+ underline: [4, 24],
166
+ overline: [53, 55],
167
+ inverse: [7, 27],
168
+ hidden: [8, 28],
169
+ strikethrough: [9, 29]
170
+ },
171
+ color: {
172
+ black: [30, 39],
173
+ red: [31, 39],
174
+ green: [32, 39],
175
+ yellow: [33, 39],
176
+ blue: [34, 39],
177
+ magenta: [35, 39],
178
+ cyan: [36, 39],
179
+ white: [37, 39],
180
+ // Bright color
181
+ blackBright: [90, 39],
182
+ gray: [90, 39],
183
+ // Alias of `blackBright`
184
+ grey: [90, 39],
185
+ // Alias of `blackBright`
186
+ redBright: [91, 39],
187
+ greenBright: [92, 39],
188
+ yellowBright: [93, 39],
189
+ blueBright: [94, 39],
190
+ magentaBright: [95, 39],
191
+ cyanBright: [96, 39],
192
+ whiteBright: [97, 39]
193
+ },
194
+ bgColor: {
195
+ bgBlack: [40, 49],
196
+ bgRed: [41, 49],
197
+ bgGreen: [42, 49],
198
+ bgYellow: [43, 49],
199
+ bgBlue: [44, 49],
200
+ bgMagenta: [45, 49],
201
+ bgCyan: [46, 49],
202
+ bgWhite: [47, 49],
203
+ // Bright color
204
+ bgBlackBright: [100, 49],
205
+ bgGray: [100, 49],
206
+ // Alias of `bgBlackBright`
207
+ bgGrey: [100, 49],
208
+ // Alias of `bgBlackBright`
209
+ bgRedBright: [101, 49],
210
+ bgGreenBright: [102, 49],
211
+ bgYellowBright: [103, 49],
212
+ bgBlueBright: [104, 49],
213
+ bgMagentaBright: [105, 49],
214
+ bgCyanBright: [106, 49],
215
+ bgWhiteBright: [107, 49]
216
+ }
217
+ };
218
+ modifierNames = Object.keys(styles.modifier);
219
+ foregroundColorNames = Object.keys(styles.color);
220
+ backgroundColorNames = Object.keys(styles.bgColor);
221
+ colorNames = [...foregroundColorNames, ...backgroundColorNames];
222
+ ansiStyles = assembleStyles();
223
+ ansi_styles_default = ansiStyles;
224
+ }
225
+ });
226
+
227
+ // node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/supports-color/index.js
228
+ function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : import_node_process.default.argv) {
229
+ const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
230
+ const position = argv.indexOf(prefix + flag);
231
+ const terminatorPosition = argv.indexOf("--");
232
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
233
+ }
234
+ function envForceColor() {
235
+ if ("FORCE_COLOR" in env) {
236
+ if (env.FORCE_COLOR === "true") {
237
+ return 1;
238
+ }
239
+ if (env.FORCE_COLOR === "false") {
240
+ return 0;
241
+ }
242
+ return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
243
+ }
244
+ }
245
+ function translateLevel(level) {
246
+ if (level === 0) {
247
+ return false;
248
+ }
249
+ return {
250
+ level,
251
+ hasBasic: true,
252
+ has256: level >= 2,
253
+ has16m: level >= 3
254
+ };
255
+ }
256
+ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
257
+ const noFlagForceColor = envForceColor();
258
+ if (noFlagForceColor !== void 0) {
259
+ flagForceColor = noFlagForceColor;
260
+ }
261
+ const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
262
+ if (forceColor === 0) {
263
+ return 0;
264
+ }
265
+ if (sniffFlags) {
266
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
267
+ return 3;
268
+ }
269
+ if (hasFlag("color=256")) {
270
+ return 2;
271
+ }
272
+ }
273
+ if ("TF_BUILD" in env && "AGENT_NAME" in env) {
274
+ return 1;
275
+ }
276
+ if (haveStream && !streamIsTTY && forceColor === void 0) {
277
+ return 0;
278
+ }
279
+ const min = forceColor || 0;
280
+ if (env.TERM === "dumb") {
281
+ return min;
282
+ }
283
+ if (import_node_process.default.platform === "win32") {
284
+ const osRelease = import_node_os.default.release().split(".");
285
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
286
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
287
+ }
288
+ return 1;
289
+ }
290
+ if ("CI" in env) {
291
+ if ("GITHUB_ACTIONS" in env || "GITEA_ACTIONS" in env) {
292
+ return 3;
293
+ }
294
+ if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
295
+ return 1;
296
+ }
297
+ return min;
298
+ }
299
+ if ("TEAMCITY_VERSION" in env) {
300
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
301
+ }
302
+ if (env.COLORTERM === "truecolor") {
303
+ return 3;
304
+ }
305
+ if (env.TERM === "xterm-kitty") {
306
+ return 3;
307
+ }
308
+ if ("TERM_PROGRAM" in env) {
309
+ const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
310
+ switch (env.TERM_PROGRAM) {
311
+ case "iTerm.app": {
312
+ return version >= 3 ? 3 : 2;
313
+ }
314
+ case "Apple_Terminal": {
315
+ return 2;
316
+ }
317
+ }
318
+ }
319
+ if (/-256(color)?$/i.test(env.TERM)) {
320
+ return 2;
321
+ }
322
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
323
+ return 1;
324
+ }
325
+ if ("COLORTERM" in env) {
326
+ return 1;
327
+ }
328
+ return min;
329
+ }
330
+ function createSupportsColor(stream, options = {}) {
331
+ const level = _supportsColor(stream, {
332
+ streamIsTTY: stream && stream.isTTY,
333
+ ...options
334
+ });
335
+ return translateLevel(level);
336
+ }
337
+ var import_node_process, import_node_os, import_node_tty, env, flagForceColor, supportsColor, supports_color_default;
338
+ var init_supports_color = __esm({
339
+ "node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/vendor/supports-color/index.js"() {
340
+ import_node_process = __toESM(require("node:process"), 1);
341
+ import_node_os = __toESM(require("node:os"), 1);
342
+ import_node_tty = __toESM(require("node:tty"), 1);
343
+ ({ env } = import_node_process.default);
344
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
345
+ flagForceColor = 0;
346
+ } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
347
+ flagForceColor = 1;
348
+ }
349
+ supportsColor = {
350
+ stdout: createSupportsColor({ isTTY: import_node_tty.default.isatty(1) }),
351
+ stderr: createSupportsColor({ isTTY: import_node_tty.default.isatty(2) })
352
+ };
353
+ supports_color_default = supportsColor;
354
+ }
355
+ });
356
+
357
+ // node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/utilities.js
358
+ function stringReplaceAll(string, substring, replacer) {
359
+ let index4 = string.indexOf(substring);
360
+ if (index4 === -1) {
361
+ return string;
362
+ }
363
+ const substringLength = substring.length;
364
+ let endIndex = 0;
365
+ let returnValue = "";
366
+ do {
367
+ returnValue += string.slice(endIndex, index4) + substring + replacer;
368
+ endIndex = index4 + substringLength;
369
+ index4 = string.indexOf(substring, endIndex);
370
+ } while (index4 !== -1);
371
+ returnValue += string.slice(endIndex);
372
+ return returnValue;
373
+ }
374
+ function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index4) {
375
+ let endIndex = 0;
376
+ let returnValue = "";
377
+ do {
378
+ const gotCR = string[index4 - 1] === "\r";
379
+ returnValue += string.slice(endIndex, gotCR ? index4 - 1 : index4) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
380
+ endIndex = index4 + 1;
381
+ index4 = string.indexOf("\n", endIndex);
382
+ } while (index4 !== -1);
383
+ returnValue += string.slice(endIndex);
384
+ return returnValue;
385
+ }
386
+ var init_utilities = __esm({
387
+ "node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/utilities.js"() {
388
+ }
389
+ });
390
+
391
+ // node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/index.js
392
+ function createChalk(options) {
393
+ return chalkFactory(options);
394
+ }
395
+ var stdoutColor, stderrColor, GENERATOR, STYLER, IS_EMPTY, levelMapping, styles2, applyOptions, chalkFactory, getModelAnsi, usedModels, proto, createStyler, createBuilder, applyStyle, chalk, chalkStderr, source_default;
396
+ var init_source = __esm({
397
+ "node_modules/.pnpm/chalk@5.3.0/node_modules/chalk/source/index.js"() {
398
+ init_ansi_styles();
399
+ init_supports_color();
400
+ init_utilities();
401
+ ({ stdout: stdoutColor, stderr: stderrColor } = supports_color_default);
402
+ GENERATOR = Symbol("GENERATOR");
403
+ STYLER = Symbol("STYLER");
404
+ IS_EMPTY = Symbol("IS_EMPTY");
405
+ levelMapping = [
406
+ "ansi",
407
+ "ansi",
408
+ "ansi256",
409
+ "ansi16m"
410
+ ];
411
+ styles2 = /* @__PURE__ */ Object.create(null);
412
+ applyOptions = (object, options = {}) => {
413
+ if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
414
+ throw new Error("The `level` option should be an integer from 0 to 3");
415
+ }
416
+ const colorLevel = stdoutColor ? stdoutColor.level : 0;
417
+ object.level = options.level === void 0 ? colorLevel : options.level;
418
+ };
419
+ chalkFactory = (options) => {
420
+ const chalk2 = (...strings) => strings.join(" ");
421
+ applyOptions(chalk2, options);
422
+ Object.setPrototypeOf(chalk2, createChalk.prototype);
423
+ return chalk2;
424
+ };
425
+ Object.setPrototypeOf(createChalk.prototype, Function.prototype);
426
+ for (const [styleName, style] of Object.entries(ansi_styles_default)) {
427
+ styles2[styleName] = {
428
+ get() {
429
+ const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
430
+ Object.defineProperty(this, styleName, { value: builder });
431
+ return builder;
432
+ }
433
+ };
434
+ }
435
+ styles2.visible = {
436
+ get() {
437
+ const builder = createBuilder(this, this[STYLER], true);
438
+ Object.defineProperty(this, "visible", { value: builder });
439
+ return builder;
440
+ }
441
+ };
442
+ getModelAnsi = (model, level, type, ...arguments_) => {
443
+ if (model === "rgb") {
444
+ if (level === "ansi16m") {
445
+ return ansi_styles_default[type].ansi16m(...arguments_);
446
+ }
447
+ if (level === "ansi256") {
448
+ return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
449
+ }
450
+ return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
451
+ }
452
+ if (model === "hex") {
453
+ return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
454
+ }
455
+ return ansi_styles_default[type][model](...arguments_);
456
+ };
457
+ usedModels = ["rgb", "hex", "ansi256"];
458
+ for (const model of usedModels) {
459
+ styles2[model] = {
460
+ get() {
461
+ const { level } = this;
462
+ return function(...arguments_) {
463
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
464
+ return createBuilder(this, styler, this[IS_EMPTY]);
465
+ };
466
+ }
467
+ };
468
+ const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
469
+ styles2[bgModel] = {
470
+ get() {
471
+ const { level } = this;
472
+ return function(...arguments_) {
473
+ const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
474
+ return createBuilder(this, styler, this[IS_EMPTY]);
475
+ };
476
+ }
477
+ };
478
+ }
479
+ proto = Object.defineProperties(() => {
480
+ }, {
481
+ ...styles2,
482
+ level: {
483
+ enumerable: true,
484
+ get() {
485
+ return this[GENERATOR].level;
486
+ },
487
+ set(level) {
488
+ this[GENERATOR].level = level;
489
+ }
490
+ }
491
+ });
492
+ createStyler = (open, close, parent) => {
493
+ let openAll;
494
+ let closeAll;
495
+ if (parent === void 0) {
496
+ openAll = open;
497
+ closeAll = close;
498
+ } else {
499
+ openAll = parent.openAll + open;
500
+ closeAll = close + parent.closeAll;
501
+ }
502
+ return {
503
+ open,
504
+ close,
505
+ openAll,
506
+ closeAll,
507
+ parent
508
+ };
509
+ };
510
+ createBuilder = (self2, _styler, _isEmpty) => {
511
+ const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
512
+ Object.setPrototypeOf(builder, proto);
513
+ builder[GENERATOR] = self2;
514
+ builder[STYLER] = _styler;
515
+ builder[IS_EMPTY] = _isEmpty;
516
+ return builder;
517
+ };
518
+ applyStyle = (self2, string) => {
519
+ if (self2.level <= 0 || !string) {
520
+ return self2[IS_EMPTY] ? "" : string;
521
+ }
522
+ let styler = self2[STYLER];
523
+ if (styler === void 0) {
524
+ return string;
525
+ }
526
+ const { openAll, closeAll } = styler;
527
+ if (string.includes("\x1B")) {
528
+ while (styler !== void 0) {
529
+ string = stringReplaceAll(string, styler.close, styler.open);
530
+ styler = styler.parent;
531
+ }
532
+ }
533
+ const lfIndex = string.indexOf("\n");
534
+ if (lfIndex !== -1) {
535
+ string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
536
+ }
537
+ return openAll + string + closeAll;
538
+ };
539
+ Object.defineProperties(createChalk.prototype, styles2);
540
+ chalk = createChalk();
541
+ chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
542
+ source_default = chalk;
543
+ }
544
+ });
545
+
36
546
  // node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/readline.js
37
547
  var require_readline = __commonJS({
38
548
  "node_modules/.pnpm/hanji@0.0.5/node_modules/hanji/readline.js"(exports2) {
@@ -545,7 +1055,7 @@ var require_hanji = __commonJS({
545
1055
  return;
546
1056
  }
547
1057
  exports2.render = render2;
548
- function renderWithTask2(view, task) {
1058
+ function renderWithTask3(view, task) {
549
1059
  return __awaiter(this, void 0, void 0, function* () {
550
1060
  const terminal = new TaskTerminal(view, process.stdout);
551
1061
  terminal.requestLayout();
@@ -554,7 +1064,7 @@ var require_hanji = __commonJS({
554
1064
  return result;
555
1065
  });
556
1066
  }
557
- exports2.renderWithTask = renderWithTask2;
1067
+ exports2.renderWithTask = renderWithTask3;
558
1068
  var terminateHandler;
559
1069
  function onTerminate(callback) {
560
1070
  terminateHandler = callback;
@@ -569,7 +1079,7 @@ var init_global = __esm({
569
1079
  "src/global.ts"() {
570
1080
  "use strict";
571
1081
  originUUID = "00000000-0000-0000-0000-000000000000";
572
- snapshotVersion = "7";
1082
+ snapshotVersion = "6";
573
1083
  }
574
1084
  });
575
1085
 
@@ -4498,7 +5008,7 @@ var init_mysqlSchema = __esm({
4498
5008
  });
4499
5009
 
4500
5010
  // src/serializer/pgSchema.ts
4501
- var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, indexColumn, index2, indexV4, indexV5, indexV6, fk2, column2, tableV32, compositePK2, uniqueConstraint2, tableV42, tableV6, tableV5, table2, schemaHash2, kitInternals2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternalV5, pgSchemaInternalV6, pgSchemaExternal, pgSchemaInternal, tableSquashed2, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashedV6, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchemaV5, pgSchemaV6, pgSchema2, backwardCompatiblePgSchema, dryPg;
5011
+ var indexV2, columnV2, tableV2, enumSchemaV1, 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, pgSchema2, backwardCompatiblePgSchema, dryPg;
4502
5012
  var init_pgSchema = __esm({
4503
5013
  "src/serializer/pgSchema.ts"() {
4504
5014
  "use strict";
@@ -4566,48 +5076,10 @@ var init_pgSchema = __esm({
4566
5076
  tables: recordType(stringType(), tableV1),
4567
5077
  enums: recordType(stringType(), enumSchemaV1)
4568
5078
  }).strict();
4569
- indexColumn = objectType({
4570
- expression: stringType(),
4571
- isExpression: booleanType(),
4572
- asc: booleanType(),
4573
- nulls: stringType().optional(),
4574
- opclass: stringType().optional()
4575
- });
4576
5079
  index2 = objectType({
4577
- name: stringType(),
4578
- columns: indexColumn.array(),
4579
- isUnique: booleanType(),
4580
- with: recordType(stringType(), anyType()).optional(),
4581
- method: stringType().default("btree"),
4582
- where: stringType().optional(),
4583
- concurrently: booleanType().default(false)
4584
- }).strict();
4585
- indexV4 = objectType({
4586
5080
  name: stringType(),
4587
5081
  columns: stringType().array(),
4588
- isUnique: booleanType(),
4589
- with: recordType(stringType(), stringType()).optional(),
4590
- method: stringType().default("btree"),
4591
- where: stringType().optional(),
4592
- concurrently: booleanType().default(false)
4593
- }).strict();
4594
- indexV5 = objectType({
4595
- name: stringType(),
4596
- columns: stringType().array(),
4597
- isUnique: booleanType(),
4598
- with: recordType(stringType(), stringType()).optional(),
4599
- method: stringType().default("btree"),
4600
- where: stringType().optional(),
4601
- concurrently: booleanType().default(false)
4602
- }).strict();
4603
- indexV6 = objectType({
4604
- name: stringType(),
4605
- columns: stringType().array(),
4606
- isUnique: booleanType(),
4607
- with: recordType(stringType(), stringType()).optional(),
4608
- method: stringType().default("btree"),
4609
- where: stringType().optional(),
4610
- concurrently: booleanType().default(false)
5082
+ isUnique: booleanType()
4611
5083
  }).strict();
4612
5084
  fk2 = objectType({
4613
5085
  name: stringType(),
@@ -4649,27 +5121,9 @@ var init_pgSchema = __esm({
4649
5121
  name: stringType(),
4650
5122
  schema: stringType(),
4651
5123
  columns: recordType(stringType(), column2),
4652
- indexes: recordType(stringType(), indexV4),
5124
+ indexes: recordType(stringType(), index2),
4653
5125
  foreignKeys: recordType(stringType(), fk2)
4654
5126
  }).strict();
4655
- tableV6 = objectType({
4656
- name: stringType(),
4657
- schema: stringType(),
4658
- columns: recordType(stringType(), column2),
4659
- indexes: recordType(stringType(), indexV6),
4660
- foreignKeys: recordType(stringType(), fk2),
4661
- compositePrimaryKeys: recordType(stringType(), compositePK2),
4662
- uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
4663
- }).strict();
4664
- tableV5 = objectType({
4665
- name: stringType(),
4666
- schema: stringType(),
4667
- columns: recordType(stringType(), column2),
4668
- indexes: recordType(stringType(), indexV5),
4669
- foreignKeys: recordType(stringType(), fk2),
4670
- compositePrimaryKeys: recordType(stringType(), compositePK2),
4671
- uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
4672
- }).strict();
4673
5127
  table2 = objectType({
4674
5128
  name: stringType(),
4675
5129
  schema: stringType(),
@@ -4714,7 +5168,7 @@ var init_pgSchema = __esm({
4714
5168
  pgSchemaInternalV5 = objectType({
4715
5169
  version: literalType("5"),
4716
5170
  dialect: literalType("pg"),
4717
- tables: recordType(stringType(), tableV5),
5171
+ tables: recordType(stringType(), table2),
4718
5172
  enums: recordType(stringType(), enumSchemaV1),
4719
5173
  schemas: recordType(stringType(), stringType()),
4720
5174
  _meta: objectType({
@@ -4724,19 +5178,6 @@ var init_pgSchema = __esm({
4724
5178
  }),
4725
5179
  internal: kitInternals2
4726
5180
  }).strict();
4727
- pgSchemaInternalV6 = objectType({
4728
- version: literalType("6"),
4729
- dialect: literalType("postgresql"),
4730
- tables: recordType(stringType(), tableV6),
4731
- enums: recordType(stringType(), enumSchema),
4732
- schemas: recordType(stringType(), stringType()),
4733
- _meta: objectType({
4734
- schemas: recordType(stringType(), stringType()),
4735
- tables: recordType(stringType(), stringType()),
4736
- columns: recordType(stringType(), stringType())
4737
- }),
4738
- internal: kitInternals2
4739
- }).strict();
4740
5181
  pgSchemaExternal = objectType({
4741
5182
  version: literalType("5"),
4742
5183
  dialect: literalType("pg"),
@@ -4750,7 +5191,7 @@ var init_pgSchema = __esm({
4750
5191
  })
4751
5192
  }).strict();
4752
5193
  pgSchemaInternal = objectType({
4753
- version: literalType("7"),
5194
+ version: literalType("6"),
4754
5195
  dialect: literalType("postgresql"),
4755
5196
  tables: recordType(stringType(), table2),
4756
5197
  enums: recordType(stringType(), enumSchema),
@@ -4785,15 +5226,8 @@ var init_pgSchema = __esm({
4785
5226
  enums: recordType(stringType(), enumSchemaV1),
4786
5227
  schemas: recordType(stringType(), stringType())
4787
5228
  }).strict();
4788
- pgSchemaSquashedV6 = objectType({
4789
- version: literalType("6"),
4790
- dialect: literalType("postgresql"),
4791
- tables: recordType(stringType(), tableSquashed2),
4792
- enums: recordType(stringType(), enumSchema),
4793
- schemas: recordType(stringType(), stringType())
4794
- }).strict();
4795
5229
  pgSchemaSquashed = objectType({
4796
- version: literalType("7"),
5230
+ version: literalType("6"),
4797
5231
  dialect: literalType("postgresql"),
4798
5232
  tables: recordType(stringType(), tableSquashed2),
4799
5233
  enums: recordType(stringType(), enumSchema),
@@ -4802,13 +5236,8 @@ var init_pgSchema = __esm({
4802
5236
  pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash2);
4803
5237
  pgSchemaV4 = pgSchemaInternalV4.merge(schemaHash2);
4804
5238
  pgSchemaV5 = pgSchemaInternalV5.merge(schemaHash2);
4805
- pgSchemaV6 = pgSchemaInternalV6.merge(schemaHash2);
4806
5239
  pgSchema2 = pgSchemaInternal.merge(schemaHash2);
4807
- backwardCompatiblePgSchema = unionType([
4808
- pgSchemaV5,
4809
- pgSchemaV6,
4810
- pgSchema2
4811
- ]);
5240
+ backwardCompatiblePgSchema = unionType([pgSchemaV5, pgSchema2]);
4812
5241
  dryPg = pgSchema2.parse({
4813
5242
  version: snapshotVersion,
4814
5243
  dialect: "postgresql",
@@ -4964,12 +5393,49 @@ var init_utils = __esm({
4964
5393
  });
4965
5394
 
4966
5395
  // src/cli/views.ts
4967
- var import_hanji;
5396
+ var import_hanji, Spinner, ProgressView;
4968
5397
  var init_views = __esm({
4969
5398
  "src/cli/views.ts"() {
4970
5399
  "use strict";
5400
+ init_source();
4971
5401
  import_hanji = __toESM(require_hanji());
4972
5402
  init_utils();
5403
+ Spinner = class {
5404
+ constructor(frames) {
5405
+ this.frames = frames;
5406
+ this.offset = 0;
5407
+ this.tick = () => {
5408
+ this.iterator();
5409
+ };
5410
+ this.value = () => {
5411
+ return this.frames[this.offset];
5412
+ };
5413
+ this.iterator = () => {
5414
+ this.offset += 1;
5415
+ this.offset %= frames.length - 1;
5416
+ };
5417
+ }
5418
+ };
5419
+ ProgressView = class extends import_hanji.TaskView {
5420
+ constructor(progressText, successText) {
5421
+ super();
5422
+ this.progressText = progressText;
5423
+ this.successText = successText;
5424
+ this.spinner = new Spinner("\u28F7\u28EF\u28DF\u287F\u28BF\u28FB\u28FD\u28FE".split(""));
5425
+ this.timeout = setInterval(() => {
5426
+ this.spinner.tick();
5427
+ this.requestLayout();
5428
+ }, 128);
5429
+ this.on("detach", () => clearInterval(this.timeout));
5430
+ }
5431
+ render(status) {
5432
+ if (status === "pending") {
5433
+ const spin = this.spinner.value();
5434
+ return `[${spin}] ${this.progressText}`;
5435
+ }
5436
+ return `[${source_default.green("\u2713")}] ${this.successText}`;
5437
+ }
5438
+ };
4973
5439
  }
4974
5440
  });
4975
5441
 
@@ -5047,12 +5513,24 @@ var init_sqliteSerializer = __esm({
5047
5513
  `SELECT
5048
5514
  m.name as "tableName", p.name as "columnName", p.type as "columnType", p."notnull" as "notNull", p.dflt_value as "defaultValue", p.pk as pk
5049
5515
  FROM sqlite_master AS m JOIN pragma_table_info(m.name) AS p
5050
- WHERE m.type = 'table' and m.tbl_name != 'sqlite_sequence' and m.tbl_name != 'sqlite_stat1' and m.tbl_name != '_litestream_seq' and m.tbl_name != '_litestream_lock' and m.tbl_name != 'libsql_wasm_func_table' and m.tbl_name != '__drizzle_migrations';
5516
+ WHERE m.type = 'table'
5517
+ and m.tbl_name != 'sqlite_sequence'
5518
+ and m.tbl_name != 'sqlite_stat1'
5519
+ and m.tbl_name != '_litestream_seq'
5520
+ and m.tbl_name != '_litestream_lock'
5521
+ and m.tbl_name != 'libsql_wasm_func_table'
5522
+ and m.tbl_name != '__drizzle_migrations'
5523
+ and m.tbl_name != '_cf_KV';
5051
5524
  `
5052
5525
  );
5053
5526
  const tablesWithSeq = [];
5054
5527
  const seq = await db.query(
5055
- `SELECT * FROM sqlite_master WHERE name != 'sqlite_sequence' and name != 'sqlite_stat1' and name != '_litestream_seq' and name != '_litestream_lock' and sql GLOB '*[ *' || CHAR(9) || CHAR(10) || CHAR(13) || ']AUTOINCREMENT[^'']*';`
5528
+ `SELECT * FROM sqlite_master WHERE name != 'sqlite_sequence'
5529
+ and name != 'sqlite_stat1'
5530
+ and name != '_litestream_seq'
5531
+ and name != '_litestream_lock'
5532
+ and tbl_name != '_cf_KV'
5533
+ and sql GLOB '*[ *' || CHAR(9) || CHAR(10) || CHAR(13) || ']AUTOINCREMENT[^'']*';`
5056
5534
  );
5057
5535
  for (const s of seq) {
5058
5536
  tablesWithSeq.push(s.name);
@@ -5137,7 +5615,8 @@ var init_sqliteSerializer = __esm({
5137
5615
  try {
5138
5616
  const fks = await db.query(
5139
5617
  `SELECT m.name as "tableFrom", f.id as "id", f."table" as "tableTo", f."from", f."to", f."on_update" as "onUpdate", f."on_delete" as "onDelete", f.seq as "seq"
5140
- FROM sqlite_master m, pragma_foreign_key_list(m.name) as f;`
5618
+ FROM sqlite_master m, pragma_foreign_key_list(m.name) as f
5619
+ where m.tbl_name != '_cf_KV';`
5141
5620
  );
5142
5621
  const fkByTableName = {};
5143
5622
  for (const fkRow of fks) {
@@ -5196,7 +5675,9 @@ FROM sqlite_master AS m,
5196
5675
  pragma_index_list(m.name) AS il,
5197
5676
  pragma_index_info(il.name) AS ii
5198
5677
  WHERE
5199
- m.type = 'table' and il.name NOT LIKE 'sqlite_autoindex_%';`
5678
+ m.type = 'table'
5679
+ and il.name NOT LIKE 'sqlite_autoindex_%'
5680
+ and m.tbl_name != '_cf_KV';`
5200
5681
  );
5201
5682
  for (const idxRow of idxs) {
5202
5683
  const tableName = idxRow.tableName;
@@ -5449,13 +5930,6 @@ var require_brace_expansion = __commonJS({
5449
5930
  }
5450
5931
  });
5451
5932
 
5452
- // src/extensions/vector.ts
5453
- var init_vector = __esm({
5454
- "src/extensions/vector.ts"() {
5455
- "use strict";
5456
- }
5457
- });
5458
-
5459
5933
  // src/serializer/pgSerializer.ts
5460
5934
  var import_pg_core2, import_pg_core3, import_drizzle_orm2, dialect4, trimChar, fromDatabase2, columnToDefault, defaultForColumn;
5461
5935
  var init_pgSerializer = __esm({
@@ -5466,7 +5940,6 @@ var init_pgSerializer = __esm({
5466
5940
  import_drizzle_orm2 = require("drizzle-orm");
5467
5941
  init_serializer();
5468
5942
  init_outputs();
5469
- init_vector();
5470
5943
  dialect4 = new import_pg_core2.PgDialect();
5471
5944
  trimChar = (str, char) => {
5472
5945
  let start = 0;
@@ -5728,10 +6201,7 @@ var init_pgSerializer = __esm({
5728
6201
  columnTypeMapped = trimChar(columnTypeMapped, '"');
5729
6202
  columnToReturn[columnName] = {
5730
6203
  name: columnName,
5731
- type: (
5732
- // filter vectors, but in future we should filter any extension that was installed by user
5733
- columnAdditionalDT === "USER-DEFINED" && enumType3 !== "vector" ? enumType3 : columnTypeMapped
5734
- ),
6204
+ type: columnAdditionalDT === "USER-DEFINED" ? enumType3 : columnTypeMapped,
5735
6205
  typeSchema: enumsToReturn[`${tableSchema}.${enumType3}`] !== void 0 ? enumsToReturn[`${tableSchema}.${enumType3}`].schema : void 0,
5736
6206
  primaryKey: primaryKey.length === 1 && cprimaryKey.length < 2,
5737
6207
  // default: isSerial ? undefined : defaultValue,
@@ -5742,42 +6212,15 @@ var init_pgSerializer = __esm({
5742
6212
  }
5743
6213
  }
5744
6214
  const dbIndexes = await db.query(
5745
- `SELECT DISTINCT ON (t.relname, ic.relname, k.i) t.relname as table_name, ic.relname AS indexname,
5746
- k.i AS index_order,
5747
- i.indisunique as is_unique,
5748
- am.amname as method,
5749
- ic.reloptions as with,
5750
- coalesce(a.attname,
5751
- (('{' || pg_get_expr(
5752
- i.indexprs,
5753
- i.indrelid
5754
- )
5755
- || '}')::text[]
5756
- )[k.i]
5757
- ) AS column_name,
5758
- CASE
5759
- WHEN pg_get_expr(i.indexprs, i.indrelid) IS NOT NULL THEN 1
5760
- ELSE 0
5761
- END AS is_expression,
5762
- i.indoption[k.i-1] & 1 = 1 AS descending,
5763
- i.indoption[k.i-1] & 2 = 2 AS nulls_first,
5764
- pg_get_expr(
5765
- i.indpred,
5766
- i.indrelid
5767
- ) as where,
5768
- opc.opcname
5769
- FROM pg_class t
5770
- LEFT JOIN pg_index i ON t.oid = i.indrelid
5771
- LEFT JOIN pg_class ic ON ic.oid = i.indexrelid
5772
- CROSS JOIN LATERAL (SELECT unnest(i.indkey), generate_subscripts(i.indkey, 1) + 1) AS k(attnum, i)
5773
- LEFT JOIN pg_attribute AS a
5774
- ON i.indrelid = a.attrelid AND k.attnum = a.attnum
5775
- JOIN pg_namespace c on c.oid = t.relnamespace
5776
- LEFT JOIN pg_am AS am ON ic.relam = am.oid
5777
- JOIN pg_opclass opc ON opc.oid = ANY(i.indclass)
5778
- WHERE
5779
- c.nspname = '${tableSchema}' AND
5780
- t.relname = '${tableName}';`
6215
+ `SELECT t.relname as table_name, i.relname AS index_name, ix.indisunique AS is_unique, a.attname AS column_name
6216
+ FROM pg_class t
6217
+ JOIN pg_index ix ON t.oid = ix.indrelid
6218
+ JOIN pg_class i ON i.oid = ix.indexrelid
6219
+ JOIN pg_attribute a ON a.attrelid = t.oid AND a.attnum = ANY(ix.indkey)
6220
+ JOIN pg_namespace ns ON ns.oid = t.relnamespace
6221
+ WHERE ns.nspname = '${tableSchema}'
6222
+ AND t.relname = '${tableName}'
6223
+ and ix.indisprimary = false;`
5781
6224
  );
5782
6225
  const dbIndexFromConstraint = await db.query(
5783
6226
  `SELECT
@@ -5794,51 +6237,18 @@ var init_pgSerializer = __esm({
5794
6237
  );
5795
6238
  const idxsInConsteraint = dbIndexFromConstraint.filter((it) => it.generated_by_constraint === 1).map((it) => it.index_name);
5796
6239
  for (const dbIndex of dbIndexes) {
5797
- const indexName = dbIndex.indexname;
6240
+ const indexName = dbIndex.index_name;
5798
6241
  const indexColumnName = dbIndex.column_name;
5799
6242
  const indexIsUnique = dbIndex.is_unique;
5800
- const indexMethod = dbIndex.method;
5801
- const indexWith = dbIndex.with;
5802
- const indexWhere = dbIndex.where;
5803
- const opclass = dbIndex.opcname;
5804
- const isExpression = dbIndex.is_expression === 1;
5805
- const desc = dbIndex.descending;
5806
- const nullsFirst = dbIndex.nulls_first;
5807
- const mappedWith = {};
5808
- if (indexWith !== null) {
5809
- indexWith.forEach((it) => {
5810
- const splitted = it.split("=");
5811
- mappedWith[splitted[0]] = splitted[1];
5812
- });
5813
- }
5814
6243
  if (idxsInConsteraint.includes(indexName))
5815
6244
  continue;
5816
6245
  if (typeof indexToReturn[indexName] !== "undefined") {
5817
- indexToReturn[indexName].columns.push({
5818
- expression: indexColumnName,
5819
- asc: !desc,
5820
- nulls: nullsFirst ? "first" : "last",
5821
- opclass,
5822
- isExpression
5823
- });
6246
+ indexToReturn[indexName].columns.push(indexColumnName);
5824
6247
  } else {
5825
6248
  indexToReturn[indexName] = {
5826
6249
  name: indexName,
5827
- columns: [
5828
- {
5829
- expression: indexColumnName,
5830
- asc: !desc,
5831
- nulls: nullsFirst ? "first" : "last",
5832
- opclass,
5833
- isExpression
5834
- }
5835
- ],
5836
- isUnique: indexIsUnique,
5837
- // should not be a part of diff detecs
5838
- concurrently: false,
5839
- method: indexMethod,
5840
- where: indexWhere === null ? void 0 : indexWhere,
5841
- with: mappedWith
6250
+ columns: [indexColumnName],
6251
+ isUnique: indexIsUnique
5842
6252
  };
5843
6253
  }
5844
6254
  }
@@ -5874,7 +6284,7 @@ var init_pgSerializer = __esm({
5874
6284
  }
5875
6285
  const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
5876
6286
  return {
5877
- version: "7",
6287
+ version: "6",
5878
6288
  dialect: "postgresql",
5879
6289
  tables: result,
5880
6290
  enums: enumsToReturn,
@@ -5896,6 +6306,7 @@ var init_pgSerializer = __esm({
5896
6306
  "time without time zone": "::time without time zone",
5897
6307
  // "timestamp with time zone": "::timestamp with time zone",
5898
6308
  "timestamp without time zone": "::timestamp without time zone",
6309
+ "timestamp(": "::timestamp without time zone",
5899
6310
  // date: "::date",
5900
6311
  // interval: "::interval",
5901
6312
  // character: "::bpchar",
@@ -5908,15 +6319,15 @@ var init_pgSerializer = __esm({
5908
6319
  "character(": "::bpchar"
5909
6320
  };
5910
6321
  defaultForColumn = (column4) => {
6322
+ if (column4.column_default === null) {
6323
+ return void 0;
6324
+ }
5911
6325
  if (column4.data_type === "serial" || column4.data_type === "smallserial" || column4.data_type === "bigserial") {
5912
6326
  return void 0;
5913
6327
  }
5914
6328
  const hasDifferentDefaultCast = Object.keys(columnToDefault).find(
5915
6329
  (it) => column4.data_type.startsWith(it)
5916
6330
  );
5917
- if (column4.column_default === null) {
5918
- return void 0;
5919
- }
5920
6331
  const columnDefaultAsString = column4.column_default.toString();
5921
6332
  if (columnDefaultAsString.endsWith(
5922
6333
  hasDifferentDefaultCast ? columnToDefault[hasDifferentDefaultCast] : column4.data_type
@@ -7281,7 +7692,14 @@ var sqlitePushIntrospect = async (db, filters) => {
7281
7692
  }
7282
7693
  return false;
7283
7694
  };
7284
- const res = await fromDatabase(db, filter2);
7695
+ const progress = new ProgressView(
7696
+ "Pulling schema from database...",
7697
+ "Pulling schema from database..."
7698
+ );
7699
+ const res = await (0, import_hanji2.renderWithTask)(
7700
+ progress,
7701
+ fromDatabase(db, filter2)
7702
+ );
7285
7703
  const schema3 = { id: originUUID, prevId: "", ...res };
7286
7704
  return { schema: schema3 };
7287
7705
  };
@@ -7289,6 +7707,8 @@ var sqlitePushIntrospect = async (db, filters) => {
7289
7707
  // src/cli/commands/pgIntrospect.ts
7290
7708
  init_pgSerializer();
7291
7709
  init_global();
7710
+ init_views();
7711
+ var import_hanji3 = __toESM(require_hanji());
7292
7712
  var pgPushIntrospect = async (db, filters, schemaFilters) => {
7293
7713
  const matchers = filters.map((it) => {
7294
7714
  return new Minimatch(it);
@@ -7303,7 +7723,14 @@ var pgPushIntrospect = async (db, filters, schemaFilters) => {
7303
7723
  }
7304
7724
  return false;
7305
7725
  };
7306
- const res = await fromDatabase2(db, filter2, schemaFilters);
7726
+ const progress = new ProgressView(
7727
+ "Pulling schema from database...",
7728
+ "Pulling schema from database..."
7729
+ );
7730
+ const res = await (0, import_hanji3.renderWithTask)(
7731
+ progress,
7732
+ fromDatabase2(db, filter2, schemaFilters)
7733
+ );
7307
7734
  const schema3 = { id: originUUID, prevId: "", ...res };
7308
7735
  const { internal, ...schemaWithoutInternals } = schema3;
7309
7736
  return { schema: schemaWithoutInternals };