drizzle-kit 1.0.0-beta.2-0f918b0 → 1.0.0-beta.2-09cddcb

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.
package/bin.cjs CHANGED
@@ -28623,41 +28623,41 @@ var require_ms = __commonJS({
28623
28623
  return void 0;
28624
28624
  }
28625
28625
  }
28626
- function fmtShort(ms2) {
28627
- var msAbs = Math.abs(ms2);
28626
+ function fmtShort(ms) {
28627
+ var msAbs = Math.abs(ms);
28628
28628
  if (msAbs >= d5) {
28629
- return Math.round(ms2 / d5) + "d";
28629
+ return Math.round(ms / d5) + "d";
28630
28630
  }
28631
28631
  if (msAbs >= h6) {
28632
- return Math.round(ms2 / h6) + "h";
28632
+ return Math.round(ms / h6) + "h";
28633
28633
  }
28634
28634
  if (msAbs >= m6) {
28635
- return Math.round(ms2 / m6) + "m";
28635
+ return Math.round(ms / m6) + "m";
28636
28636
  }
28637
28637
  if (msAbs >= s6) {
28638
- return Math.round(ms2 / s6) + "s";
28638
+ return Math.round(ms / s6) + "s";
28639
28639
  }
28640
- return ms2 + "ms";
28640
+ return ms + "ms";
28641
28641
  }
28642
- function fmtLong(ms2) {
28643
- var msAbs = Math.abs(ms2);
28642
+ function fmtLong(ms) {
28643
+ var msAbs = Math.abs(ms);
28644
28644
  if (msAbs >= d5) {
28645
- return plural2(ms2, msAbs, d5, "day");
28645
+ return plural2(ms, msAbs, d5, "day");
28646
28646
  }
28647
28647
  if (msAbs >= h6) {
28648
- return plural2(ms2, msAbs, h6, "hour");
28648
+ return plural2(ms, msAbs, h6, "hour");
28649
28649
  }
28650
28650
  if (msAbs >= m6) {
28651
- return plural2(ms2, msAbs, m6, "minute");
28651
+ return plural2(ms, msAbs, m6, "minute");
28652
28652
  }
28653
28653
  if (msAbs >= s6) {
28654
- return plural2(ms2, msAbs, s6, "second");
28654
+ return plural2(ms, msAbs, s6, "second");
28655
28655
  }
28656
- return ms2 + " ms";
28656
+ return ms + " ms";
28657
28657
  }
28658
- function plural2(ms2, msAbs, n5, name) {
28658
+ function plural2(ms, msAbs, n5, name) {
28659
28659
  var isPlural = msAbs >= n5 * 1.5;
28660
- return Math.round(ms2 / n5) + " " + name + (isPlural ? "s" : "");
28660
+ return Math.round(ms / n5) + " " + name + (isPlural ? "s" : "");
28661
28661
  }
28662
28662
  }
28663
28663
  });
