drizzle-kit 1.0.0-beta.3-7648fde → 1.0.0-beta.3-702eadc

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
@@ -5999,7 +5999,6 @@ var init_stringify = __esm({
5999
5999
  case `number`:
6000
6000
  return Number.isFinite(value) ? value.toString() : `null`;
6001
6001
  case `boolean`:
6002
- return value.toString();
6003
6002
  case `bigint`:
6004
6003
  return n6 ? `${value.toString()}n` : value.toString();
6005
6004
  case `object`: {
@@ -6237,7 +6236,7 @@ function formatTime(date2) {
6237
6236
  const iso = instant.toString({ timeZone: "UTC" });
6238
6237
  return iso;
6239
6238
  }
6240
- var SmallInt, Int, BigInt2, Numeric, Real, Double, Boolean2, Char, Varchar, Text, toDefaultArray, Json, Jsonb, Time, TimeTz, DateType, Timestamp, TimestampTz, Uuid, Interval2, Inet, Cidr, MacAddr, MacAddr8, Vector, HalfVec, SparseVec, Bit, Point, Line, GeometryPoint, Enum, Serial, BigSerial, SmallSerial, Custom, typeFor, splitSqlType, vectorOps, indexName, isSerialExpression, parseOnType, systemNamespaceNames, isSystemNamespace, wrapRecord, parseViewDefinition, defaultNameForIdentitySequence, defaultNameForPK, defaultNameForFK, defaultNameForUnique, defaultNameForIndex, trimDefaultValueSuffix, defaultForColumn, defaultToSQL, isDefaultAction, isSerialType, mapSerialToInt, defaultsCommutative, defaults;
6239
+ var SmallInt, Int, BigInt2, Numeric, Real, Double, Boolean2, Char, Varchar, Text, toDefaultArray, Json, Jsonb, Time, TimeTz, DateType, Timestamp, TimestampTz, Uuid, Interval2, Inet, Cidr, MacAddr, MacAddr8, Vector, HalfVec, SparseVec, Bit, Point, Line, GeometryPoint, Enum, Serial, BigSerial, SmallSerial, Custom, typeFor, splitSqlType, vectorOps, indexName, isSerialExpression, parseOnType, systemNamespaceNames, isSystemNamespace, wrapRecord, parseViewDefinition, defaultNameForIdentitySequence, defaultNameForPK, defaultNameForFK, defaultNameForUnique, defaultNameForIndex, trimDefaultValueSuffix, defaultForColumn, defaultToSQL, isDefaultAction, isSerialType, defaultsCommutative, defaults;
6241
6240
  var init_grammar = __esm({
6242
6241
  "src/dialects/postgres/grammar.ts"() {
6243
6242
  "use strict";
@@ -7826,18 +7825,6 @@ var init_grammar = __esm({
7826
7825
  isSerialType = (type) => {
7827
7826
  return /^(?:serial|bigserial|smallserial)$/i.test(type);
7828
7827
  };
7829
- mapSerialToInt = (type) => {
7830
- switch (type) {
7831
- case "smallserial":
7832
- return "smallint";
7833
- case "serial":
7834
- return "int";
7835
- case "bigserial":
7836
- return "bigint";
7837
- default:
7838
- throw new Error(`Unsupported type: ${type}`);
7839
- }
7840
- };
7841
7828
  defaultsCommutative = (diffDef, type, dimensions) => {
7842
7829
  if (!diffDef) return false;
7843
7830
  let from = diffDef.from;
@@ -15227,7 +15214,8 @@ var init_schemaValidator = __esm({
15227
15214
  "singlestore",
15228
15215
  "gel",
15229
15216
  "mssql",
15230
- "cockroach"
15217
+ "cockroach",
15218
+ "duckdb"
15231
15219
  ];
15232
15220
  dialect = enumType(dialects);
15233
15221
  }
@@ -23048,7 +23036,7 @@ var init_convertor = __esm({
23048
23036
  return [drop, add];
23049
23037
  });
23050
23038
  alterColumnConvertor = convertor("alter_column", (st) => {
23051
- const { diff: diff2, to: column7, isEnum, wasEnum, wasSerial, toSerial } = st;
23039
+ const { diff: diff2, to: column7, isEnum, wasEnum, wasSerial } = st;
23052
23040
  const statements = [];
23053
23041
  const key = column7.schema !== "public" ? `"${column7.schema}"."${column7.table}"` : `"${column7.table}"`;
23054
23042
  const recreateDefault = diff2.type && (isEnum || wasEnum) && diff2.$left.default;
@@ -23058,21 +23046,17 @@ var init_convertor = __esm({
23058
23046
  if (diff2.type) {
23059
23047
  const typeSchema = column7.typeSchema && column7.typeSchema !== "public" ? `"${column7.typeSchema}".` : "";
23060
23048
  const textProxy = wasEnum && isEnum ? "text::" : "";
23061
- const suffix = isEnum ? ` USING "${column7.name}"::${textProxy}${typeSchema}"${column7.type}"${"[]".repeat(column7.dimensions)}` : ` USING "${column7.name}"::${toSerial ? mapSerialToInt(column7.type) : column7.type}${"[]".repeat(column7.dimensions)}`;
23062
- const type = diff2.typeSchema?.to && diff2.typeSchema.to !== "public" ? `"${diff2.typeSchema.to}"."${diff2.type.to}"` : isEnum ? `"${diff2.type.to}"` : toSerial ? mapSerialToInt(diff2.type.to) : diff2.type.to;
23063
- if (wasSerial) {
23064
- statements.push(`ALTER TABLE ${key} ALTER COLUMN "${column7.name}" DROP DEFAULT;`);
23065
- const sequenceKey = column7.schema !== "public" ? `"${column7.schema}"."${column7.table}_${column7.name}_seq"` : `"${column7.table}_${column7.name}_seq"`;
23066
- statements.push(`DROP SEQUENCE ${sequenceKey};`);
23049
+ const suffix = isEnum ? ` USING "${column7.name}"::${textProxy}${typeSchema}"${column7.type}"${"[]".repeat(column7.dimensions)}` : ` USING "${column7.name}"::${column7.type}${"[]".repeat(column7.dimensions)}`;
23050
+ let type;
23051
+ if (diff2.type) {
23052
+ type = diff2.typeSchema?.to && diff2.typeSchema.to !== "public" ? `"${diff2.typeSchema.to}"."${diff2.type.to}"` : isEnum ? `"${diff2.type.to}"` : diff2.type.to;
23053
+ } else {
23054
+ type = `${typeSchema}${column7.typeSchema ? `"${column7.type}"` : column7.type}`;
23067
23055
  }
23068
- if (toSerial) {
23056
+ if (wasSerial) {
23057
+ statements.push(`ALTER TABLE ${key} ALTER COLUMN "${column7.name}" DROP DEFAULT`);
23069
23058
  const sequenceKey = column7.schema !== "public" ? `"${column7.schema}"."${column7.table}_${column7.name}_seq"` : `"${column7.table}_${column7.name}_seq"`;
23070
- const sequenceName = column7.schema !== "public" ? `${column7.schema}.${column7.table}_${column7.name}_seq` : `${column7.table}_${column7.name}_seq`;
23071
- statements.push(`CREATE SEQUENCE ${sequenceKey};`);
23072
- statements.push(
23073
- `ALTER TABLE ${key} ALTER COLUMN "${column7.name}" SET DEFAULT nextval('${sequenceName}')`
23074
- );
23075
- statements.push(`ALTER SEQUENCE ${sequenceKey} OWNED BY "${column7.schema}"."${column7.table}"."${column7.name}";`);
23059
+ statements.push(`DROP SEQUENCE ${sequenceKey}`);
23076
23060
  }
23077
23061
  statements.push(
23078
23062
  `ALTER TABLE ${key} ALTER COLUMN "${column7.name}" SET DATA TYPE ${type}${"[]".repeat(column7.dimensions)}${suffix};`
@@ -24374,7 +24358,6 @@ var init_diff = __esm({
24374
24358
  }).map((it) => {
24375
24359
  const column7 = it.$right;
24376
24360
  const wasSerial = isSerialType(it.$left.type);
24377
- const toSerial = !isSerialType(it.$left.type) && isSerialType(it.$right.type);
24378
24361
  const isEnum = ddl22.enums.one({ schema: column7.typeSchema ?? "public", name: column7.type }) !== null;
24379
24362
  const wasEnum = (it.type && ddl1.enums.one({ schema: column7.typeSchema ?? "public", name: it.type.from }) !== null) ?? false;
24380
24363
  return prepareStatement("alter_column", {
@@ -24382,8 +24365,7 @@ var init_diff = __esm({
24382
24365
  to: column7,
24383
24366
  isEnum,
24384
24367
  wasEnum,
24385
- wasSerial,
24386
- toSerial
24368
+ wasSerial
24387
24369
  });
24388
24370
  });
24389
24371
  const createSequences = createdSequences.map((it) => prepareStatement("create_sequence", { sequence: it }));
@@ -25070,7 +25052,7 @@ var init_introspect = __esm({
25070
25052
  });
25071
25053
  }
25072
25054
  for (const seq of sequencesList) {
25073
- const depend = dependList.find((it) => it.oid === seq.oid);
25055
+ const depend = dependList.find((it) => Number(it.oid) === Number(seq.oid));
25074
25056
  if (depend && (depend.deptype === "a" || depend.deptype === "i")) {
25075
25057
  continue;
25076
25058
  }
@@ -25134,22 +25116,22 @@ var init_introspect = __esm({
25134
25116
  continue;
25135
25117
  }
25136
25118
  const expr = serialsList.find(
25137
- (it) => it.tableId === column7.tableId && it.ordinality === column7.ordinality
25119
+ (it) => Number(it.tableId) === Number(column7.tableId) && it.ordinality === column7.ordinality
25138
25120
  );
25139
25121
  if (expr) {
25140
- const table6 = tablesList.find((it) => it.oid === column7.tableId);
25122
+ const table6 = tablesList.find((it) => Number(it.oid) === Number(column7.tableId));
25141
25123
  const isSerial = isSerialExpression(expr.expression, table6.schema);
25142
25124
  column7.type = isSerial ? type === "bigint" ? "bigserial" : type === "integer" ? "serial" : "smallserial" : type;
25143
25125
  }
25144
25126
  }
25145
25127
  for (const column7 of columnsList.filter((x6) => x6.kind === "r" || x6.kind === "p")) {
25146
- const table6 = tablesList.find((it) => it.oid === column7.tableId);
25128
+ const table6 = tablesList.find((it) => Number(it.oid) === Number(column7.tableId));
25147
25129
  const enumType2 = column7.typeId in groupedEnums ? groupedEnums[column7.typeId] : column7.typeId in groupedArrEnums ? groupedArrEnums[column7.typeId] : null;
25148
25130
  let columnTypeMapped = enumType2 ? enumType2.name : column7.type.replaceAll("[]", "");
25149
25131
  columnTypeMapped = columnTypeMapped.replace("character varying", "varchar").replace(" without time zone", "").replace("character", "char").replace("geometry(Point", "geometry(point");
25150
25132
  columnTypeMapped = trimChar(columnTypeMapped, '"');
25151
25133
  const columnDefault = defaultsList.find(
25152
- (it) => it.tableId === column7.tableId && it.ordinality === column7.ordinality
25134
+ (it) => Number(it.tableId) === Number(column7.tableId) && it.ordinality === column7.ordinality
25153
25135
  );
25154
25136
  const defaultValue = defaultForColumn(
25155
25137
  columnTypeMapped,
@@ -25158,10 +25140,10 @@ var init_introspect = __esm({
25158
25140
  Boolean(enumType2)
25159
25141
  );
25160
25142
  const unique = constraintsList.find((it) => {
25161
- return it.type === "u" && it.tableId === column7.tableId && it.columnsOrdinals.length === 1 && it.columnsOrdinals.includes(column7.ordinality);
25143
+ return it.type === "u" && Number(it.tableId) === Number(column7.tableId) && it.columnsOrdinals.length === 1 && it.columnsOrdinals.includes(column7.ordinality);
25162
25144
  }) ?? null;
25163
25145
  const pk = constraintsList.find((it) => {
25164
- return it.type === "p" && it.tableId === column7.tableId && it.columnsOrdinals.length === 1 && it.columnsOrdinals.includes(column7.ordinality);
25146
+ return it.type === "p" && Number(it.tableId) === Number(column7.tableId) && it.columnsOrdinals.length === 1 && it.columnsOrdinals.includes(column7.ordinality);
25165
25147
  }) ?? null;
25166
25148
  const metadata = column7.metadata;
25167
25149
  if (column7.generatedType === "s" && (!metadata || !metadata.expression)) {
@@ -25176,7 +25158,7 @@ ${JSON.stringify(column7.metadata)}`
25176
25158
  ${JSON.stringify(column7.metadata)}`
25177
25159
  );
25178
25160
  }
25179
- const sequence = metadata?.seqId ? sequencesList.find((it) => it.oid === Number(metadata.seqId)) ?? null : null;
25161
+ const sequence = metadata?.seqId ? sequencesList.find((it) => Number(it.oid) === Number(metadata.seqId)) ?? null : null;
25180
25162
  columns.push({
25181
25163
  entityType: "columns",
25182
25164
  schema: table6.schema,
@@ -25206,10 +25188,12 @@ ${JSON.stringify(column7.metadata)}`
25206
25188
  });
25207
25189
  }
25208
25190
  for (const unique of constraintsList.filter((it) => it.type === "u")) {
25209
- const table6 = tablesList.find((it) => it.oid === unique.tableId);
25210
- const schema5 = namespaces.find((it) => it.oid === unique.schemaId);
25191
+ const table6 = tablesList.find((it) => Number(it.oid) === Number(unique.tableId));
25192
+ const schema5 = namespaces.find((it) => Number(it.oid) === Number(unique.schemaId));
25211
25193
  const columns2 = unique.columnsOrdinals.map((it) => {
25212
- const column7 = columnsList.find((column8) => column8.tableId === unique.tableId && column8.ordinality === it);
25194
+ const column7 = columnsList.find(
25195
+ (column8) => Number(column8.tableId) === Number(unique.tableId) && column8.ordinality === it
25196
+ );
25213
25197
  return column7.name;
25214
25198
  });
25215
25199
  uniques.push({
@@ -25223,10 +25207,12 @@ ${JSON.stringify(column7.metadata)}`
25223
25207
  });
25224
25208
  }
25225
25209
  for (const pk of constraintsList.filter((it) => it.type === "p")) {
25226
- const table6 = tablesList.find((it) => it.oid === pk.tableId);
25227
- const schema5 = namespaces.find((it) => it.oid === pk.schemaId);
25210
+ const table6 = tablesList.find((it) => Number(it.oid) === Number(pk.tableId));
25211
+ const schema5 = namespaces.find((it) => Number(it.oid) === Number(pk.schemaId));
25228
25212
  const columns2 = pk.columnsOrdinals.map((it) => {
25229
- const column7 = columnsList.find((column8) => column8.tableId === pk.tableId && column8.ordinality === it);
25213
+ const column7 = columnsList.find(
25214
+ (column8) => Number(column8.tableId) === Number(pk.tableId) && column8.ordinality === it
25215
+ );
25230
25216
  return column7.name;
25231
25217
  });
25232
25218
  pks.push({
@@ -25239,15 +25225,19 @@ ${JSON.stringify(column7.metadata)}`
25239
25225
  });
25240
25226
  }
25241
25227
  for (const fk5 of constraintsList.filter((it) => it.type === "f")) {
25242
- const table6 = tablesList.find((it) => it.oid === fk5.tableId);
25243
- const schema5 = namespaces.find((it) => it.oid === fk5.schemaId);
25244
- const tableTo = tablesList.find((it) => it.oid === fk5.tableToId);
25228
+ const table6 = tablesList.find((it) => Number(it.oid) === Number(fk5.tableId));
25229
+ const schema5 = namespaces.find((it) => Number(it.oid) === Number(fk5.schemaId));
25230
+ const tableTo = tablesList.find((it) => Number(it.oid) === Number(fk5.tableToId));
25245
25231
  const columns2 = fk5.columnsOrdinals.map((it) => {
25246
- const column7 = columnsList.find((column8) => column8.tableId === fk5.tableId && column8.ordinality === it);
25232
+ const column7 = columnsList.find(
25233
+ (column8) => Number(column8.tableId) === Number(fk5.tableId) && column8.ordinality === it
25234
+ );
25247
25235
  return column7.name;
25248
25236
  });
25249
25237
  const columnsTo = fk5.columnsToOrdinals.map((it) => {
25250
- const column7 = columnsList.find((column8) => column8.tableId === fk5.tableToId && column8.ordinality === it);
25238
+ const column7 = columnsList.find(
25239
+ (column8) => Number(column8.tableId) === Number(fk5.tableToId) && column8.ordinality === it
25240
+ );
25251
25241
  return column7.name;
25252
25242
  });
25253
25243
  fks.push({
@@ -25265,8 +25255,8 @@ ${JSON.stringify(column7.metadata)}`
25265
25255
  });
25266
25256
  }
25267
25257
  for (const check of constraintsList.filter((it) => it.type === "c")) {
25268
- const table6 = tablesList.find((it) => it.oid === check.tableId);
25269
- const schema5 = namespaces.find((it) => it.oid === check.schemaId);
25258
+ const table6 = tablesList.find((it) => Number(it.oid) === Number(check.tableId));
25259
+ const schema5 = namespaces.find((it) => Number(it.oid) === Number(check.schemaId));
25270
25260
  checks.push({
25271
25261
  entityType: "checks",
25272
25262
  schema: schema5.name,
@@ -25327,10 +25317,10 @@ ${JSON.stringify(column7.metadata)}`
25327
25317
  });
25328
25318
  for (const idx of idxs) {
25329
25319
  const { metadata } = idx;
25330
- const forUnique = metadata.isUnique && constraintsList.some((x6) => x6.type === "u" && x6.indexId === idx.oid);
25331
- const forPK = metadata.isPrimary && constraintsList.some((x6) => x6.type === "p" && x6.indexId === idx.oid);
25320
+ const forUnique = metadata.isUnique && constraintsList.some((x6) => x6.type === "u" && Number(x6.indexId) === Number(idx.oid));
25321
+ const forPK = metadata.isPrimary && constraintsList.some((x6) => x6.type === "p" && Number(x6.indexId) === Number(idx.oid));
25332
25322
  const expr = splitExpressions(metadata.expression);
25333
- const table6 = tablesList.find((it) => it.oid === idx.metadata.tableId);
25323
+ const table6 = tablesList.find((it) => Number(it.oid) === Number(idx.metadata.tableId));
25334
25324
  const nonColumnsCount = metadata.columnOrdinals.reduce((acc, it) => {
25335
25325
  if (it === 0) acc += 1;
25336
25326
  return acc;
@@ -25362,7 +25352,7 @@ ${JSON.stringify(column7.metadata)}`
25362
25352
  k6 += 1;
25363
25353
  } else {
25364
25354
  const column7 = columnsList.find((column8) => {
25365
- return column8.tableId === metadata.tableId && column8.ordinality === ordinal;
25355
+ return Number(column8.tableId) === Number(metadata.tableId) && column8.ordinality === ordinal;
25366
25356
  });
25367
25357
  if (!column7) throw new Error(`missing column: ${metadata.tableId}:${ordinal}`);
25368
25358
  const options = opts[i7];
@@ -25407,7 +25397,7 @@ ${JSON.stringify(column7.metadata)}`
25407
25397
  });
25408
25398
  }
25409
25399
  for (const it of columnsList.filter((x6) => x6.kind === "m" || x6.kind === "v")) {
25410
- const view5 = viewsList.find((x6) => x6.oid === it.tableId);
25400
+ const view5 = viewsList.find((x6) => Number(x6.oid) === Number(it.tableId));
25411
25401
  const typeDimensions = it.type.split("[]").length - 1;
25412
25402
  const enumType2 = it.typeId in groupedEnums ? groupedEnums[it.typeId] : it.typeId in groupedArrEnums ? groupedArrEnums[it.typeId] : null;
25413
25403
  let columnTypeMapped = enumType2 ? enumType2.name : it.type.replace("[]", "");
@@ -25429,8 +25419,8 @@ ${JSON.stringify(column7.metadata)}`
25429
25419
  });
25430
25420
  }
25431
25421
  for (const view5 of viewsList) {
25432
- const accessMethod = view5.accessMethod === 0 ? null : ams.find((it) => it.oid === view5.accessMethod);
25433
- const tablespace = view5.tablespaceid === 0 ? null : tablespaces.find((it) => it.oid === view5.tablespaceid).name;
25422
+ const accessMethod = Number(view5.accessMethod) === 0 ? null : ams.find((it) => Number(it.oid) === Number(view5.accessMethod));
25423
+ const tablespace = Number(view5.tablespaceid) === 0 ? null : tablespaces.find((it) => Number(it.oid) === Number(view5.tablespaceid)).name;
25434
25424
  const definition = parseViewDefinition(view5.definition);
25435
25425
  const withOpts = wrapRecord(
25436
25426
  view5.options?.reduce((acc, it) => {
@@ -145297,6 +145287,7 @@ __export(connections_exports, {
145297
145287
  connectToSQLite: () => connectToSQLite,
145298
145288
  connectToSingleStore: () => connectToSingleStore,
145299
145289
  prepareCockroach: () => prepareCockroach,
145290
+ prepareDuckDb: () => prepareDuckDb,
145300
145291
  prepareGelDB: () => prepareGelDB,
145301
145292
  preparePostgresDB: () => preparePostgresDB
145302
145293
  });
@@ -145314,7 +145305,7 @@ function parseMssqlUrl(url) {
145314
145305
  }
145315
145306
  };
145316
145307
  }
145317
- var ms, normalisePGliteUrl, preparePostgresDB, prepareCockroach, prepareGelDB, parseSingleStoreCredentials, connectToSingleStore, parseMysqlCredentials, connectToMySQL, parseMssqlCredentials, connectToMsSQL, prepareSqliteParams, preparePGliteParams, connectToSQLite, connectToLibSQL;
145308
+ var ms, normalisePGliteUrl, preparePostgresDB, prepareDuckDb, prepareCockroach, prepareGelDB, parseSingleStoreCredentials, connectToSingleStore, parseMysqlCredentials, connectToMySQL, parseMssqlCredentials, connectToMsSQL, prepareSqliteParams, preparePGliteParams, connectToSQLite, connectToLibSQL;
145318
145309
  var init_connections = __esm({
145319
145310
  "src/cli/connections.ts"() {
145320
145311
  "use strict";
@@ -145449,7 +145440,13 @@ var init_connections = __esm({
145449
145440
  }
145450
145441
  return results;
145451
145442
  };
145452
- return { packageName: "pglite", query, proxy, transactionProxy, migrate: migrateFn };
145443
+ return {
145444
+ packageName: "pglite",
145445
+ query,
145446
+ proxy,
145447
+ transactionProxy,
145448
+ migrate: migrateFn
145449
+ };
145453
145450
  }
145454
145451
  assertUnreachable(driver2);
145455
145452
  }
@@ -145690,7 +145687,13 @@ var init_connections = __esm({
145690
145687
  }
145691
145688
  return results;
145692
145689
  };
145693
- return { packageName: "postgres", query, proxy, transactionProxy, migrate: migrateFn };
145690
+ return {
145691
+ packageName: "postgres",
145692
+ query,
145693
+ proxy,
145694
+ transactionProxy,
145695
+ migrate: migrateFn
145696
+ };
145694
145697
  }
145695
145698
  if (await checkPackage("@vercel/postgres")) {
145696
145699
  console.log(
@@ -145771,7 +145774,13 @@ var init_connections = __esm({
145771
145774
  }
145772
145775
  return results;
145773
145776
  };
145774
- return { packageName: "@vercel/postgres", query, proxy, transactionProxy, migrate: migrateFn };
145777
+ return {
145778
+ packageName: "@vercel/postgres",
145779
+ query,
145780
+ proxy,
145781
+ transactionProxy,
145782
+ migrate: migrateFn
145783
+ };
145775
145784
  }
145776
145785
  if (await checkPackage("@neondatabase/serverless")) {
145777
145786
  console.log(
@@ -145784,7 +145793,11 @@ var init_connections = __esm({
145784
145793
  "'@neondatabase/serverless' can only connect to remote Neon/Vercel Postgres/Supabase instances through a websocket"
145785
145794
  )
145786
145795
  );
145787
- const { Pool, neonConfig, types: pgTypes } = await import("@neondatabase/serverless");
145796
+ const {
145797
+ Pool,
145798
+ neonConfig,
145799
+ types: pgTypes
145800
+ } = await import("@neondatabase/serverless");
145788
145801
  const { drizzle } = await import("drizzle-orm/neon-serverless");
145789
145802
  const { migrate } = await import("drizzle-orm/neon-serverless/migrator");
145790
145803
  const ssl = "ssl" in credentials ? credentials.ssl === "prefer" || credentials.ssl === "require" || credentials.ssl === "allow" ? { rejectUnauthorized: false } : credentials.ssl === "verify-full" ? {} : credentials.ssl : {};
@@ -145854,7 +145867,13 @@ var init_connections = __esm({
145854
145867
  }
145855
145868
  return results;
145856
145869
  };
145857
- return { packageName: "@neondatabase/serverless", query, proxy, transactionProxy, migrate: migrateFn };
145870
+ return {
145871
+ packageName: "@neondatabase/serverless",
145872
+ query,
145873
+ proxy,
145874
+ transactionProxy,
145875
+ migrate: migrateFn
145876
+ };
145858
145877
  }
145859
145878
  if (await checkPackage("bun")) {
145860
145879
  console.log(withStyle.info(`Using 'bun' driver for database querying`));
@@ -145905,6 +145924,54 @@ var init_connections = __esm({
145905
145924
  console.warn("For the 'bun' driver, run your script using: bun --bun");
145906
145925
  process.exit(1);
145907
145926
  };
145927
+ prepareDuckDb = async (credentials) => {
145928
+ if (await checkPackage("@duckdb/node-api")) {
145929
+ console.log(
145930
+ withStyle.info(`Using '@duckdb/node-api' driver for database querying`)
145931
+ );
145932
+ const { DuckDBInstance } = await import("@duckdb/node-api");
145933
+ const instance = await DuckDBInstance.create(credentials.url);
145934
+ const client = await instance.connect();
145935
+ const query = async (sql, params = []) => {
145936
+ const result2 = await client.run(sql, params);
145937
+ const rows = await result2.getRowObjectsJson();
145938
+ return rows;
145939
+ };
145940
+ const proxy = async (params) => {
145941
+ const result2 = await client.run(params.sql, params.params);
145942
+ return params.mode === "array" ? await result2.getRowsJson() : await result2.getRowObjectsJson();
145943
+ };
145944
+ const transactionProxy = async (queries) => {
145945
+ const results = [];
145946
+ try {
145947
+ await client.run("BEGIN");
145948
+ for (const query2 of queries) {
145949
+ const result2 = await client.run(query2.sql);
145950
+ results.push(await result2.getRowObjectsJson());
145951
+ }
145952
+ await client.run("COMMIT");
145953
+ } catch (error3) {
145954
+ await client.run("ROLLBACK");
145955
+ results.push(error3);
145956
+ }
145957
+ return results;
145958
+ };
145959
+ return {
145960
+ packageName: "@duckdb/node-api",
145961
+ query,
145962
+ proxy,
145963
+ transactionProxy,
145964
+ migrate: () => {
145965
+ throw new Error("DuckDB does not support migrations");
145966
+ }
145967
+ };
145968
+ }
145969
+ console.error(
145970
+ // "To connect to DuckDb database - please install either of 'duckdb', '@duckdb/node-api' drivers",
145971
+ "To connect to DuckDb database - please install '@duckdb/node-api' driver"
145972
+ );
145973
+ process.exit(1);
145974
+ };
145908
145975
  prepareCockroach = async (credentials) => {
145909
145976
  if (await checkPackage("pg")) {
145910
145977
  const { default: pg } = await import("pg");
@@ -145957,9 +146024,7 @@ var init_connections = __esm({
145957
146024
  };
145958
146025
  return { query, proxy, migrate: migrateFn };
145959
146026
  }
145960
- console.error(
145961
- "To connect to Cockroach - please install 'pg' package"
145962
- );
146027
+ console.error("To connect to Cockroach - please install 'pg' package");
145963
146028
  process.exit(1);
145964
146029
  };
145965
146030
  prepareGelDB = async (credentials) => {
@@ -146018,9 +146083,7 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
146018
146083
  };
146019
146084
  return { packageName: "gel", query, proxy, transactionProxy };
146020
146085
  }
146021
- console.error(
146022
- "To connect to gel database - please install 'edgedb' driver"
146023
- );
146086
+ console.error("To connect to gel database - please install 'edgedb' driver");
146024
146087
  process.exit(1);
146025
146088
  };
146026
146089
  parseSingleStoreCredentials = (credentials) => {
@@ -146472,9 +146535,7 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
146472
146535
  migrate: migrateFn
146473
146536
  };
146474
146537
  }
146475
- console.error(
146476
- "To connect to MsSQL database - please install 'mssql' driver"
146477
- );
146538
+ console.error("To connect to MsSQL database - please install 'mssql' driver");
146478
146539
  process.exit(1);
146479
146540
  };
146480
146541
  prepareSqliteParams = (params, driver2) => {
@@ -146579,7 +146640,10 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
146579
146640
  await remoteCallback(query2, [], "run");
146580
146641
  };
146581
146642
  const proxy = async (params) => {
146582
- const preparedParams = prepareSqliteParams(params.params || [], "d1-http");
146643
+ const preparedParams = prepareSqliteParams(
146644
+ params.params || [],
146645
+ "d1-http"
146646
+ );
146583
146647
  const result2 = await remoteCallback(
146584
146648
  params.sql,
146585
146649
  preparedParams,
@@ -146804,17 +146868,19 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
146804
146868
  };
146805
146869
  const transactionProxy = async (queries) => {
146806
146870
  const results = [];
146807
- const tx = sqlite.transaction((queries2) => {
146808
- for (const query of queries2) {
146809
- let result2 = [];
146810
- if (query.method === "values" || query.method === "get" || query.method === "all") {
146811
- result2 = sqlite.prepare(query.sql).all();
146812
- } else {
146813
- sqlite.prepare(query.sql).run();
146871
+ const tx = sqlite.transaction(
146872
+ (queries2) => {
146873
+ for (const query of queries2) {
146874
+ let result2 = [];
146875
+ if (query.method === "values" || query.method === "get" || query.method === "all") {
146876
+ result2 = sqlite.prepare(query.sql).all();
146877
+ } else {
146878
+ sqlite.prepare(query.sql).run();
146879
+ }
146880
+ results.push(result2);
146814
146881
  }
146815
- results.push(result2);
146816
146882
  }
146817
- });
146883
+ );
146818
146884
  try {
146819
146885
  tx(queries);
146820
146886
  } catch (error3) {
@@ -146822,7 +146888,13 @@ To link your project, please refer https://docs.geldata.com/reference/cli/gel_in
146822
146888
  }
146823
146889
  return results;
146824
146890
  };
146825
- return { ...db, packageName: "better-sqlite3", proxy, transactionProxy, migrate: migrateFn };
146891
+ return {
146892
+ ...db,
146893
+ packageName: "better-sqlite3",
146894
+ proxy,
146895
+ transactionProxy,
146896
+ migrate: migrateFn
146897
+ };
146826
146898
  }
146827
146899
  if (await checkPackage("bun")) {
146828
146900
  console.log(withStyle.info(`Using 'bun' driver for database querying`));
@@ -152362,6 +152434,7 @@ var init_cors = __esm({
152362
152434
  // src/cli/commands/studio.ts
152363
152435
  var studio_exports = {};
152364
152436
  __export(studio_exports, {
152437
+ drizzleForDuckDb: () => drizzleForDuckDb,
152365
152438
  drizzleForLibSQL: () => drizzleForLibSQL,
152366
152439
  drizzleForMySQL: () => drizzleForMySQL,
152367
152440
  drizzleForPostgres: () => drizzleForPostgres,
@@ -152392,7 +152465,7 @@ import { getTableConfig as singlestoreTableConfig, SingleStoreTable } from "driz
152392
152465
  import { getTableConfig as sqliteTableConfig, SQLiteTable } from "drizzle-orm/sqlite-core";
152393
152466
  import fs10 from "fs";
152394
152467
  import { createServer } from "https";
152395
- var preparePgSchema, prepareMySqlSchema, prepareMsSqlSchema, prepareSQLiteSchema, prepareSingleStoreSchema, getCustomDefaults, drizzleForPostgres, drizzleForMySQL, drizzleForSQLite, drizzleForLibSQL, drizzleForSingleStore, extractRelations, init2, proxySchema, transactionProxySchema, benchmarkProxySchema, defaultsSchema, schema4, jsonStringify, prepareServer;
152468
+ var preparePgSchema, prepareMySqlSchema, prepareMsSqlSchema, prepareSQLiteSchema, prepareSingleStoreSchema, getCustomDefaults, drizzleForPostgres, drizzleForDuckDb, drizzleForMySQL, drizzleForSQLite, drizzleForLibSQL, drizzleForSingleStore, extractRelations, init2, proxySchema, transactionProxySchema, benchmarkProxySchema, defaultsSchema, schema4, jsonStringify, prepareServer;
152396
152469
  var init_studio = __esm({
152397
152470
  "src/cli/commands/studio.ts"() {
152398
152471
  "use strict";
@@ -152614,6 +152687,23 @@ var init_studio = __esm({
152614
152687
  casing: casing2
152615
152688
  };
152616
152689
  };
152690
+ drizzleForDuckDb = async (credentials) => {
152691
+ const { prepareDuckDb: prepareDuckDb2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
152692
+ const db = await prepareDuckDb2(credentials);
152693
+ const dbUrl = `duckdb://${credentials.url}`;
152694
+ const dbHash = createHash4("sha256").update(dbUrl).digest("hex");
152695
+ return {
152696
+ dbHash,
152697
+ dialect: "duckdb",
152698
+ driver: void 0,
152699
+ packageName: db.packageName,
152700
+ proxy: db.proxy,
152701
+ transactionProxy: db.transactionProxy,
152702
+ customDefaults: [],
152703
+ schema: {},
152704
+ relations: {}
152705
+ };
152706
+ };
152617
152707
  drizzleForMySQL = async (credentials, mysqlSchema, relations2, schemaFiles, casing2) => {
152618
152708
  const { connectToMySQL: connectToMySQL2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
152619
152709
  const { proxy, transactionProxy, benchmarkProxy, database, packageName } = await connectToMySQL2(credentials);