drizzle-kit 1.0.0-beta.2-0f918b0 → 1.0.0-beta.2-a1a6b39

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/api-postgres.mjs CHANGED
@@ -34431,7 +34431,7 @@ var require_websocket = __commonJS({
34431
34431
  var EventEmitter = __require("events");
34432
34432
  var https2 = __require("https");
34433
34433
  var http3 = __require("http");
34434
- var net2 = __require("net");
34434
+ var net = __require("net");
34435
34435
  var tls = __require("tls");
34436
34436
  var { randomBytes, createHash: createHash5 } = __require("crypto");
34437
34437
  var { Duplex, Readable: Readable6 } = __require("stream");
@@ -35162,12 +35162,12 @@ var require_websocket = __commonJS({
35162
35162
  }
35163
35163
  function netConnect(options) {
35164
35164
  options.path = options.socketPath;
35165
- return net2.connect(options);
35165
+ return net.connect(options);
35166
35166
  }
35167
35167
  function tlsConnect(options) {
35168
35168
  options.path = void 0;
35169
35169
  if (!options.servername && options.servername !== "") {
35170
- options.servername = net2.isIP(options.host) ? "" : options.host;
35170
+ options.servername = net.isIP(options.host) ? "" : options.host;
35171
35171
  }
35172
35172
  return tls.connect(options);
35173
35173
  }
@@ -39485,7 +39485,7 @@ var init_timing = __esm({
39485
39485
  "../node_modules/.pnpm/@smithy+node-http-handler@4.4.5/node_modules/@smithy/node-http-handler/dist-es/timing.js"() {
39486
39486
  "use strict";
39487
39487
  timing = {
39488
- setTimeout: (cb, ms2) => setTimeout(cb, ms2),
39488
+ setTimeout: (cb, ms) => setTimeout(cb, ms),
39489
39489
  clearTimeout: (timeoutId) => clearTimeout(timeoutId)
39490
39490
  };
39491
39491
  }
@@ -41373,13 +41373,13 @@ var init_schema_date_utils = __esm({
41373
41373
  if (!matches) {
41374
41374
  throw new TypeError(`Invalid RFC3339 timestamp format ${value}`);
41375
41375
  }
41376
- const [, yearStr, monthStr, dayStr, hours, minutes, seconds, , ms2, offsetStr] = matches;
41376
+ const [, yearStr, monthStr, dayStr, hours, minutes, seconds, , ms, offsetStr] = matches;
41377
41377
  range(monthStr, 1, 12);
41378
41378
  range(dayStr, 1, 31);
41379
41379
  range(hours, 0, 23);
41380
41380
  range(minutes, 0, 59);
41381
41381
  range(seconds, 0, 60);
41382
- 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));
41382
+ 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));
41383
41383
  date2.setUTCFullYear(Number(yearStr));
41384
41384
  if (offsetStr.toUpperCase() != "Z") {
41385
41385
  const [, sign2, offsetH, offsetM] = /([+-])(\d\d):(\d\d)/.exec(offsetStr) || [void 0, "+", 0, 0];
@@ -61392,8 +61392,8 @@ var require_datetime2 = __commonJS({
61392
61392
  if (!(object instanceof Date)) {
61393
61393
  throw new errors_1.InvalidArgumentError(`a Date instance was expected, got "${object}"`);
61394
61394
  }
61395
- const ms2 = object.getTime() - TIMESHIFT;
61396
- const us = ms2 * 1e3;
61395
+ const ms = object.getTime() - TIMESHIFT;
61396
+ const us = ms * 1e3;
61397
61397
  buf.writeInt32(8);
61398
61398
  buf.writeInt64(us);
61399
61399
  }
@@ -61403,12 +61403,12 @@ var require_datetime2 = __commonJS({
61403
61403
  return ctx.postDecode(this, us2 + BI_TIMESHIFT_US);
61404
61404
  }
61405
61405
  const us = Number(buf.readBigInt64());
61406
- let ms2 = Math.round(us / 1e3);
61407
- if (Math.abs(us % 1e3) === 500 && Math.abs(ms2) % 2 === 1) {
61408
- ms2 -= 1;
61406
+ let ms = Math.round(us / 1e3);
61407
+ if (Math.abs(us % 1e3) === 500 && Math.abs(ms) % 2 === 1) {
61408
+ ms -= 1;
61409
61409
  }
61410
- ms2 += TIMESHIFT;
61411
- return new Date(ms2);
61410
+ ms += TIMESHIFT;
61411
+ return new Date(ms);
61412
61412
  }
61413
61413
  };
61414
61414
  exports2.DateTimeCodec = DateTimeCodec;
@@ -61429,8 +61429,8 @@ var require_datetime2 = __commonJS({
61429
61429
  if (!(object instanceof datetime_1.LocalDateTime)) {
61430
61430
  throw new errors_1.InvalidArgumentError(`a LocalDateTime instance was expected, got "${object}"`);
61431
61431
  }
61432
- const ms2 = BigInt(datetime_1.localDateInstances.get(object).getTime() - TIMESHIFT);
61433
- let us = ms2 * 1000n + BigInt(object.hour * 36e8 + object.minute * 6e7 + object.second * 1e6 + object.millisecond * 1e3 + object.microsecond);
61432
+ const ms = BigInt(datetime_1.localDateInstances.get(object).getTime() - TIMESHIFT);
61433
+ let us = ms * 1000n + BigInt(object.hour * 36e8 + object.minute * 6e7 + object.second * 1e6 + object.millisecond * 1e3 + object.microsecond);
61434
61434
  if (object.nanosecond === 500 && Math.abs(object.microsecond) % 2 === 1 || object.nanosecond > 500) {
61435
61435
  us += 1n;
61436
61436
  }
@@ -61444,13 +61444,13 @@ var require_datetime2 = __commonJS({
61444
61444
  }
61445
61445
  const bi_ms = bi_us / 1000n;
61446
61446
  let us = Number(bi_us - bi_ms * 1000n);
61447
- let ms2 = Number(bi_ms);
61447
+ let ms = Number(bi_ms);
61448
61448
  if (us < 0) {
61449
61449
  us += 1e3;
61450
- ms2 -= 1;
61450
+ ms -= 1;
61451
61451
  }
61452
- ms2 += TIMESHIFT;
61453
- const date2 = new Date(ms2);
61452
+ ms += TIMESHIFT;
61453
+ const date2 = new Date(ms);
61454
61454
  return new datetime_1.LocalDateTime(date2.getUTCFullYear(), date2.getUTCMonth() + 1, date2.getUTCDate(), date2.getUTCHours(), date2.getUTCMinutes(), date2.getUTCSeconds(), date2.getUTCMilliseconds(), us);
61455
61455
  }
61456
61456
  };
@@ -61512,13 +61512,13 @@ var require_datetime2 = __commonJS({
61512
61512
  }
61513
61513
  let us = Number(bius);
61514
61514
  let seconds = Math.floor(us / 1e6);
61515
- const ms2 = Math.floor(us % 1e6 / 1e3);
61516
- us = us % 1e6 - ms2 * 1e3;
61515
+ const ms = Math.floor(us % 1e6 / 1e3);
61516
+ us = us % 1e6 - ms * 1e3;
61517
61517
  let minutes = Math.floor(seconds / 60);
61518
61518
  seconds = Math.floor(seconds % 60);
61519
61519
  const hours = Math.floor(minutes / 60);
61520
61520
  minutes = Math.floor(minutes % 60);
61521
- return new datetime_1.LocalTime(hours, minutes, seconds, ms2, us);
61521
+ return new datetime_1.LocalTime(hours, minutes, seconds, ms, us);
61522
61522
  }
61523
61523
  };
61524
61524
  exports2.LocalTimeCodec = LocalTimeCodec;
@@ -61595,14 +61595,14 @@ var require_datetime2 = __commonJS({
61595
61595
  const biMillion = 1000000n;
61596
61596
  const biSeconds = bius / biMillion;
61597
61597
  let us = Number(bius - biSeconds * biMillion);
61598
- const ms2 = Math.floor(us / 1e3);
61598
+ const ms = Math.floor(us / 1e3);
61599
61599
  us = us % 1e3;
61600
61600
  let seconds = Number(biSeconds);
61601
61601
  let minutes = Math.floor(seconds / 60);
61602
61602
  seconds = Math.floor(seconds % 60);
61603
61603
  const hours = Math.floor(minutes / 60);
61604
61604
  minutes = Math.floor(minutes % 60);
61605
- return new datetime_1.Duration(0, 0, 0, 0, hours * sign2, minutes * sign2, seconds * sign2, ms2 * sign2, us * sign2);
61605
+ return new datetime_1.Duration(0, 0, 0, 0, hours * sign2, minutes * sign2, seconds * sign2, ms * sign2, us * sign2);
61606
61606
  }
61607
61607
  };
61608
61608
  exports2.DurationCodec = DurationCodec;
@@ -61648,7 +61648,7 @@ var require_datetime2 = __commonJS({
61648
61648
  const million = BigInt(1e6);
61649
61649
  const biSeconds = bius / million;
61650
61650
  let us = Number(bius - biSeconds * million);
61651
- const ms2 = Math.trunc(us / 1e3);
61651
+ const ms = Math.trunc(us / 1e3);
61652
61652
  us = us % 1e3;
61653
61653
  let seconds = Number(biSeconds);
61654
61654
  let minutes = Math.trunc(seconds / 60);
@@ -61659,7 +61659,7 @@ var require_datetime2 = __commonJS({
61659
61659
  days = Math.trunc(days % 7);
61660
61660
  const years = Math.trunc(months2 / 12);
61661
61661
  months2 = Math.trunc(months2 % 12);
61662
- return new datetime_1.RelativeDuration(years, months2, weeks, days, hours * sign2, minutes * sign2, seconds * sign2, ms2 * sign2, us * sign2);
61662
+ return new datetime_1.RelativeDuration(years, months2, weeks, days, hours * sign2, minutes * sign2, seconds * sign2, ms * sign2, us * sign2);
61663
61663
  }
61664
61664
  };
61665
61665
  exports2.RelativeDurationCodec = RelativeDurationCodec;
@@ -71823,41 +71823,41 @@ var require_ms = __commonJS({
71823
71823
  return void 0;
71824
71824
  }
71825
71825
  }
71826
- function fmtShort(ms2) {
71827
- var msAbs = Math.abs(ms2);
71826
+ function fmtShort(ms) {
71827
+ var msAbs = Math.abs(ms);
71828
71828
  if (msAbs >= d6) {
71829
- return Math.round(ms2 / d6) + "d";
71829
+ return Math.round(ms / d6) + "d";
71830
71830
  }
71831
71831
  if (msAbs >= h7) {
71832
- return Math.round(ms2 / h7) + "h";
71832
+ return Math.round(ms / h7) + "h";
71833
71833
  }
71834
71834
  if (msAbs >= m7) {
71835
- return Math.round(ms2 / m7) + "m";
71835
+ return Math.round(ms / m7) + "m";
71836
71836
  }
71837
71837
  if (msAbs >= s7) {
71838
- return Math.round(ms2 / s7) + "s";
71838
+ return Math.round(ms / s7) + "s";
71839
71839
  }
71840
- return ms2 + "ms";
71840
+ return ms + "ms";
71841
71841
  }
71842
- function fmtLong(ms2) {
71843
- var msAbs = Math.abs(ms2);
71842
+ function fmtLong(ms) {
71843
+ var msAbs = Math.abs(ms);
71844
71844
  if (msAbs >= d6) {
71845
- return plural2(ms2, msAbs, d6, "day");
71845
+ return plural2(ms, msAbs, d6, "day");
71846
71846
  }
71847
71847
  if (msAbs >= h7) {
71848
- return plural2(ms2, msAbs, h7, "hour");
71848
+ return plural2(ms, msAbs, h7, "hour");
71849
71849
  }
71850
71850
  if (msAbs >= m7) {
71851
- return plural2(ms2, msAbs, m7, "minute");
71851
+ return plural2(ms, msAbs, m7, "minute");
71852
71852
  }
71853
71853
  if (msAbs >= s7) {
71854
- return plural2(ms2, msAbs, s7, "second");
71854
+ return plural2(ms, msAbs, s7, "second");
71855
71855
  }
71856
- return ms2 + " ms";
71856
+ return ms + " ms";
71857
71857
  }
71858
- function plural2(ms2, msAbs, n6, name) {
71858
+ function plural2(ms, msAbs, n6, name) {
71859
71859
  var isPlural = msAbs >= n6 * 1.5;
71860
- return Math.round(ms2 / n6) + " " + name + (isPlural ? "s" : "");
71860
+ return Math.round(ms / n6) + " " + name + (isPlural ? "s" : "");
71861
71861
  }
71862
71862
  }
71863
71863
  });
@@ -71901,8 +71901,8 @@ var require_common2 = __commonJS({
71901
71901
  }
71902
71902
  const self2 = debug;
71903
71903
  const curr = Number(/* @__PURE__ */ new Date());
71904
- const ms2 = curr - (prevTime || curr);
71905
- self2.diff = ms2;
71904
+ const ms = curr - (prevTime || curr);
71905
+ self2.diff = ms;
71906
71906
  self2.prev = prevTime;
71907
71907
  self2.curr = curr;
71908
71908
  prevTime = curr;
@@ -87405,11 +87405,11 @@ var require_TokenExpiredError = __commonJS({
87405
87405
  var require_timespan = __commonJS({
87406
87406
  "../node_modules/.pnpm/jsonwebtoken@9.0.2/node_modules/jsonwebtoken/lib/timespan.js"(exports2, module) {
87407
87407
  "use strict";
87408
- var ms2 = require_ms();
87408
+ var ms = require_ms();
87409
87409
  module.exports = function(time2, iat) {
87410
87410
  var timestamp = iat || Math.floor(Date.now() / 1e3);
87411
87411
  if (typeof time2 === "string") {
87412
- var milliseconds = ms2(time2);
87412
+ var milliseconds = ms(time2);
87413
87413
  if (typeof milliseconds === "undefined") {
87414
87414
  return;
87415
87415
  }
@@ -101947,7 +101947,7 @@ var require_dist = __commonJS({
101947
101947
  };
101948
101948
  Object.defineProperty(exports2, "__esModule", { value: true });
101949
101949
  exports2.Agent = void 0;
101950
- var net2 = __importStar2(__require("net"));
101950
+ var net = __importStar2(__require("net"));
101951
101951
  var http3 = __importStar2(__require("http"));
101952
101952
  var https_1 = __require("https");
101953
101953
  __exportStar2(require_helpers2(), exports2);
@@ -101987,7 +101987,7 @@ var require_dist = __commonJS({
101987
101987
  if (!this.sockets[name]) {
101988
101988
  this.sockets[name] = [];
101989
101989
  }
101990
- const fakeSocket = new net2.Socket({ writable: false });
101990
+ const fakeSocket = new net.Socket({ writable: false });
101991
101991
  this.sockets[name].push(fakeSocket);
101992
101992
  this.totalSocketCount++;
101993
101993
  return fakeSocket;
@@ -102199,7 +102199,7 @@ var require_dist2 = __commonJS({
102199
102199
  };
102200
102200
  Object.defineProperty(exports2, "__esModule", { value: true });
102201
102201
  exports2.HttpsProxyAgent = void 0;
102202
- var net2 = __importStar2(__require("net"));
102202
+ var net = __importStar2(__require("net"));
102203
102203
  var tls = __importStar2(__require("tls"));
102204
102204
  var assert_1 = __importDefault2(__require("assert"));
102205
102205
  var debug_1 = __importDefault2(require_src2());
@@ -102208,7 +102208,7 @@ var require_dist2 = __commonJS({
102208
102208
  var parse_proxy_response_1 = require_parse_proxy_response();
102209
102209
  var debug = (0, debug_1.default)("https-proxy-agent");
102210
102210
  var setServernameFromNonIpHost = (options) => {
102211
- if (options.servername === void 0 && options.host && !net2.isIP(options.host)) {
102211
+ if (options.servername === void 0 && options.host && !net.isIP(options.host)) {
102212
102212
  return {
102213
102213
  ...options,
102214
102214
  servername: options.host
@@ -102248,10 +102248,10 @@ var require_dist2 = __commonJS({
102248
102248
  socket = tls.connect(setServernameFromNonIpHost(this.connectOpts));
102249
102249
  } else {
102250
102250
  debug("Creating `net.Socket`: %o", this.connectOpts);
102251
- socket = net2.connect(this.connectOpts);
102251
+ socket = net.connect(this.connectOpts);
102252
102252
  }
102253
102253
  const headers = typeof this.proxyHeaders === "function" ? this.proxyHeaders() : { ...this.proxyHeaders };
102254
- const host = net2.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
102254
+ const host = net.isIPv6(opts.host) ? `[${opts.host}]` : opts.host;
102255
102255
  let payload = `CONNECT ${host}:${opts.port} HTTP/1.1\r
102256
102256
  `;
102257
102257
  if (proxy.username || proxy.password) {
@@ -102284,7 +102284,7 @@ var require_dist2 = __commonJS({
102284
102284
  return socket;
102285
102285
  }
102286
102286
  socket.destroy();
102287
- const fakeSocket = new net2.Socket({ writable: false });
102287
+ const fakeSocket = new net.Socket({ writable: false });
102288
102288
  fakeSocket.readable = true;
102289
102289
  req.once("socket", (s7) => {
102290
102290
  debug("Replaying proxy buffer for failed request");
@@ -102349,7 +102349,7 @@ var require_dist3 = __commonJS({
102349
102349
  };
102350
102350
  Object.defineProperty(exports2, "__esModule", { value: true });
102351
102351
  exports2.HttpProxyAgent = void 0;
102352
- var net2 = __importStar2(__require("net"));
102352
+ var net = __importStar2(__require("net"));
102353
102353
  var tls = __importStar2(__require("tls"));
102354
102354
  var debug_1 = __importDefault2(require_src2());
102355
102355
  var events_1 = __require("events");
@@ -102422,7 +102422,7 @@ var require_dist3 = __commonJS({
102422
102422
  socket = tls.connect(this.connectOpts);
102423
102423
  } else {
102424
102424
  debug("Creating `net.Socket`: %o", this.connectOpts);
102425
- socket = net2.connect(this.connectOpts);
102425
+ socket = net.connect(this.connectOpts);
102426
102426
  }
102427
102427
  await (0, events_1.once)(socket, "connect");
102428
102428
  return socket;
@@ -141301,7 +141301,7 @@ var require_connection = __commonJS({
141301
141301
  var _crypto = _interopRequireDefault(__require("crypto"));
141302
141302
  var _os = _interopRequireDefault(__require("os"));
141303
141303
  var tls = _interopRequireWildcard(__require("tls"));
141304
- var net2 = _interopRequireWildcard(__require("net"));
141304
+ var net = _interopRequireWildcard(__require("net"));
141305
141305
  var _dns = _interopRequireDefault(__require("dns"));
141306
141306
  var _constants = _interopRequireDefault(__require("constants"));
141307
141307
  var _stream = __require("stream");
@@ -142350,7 +142350,7 @@ var require_connection = __commonJS({
142350
142350
  async wrapWithTls(socket, signal) {
142351
142351
  signal.throwIfAborted();
142352
142352
  const secureContext = tls.createSecureContext(this.secureContextOptions);
142353
- const serverName = !net2.isIP(this.config.server) ? this.config.server : "";
142353
+ const serverName = !net.isIP(this.config.server) ? this.config.server : "";
142354
142354
  const encryptOptions = {
142355
142355
  host: this.config.server,
142356
142356
  socket,
@@ -145259,7 +145259,6 @@ __export(connections_exports, {
145259
145259
  prepareGelDB: () => prepareGelDB,
145260
145260
  preparePostgresDB: () => preparePostgresDB
145261
145261
  });
145262
- import net from "net";
145263
145262
  function parseMssqlUrl(url) {
145264
145263
  return {
145265
145264
  user: url.username,
@@ -145273,7 +145272,7 @@ function parseMssqlUrl(url) {
145273
145272
  }
145274
145273
  };
145275
145274
  }
145276
- var ms, normalisePGliteUrl, preparePostgresDB, prepareCockroach, prepareGelDB, parseSingleStoreCredentials, connectToSingleStore, parseMysqlCredentials, connectToMySQL, parseMssqlCredentials, connectToMsSQL, prepareSqliteParams, preparePGliteParams, connectToSQLite, connectToLibSQL;
145275
+ var normalisePGliteUrl, preparePostgresDB, prepareCockroach, prepareGelDB, parseSingleStoreCredentials, connectToSingleStore, parseMysqlCredentials, connectToMySQL, parseMssqlCredentials, connectToMsSQL, prepareSqliteParams, preparePGliteParams, connectToSQLite, connectToLibSQL;
145277
145276
  var init_connections = __esm({
145278
145277
  "src/cli/connections.ts"() {
145279
145278
  "use strict";
@@ -145284,7 +145283,6 @@ var init_connections = __esm({
145284
145283
  init_when_json_met_bigint();
145285
145284
  init_utils3();
145286
145285
  init_outputs();
145287
- ms = (a6, b6) => Number(b6 - a6) / 1e6;
145288
145286
  normalisePGliteUrl = (it) => {
145289
145287
  if (it.startsWith("file:")) {
145290
145288
  return it.substring(5);
@@ -145439,13 +145437,13 @@ var init_connections = __esm({
145439
145437
  return pg.types.getTypeParser(typeId, format2);
145440
145438
  }
145441
145439
  };
145442
- const pool = "url" in credentials ? new pg.Pool({ connectionString: credentials.url, max: 1 }) : new pg.Pool({ ...credentials, ssl, max: 1 });
145443
- const db = drizzle({ client: pool });
145440
+ const client = "url" in credentials ? new pg.Pool({ connectionString: credentials.url, max: 1 }) : new pg.Pool({ ...credentials, ssl, max: 1 });
145441
+ const db = drizzle({ client });
145444
145442
  const migrateFn = async (config) => {
145445
145443
  return migrate(db, config);
145446
145444
  };
145447
145445
  const query = async (sql, params) => {
145448
- const result2 = await pool.query({
145446
+ const result2 = await client.query({
145449
145447
  text: sql,
145450
145448
  values: params ?? [],
145451
145449
  types: types3
@@ -145455,7 +145453,7 @@ var init_connections = __esm({
145455
145453
  return result2.rows;
145456
145454
  };
145457
145455
  const proxy = async (params) => {
145458
- const result2 = await pool.query({
145456
+ const result2 = await client.query({
145459
145457
  text: params.sql,
145460
145458
  values: params.params,
145461
145459
  ...params.mode === "array" && { rowMode: "array" },
@@ -145467,7 +145465,7 @@ var init_connections = __esm({
145467
145465
  };
145468
145466
  const transactionProxy = async (queries) => {
145469
145467
  const results = [];
145470
- const tx = await pool.connect();
145468
+ const tx = await client.connect();
145471
145469
  try {
145472
145470
  await tx.query("BEGIN");
145473
145471
  for (const query2 of queries) {
@@ -145486,77 +145484,7 @@ var init_connections = __esm({
145486
145484
  }
145487
145485
  return results;
145488
145486
  };
145489
- const benchmarkQuery = async (client, sql, params) => {
145490
- const explainResult = await pool.query({
145491
- text: `EXPLAIN ANALYZE ${sql}`,
145492
- values: params ?? [],
145493
- types: types3
145494
- });
145495
- const stringifiedResult = JSON.stringify(explainResult.rows);
145496
- const planningMatch = stringifiedResult.match(/Planning Time:\s*([\d.]+)\s*ms/i);
145497
- const executionMatch = stringifiedResult.match(/Execution Time:\s*([\d.]+)\s*ms/i);
145498
- const planningTime = Number(planningMatch[1]);
145499
- const executionTime = Number(executionMatch[1]);
145500
- let querySentAt = 0n;
145501
- let firstDataAt = 0n;
145502
- let lastDataAt = 0n;
145503
- let bytesReceived = 0;
145504
- client.connection.addListener("rowDescription", (data) => {
145505
- if (firstDataAt === 0n) {
145506
- firstDataAt = process.hrtime.bigint();
145507
- }
145508
- bytesReceived += data.length;
145509
- });
145510
- client.connection.addListener("dataRow", (data) => {
145511
- bytesReceived += data.length;
145512
- });
145513
- client.connection.addListener("commandComplete", () => {
145514
- lastDataAt = process.hrtime.bigint();
145515
- });
145516
- querySentAt = process.hrtime.bigint();
145517
- await client.query(sql, params);
145518
- client.connection.removeAllListeners("rowDescription");
145519
- client.connection.removeAllListeners("dataRow");
145520
- client.connection.removeAllListeners("commandComplete");
145521
- return {
145522
- planning: planningTime,
145523
- execution: executionTime,
145524
- dataDownload: ms(firstDataAt, lastDataAt) + ms(querySentAt, firstDataAt) - executionTime - planningTime,
145525
- total: ms(querySentAt, lastDataAt),
145526
- dataSize: bytesReceived
145527
- };
145528
- };
145529
- const benchmarkProxy = async ({ sql, params }, repeats) => {
145530
- let startAt = 0n;
145531
- let tcpConnectedAt = 0n;
145532
- let tlsConnectedAt = null;
145533
- let dbReadyAt = 0n;
145534
- const client = "url" in credentials ? new pg.Client({ connectionString: credentials.url }) : new pg.Client({ ...credentials, ssl });
145535
- client.connection.once("connect", () => {
145536
- tcpConnectedAt = process.hrtime.bigint();
145537
- });
145538
- client.connection.prependOnceListener("sslconnect", () => {
145539
- tlsConnectedAt = process.hrtime.bigint();
145540
- });
145541
- client.connection.prependOnceListener("readyForQuery", () => {
145542
- dbReadyAt = process.hrtime.bigint();
145543
- });
145544
- startAt = process.hrtime.bigint();
145545
- await client.connect();
145546
- const results = [];
145547
- for (let i7 = 0; i7 < repeats; i7++) {
145548
- const r7 = await benchmarkQuery(client, sql, params);
145549
- results.push(r7);
145550
- }
145551
- await client.end();
145552
- return {
145553
- tcpHandshake: ms(startAt, tcpConnectedAt),
145554
- tlsHandshake: tlsConnectedAt ? ms(tcpConnectedAt, tlsConnectedAt) : null,
145555
- dbHandshake: ms(tlsConnectedAt ?? tcpConnectedAt, dbReadyAt),
145556
- queries: results
145557
- };
145558
- };
145559
- return { packageName: "pg", query, proxy, transactionProxy, benchmarkProxy, migrate: migrateFn };
145487
+ return { packageName: "pg", query, proxy, transactionProxy, migrate: migrateFn };
145560
145488
  }
145561
145489
  if (await checkPackage("postgres")) {
145562
145490
  console.log(
@@ -146051,6 +145979,7 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
146051
145979
  }
146052
145980
  return next();
146053
145981
  };
145982
+ await connection.connect();
146054
145983
  const query = async (sql, params) => {
146055
145984
  const res = await connection.execute({
146056
145985
  sql,
@@ -146090,112 +146019,11 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
146090
146019
  }
146091
146020
  return results;
146092
146021
  };
146093
- const benchmarkQuery = async (newConnection, sql, params) => {
146094
- const explainResult = await connection.query({
146095
- sql: `EXPLAIN ANALYZE ${sql}`,
146096
- values: params ?? [],
146097
- typeCast
146098
- });
146099
- const stringifiedResult = JSON.stringify(explainResult[0]);
146100
- const timeMatch = stringifiedResult.match(
146101
- /actual time=([0-9.eE+-]+)\.\.([0-9.eE+-]+)/
146102
- );
146103
- const lastRowTime = Number(timeMatch[2]);
146104
- const executionTime = lastRowTime;
146105
- let querySentAt = 0n;
146106
- let firstDataAt = 0n;
146107
- let lastDataAt = 0n;
146108
- let bytesReceived = 0;
146109
- querySentAt = process.hrtime.bigint();
146110
- await new Promise((resolve2, reject) => {
146111
- const query2 = newConnection.query({
146112
- sql,
146113
- values: params ?? [],
146114
- typeCast
146115
- // rowsAsArray: true,
146116
- });
146117
- query2.on("error", (err2) => {
146118
- reject(err2);
146119
- });
146120
- query2.on("fields", (fields) => {
146121
- if (firstDataAt === 0n) {
146122
- firstDataAt = process.hrtime.bigint();
146123
- }
146124
- bytesReceived += fields[0]._buf.length;
146125
- });
146126
- query2.on("end", () => {
146127
- lastDataAt = process.hrtime.bigint();
146128
- resolve2();
146129
- });
146130
- });
146131
- return {
146132
- planning: null,
146133
- execution: executionTime,
146134
- dataDownload: ms(firstDataAt, lastDataAt) + ms(querySentAt, firstDataAt) - executionTime,
146135
- total: ms(querySentAt, lastDataAt),
146136
- dataSize: bytesReceived
146137
- };
146138
- };
146139
- const benchmarkProxy = async ({ sql, params }, repeats) => {
146140
- const { createConnection: createConnection2 } = await import("mysql2");
146141
- let startAt = 0n;
146142
- let tcpConnectedAt = 0n;
146143
- let tlsConnectedAt = null;
146144
- const createStream = ({ config }) => {
146145
- let stream;
146146
- if (config.socketPath) {
146147
- stream = net.connect(config.socketPath);
146148
- } else {
146149
- stream = net.connect(config.port, config.host);
146150
- }
146151
- if (config.enableKeepAlive) {
146152
- stream.on("connect", () => {
146153
- stream.setKeepAlive(true, config.keepAliveInitialDelay);
146154
- });
146155
- }
146156
- stream.setNoDelay(true);
146157
- stream.once("connect", () => {
146158
- tcpConnectedAt = process.hrtime.bigint();
146159
- });
146160
- return stream;
146161
- };
146162
- startAt = process.hrtime.bigint();
146163
- const connection2 = result2.url ? createConnection2({
146164
- uri: result2.url,
146165
- stream: createStream
146166
- }) : createConnection2({
146167
- ...result2.credentials,
146168
- stream: createStream
146169
- });
146170
- await new Promise((resolve2, reject) => {
146171
- connection2.connect((err2) => {
146172
- tlsConnectedAt = process.hrtime.bigint();
146173
- if (err2) {
146174
- reject(err2);
146175
- } else {
146176
- resolve2();
146177
- }
146178
- });
146179
- });
146180
- const results = [];
146181
- for (let i7 = 0; i7 < repeats; i7++) {
146182
- const r7 = await benchmarkQuery(connection2, sql, params);
146183
- results.push(r7);
146184
- }
146185
- connection2.end();
146186
- return {
146187
- tcpHandshake: ms(startAt, tcpConnectedAt),
146188
- tlsHandshake: tlsConnectedAt ? ms(tcpConnectedAt, tlsConnectedAt) : null,
146189
- dbHandshake: null,
146190
- queries: results
146191
- };
146192
- };
146193
146022
  return {
146194
146023
  db: { query },
146195
146024
  packageName: "mysql2",
146196
146025
  proxy,
146197
146026
  transactionProxy,
146198
- benchmarkProxy,
146199
146027
  database: result2.database,
146200
146028
  migrate: migrateFn
146201
146029
  };
@@ -148749,8 +148577,8 @@ ${sql}
148749
148577
  `;
148750
148578
  return content;
148751
148579
  };
148752
- prepareSnapshotFolderName = (ms2) => {
148753
- const now = ms2 ? new Date(ms2) : /* @__PURE__ */ new Date();
148580
+ prepareSnapshotFolderName = (ms) => {
148581
+ const now = ms ? new Date(ms) : /* @__PURE__ */ new Date();
148754
148582
  return `${now.getFullYear()}${two(now.getUTCMonth() + 1)}${two(
148755
148583
  now.getUTCDate()
148756
148584
  )}${two(now.getUTCHours())}${two(now.getUTCMinutes())}${two(
@@ -152265,7 +152093,7 @@ import { getTableConfig as singlestoreTableConfig, SingleStoreTable } from "driz
152265
152093
  import { getTableConfig as sqliteTableConfig, SQLiteTable } from "drizzle-orm/sqlite-core";
152266
152094
  import fs10 from "fs";
152267
152095
  import { createServer } from "https";
152268
- var preparePgSchema, prepareMySqlSchema, prepareMsSqlSchema, prepareSQLiteSchema, prepareSingleStoreSchema, getCustomDefaults, drizzleForPostgres, drizzleForMySQL, drizzleForSQLite, drizzleForLibSQL, drizzleForSingleStore, extractRelations, init2, proxySchema, transactionProxySchema, benchmarkProxySchema, defaultsSchema, schema5, jsonStringify, prepareServer;
152096
+ var preparePgSchema, prepareMySqlSchema, prepareMsSqlSchema, prepareSQLiteSchema, prepareSingleStoreSchema, getCustomDefaults, drizzleForPostgres, drizzleForMySQL, drizzleForSQLite, drizzleForLibSQL, drizzleForSingleStore, extractRelations, init2, proxySchema, transactionProxySchema, defaultsSchema, schema5, jsonStringify, prepareServer;
152269
152097
  var init_studio = __esm({
152270
152098
  "src/cli/commands/studio.ts"() {
152271
152099
  "use strict";
@@ -152479,7 +152307,6 @@ var init_studio = __esm({
152479
152307
  packageName: db.packageName,
152480
152308
  proxy: db.proxy,
152481
152309
  transactionProxy: db.transactionProxy,
152482
- benchmarkProxy: db.benchmarkProxy,
152483
152310
  customDefaults,
152484
152311
  schema: pgSchema2,
152485
152312
  relations: relations2,
@@ -152489,7 +152316,7 @@ var init_studio = __esm({
152489
152316
  };
152490
152317
  drizzleForMySQL = async (credentials, mysqlSchema, relations2, schemaFiles, casing2) => {
152491
152318
  const { connectToMySQL: connectToMySQL2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
152492
- const { proxy, transactionProxy, benchmarkProxy, database, packageName } = await connectToMySQL2(credentials);
152319
+ const { proxy, transactionProxy, database, packageName } = await connectToMySQL2(credentials);
152493
152320
  const customDefaults = getCustomDefaults(mysqlSchema, casing2);
152494
152321
  let dbUrl;
152495
152322
  if ("url" in credentials) {
@@ -152505,7 +152332,6 @@ var init_studio = __esm({
152505
152332
  databaseName: database,
152506
152333
  proxy,
152507
152334
  transactionProxy,
152508
- benchmarkProxy,
152509
152335
  customDefaults,
152510
152336
  schema: mysqlSchema,
152511
152337
  relations: relations2,
@@ -152675,23 +152501,6 @@ var init_studio = __esm({
152675
152501
  ]).optional()
152676
152502
  }).array()
152677
152503
  });
152678
- benchmarkProxySchema = external_exports.object({
152679
- type: external_exports.literal("bproxy"),
152680
- data: external_exports.object({
152681
- query: external_exports.object({
152682
- sql: external_exports.string(),
152683
- params: external_exports.array(external_exports.any()).optional(),
152684
- method: external_exports.union([
152685
- external_exports.literal("values"),
152686
- external_exports.literal("get"),
152687
- external_exports.literal("all"),
152688
- external_exports.literal("run"),
152689
- external_exports.literal("execute")
152690
- ]).optional()
152691
- }),
152692
- repeats: external_exports.number().min(1).optional()
152693
- })
152694
- });
152695
152504
  defaultsSchema = external_exports.object({
152696
152505
  type: external_exports.literal("defaults"),
152697
152506
  data: external_exports.array(
@@ -152706,7 +152515,6 @@ var init_studio = __esm({
152706
152515
  init2,
152707
152516
  proxySchema,
152708
152517
  transactionProxySchema,
152709
- benchmarkProxySchema,
152710
152518
  defaultsSchema
152711
152519
  ]);
152712
152520
  jsonStringify = (data) => {
@@ -152729,7 +152537,6 @@ var init_studio = __esm({
152729
152537
  databaseName,
152730
152538
  proxy,
152731
152539
  transactionProxy,
152732
- benchmarkProxy,
152733
152540
  customDefaults,
152734
152541
  schema: drizzleSchema,
152735
152542
  relations: relations2,
@@ -152793,7 +152600,7 @@ var init_studio = __esm({
152793
152600
  console.warn("Error message:", error3.message);
152794
152601
  }
152795
152602
  return c6.json({
152796
- version: "6.3",
152603
+ version: "6.2",
152797
152604
  dialect: dialect6,
152798
152605
  driver: driver2,
152799
152606
  packageName,
@@ -152831,21 +152638,6 @@ var init_studio = __esm({
152831
152638
  }
152832
152639
  );
152833
152640
  }
152834
- if (type === "bproxy") {
152835
- if (!benchmarkProxy) {
152836
- throw new Error("Benchmark proxy is not configured for this database.");
152837
- }
152838
- const result2 = await benchmarkProxy(body.data.query, body.data.repeats || 1);
152839
- const res = jsonStringify(result2);
152840
- return c6.body(
152841
- res,
152842
- {
152843
- headers: {
152844
- "Content-Type": "application/json"
152845
- }
152846
- }
152847
- );
152848
- }
152849
152641
  if (type === "defaults") {
152850
152642
  const columns = body.data;
152851
152643
  const result2 = columns.map((column8) => {