@@ -28700,8 +28700,8 @@ var require_common2 = __commonJS({
28700
28700
  }
28701
28701
  const self2 = debug;
28702
28702
  const curr = Number(/* @__PURE__ */ new Date());
28703
- const ms2 = curr - (prevTime || curr);
28704
- self2.diff = ms2;
28703
+ const ms = curr - (prevTime || curr);
28704
+ self2.diff = ms;
28705
28705
  self2.prev = prevTime;
28706
28706
  self2.curr = curr;
28707
28707
  prevTime = curr;
@@ -35839,8 +35839,8 @@ ${sql}
35839
35839
  `;
35840
35840
  return content;
35841
35841
  };
35842
- prepareSnapshotFolderName = (ms2) => {
35843
- const now = ms2 ? new Date(ms2) : /* @__PURE__ */ new Date();
35842
+ prepareSnapshotFolderName = (ms) => {
35843
+ const now = ms ? new Date(ms) : /* @__PURE__ */ new Date();
35844
35844
  return `${now.getFullYear()}${two(now.getUTCMonth() + 1)}${two(
35845
35845
  now.getUTCDate()
35846
35846
  )}${two(now.getUTCHours())}${two(now.getUTCMinutes())}${two(
@@ -55589,7 +55589,7 @@ var require_websocket = __commonJS({
55589
55589
  var EventEmitter = require("events");
55590
55590
  var https2 = require("https");
55591
55591
  var http3 = require("http");
55592
- var net2 = require("net");
55592
+ var net = require("net");
55593
55593
  var tls = require("tls");
55594
55594
  var { randomBytes, createHash: createHash2 } = require("crypto");
55595
55595
  var { Duplex, Readable: Readable2 } = require("stream");
@@ -56320,12 +56320,12 @@ var require_websocket = __commonJS({
56320
56320
  }
56321
56321
  function netConnect(options) {
56322
56322
  options.path = options.socketPath;
56323
- return net2.connect(options);
56323
+ return net.connect(options);
56324
56324
  }
56325
56325
  function tlsConnect(options) {
56326
56326
  options.path = void 0;
56327
56327
  if (!options.servername && options.servername !== "") {
56328
- options.servername = net2.isIP(options.host) ? "" : options.host;
56328
+ options.servername = net.isIP(options.host) ? "" : options.host;
56329
56329
  }
56330
56330
  return tls.connect(options);
56331
56331
  }
@@ -58616,7 +58616,7 @@ var require_dist_cjs14 = __commonJS({
58616
58616
  return transformedHeaders;
58617
58617
  };
58618
58618
  var timing = {
58619
- setTimeout: (cb, ms2) => setTimeout(cb, ms2),
58619
+ setTimeout: (cb, ms) => setTimeout(cb, ms),
58620
58620
  clearTimeout: (timeoutId) => clearTimeout(timeoutId)
58621
58621
  };
58622
58622
  var DEFER_EVENT_LISTENER_TIME$2 = 1e3;
@@ -61675,13 +61675,13 @@ var init_schema_date_utils = __esm({
61675
61675
  if (!matches) {
61676
61676
  throw new TypeError(`Invalid RFC3339 timestamp format ${value}`);
61677
61677
  }
61678
- const [, yearStr, monthStr, dayStr, hours, minutes, seconds, , ms2, offsetStr] = matches;
61678
+ const [, yearStr, monthStr, dayStr, hours, minutes, seconds, , ms, offsetStr] = matches;
61679
61679
  range(monthStr, 1, 12);
61680
61680
  range(dayStr, 1, 31);
61681
61681
  range(hours, 0, 23);
61682
61682
  range(minutes, 0, 59);
61683
61683
  range(seconds, 0, 60);
61684
- const date2 = new Date(Date.UTC(Number(yearStr), Number(monthStr) - 1, Number(dayStr), Number(hours), Number(minutes), Number(seconds), Number(ms2) ? Math.round(parseFloat(`0.${ms2}`) * 1e3) : 0));
61684
+ const date2 = new Date(Date.UTC(Number(yearStr), Number(monthStr) - 1, Number(dayStr), Number(hours), Number(minutes), Number(seconds), Number(ms) ? Math.round(parseFloat(`0.${ms}`) * 1e3) : 0));
61685
61685
  date2.setUTCFullYear(Number(yearStr));
61686
61686
  if (offsetStr.toUpperCase() != "Z") {
61687
61687
  const [, sign, offsetH, offsetM] = /([+-])(\d\d):(\d\d)/.exec(offsetStr) || [void 0, "+", 0, 0];
@@ -81572,8 +81572,8 @@ var require_datetime2 = __commonJS({
81572
81572
  if (!(object instanceof Date)) {
81573
81573
  throw new errors_1.InvalidArgumentError(`a Date instance was expected, got "${object}"`);
81574
81574
  }
81575
- const ms2 = object.getTime() - TIMESHIFT;
81576
- const us = ms2 * 1e3;
81575
+ const ms = object.getTime() - TIMESHIFT;
81576
+ const us = ms * 1e3;
81577
81577
  buf.writeInt32(8);
81578
81578
  buf.writeInt64(us);
81579
81579
  }
@@ -81583,12 +81583,12 @@ var require_datetime2 = __commonJS({
81583
81583
  return ctx.postDecode(this, us2 + BI_TIMESHIFT_US);
81584
81584
  }
81585
81585
  const us = Number(buf.readBigInt64());
81586
- let ms2 = Math.round(us / 1e3);
81587
- if (Math.abs(us % 1e3) === 500 && Math.abs(ms2) % 2 === 1) {
81588
- ms2 -= 1;
81586
+ let ms = Math.round(us / 1e3);
81587
+ if (Math.abs(us % 1e3) === 500 && Math.abs(ms) % 2 === 1) {
81588
+ ms -= 1;
81589
81589
  }
81590
- ms2 += TIMESHIFT;
81591
- return new Date(ms2);
81590
+ ms += TIMESHIFT;
81591
+ return new Date(ms);
81592
81592
  }
81593
81593
  };
81594
81594
  exports2.DateTimeCodec = DateTimeCodec;
@@ -81609,8 +81609,8 @@ var require_datetime2 = __commonJS({
81609
81609
  if (!(object instanceof datetime_1.LocalDateTime)) {
81610
81610
  throw new errors_1.InvalidArgumentError(`a LocalDateTime instance was expected, got "${object}"`);
81611
81611
  }
81612
- const ms2 = BigInt(datetime_1.localDateInstances.get(object).getTime() - TIMESHIFT);
81613
- let us = ms2 * 1000n + BigInt(object.hour * 36e8 + object.minute * 6e7 + object.second * 1e6 + object.millisecond * 1e3 + object.microsecond);
81612
+ const ms = BigInt(datetime_1.localDateInstances.get(object).getTime() - TIMESHIFT);
81613
+ let us = ms * 1000n + BigInt(object.hour * 36e8 + object.minute * 6e7 + object.second * 1e6 + object.millisecond * 1e3 + object.microsecond);
81614
81614
  if (object.nanosecond === 500 && Math.abs(object.microsecond) % 2 === 1 || object.nanosecond > 500) {
81615
81615
  us += 1n;
81616
81616
  }
@@ -81624,13 +81624,13 @@ var require_datetime2 = __commonJS({
81624
81624
  }
81625
81625
  const bi_ms = bi_us / 1000n;
81626
81626
  let us = Number(bi_us - bi_ms * 1000n);
81627
- let ms2 = Number(bi_ms);
81627
+ let ms = Number(bi_ms);
81628
81628
  if (us < 0) {
81629
81629
  us += 1e3;
81630
- ms2 -= 1;
81630
+ ms -= 1;
81631
81631
  }
81632
- ms2 += TIMESHIFT;
81633
- const date2 = new Date(ms2);
81632
+ ms += TIMESHIFT;
81633
+ const date2 = new Date(ms);
81634
81634
  return new datetime_1.LocalDateTime(date2.getUTCFullYear(), date2.getUTCMonth() + 1, date2.getUTCDate(), date2.getUTCHours(), date2.getUTCMinutes(), date2.getUTCSeconds(), date2.getUTCMilliseconds(), us);
81635
81635
  }
81636
81636
  };
@@ -81692,13 +81692,13 @@ var require_datetime2 = __commonJS({
81692
81692
  }
81693
81693
  let us = Number(bius);
81694
81694
  let seconds = Math.floor(us / 1e6);
81695
- const ms2 = Math.floor(us % 1e6 / 1e3);
81696
- us = us % 1e6 - ms2 * 1e3;
81695
+ const ms = Math.floor(us % 1e6 / 1e3);
81696
+ us = us % 1e6 - ms * 1e3;
81697
81697
  let minutes = Math.floor(seconds / 60);
81698
81698
  seconds = Math.floor(seconds % 60);
81699
81699
  const hours = Math.floor(minutes / 60);
81700
81700
  minutes = Math.floor(minutes % 60);
81701
- return new datetime_1.LocalTime(hours, minutes, seconds, ms2, us);
81701
+ return new datetime_1.LocalTime(hours, minutes, seconds, ms, us);
81702
81702
  }
81703
81703
  };
81704
81704
  exports2.LocalTimeCodec = LocalTimeCodec;
@@ -81775,14 +81775,14 @@ var require_datetime2 = __commonJS({
81775
81775
  const biMillion = 1000000n;
81776
81776
  const biSeconds = bius / biMillion;
81777
81777
  let us = Number(bius - biSeconds * biMillion);
81778
- const ms2 = Math.floor(us / 1e3);
81778
+ const ms = Math.floor(us / 1e3);
81779
81779
  us = us % 1e3;
81780
81780
  let seconds = Number(biSeconds);
81781
81781
  let minutes = Math.floor(seconds / 60);
81782
81782
  seconds = Math.floor(seconds % 60);
81783
81783
  const hours = Math.floor(minutes / 60);
81784
81784
  minutes = Math.floor(minutes % 60);
81785
- return new datetime_1.Duration(0, 0, 0, 0, hours * sign, minutes * sign, seconds * sign, ms2 * sign, us * sign);
81785
+ return new datetime_1.Duration(0, 0, 0, 0, hours * sign, minutes * sign, seconds * sign, ms * sign, us * sign);
81786
81786
  }
81787
81787
  };
81788
81788
  exports2.DurationCodec = DurationCodec;
@@ -81828,7 +81828,7 @@ var require_datetime2 = __commonJS({
81828
81828
  const million = BigInt(1e6);
81829
81829
  const biSeconds = bius / million;
81830
81830
  let us = Number(bius - biSeconds * million);
81831
- const ms2 = Math.trunc(us / 1e3);
81831
+ const ms = Math.trunc(us / 1e3);
81832
81832
  us = us % 1e3;
81833
81833
  let seconds = Number(biSeconds);
81834
81834
  let minutes = Math.trunc(seconds / 60);
@@ -81839,7 +81839,7 @@ var require_datetime2 = __commonJS({
81839
81839
  days = Math.trunc(days % 7);
81840
81840
  const years = Math.trunc(months2 / 12);
81841
81841
  months2 = Math.trunc(months2 % 12);
81842
- return new datetime_1.RelativeDuration(years, months2, weeks, days, hours * sign, minutes * sign, seconds * sign, ms2 * sign, us * sign);
81842
+ return new datetime_1.RelativeDuration(years, months2, weeks, days, hours * sign, minutes * sign, seconds * sign, ms * sign, us * sign);
81843
81843
  }
81844
81844
  };
81845
81845
  exports2.RelativeDurationCodec = RelativeDurationCodec;
@@ -106326,11 +106326,11 @@ var require_TokenExpiredError = __commonJS({
106326
106326
  // ../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/timespan.js
106327
106327
  var require_timespan = __commonJS({
106328
106328
  "../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/timespan.js"(exports2, module2) {
106329
- var ms2 = require_ms();
106329
+ var ms = require_ms();
106330
106330
  module2.exports = function(time2, iat) {
106331
106331
  var timestamp = iat || Math.floor(Date.now() / 1e3);
106332
106332
  if (typeof time2 === "string") {
106333
- var milliseconds = ms2(time2);
106333
+ var milliseconds = ms(time2);
106334
106334
  if (typeof milliseconds === "undefined") {
106335
106335
  return;
106336
106336
  }
@@ -120917,7 +120917,7 @@ var require_dist = __commonJS({
120917
120917
  };
120918
120918
  Object.defineProperty(exports2, "__esModule", { value: true });
120919
120919
  exports2.Agent = void 0;
120920
- var net2 = __importStar2(require("net"));
120920
+ var net = __importStar2(require("net"));
120921
120921
  var http3 = __importStar2(require("http"));
120922
120922
  var https_1 = require("https");
120923
120923
  __exportStar2(require_helpers2(), exports2);
@@ -120957,7 +120957,7 @@ var require_dist = __commonJS({
120957
120957
  if (!this.sockets[name]) {
120958
120958
  this.sockets[name] = [];
120959
120959
  }
120960
- const fakeSocket = new net2.Socket({ writable: false });
120960
+ const fakeSocket = new net.Socket({ writable: false });
120961
120961
  this.sockets[name].push(fakeSocket);
120962
120962
  this.totalSocketCount++;
120963
120963
  return fakeSocket;
@@ -121169,7 +121169,7 @@ var require_dist2 = __commonJS({
121169
121169
  };
121170
121170
  Object.defineProperty(exports2, "__esModule", { value: true });
121171
121171
  exports2.HttpsProxyAgent = void 0;
121172
- var net2 = __importStar2(require("net"));
121172
+ var net = __importStar2(require("net"));
121173
121173
  var tls = __importStar2(require("tls"));
121174
121174
  var assert_1 = __importDefault2(require("assert"));
121175
121175
  var debug_1 = __importDefault2(require_src2());
@@ -121178,7 +121178,7 @@ var require_dist2 = __commonJS({
121178
121178
  var parse_proxy_response_1 = require_parse_proxy_response();
121179
121179
  var debug = (0, debug_1.default)("https-proxy-agent");
121180
121180
  var setServernameFromNonIpHost = (options) => {
121181
- if (options.servername === void 0 && options.host && !net2.isIP(options.host)) {
121181
+ if (options.servername === void 0 && options.host && !net.isIP(options.host)) {
121182
121182
  return {
121183
121183
  ...options,
121184
121184
  servername: options.host
@@ -121218,10 +121218,10 @@ var require_dist2 = __commonJS({
121218
121218
  socket = tls.connect(setServernameFromNonIpHost(this.connectOpts));
121219
121219
  } else {
121220
121220
  debug("Creating `net.Socket`: %o", this.connectOpts);
121221
- socket = net2.connect(this.connectOpts);
121221
+ socket = net.connect(this.connectOpts);
121222
121222
  }
121223
121223
  const headers = typeof this.proxyHeaders === "function" ? this.proxyHeaders() : { ...this.proxyHeaders };
121224
- const host = net2.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
121224
+ const host = net.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
121225
121225
  let payload2 = `CONNECT ${host}:${opts.port} HTTP/1.1\r
121226
121226
  `;
121227
121227
  if (proxy.username || proxy.password) {
@@ -121254,7 +121254,7 @@ var require_dist2 = __commonJS({
121254
121254
  return socket;
121255
121255
  }
121256
121256
  socket.destroy();
121257
- const fakeSocket = new net2.Socket({ writable: false });
121257
+ const fakeSocket = new net.Socket({ writable: false });
121258
121258
  fakeSocket.readable = true;
121259
121259
  req.once("socket", (s6) => {
121260
121260
  debug("Replaying proxy buffer for failed request");
@@ -121319,7 +121319,7 @@ var require_dist3 = __commonJS({
121319
121319
  };
121320
121320
  Object.defineProperty(exports2, "__esModule", { value: true });
121321
121321
  exports2.HttpProxyAgent = void 0;
121322
- var net2 = __importStar2(require("net"));
121322
+ var net = __importStar2(require("net"));
121323
121323
  var tls = __importStar2(require("tls"));
121324
121324
  var debug_1 = __importDefault2(require_src2());
121325
121325
  var events_1 = require("events");
@@ -121392,7 +121392,7 @@ var require_dist3 = __commonJS({
121392
121392
  socket = tls.connect(this.connectOpts);
121393
121393
  } else {
121394
121394
  debug("Creating `net.Socket`: %o", this.connectOpts);
121395
- socket = net2.connect(this.connectOpts);
121395
+ socket = net.connect(this.connectOpts);
121396
121396
  }
121397
121397
  await (0, events_1.once)(socket, "connect");
121398
121398
  return socket;
@@ -160306,7 +160306,7 @@ var require_connection = __commonJS({
160306
160306
  var _crypto = _interopRequireDefault(require("crypto"));
160307
160307
  var _os = _interopRequireDefault(require("os"));
160308
160308
  var tls = _interopRequireWildcard(require("tls"));
160309
- var net2 = _interopRequireWildcard(require("net"));
160309
+ var net = _interopRequireWildcard(require("net"));
160310
160310
  var _dns = _interopRequireDefault(require("dns"));
160311
160311
  var _constants = _interopRequireDefault(require("constants"));
160312
160312
  var _stream = require("stream");
@@ -161355,7 +161355,7 @@ var require_connection = __commonJS({
161355
161355
  async wrapWithTls(socket, signal) {
161356
161356
  signal.throwIfAborted();
161357
161357
  const secureContext = tls.createSecureContext(this.secureContextOptions);
161358
- const serverName = !net2.isIP(this.config.server) ? this.config.server : "";
161358
+ const serverName = !net.isIP(this.config.server) ? this.config.server : "";
161359
161359
  const encryptOptions = {
161360
161360
  host: this.config.server,
161361
161361
  socket,
@@ -164282,11 +164282,10 @@ function parseMssqlUrl(url) {
164282
164282
  }
164283
164283
  };
164284
164284
  }
164285
- var import_net, ms, normalisePGliteUrl, preparePostgresDB, prepareCockroach, prepareGelDB, parseSingleStoreCredentials, connectToSingleStore, parseMysqlCredentials, connectToMySQL, parseMssqlCredentials, connectToMsSQL, prepareSqliteParams, preparePGliteParams, connectToSQLite, connectToLibSQL;
164285
+ var normalisePGliteUrl, preparePostgresDB, prepareCockroach, prepareGelDB, parseSingleStoreCredentials, connectToSingleStore, parseMysqlCredentials, connectToMySQL, parseMssqlCredentials, connectToMsSQL, prepareSqliteParams, preparePGliteParams, connectToSQLite, connectToLibSQL;
164286
164286
  var init_connections = __esm({
164287
164287
  "src/cli/connections.ts"() {
164288
164288
  "use strict";
164289
- import_net = __toESM(require("net"));
164290
164289
  init_src();
164291
164290
  init_wrapper();
164292
164291
  init_utils2();
@@ -164294,7 +164293,6 @@ var init_connections = __esm({
164294
164293
  init_when_json_met_bigint();
164295
164294
  init_utils4();
164296
164295
  init_outputs();
164297
- ms = (a5, b5) => Number(b5 - a5) / 1e6;
164298
164296
  normalisePGliteUrl = (it2) => {
164299
164297
  if (it2.startsWith("file:")) {
164300
164298
  return it2.substring(5);
@@ -164449,13 +164447,13 @@ var init_connections = __esm({
164449
164447
  return pg.types.getTypeParser(typeId, format2);
164450
164448
  }
164451
164449
  };
164452
- const pool = "url" in credentials2 ? new pg.Pool({ connectionString: credentials2.url, max: 1 }) : new pg.Pool({ ...credentials2, ssl, max: 1 });
164453
- const db = drizzle({ client: pool });
164450
+ const client = "url" in credentials2 ? new pg.Pool({ connectionString: credentials2.url, max: 1 }) : new pg.Pool({ ...credentials2, ssl, max: 1 });
164451
+ const db = drizzle({ client });
164454
164452
  const migrateFn = async (config) => {
164455
164453
  return migrate2(db, config);
164456
164454
  };
164457
164455
  const query = async (sql, params) => {
164458
- const result2 = await pool.query({
164456
+ const result2 = await client.query({
164459
164457
  text: sql,
164460
164458
  values: params ?? [],
164461
164459
  types: types3
@@ -164465,7 +164463,7 @@ var init_connections = __esm({
164465
164463
  return result2.rows;
164466
164464
  };
164467
164465
  const proxy = async (params) => {
164468
- const result2 = await pool.query({
164466
+ const result2 = await client.query({
164469
164467
  text: params.sql,
164470
164468
  values: params.params,
164471
164469
  ...params.mode === "array" && { rowMode: "array" },
@@ -164477,7 +164475,7 @@ var init_connections = __esm({
164477
164475
  };
164478
164476
  const transactionProxy = async (queries) => {
164479
164477
  const results = [];
164480
- const tx = await pool.connect();
164478
+ const tx = await client.connect();
164481
164479
  try {
164482
164480
  await tx.query("BEGIN");
164483
164481
  for (const query2 of queries) {
@@ -164496,77 +164494,7 @@ var init_connections = __esm({
164496
164494
  }
164497
164495
  return results;
164498
164496
  };
164499
- const benchmarkQuery = async (client, sql, params) => {
164500
- const explainResult = await pool.query({
164501
- text: `EXPLAIN ANALYZE ${sql}`,
164502
- values: params ?? [],
164503
- types: types3
164504
- });
164505
- const stringifiedResult = JSON.stringify(explainResult.rows);
164506
- const planningMatch = stringifiedResult.match(/Planning Time:\s*([\d.]+)\s*ms/i);
164507
- const executionMatch = stringifiedResult.match(/Execution Time:\s*([\d.]+)\s*ms/i);
164508
- const planningTime = Number(planningMatch[1]);
164509
- const executionTime = Number(executionMatch[1]);
164510
- let querySentAt = 0n;
164511
- let firstDataAt = 0n;
164512
- let lastDataAt = 0n;
164513
- let bytesReceived = 0;
164514
- client.connection.addListener("rowDescription", (data2) => {
164515
- if (firstDataAt === 0n) {
164516
- firstDataAt = process.hrtime.bigint();
164517
- }
164518
- bytesReceived += data2.length;
164519
- });
164520
- client.connection.addListener("dataRow", (data2) => {
164521
- bytesReceived += data2.length;
164522
- });
164523
- client.connection.addListener("commandComplete", () => {
164524
- lastDataAt = process.hrtime.bigint();
164525
- });
164526
- querySentAt = process.hrtime.bigint();
164527
- await client.query(sql, params);
164528
- client.connection.removeAllListeners("rowDescription");
164529
- client.connection.removeAllListeners("dataRow");
164530
- client.connection.removeAllListeners("commandComplete");
164531
- return {
164532
- planning: planningTime,
164533
- execution: executionTime,
164534
- dataDownload: ms(firstDataAt, lastDataAt) + ms(querySentAt, firstDataAt) - executionTime - planningTime,
164535
- total: ms(querySentAt, lastDataAt),
164536
- dataSize: bytesReceived
164537
- };
164538
- };
164539
- const benchmarkProxy = async ({ sql, params }, repeats) => {
164540
- let startAt = 0n;
164541
- let tcpConnectedAt = 0n;
164542
- let tlsConnectedAt = null;
164543
- let dbReadyAt = 0n;
164544
- const client = "url" in credentials2 ? new pg.Client({ connectionString: credentials2.url }) : new pg.Client({ ...credentials2, ssl });
164545
- client.connection.once("connect", () => {
164546
- tcpConnectedAt = process.hrtime.bigint();
164547
- });
164548
- client.connection.prependOnceListener("sslconnect", () => {
164549
- tlsConnectedAt = process.hrtime.bigint();
164550
- });
164551
- client.connection.prependOnceListener("readyForQuery", () => {
164552
- dbReadyAt = process.hrtime.bigint();
164553
- });
164554
- startAt = process.hrtime.bigint();
164555
- await client.connect();
164556
- const results = [];
164557
- for (let i6 = 0; i6 < repeats; i6++) {
164558
- const r6 = await benchmarkQuery(client, sql, params);
164559
- results.push(r6);
164560
- }
164561
- await client.end();
164562
- return {
164563
- tcpHandshake: ms(startAt, tcpConnectedAt),
164564
- tlsHandshake: tlsConnectedAt ? ms(tcpConnectedAt, tlsConnectedAt) : null,
164565
- dbHandshake: ms(tlsConnectedAt ?? tcpConnectedAt, dbReadyAt),
164566
- queries: results
164567
- };
164568
- };
164569
- return { packageName: "pg", query, proxy, transactionProxy, benchmarkProxy, migrate: migrateFn };
164497
+ return { packageName: "pg", query, proxy, transactionProxy, migrate: migrateFn };
164570
164498
  }
164571
164499
  if (await checkPackage("postgres")) {
164572
164500
  console.log(
@@ -165061,6 +164989,7 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
165061
164989
  }
165062
164990
  return next();
165063
164991
  };
164992
+ await connection.connect();
165064
164993
  const query = async (sql, params) => {
165065
164994
  const res = await connection.execute({
165066
164995
  sql,
@@ -165100,112 +165029,11 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
165100
165029
  }
165101
165030
  return results;
165102
165031
  };
165103
- const benchmarkQuery = async (newConnection, sql, params) => {
165104
- const explainResult = await connection.query({
165105
- sql: `EXPLAIN ANALYZE ${sql}`,
165106
- values: params ?? [],
165107
- typeCast
165108
- });
165109
- const stringifiedResult = JSON.stringify(explainResult[0]);
165110
- const timeMatch = stringifiedResult.match(
165111
- /actual time=([0-9.eE+-]+)\.\.([0-9.eE+-]+)/
165112
- );
165113
- const lastRowTime = Number(timeMatch[2]);
165114
- const executionTime = lastRowTime;
165115
- let querySentAt = 0n;
165116
- let firstDataAt = 0n;
165117
- let lastDataAt = 0n;
165118
- let bytesReceived = 0;
165119
- querySentAt = process.hrtime.bigint();
165120
- await new Promise((resolve3, reject) => {
165121
- const query2 = newConnection.query({
165122
- sql,
165123
- values: params ?? [],
165124
- typeCast
165125
- // rowsAsArray: true,
165126
- });
165127
- query2.on("error", (err2) => {
165128
- reject(err2);
165129
- });
165130
- query2.on("fields", (fields) => {
165131
- if (firstDataAt === 0n) {
165132
- firstDataAt = process.hrtime.bigint();
165133
- }
165134
- bytesReceived += fields[0]._buf.length;
165135
- });
165136
- query2.on("end", () => {
165137
- lastDataAt = process.hrtime.bigint();
165138
- resolve3();
165139
- });
165140
- });
165141
- return {
165142
- planning: null,
165143
- execution: executionTime,
165144
- dataDownload: ms(firstDataAt, lastDataAt) + ms(querySentAt, firstDataAt) - executionTime,
165145
- total: ms(querySentAt, lastDataAt),
165146
- dataSize: bytesReceived
165147
- };
165148
- };
165149
- const benchmarkProxy = async ({ sql, params }, repeats) => {
165150
- const { createConnection: createConnection2 } = await import("mysql2");
165151
- let startAt = 0n;
165152
- let tcpConnectedAt = 0n;
165153
- let tlsConnectedAt = null;
165154
- const createStream = ({ config }) => {
165155
- let stream;
165156
- if (config.socketPath) {
165157
- stream = import_net.default.connect(config.socketPath);
165158
- } else {
165159
- stream = import_net.default.connect(config.port, config.host);
165160
- }
165161
- if (config.enableKeepAlive) {
165162
- stream.on("connect", () => {
165163
- stream.setKeepAlive(true, config.keepAliveInitialDelay);
165164
- });
165165
- }
165166
- stream.setNoDelay(true);
165167
- stream.once("connect", () => {
165168
- tcpConnectedAt = process.hrtime.bigint();
165169
- });
165170
- return stream;
165171
- };
165172
- startAt = process.hrtime.bigint();
165173
- const connection2 = result2.url ? createConnection2({
165174
- uri: result2.url,
165175
- stream: createStream
165176
- }) : createConnection2({
165177
- ...result2.credentials,
165178
- stream: createStream
165179
- });
165180
- await new Promise((resolve3, reject) => {
165181
- connection2.connect((err2) => {
165182
- tlsConnectedAt = process.hrtime.bigint();
165183
- if (err2) {
165184
- reject(err2);
165185
- } else {
165186
- resolve3();
165187
- }
165188
- });
165189
- });
165190
- const results = [];
165191
- for (let i6 = 0; i6 < repeats; i6++) {
165192
- const r6 = await benchmarkQuery(connection2, sql, params);
165193
- results.push(r6);
165194
- }
165195
- connection2.end();
165196
- return {
165197
- tcpHandshake: ms(startAt, tcpConnectedAt),
165198
- tlsHandshake: tlsConnectedAt ? ms(tcpConnectedAt, tlsConnectedAt) : null,
165199
- dbHandshake: null,
165200
- queries: results
165201
- };
165202
- };
165203
165032
  return {
165204
165033
  db: { query },
165205
165034
  packageName: "mysql2",
165206
165035
  proxy,
165207
165036
  transactionProxy,
165208
- benchmarkProxy,
165209
165037
  database: result2.database,
165210
165038
  migrate: migrateFn
165211
165039
  };
@@ -176860,7 +176688,7 @@ __export(studio_exports, {
176860
176688
  prepareServer: () => prepareServer,
176861
176689
  prepareSingleStoreSchema: () => prepareSingleStoreSchema
176862
176690
  });
176863
- var import_crypto11, import_drizzle_orm8, import_relations8, import_mssql_core3, import_mysql_core3, import_pg_core3, import_singlestore_core2, import_sqlite_core3, import_fs16, import_node_https2, preparePgSchema, prepareMySqlSchema, prepareMsSqlSchema, prepareSQLiteSchema, prepareSingleStoreSchema, getCustomDefaults, drizzleForPostgres, drizzleForMySQL, drizzleForSQLite, drizzleForLibSQL, drizzleForSingleStore, extractRelations, init, proxySchema, transactionProxySchema, benchmarkProxySchema, defaultsSchema, schema5, jsonStringify, prepareServer;
176691
+ var import_crypto11, import_drizzle_orm8, import_relations8, import_mssql_core3, import_mysql_core3, import_pg_core3, import_singlestore_core2, import_sqlite_core3, import_fs16, import_node_https2, preparePgSchema, prepareMySqlSchema, prepareMsSqlSchema, prepareSQLiteSchema, prepareSingleStoreSchema, getCustomDefaults, drizzleForPostgres, drizzleForMySQL, drizzleForSQLite, drizzleForLibSQL, drizzleForSingleStore, extractRelations, init, proxySchema, transactionProxySchema, defaultsSchema, schema5, jsonStringify, prepareServer;
176864
176692
  var init_studio = __esm({
176865
176693
  "src/cli/commands/studio.ts"() {
176866
176694
  "use strict";
@@ -177084,7 +176912,6 @@ var init_studio = __esm({
177084
176912
  packageName: db.packageName,
177085
176913
  proxy: db.proxy,
177086
176914
  transactionProxy: db.transactionProxy,
177087
- benchmarkProxy: db.benchmarkProxy,
177088
176915
  customDefaults,
177089
176916
  schema: pgSchema2,
177090
176917
  relations: relations5,
@@ -177094,7 +176921,7 @@ var init_studio = __esm({
177094
176921
  };
177095
176922
  drizzleForMySQL = async (credentials2, mysqlSchema, relations5, schemaFiles, casing2) => {
177096
176923
  const { connectToMySQL: connectToMySQL2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
177097
- const { proxy, transactionProxy, benchmarkProxy, database, packageName } = await connectToMySQL2(credentials2);
176924
+ const { proxy, transactionProxy, database, packageName } = await connectToMySQL2(credentials2);
177098
176925
  const customDefaults = getCustomDefaults(mysqlSchema, casing2);
177099
176926
  let dbUrl;
177100
176927
  if ("url" in credentials2) {
@@ -177110,7 +176937,6 @@ var init_studio = __esm({
177110
176937
  databaseName: database,
177111
176938
  proxy,
177112
176939
  transactionProxy,
177113
- benchmarkProxy,
177114
176940
  customDefaults,
177115
176941
  schema: mysqlSchema,
177116
176942
  relations: relations5,
@@ -177280,23 +177106,6 @@ var init_studio = __esm({
177280
177106
  ]).optional()
177281
177107
  }).array()
177282
177108
  });
177283
- benchmarkProxySchema = external_exports.object({
177284
- type: external_exports.literal("bproxy"),
177285
- data: external_exports.object({
177286
- query: external_exports.object({
177287
- sql: external_exports.string(),
177288
- params: external_exports.array(external_exports.any()).optional(),
177289
- method: external_exports.union([
177290
- external_exports.literal("values"),
177291
- external_exports.literal("get"),
177292
- external_exports.literal("all"),
177293
- external_exports.literal("run"),
177294
- external_exports.literal("execute")
177295
- ]).optional()
177296
- }),
177297
- repeats: external_exports.number().min(1).optional()
177298
- })
177299
- });
177300
177109
  defaultsSchema = external_exports.object({
177301
177110
  type: external_exports.literal("defaults"),
177302
177111
  data: external_exports.array(
@@ -177311,7 +177120,6 @@ var init_studio = __esm({
177311
177120
  init,
177312
177121
  proxySchema,
177313
177122
  transactionProxySchema,
177314
- benchmarkProxySchema,
177315
177123
  defaultsSchema
177316
177124
  ]);
177317
177125
  jsonStringify = (data2) => {
@@ -177334,7 +177142,6 @@ var init_studio = __esm({
177334
177142
  databaseName,
177335
177143
  proxy,
177336
177144
  transactionProxy,
177337
- benchmarkProxy,
177338
177145
  customDefaults,
177339
177146
  schema: drizzleSchema,
177340
177147
  relations: relations5,
@@ -177398,7 +177205,7 @@ var init_studio = __esm({
177398
177205
  console.warn("Error message:", error4.message);
177399
177206
  }
177400
177207
  return c5.json({
177401
- version: "6.3",
177208
+ version: "6.2",
177402
177209
  dialect: dialect6,
177403
177210
  driver: driver2,
177404
177211
  packageName,
@@ -177436,21 +177243,6 @@ var init_studio = __esm({
177436
177243
  }
177437
177244
  );
177438
177245
  }
177439
- if (type === "bproxy") {
177440
- if (!benchmarkProxy) {
177441
- throw new Error("Benchmark proxy is not configured for this database.");
177442
- }
177443
- const result2 = await benchmarkProxy(body.data.query, body.data.repeats || 1);
177444
- const res = jsonStringify(result2);
177445
- return c5.body(
177446
- res,
177447
- {
177448
- headers: {
177449
- "Content-Type": "application/json"
177450
- }
177451
- }
177452
- );
177453
- }
177454
177246
  if (type === "defaults") {
177455
177247
  const columns = body.data;
177456
177248
  const result2 = columns.map((column12) => {