drizzle-kit 0.20.3 → 0.20.4-5f82cc8

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
@@ -6815,11 +6815,11 @@ var require_node2 = __commonJS({
6815
6815
  this._set = hasNativeMap ? /* @__PURE__ */ new Map() : /* @__PURE__ */ Object.create(null);
6816
6816
  }
6817
6817
  ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
6818
- var set = new ArraySet();
6818
+ var set2 = new ArraySet();
6819
6819
  for (var i = 0, len = aArray.length; i < len; i++) {
6820
- set.add(aArray[i], aAllowDuplicates);
6820
+ set2.add(aArray[i], aAllowDuplicates);
6821
6821
  }
6822
- return set;
6822
+ return set2;
6823
6823
  };
6824
6824
  ArraySet.prototype.size = function ArraySet_size() {
6825
6825
  return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length;
@@ -13295,6 +13295,14 @@ WHERE
13295
13295
  });
13296
13296
 
13297
13297
  // src/serializer/index.ts
13298
+ var serializer_exports = {};
13299
+ __export(serializer_exports, {
13300
+ prepareFilenames: () => prepareFilenames,
13301
+ serializeMySql: () => serializeMySql,
13302
+ serializePg: () => serializePg,
13303
+ serializeSQLite: () => serializeSQLite,
13304
+ sqlToStr: () => sqlToStr
13305
+ });
13298
13306
  var import_fs2, import_path2, glob, sqlToStr, serializeMySql, serializePg, serializeSQLite, prepareFilenames;
13299
13307
  var init_serializer = __esm({
13300
13308
  "src/serializer/index.ts"() {
@@ -18785,10 +18793,14 @@ var init_utils2 = __esm({
18785
18793
  }
18786
18794
  });
18787
18795
 
18788
- // src/introspect.ts
18796
+ // src/introspect-pg.ts
18797
+ var introspect_pg_exports = {};
18798
+ __export(introspect_pg_exports, {
18799
+ schemaToTypeScript: () => schemaToTypeScript
18800
+ });
18789
18801
  var pgImportsList, objToStatement2, timeConfig, possibleIntervals, intervalStrToObj, intervalConfig, importsPatch, relations, withCasing, schemaToTypeScript, isCyclic, isSelf, column4, dimensionsInArray, createTableColumns, createTableIndexes, createTablePKs, createTableUniques, createTableFKs;
18790
- var init_introspect = __esm({
18791
- "src/introspect.ts"() {
18802
+ var init_introspect_pg = __esm({
18803
+ "src/introspect-pg.ts"() {
18792
18804
  init_utils2();
18793
18805
  init_pgSerializer();
18794
18806
  pgImportsList = /* @__PURE__ */ new Set([
@@ -18946,7 +18958,7 @@ var init_introspect = __esm({
18946
18958
  res.pg.push("pgEnum");
18947
18959
  }
18948
18960
  const columnImports = Object.values(it.columns).map((col) => {
18949
- let patched = importsPatch[col.type] ?? col.type;
18961
+ let patched = importsPatch[col.type] || col.type;
18950
18962
  patched = patched.startsWith("varchar(") ? "varchar" : patched;
18951
18963
  patched = patched.startsWith("char(") ? "char" : patched;
18952
18964
  patched = patched.startsWith("numeric(") ? "numeric" : patched;
@@ -19015,18 +19027,23 @@ var init_introspect = __esm({
19015
19027
  return statement;
19016
19028
  });
19017
19029
  const uniquePgImports = ["pgTable", ...new Set(imports.pg)];
19018
- let result = `import { ${uniquePgImports.join(
19030
+ const importsTs = `import { ${uniquePgImports.join(
19019
19031
  ", "
19020
19032
  )} } from "drizzle-orm/pg-core"
19033
+ import { sql } from "drizzle-orm"
19021
19034
 
19022
19035
  `;
19023
- result += `import { sql } from "drizzle-orm"
19024
- `;
19025
- result += enumStatements;
19026
- result += schemaStatements;
19027
- result += "\n";
19028
- result += tableStatements.join("\n\n");
19029
- return result;
19036
+ let decalrations = enumStatements;
19037
+ decalrations += schemaStatements;
19038
+ decalrations += "\n";
19039
+ decalrations += tableStatements.join("\n\n");
19040
+ const file = importsTs + decalrations;
19041
+ const schemaEntry = `
19042
+ {
19043
+ ${Object.values(schema4.tables).map((it) => withCasing(it.name, casing)).join(",\n")}
19044
+ }
19045
+ `;
19046
+ return { file, imports: importsTs, decalrations, schemaEntry };
19030
19047
  };
19031
19048
  isCyclic = (fk4) => {
19032
19049
  const key = `${fk4.tableFrom}-${fk4.tableTo}`;
@@ -19803,9 +19820,9 @@ var init_mjs = __esm({
19803
19820
  star = qmark + "*?";
19804
19821
  twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
19805
19822
  twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?";
19806
- charSet = (s) => s.split("").reduce((set, c) => {
19807
- set[c] = true;
19808
- return set;
19823
+ charSet = (s) => s.split("").reduce((set2, c) => {
19824
+ set2[c] = true;
19825
+ return set2;
19809
19826
  }, {});
19810
19827
  reSpecials = charSet("().*{}+?[]^$\\!");
19811
19828
  addPatternStartSet = charSet("[.(");
@@ -19947,7 +19964,7 @@ var init_mjs = __esm({
19947
19964
  const rawGlobParts = this.globSet.map((s) => this.slashSplit(s));
19948
19965
  this.globParts = this.preprocess(rawGlobParts);
19949
19966
  this.debug(this.pattern, this.globParts);
19950
- let set = this.globParts.map((s, _, __) => {
19967
+ let set2 = this.globParts.map((s, _, __) => {
19951
19968
  if (this.isWindows && this.windowsNoMagicRoot) {
19952
19969
  const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && !globMagic.test(s[3]);
19953
19970
  const isDrive = /^[a-z]:/i.test(s[0]);
@@ -19959,8 +19976,8 @@ var init_mjs = __esm({
19959
19976
  }
19960
19977
  return s.map((ss) => this.parse(ss));
19961
19978
  });
19962
- this.debug(this.pattern, set);
19963
- this.set = set.filter((s) => s.indexOf(false) === -1);
19979
+ this.debug(this.pattern, set2);
19980
+ this.set = set2.filter((s) => s.indexOf(false) === -1);
19964
19981
  if (this.isWindows) {
19965
19982
  for (let i = 0; i < this.set.length; i++) {
19966
19983
  const p = this.set[i];
@@ -20016,19 +20033,19 @@ var init_mjs = __esm({
20016
20033
  // get rid of adjascent ** and resolve .. portions
20017
20034
  levelOneOptimize(globParts) {
20018
20035
  return globParts.map((parts) => {
20019
- parts = parts.reduce((set, part) => {
20020
- const prev = set[set.length - 1];
20036
+ parts = parts.reduce((set2, part) => {
20037
+ const prev = set2[set2.length - 1];
20021
20038
  if (part === "**" && prev === "**") {
20022
- return set;
20039
+ return set2;
20023
20040
  }
20024
20041
  if (part === "..") {
20025
20042
  if (prev && prev !== ".." && prev !== "." && prev !== "**") {
20026
- set.pop();
20027
- return set;
20043
+ set2.pop();
20044
+ return set2;
20028
20045
  }
20029
20046
  }
20030
- set.push(part);
20031
- return set;
20047
+ set2.push(part);
20048
+ return set2;
20032
20049
  }, []);
20033
20050
  return parts.length === 0 ? [""] : parts;
20034
20051
  });
@@ -20546,15 +20563,15 @@ var init_mjs = __esm({
20546
20563
  makeRe() {
20547
20564
  if (this.regexp || this.regexp === false)
20548
20565
  return this.regexp;
20549
- const set = this.set;
20550
- if (!set.length) {
20566
+ const set2 = this.set;
20567
+ if (!set2.length) {
20551
20568
  this.regexp = false;
20552
20569
  return this.regexp;
20553
20570
  }
20554
20571
  const options = this.options;
20555
20572
  const twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot;
20556
20573
  const flags = options.nocase ? "i" : "";
20557
- let re = set.map((pattern) => {
20574
+ let re = set2.map((pattern) => {
20558
20575
  const pp = pattern.map((p) => typeof p === "string" ? regExpEscape(p) : p === GLOBSTAR ? GLOBSTAR : p._src);
20559
20576
  pp.forEach((p, i) => {
20560
20577
  const next = pp[i + 1];
@@ -20613,16 +20630,16 @@ var init_mjs = __esm({
20613
20630
  }
20614
20631
  const ff = this.slashSplit(f);
20615
20632
  this.debug(this.pattern, "split", ff);
20616
- const set = this.set;
20617
- this.debug(this.pattern, "set", set);
20633
+ const set2 = this.set;
20634
+ this.debug(this.pattern, "set", set2);
20618
20635
  let filename = ff[ff.length - 1];
20619
20636
  if (!filename) {
20620
20637
  for (let i = ff.length - 2; !filename && i >= 0; i--) {
20621
20638
  filename = ff[i];
20622
20639
  }
20623
20640
  }
20624
- for (let i = 0; i < set.length; i++) {
20625
- const pattern = set[i];
20641
+ for (let i = 0; i < set2.length; i++) {
20642
+ const pattern = set2[i];
20626
20643
  let file = ff;
20627
20644
  if (options.matchBase && pattern.length === 1) {
20628
20645
  file = [filename];
@@ -25382,7 +25399,7 @@ var init_pgIntrospect = __esm({
25382
25399
  import_hanji4 = __toESM(require_hanji());
25383
25400
  init_views();
25384
25401
  init_pgSerializer();
25385
- init_introspect();
25402
+ init_introspect_pg();
25386
25403
  init_global();
25387
25404
  init_mjs();
25388
25405
  pgSchemas = async (client) => {
@@ -25709,10 +25726,15 @@ var init_pgPushUtils = __esm({
25709
25726
  }
25710
25727
  });
25711
25728
 
25712
- // src/sqlite-introspect.ts
25729
+ // src/introspect-sqlite.ts
25730
+ var introspect_sqlite_exports = {};
25731
+ __export(introspect_sqlite_exports, {
25732
+ indexName: () => indexName3,
25733
+ schemaToTypeScript: () => schemaToTypeScript2
25734
+ });
25713
25735
  var sqliteImportsList, indexName3, objToStatement22, relations2, withCasing2, schemaToTypeScript2, isCyclic2, isSelf2, mapColumnDefault, column5, createTableColumns2, createTableIndexes2, createTableUniques2, createTablePKs2, createTableFKs2;
25714
- var init_sqlite_introspect = __esm({
25715
- "src/sqlite-introspect.ts"() {
25736
+ var init_introspect_sqlite = __esm({
25737
+ "src/introspect-sqlite.ts"() {
25716
25738
  init_utils2();
25717
25739
  sqliteImportsList = /* @__PURE__ */ new Set([
25718
25740
  "sqliteTable",
@@ -25829,15 +25851,20 @@ var init_sqlite_introspect = __esm({
25829
25851
  "AnySQLiteColumn",
25830
25852
  ...new Set(imports.sqlite)
25831
25853
  ];
25832
- let result = `import { ${uniqueSqliteImports.join(
25854
+ const importsTs = `import { ${uniqueSqliteImports.join(
25833
25855
  ", "
25834
- )} } from "drizzle-orm/sqlite-core"
25835
- import { sql } from "drizzle-orm"
25856
+ )} } from "drizzle-orm/pg-core"
25857
+ import { sql } from "drizzle-orm"
25836
25858
 
25837
25859
  `;
25838
- result += "\n";
25839
- result += tableStatements.join("\n\n");
25840
- return result;
25860
+ const decalrations = tableStatements.join("\n\n");
25861
+ const file = importsTs + decalrations;
25862
+ const schemaEntry = `
25863
+ {
25864
+ ${Object.values(schema4.tables).map((it) => withCasing2(it.name, casing)).join(",")}
25865
+ }
25866
+ `;
25867
+ return { file, imports: importsTs, decalrations, schemaEntry };
25841
25868
  };
25842
25869
  isCyclic2 = (fk4) => {
25843
25870
  const key = `${fk4.tableFrom}-${fk4.tableTo}`;
@@ -26011,7 +26038,7 @@ var init_sqliteIntrospect = __esm({
26011
26038
  init_views();
26012
26039
  init_global();
26013
26040
  init_sqliteSerializer();
26014
- init_sqlite_introspect();
26041
+ init_introspect_sqlite();
26015
26042
  init_mjs();
26016
26043
  import_hanji7 = __toESM(require_hanji());
26017
26044
  connectToSQLite = async (config) => {
@@ -53900,18 +53927,18 @@ var require_set = __commonJS({
53900
53927
  }
53901
53928
  static from(schema4, iterable, ctx) {
53902
53929
  const { replacer } = ctx;
53903
- const set2 = new this(schema4);
53930
+ const set3 = new this(schema4);
53904
53931
  if (iterable && Symbol.iterator in Object(iterable))
53905
53932
  for (let value of iterable) {
53906
53933
  if (typeof replacer === "function")
53907
53934
  value = replacer.call(iterable, value, value);
53908
- set2.items.push(Pair.createPair(value, null, ctx));
53935
+ set3.items.push(Pair.createPair(value, null, ctx));
53909
53936
  }
53910
- return set2;
53937
+ return set3;
53911
53938
  }
53912
53939
  };
53913
53940
  YAMLSet.tag = "tag:yaml.org,2002:set";
53914
- var set = {
53941
+ var set2 = {
53915
53942
  collection: "map",
53916
53943
  identify: (value) => value instanceof Set,
53917
53944
  nodeClass: YAMLSet,
@@ -53930,7 +53957,7 @@ var require_set = __commonJS({
53930
53957
  }
53931
53958
  };
53932
53959
  exports.YAMLSet = YAMLSet;
53933
- exports.set = set;
53960
+ exports.set = set2;
53934
53961
  }
53935
53962
  });
53936
53963
 
@@ -54036,7 +54063,7 @@ var require_schema3 = __commonJS({
54036
54063
  var int = require_int2();
54037
54064
  var omap = require_omap();
54038
54065
  var pairs = require_pairs();
54039
- var set = require_set();
54066
+ var set2 = require_set();
54040
54067
  var timestamp = require_timestamp();
54041
54068
  var schema4 = [
54042
54069
  map.map,
@@ -54055,7 +54082,7 @@ var require_schema3 = __commonJS({
54055
54082
  binary.binary,
54056
54083
  omap.omap,
54057
54084
  pairs.pairs,
54058
- set.set,
54085
+ set2.set,
54059
54086
  timestamp.intTime,
54060
54087
  timestamp.floatTime,
54061
54088
  timestamp.timestamp
@@ -54081,7 +54108,7 @@ var require_tags = __commonJS({
54081
54108
  var omap = require_omap();
54082
54109
  var pairs = require_pairs();
54083
54110
  var schema$2 = require_schema3();
54084
- var set = require_set();
54111
+ var set2 = require_set();
54085
54112
  var timestamp = require_timestamp();
54086
54113
  var schemas = /* @__PURE__ */ new Map([
54087
54114
  ["core", schema4.schema],
@@ -54106,14 +54133,14 @@ var require_tags = __commonJS({
54106
54133
  omap: omap.omap,
54107
54134
  pairs: pairs.pairs,
54108
54135
  seq: seq.seq,
54109
- set: set.set,
54136
+ set: set2.set,
54110
54137
  timestamp: timestamp.timestamp
54111
54138
  };
54112
54139
  var coreKnownTags = {
54113
54140
  "tag:yaml.org,2002:binary": binary.binary,
54114
54141
  "tag:yaml.org,2002:omap": omap.omap,
54115
54142
  "tag:yaml.org,2002:pairs": pairs.pairs,
54116
- "tag:yaml.org,2002:set": set.set,
54143
+ "tag:yaml.org,2002:set": set2.set,
54117
54144
  "tag:yaml.org,2002:timestamp": timestamp.timestamp
54118
54145
  };
54119
54146
  function getTags(customTags, schemaName) {
@@ -58233,7 +58260,9 @@ var init_studioUtils = __esm({
58233
58260
  };
58234
58261
  prepareMySqlSchema = async (path4) => {
58235
58262
  const imports = prepareFilenames(path4);
58236
- const mysqlSchema4 = { public: {} };
58263
+ const mysqlSchema4 = {
58264
+ public: {}
58265
+ };
58237
58266
  const relations4 = {};
58238
58267
  const { unregister } = await safeRegister();
58239
58268
  for (let i = 0; i < imports.length; i++) {
@@ -58255,7 +58284,9 @@ var init_studioUtils = __esm({
58255
58284
  };
58256
58285
  prepareSQLiteSchema = async (path4) => {
58257
58286
  const imports = prepareFilenames(path4);
58258
- const sqliteSchema2 = { public: {} };
58287
+ const sqliteSchema2 = {
58288
+ public: {}
58289
+ };
58259
58290
  const relations4 = {};
58260
58291
  const { unregister } = await safeRegister();
58261
58292
  for (let i = 0; i < imports.length; i++) {
@@ -58305,34 +58336,53 @@ var init_studioUtils = __esm({
58305
58336
  unregister();
58306
58337
  return { pgSchema: pgSchema4, mysqlSchema: mysqlSchema4, sqliteSchema: sqliteSchema2 };
58307
58338
  };
58308
- drizzleForPostgres = async (connectionConfig, pgSchema4, relations4, verbose) => {
58339
+ drizzleForPostgres = async (connectionConfig, pgSchema4, relations4, ts, verbose) => {
58309
58340
  assertPackages("pg");
58310
58341
  const { drizzle: drizzle2 } = await import("drizzle-orm/node-postgres");
58311
58342
  const pg = await Promise.resolve().then(() => __toESM(require_lib2()));
58312
- const db = drizzle2(new pg.default.Pool(connectionConfig.dbCredentials), {
58343
+ const client = new pg.default.Pool(connectionConfig.dbCredentials);
58344
+ const db = drizzle2(client, {
58313
58345
  logger: verbose
58314
58346
  });
58347
+ const proxy = async (params) => {
58348
+ return client.query({
58349
+ text: params.sql,
58350
+ values: params.params,
58351
+ rowMode: "array"
58352
+ });
58353
+ };
58315
58354
  return {
58316
- type: "pg",
58355
+ dialect: "pg",
58317
58356
  db,
58357
+ proxy,
58318
58358
  schema: pgSchema4,
58319
- relations: relations4
58359
+ relations: relations4,
58360
+ ts
58320
58361
  };
58321
58362
  };
58322
- drizzleForMySQL = async (config, mysqlSchema4, relations4, verbose) => {
58363
+ drizzleForMySQL = async (config, mysqlSchema4, relations4, ts, verbose) => {
58323
58364
  assertPackages("mysql2");
58324
58365
  const { drizzle: drizzle2 } = await import("drizzle-orm/mysql2");
58325
58366
  const { createPool } = await Promise.resolve().then(() => __toESM(require_promise()));
58326
58367
  const client = createPool({ ...config.dbCredentials, connectionLimit: 1 });
58327
58368
  const db = drizzle2(client, { logger: verbose });
58369
+ const proxy = async (params) => {
58370
+ return client.query({
58371
+ sql: params.sql,
58372
+ values: params.params,
58373
+ rowsAsArray: true
58374
+ });
58375
+ };
58328
58376
  return {
58329
- type: "mysql",
58377
+ dialect: "mysql",
58330
58378
  db,
58379
+ proxy,
58331
58380
  schema: mysqlSchema4,
58332
- relations: relations4
58381
+ relations: relations4,
58382
+ ts
58333
58383
  };
58334
58384
  };
58335
- drizzleForSQLite = async (config, sqliteSchema2, relations4, verbose) => {
58385
+ drizzleForSQLite = async (config, sqliteSchema2, relations4, ts, verbose) => {
58336
58386
  const { driver, dbCredentials: creds } = config;
58337
58387
  if (driver === "d1") {
58338
58388
  const { drizzle: drizzle2 } = await Promise.resolve().then(() => (init_driver(), driver_exports));
@@ -58340,11 +58390,16 @@ var init_studioUtils = __esm({
58340
58390
  const db = drizzle2(execute2, creds.wranglerConfigPath, creds.dbName, {
58341
58391
  logger: verbose
58342
58392
  });
58393
+ const proxy = async (params) => {
58394
+ throw new Error("Proxy is not implemented for D1");
58395
+ };
58343
58396
  return {
58344
- type: "sqlite",
58397
+ dialect: "sqlite",
58345
58398
  db,
58399
+ proxy,
58346
58400
  schema: sqliteSchema2,
58347
- relations: relations4
58401
+ relations: relations4,
58402
+ ts
58348
58403
  };
58349
58404
  }
58350
58405
  if (driver === "better-sqlite") {
@@ -58353,11 +58408,17 @@ var init_studioUtils = __esm({
58353
58408
  const Database = await import("better-sqlite3");
58354
58409
  const client = new Database.default(creds.url);
58355
58410
  const db = drizzle2(client, { logger: verbose });
58411
+ const proxy = async (params) => {
58412
+ const sql2 = params.sql;
58413
+ return client.prepare(sql2).all(params.params);
58414
+ };
58356
58415
  return {
58357
- type: "sqlite",
58416
+ dialect: "sqlite",
58358
58417
  db,
58418
+ proxy,
58359
58419
  schema: sqliteSchema2,
58360
- relations: relations4
58420
+ relations: relations4,
58421
+ ts
58361
58422
  };
58362
58423
  }
58363
58424
  if (driver === "libsql" || driver === "turso") {
@@ -58369,11 +58430,19 @@ var init_studioUtils = __esm({
58369
58430
  client,
58370
58431
  { logger: verbose }
58371
58432
  );
58433
+ const proxy = async (params) => {
58434
+ return client.execute({
58435
+ sql: params.sql,
58436
+ args: params.params
58437
+ });
58438
+ };
58372
58439
  return {
58373
- type: "sqlite",
58440
+ dialect: "sqlite",
58374
58441
  db,
58442
+ proxy,
58375
58443
  schema: sqliteSchema2,
58376
- relations: relations4
58444
+ relations: relations4,
58445
+ ts
58377
58446
  };
58378
58447
  }
58379
58448
  assertUnreachable(driver);
@@ -59379,10 +59448,14 @@ var require_cli_options = __commonJS({
59379
59448
  }
59380
59449
  });
59381
59450
 
59382
- // src/mysql-introspect.ts
59383
- var mysqlImportsList, objToStatement23, timeConfig2, binaryConfig, importsPatch2, relations3, withCasing3, schemaToTypeScript3, isCyclic3, isSelf3, mapColumnDefault2, mapColumnDefaultForJson, column6, createTableColumns3, createTableIndexes3, createTableUniques3, createTablePKs3, createTableFKs3;
59384
- var init_mysql_introspect = __esm({
59385
- "src/mysql-introspect.ts"() {
59451
+ // src/introspect-mysql.ts
59452
+ var introspect_mysql_exports = {};
59453
+ __export(introspect_mysql_exports, {
59454
+ schemaToTypeScript: () => schemaToTypeScript3
59455
+ });
59456
+ var mysqlImportsList, objToStatement23, timeConfig2, binaryConfig, importsPatch2, relations3, prepareCasing, schemaToTypeScript3, isCyclic3, isSelf3, mapColumnDefault2, mapColumnDefaultForJson, column6, createTableColumns3, createTableIndexes3, createTableUniques3, createTablePKs3, createTableFKs3;
59457
+ var init_introspect_mysql = __esm({
59458
+ "src/introspect-mysql.ts"() {
59386
59459
  init_utils2();
59387
59460
  init_mysqlSerializer();
59388
59461
  mysqlImportsList = /* @__PURE__ */ new Set([
@@ -59450,7 +59523,7 @@ var init_mysql_introspect = __esm({
59450
59523
  "timestamp without time zone": "timestamp"
59451
59524
  };
59452
59525
  relations3 = /* @__PURE__ */ new Set();
59453
- withCasing3 = (value, casing) => {
59526
+ prepareCasing = (casing) => (value) => {
59454
59527
  if (typeof casing === "undefined") {
59455
59528
  return value;
59456
59529
  }
@@ -59460,6 +59533,7 @@ var init_mysql_introspect = __esm({
59460
59533
  return value;
59461
59534
  };
59462
59535
  schemaToTypeScript3 = (schema4, casing) => {
59536
+ const withCasing3 = prepareCasing(casing);
59463
59537
  Object.values(schema4.tables).forEach((table4) => {
59464
59538
  Object.values(table4.foreignKeys).forEach((fk4) => {
59465
59539
  const relation = `${fk4.tableFrom}-${fk4.tableTo}`;
@@ -59468,7 +59542,7 @@ var init_mysql_introspect = __esm({
59468
59542
  });
59469
59543
  const schemas = Object.fromEntries(
59470
59544
  Object.entries(schema4.schemas).map((it) => {
59471
- return [it[0], withCasing3(it[1], casing)];
59545
+ return [it[0], withCasing3(it[1])];
59472
59546
  })
59473
59547
  );
59474
59548
  const imports = Object.values(schema4.tables).reduce(
@@ -59515,20 +59589,19 @@ var init_mysql_introspect = __esm({
59515
59589
  const tableSchema = schemas[table4.schema];
59516
59590
  const func = tableSchema ? tableSchema : "mysqlTable";
59517
59591
  let statement = "";
59518
- if (imports.mysql.includes(withCasing3(table4.name, casing))) {
59592
+ if (imports.mysql.includes(withCasing3(table4.name))) {
59519
59593
  statement = `// Table name is in conflict with ${withCasing3(
59520
- table4.name,
59521
- casing
59594
+ table4.name
59522
59595
  )} import.
59523
59596
  // Please change to any other name, that is not in imports list
59524
59597
  `;
59525
59598
  }
59526
- statement += `export const ${withCasing3(table4.name, casing)} = ${func}("${table4.name}", {
59599
+ statement += `export const ${withCasing3(table4.name)} = ${func}("${table4.name}", {
59527
59600
  `;
59528
59601
  statement += createTableColumns3(
59529
59602
  Object.values(table4.columns),
59530
59603
  Object.values(table4.foreignKeys),
59531
- casing,
59604
+ withCasing3,
59532
59605
  table4.name,
59533
59606
  schema4
59534
59607
  );
@@ -59543,16 +59616,16 @@ var init_mysql_introspect = __esm({
59543
59616
  statement += createTableIndexes3(
59544
59617
  table4.name,
59545
59618
  Object.values(table4.indexes),
59546
- casing
59619
+ withCasing3
59547
59620
  );
59548
- statement += createTableFKs3(Object.values(filteredFKs), casing);
59621
+ statement += createTableFKs3(Object.values(filteredFKs), withCasing3);
59549
59622
  statement += createTablePKs3(
59550
59623
  Object.values(table4.compositePrimaryKeys),
59551
- casing
59624
+ withCasing3
59552
59625
  );
59553
59626
  statement += createTableUniques3(
59554
59627
  Object.values(table4.uniqueConstraints),
59555
- casing
59628
+ withCasing3
59556
59629
  );
59557
59630
  statement += " }\n";
59558
59631
  statement += "}";
@@ -59572,10 +59645,22 @@ var init_mysql_introspect = __esm({
59572
59645
  import { sql } from "drizzle-orm"
59573
59646
 
59574
59647
  `;
59575
- const bodyTs = schemaStatements + "\n" + tableStatements.join("\n\n");
59576
- let result = importsTs;
59577
- result += bodyTs;
59578
- return result;
59648
+ let decalrations = schemaStatements;
59649
+ decalrations += "\n";
59650
+ decalrations += tableStatements.join("\n\n");
59651
+ const file = importsTs + decalrations;
59652
+ const schemaEntry = `
59653
+ {
59654
+ ${Object.values(schema4.tables).map((it) => withCasing3(it.name)).join(",")}
59655
+ }
59656
+ `;
59657
+ return {
59658
+ file,
59659
+ // backward compatible, print to file
59660
+ imports: importsTs,
59661
+ decalrations,
59662
+ schemaEntry
59663
+ };
59579
59664
  };
59580
59665
  isCyclic3 = (fk4) => {
59581
59666
  const key = `${fk4.tableFrom}-${fk4.tableTo}`;
@@ -59597,51 +59682,51 @@ import { sql } from "drizzle-orm"
59597
59682
  }
59598
59683
  return defaultValue;
59599
59684
  };
59600
- column6 = (type, name, defaultValue, autoincrement, onUpdate, casing, isExpression) => {
59685
+ column6 = (type, name, casing, defaultValue, autoincrement, onUpdate, isExpression) => {
59601
59686
  let lowered = type;
59602
59687
  if (!type.startsWith("enum(")) {
59603
59688
  lowered = type.toLowerCase();
59604
59689
  }
59605
59690
  if (lowered === "serial") {
59606
- return `${withCasing3(name, casing)}: serial("${name}")`;
59691
+ return `${casing(name)}: serial("${name}")`;
59607
59692
  }
59608
59693
  if (lowered.startsWith("int")) {
59609
59694
  const isUnsigned = lowered.startsWith("int unsigned");
59610
- let out = `${withCasing3(name, casing)}: int("${name}"${isUnsigned ? ", { unsigned: true }" : ""})`;
59695
+ let out = `${casing(name)}: int("${name}"${isUnsigned ? ", { unsigned: true }" : ""})`;
59611
59696
  out += autoincrement ? `.autoincrement()` : "";
59612
59697
  out += typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
59613
59698
  return out;
59614
59699
  }
59615
59700
  if (lowered.startsWith("tinyint")) {
59616
59701
  const isUnsigned = lowered.startsWith("tinyint unsigned");
59617
- let out = `${withCasing3(name, casing)}: tinyint("${name}"${isUnsigned ? ", { unsigned: true }" : ""})`;
59702
+ let out = `${casing(name)}: tinyint("${name}"${isUnsigned ? ", { unsigned: true }" : ""})`;
59618
59703
  out += autoincrement ? `.autoincrement()` : "";
59619
59704
  out += typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
59620
59705
  return out;
59621
59706
  }
59622
59707
  if (lowered.startsWith("smallint")) {
59623
59708
  const isUnsigned = lowered.startsWith("smallint unsigned");
59624
- let out = `${withCasing3(name, casing)}: smallint("${name}"${isUnsigned ? ", { unsigned: true }" : ""})`;
59709
+ let out = `${casing(name)}: smallint("${name}"${isUnsigned ? ", { unsigned: true }" : ""})`;
59625
59710
  out += autoincrement ? `.autoincrement()` : "";
59626
59711
  out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
59627
59712
  return out;
59628
59713
  }
59629
59714
  if (lowered.startsWith("mediumint")) {
59630
59715
  const isUnsigned = lowered.startsWith("mediumint unsigned");
59631
- let out = `${withCasing3(name, casing)}: mediumint("${name}"${isUnsigned ? ", { unsigned: true }" : ""})`;
59716
+ let out = `${casing(name)}: mediumint("${name}"${isUnsigned ? ", { unsigned: true }" : ""})`;
59632
59717
  out += autoincrement ? `.autoincrement()` : "";
59633
59718
  out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
59634
59719
  return out;
59635
59720
  }
59636
59721
  if (lowered.startsWith("bigint")) {
59637
59722
  const isUnsigned = lowered.startsWith("bigint unsigned");
59638
- let out = `${withCasing3(name, casing)}: bigint("${name}", { mode: "number"${isUnsigned ? ", unsigned: true" : ""} })`;
59723
+ let out = `${casing(name)}: bigint("${name}", { mode: "number"${isUnsigned ? ", unsigned: true" : ""} })`;
59639
59724
  out += autoincrement ? `.autoincrement()` : "";
59640
59725
  out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
59641
59726
  return out;
59642
59727
  }
59643
59728
  if (lowered === "boolean") {
59644
- let out = `${withCasing3(name, casing)}: boolean("${name}")`;
59729
+ let out = `${casing(name)}: boolean("${name}")`;
59645
59730
  out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
59646
59731
  return out;
59647
59732
  }
@@ -59651,17 +59736,17 @@ import { sql } from "drizzle-orm"
59651
59736
  const [precision, scale] = lowered.slice(7, lowered.length - 1).split(",");
59652
59737
  params = { precision, scale };
59653
59738
  }
59654
- let out = params ? `${withCasing3(name, casing)}: double("${name}", ${timeConfig2(params)})` : `${withCasing3(name, casing)}: double("${name}")`;
59739
+ let out = params ? `${casing(name)}: double("${name}", ${timeConfig2(params)})` : `${casing(name)}: double("${name}")`;
59655
59740
  out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
59656
59741
  return out;
59657
59742
  }
59658
59743
  if (lowered === "float") {
59659
- let out = `${withCasing3(name, casing)}: float("${name}")`;
59744
+ let out = `${casing(name)}: float("${name}")`;
59660
59745
  out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
59661
59746
  return out;
59662
59747
  }
59663
59748
  if (lowered === "real") {
59664
- let out = `${withCasing3(name, casing)}: real("${name}")`;
59749
+ let out = `${casing(name)}: real("${name}")`;
59665
59750
  out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
59666
59751
  return out;
59667
59752
  }
@@ -59670,7 +59755,7 @@ import { sql } from "drizzle-orm"
59670
59755
  let fsp = lowered.length > keyLength ? Number(lowered.substring(keyLength, lowered.length - 1)) : null;
59671
59756
  fsp = fsp ? fsp : null;
59672
59757
  const params = timeConfig2({ fsp, mode: "'string'" });
59673
- let out = params ? `${withCasing3(name, casing)}: timestamp("${name}", ${params})` : `${withCasing3(name, casing)}: timestamp("${name}")`;
59758
+ let out = params ? `${casing(name)}: timestamp("${name}", ${params})` : `${casing(name)}: timestamp("${name}")`;
59674
59759
  defaultValue = defaultValue === "now()" || defaultValue === "(CURRENT_TIMESTAMP)" ? ".defaultNow()" : defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
59675
59760
  out += defaultValue;
59676
59761
  let onUpdateNow = onUpdate ? ".onUpdateNow()" : "";
@@ -59682,55 +59767,53 @@ import { sql } from "drizzle-orm"
59682
59767
  let fsp = lowered.length > keyLength ? Number(lowered.substring(keyLength, lowered.length - 1)) : null;
59683
59768
  fsp = fsp ? fsp : null;
59684
59769
  const params = timeConfig2({ fsp });
59685
- let out = params ? `${withCasing3(name, casing)}: time("${name}", ${params})` : `${withCasing3(name, casing)}: time("${name}")`;
59770
+ let out = params ? `${casing(name)}: time("${name}", ${params})` : `${casing(name)}: time("${name}")`;
59686
59771
  defaultValue = defaultValue === "now()" ? ".defaultNow()" : defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
59687
59772
  out += defaultValue;
59688
59773
  return out;
59689
59774
  }
59690
59775
  if (lowered === "date") {
59691
59776
  let out = `// you can use { mode: 'date' }, if you want to have Date as type for this column
59692
- ${withCasing3(
59693
- name,
59694
- casing
59777
+ ${casing(
59778
+ name
59695
59779
  )}: date("${name}", { mode: 'string' })`;
59696
59780
  defaultValue = defaultValue === "now()" ? ".defaultNow()" : defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
59697
59781
  out += defaultValue;
59698
59782
  return out;
59699
59783
  }
59700
59784
  if (lowered === "text") {
59701
- let out = `${withCasing3(name, casing)}: text("${name}")`;
59785
+ let out = `${casing(name)}: text("${name}")`;
59702
59786
  out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
59703
59787
  return out;
59704
59788
  }
59705
59789
  if (lowered === "tinytext") {
59706
- let out = `${withCasing3(name, casing)}: tinytext("${name}")`;
59790
+ let out = `${casing(name)}: tinytext("${name}")`;
59707
59791
  out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
59708
59792
  return out;
59709
59793
  }
59710
59794
  if (lowered === "mediumtext") {
59711
- let out = `${withCasing3(name, casing)}: mediumtext("${name}")`;
59795
+ let out = `${casing(name)}: mediumtext("${name}")`;
59712
59796
  out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
59713
59797
  return out;
59714
59798
  }
59715
59799
  if (lowered === "longtext") {
59716
- let out = `${withCasing3(name, casing)}: longtext("${name}")`;
59800
+ let out = `${casing(name)}: longtext("${name}")`;
59717
59801
  out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
59718
59802
  return out;
59719
59803
  }
59720
59804
  if (lowered === "year") {
59721
- let out = `${withCasing3(name, casing)}: year("${name}")`;
59805
+ let out = `${casing(name)}: year("${name}")`;
59722
59806
  out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
59723
59807
  return out;
59724
59808
  }
59725
59809
  if (lowered === "json") {
59726
- let out = `${withCasing3(name, casing)}: json("${name}")`;
59810
+ let out = `${casing(name)}: json("${name}")`;
59727
59811
  out += defaultValue ? `.default(${mapColumnDefaultForJson(defaultValue)})` : "";
59728
59812
  return out;
59729
59813
  }
59730
59814
  if (lowered.startsWith("varchar")) {
59731
- let out = `${withCasing3(
59732
- name,
59733
- casing
59815
+ let out = `${casing(
59816
+ name
59734
59817
  )}: varchar("${name}", { length: ${lowered.substring(
59735
59818
  "varchar".length + 1,
59736
59819
  lowered.length - 1
@@ -59739,9 +59822,8 @@ import { sql } from "drizzle-orm"
59739
59822
  return out;
59740
59823
  }
59741
59824
  if (lowered.startsWith("char")) {
59742
- let out = `${withCasing3(
59743
- name,
59744
- casing
59825
+ let out = `${casing(
59826
+ name
59745
59827
  )}: char("${name}", { length: ${lowered.substring(
59746
59828
  "char".length + 1,
59747
59829
  lowered.length - 1
@@ -59753,13 +59835,12 @@ import { sql } from "drizzle-orm"
59753
59835
  let out = `// you can use { mode: 'date' }, if you want to have Date as type for this column
59754
59836
  `;
59755
59837
  const fsp = lowered.startsWith("datetime(") ? lowered.substring("datetime".length + 1, lowered.length - 1) : void 0;
59756
- out = fsp ? `${withCasing3(
59757
- name,
59758
- casing
59838
+ out = fsp ? `${casing(
59839
+ name
59759
59840
  )}: datetime("${name}", { mode: 'string', fsp: ${lowered.substring(
59760
59841
  "datetime".length + 1,
59761
59842
  lowered.length - 1
59762
- )} })` : `${withCasing3(name, casing)}: datetime("${name}", { mode: 'string'})`;
59843
+ )} })` : `${casing(name)}: datetime("${name}", { mode: 'string'})`;
59763
59844
  defaultValue = defaultValue === "now()" ? ".defaultNow()" : defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
59764
59845
  out += defaultValue;
59765
59846
  return out;
@@ -59770,7 +59851,7 @@ import { sql } from "drizzle-orm"
59770
59851
  const [precision, scale] = lowered.slice(8, lowered.length - 1).split(",");
59771
59852
  params = { precision, scale };
59772
59853
  }
59773
- let out = params ? `${withCasing3(name, casing)}: decimal("${name}", ${timeConfig2(params)})` : `${withCasing3(name, casing)}: decimal("${name}")`;
59854
+ let out = params ? `${casing(name)}: decimal("${name}", ${timeConfig2(params)})` : `${casing(name)}: decimal("${name}")`;
59774
59855
  defaultValue = typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
59775
59856
  out += defaultValue;
59776
59857
  return out;
@@ -59780,14 +59861,14 @@ import { sql } from "drizzle-orm"
59780
59861
  let length = lowered.length > keyLength ? Number(lowered.substring(keyLength, lowered.length - 1)) : null;
59781
59862
  length = length ? length : null;
59782
59863
  const params = binaryConfig({ length });
59783
- let out = params ? `${withCasing3(name, casing)}: binary("${name}", ${params})` : `${withCasing3(name, casing)}: binary("${name}")`;
59864
+ let out = params ? `${casing(name)}: binary("${name}", ${params})` : `${casing(name)}: binary("${name}")`;
59784
59865
  defaultValue = defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
59785
59866
  out += defaultValue;
59786
59867
  return out;
59787
59868
  }
59788
59869
  if (lowered.startsWith("enum")) {
59789
59870
  const values = lowered.substring("enum".length + 1, lowered.length - 1);
59790
- let out = `${withCasing3(name, casing)}: mysqlEnum("${name}", [${values}])`;
59871
+ let out = `${casing(name)}: mysqlEnum("${name}", [${values}])`;
59791
59872
  out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
59792
59873
  return out;
59793
59874
  }
@@ -59796,7 +59877,7 @@ import { sql } from "drizzle-orm"
59796
59877
  let length = lowered.length > keyLength ? Number(lowered.substring(keyLength, lowered.length - 1)) : null;
59797
59878
  length = length ? length : null;
59798
59879
  const params = binaryConfig({ length });
59799
- let out = params ? `${withCasing3(name, casing)}: varbinary("${name}", ${params})` : `${withCasing3(name, casing)}: varbinary("${name}")`;
59880
+ let out = params ? `${casing(name)}: varbinary("${name}", ${params})` : `${casing(name)}: varbinary("${name}")`;
59800
59881
  defaultValue = defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
59801
59882
  out += defaultValue;
59802
59883
  return out;
@@ -59822,10 +59903,10 @@ import { sql } from "drizzle-orm"
59822
59903
  statement += column6(
59823
59904
  it.type,
59824
59905
  it.name,
59906
+ casing,
59825
59907
  it.default,
59826
59908
  it.autoincrement,
59827
59909
  it.onUpdate,
59828
- casing,
59829
59910
  ((_c = (_b = (_a3 = schema4.internal) == null ? void 0 : _a3.tables[tableName]) == null ? void 0 : _b.columns[it.name]) == null ? void 0 : _c.isDefaultAnExpression) ?? false
59830
59911
  );
59831
59912
  statement += it.primaryKey ? ".primaryKey()" : "";
@@ -59839,15 +59920,13 @@ import { sql } from "drizzle-orm"
59839
59920
  const typeSuffix = isCyclic3(it2) ? ": AnyMySqlColumn" : "";
59840
59921
  const paramsStr = objToStatement23(params);
59841
59922
  if (paramsStr) {
59842
- return `.references(()${typeSuffix} => ${withCasing3(
59843
- it2.tableTo,
59844
- casing
59845
- )}.${withCasing3(it2.columnsTo[0], casing)}, ${paramsStr} )`;
59923
+ return `.references(()${typeSuffix} => ${casing(
59924
+ it2.tableTo
59925
+ )}.${casing(it2.columnsTo[0])}, ${paramsStr} )`;
59846
59926
  }
59847
- return `.references(()${typeSuffix} => ${withCasing3(
59848
- it2.tableTo,
59849
- casing
59850
- )}.${withCasing3(it2.columnsTo[0], casing)})`;
59927
+ return `.references(()${typeSuffix} => ${casing(it2.tableTo)}.${casing(
59928
+ it2.columnsTo[0]
59929
+ )})`;
59851
59930
  }).join("");
59852
59931
  statement += fksStatement;
59853
59932
  }
@@ -59860,13 +59939,13 @@ import { sql } from "drizzle-orm"
59860
59939
  idxs.forEach((it) => {
59861
59940
  let idxKey = it.name.startsWith(tableName) && it.name !== tableName ? it.name.slice(tableName.length + 1) : it.name;
59862
59941
  idxKey = idxKey.endsWith("_index") ? idxKey.slice(0, -"_index".length) + "_idx" : idxKey;
59863
- idxKey = withCasing3(idxKey, casing);
59942
+ idxKey = casing(idxKey);
59864
59943
  const indexGeneratedName = indexName(tableName, it.columns);
59865
59944
  const escapedIndexName = indexGeneratedName === it.name ? "" : `"${it.name}"`;
59866
59945
  statement += ` ${idxKey}: `;
59867
59946
  statement += it.isUnique ? "uniqueIndex(" : "index(";
59868
59947
  statement += `${escapedIndexName})`;
59869
- statement += `.on(${it.columns.map((it2) => `table.${withCasing3(it2, casing)}`).join(", ")}),`;
59948
+ statement += `.on(${it.columns.map((it2) => `table.${casing(it2)}`).join(", ")}),`;
59870
59949
  statement += `
59871
59950
  `;
59872
59951
  });
@@ -59875,11 +59954,11 @@ import { sql } from "drizzle-orm"
59875
59954
  createTableUniques3 = (unqs, casing) => {
59876
59955
  let statement = "";
59877
59956
  unqs.forEach((it) => {
59878
- const idxKey = withCasing3(it.name, casing);
59957
+ const idxKey = casing(it.name);
59879
59958
  statement += ` ${idxKey}: `;
59880
59959
  statement += "unique(";
59881
59960
  statement += `"${it.name}")`;
59882
- statement += `.on(${it.columns.map((it2) => `table.${withCasing3(it2, casing)}`).join(", ")}),`;
59961
+ statement += `.on(${it.columns.map((it2) => `table.${casing(it2)}`).join(", ")}),`;
59883
59962
  statement += `
59884
59963
  `;
59885
59964
  });
@@ -59888,11 +59967,11 @@ import { sql } from "drizzle-orm"
59888
59967
  createTablePKs3 = (pks, casing) => {
59889
59968
  let statement = "";
59890
59969
  pks.forEach((it) => {
59891
- let idxKey = withCasing3(it.name, casing);
59970
+ let idxKey = casing(it.name);
59892
59971
  statement += ` ${idxKey}: `;
59893
59972
  statement += "primaryKey({ columns: [";
59894
59973
  statement += `${it.columns.map((c) => {
59895
- return `table.${withCasing3(c, casing)}`;
59974
+ return `table.${casing(c)}`;
59896
59975
  }).join(", ")}]${it.name ? `, name: "${it.name}"` : ""}}`;
59897
59976
  statement += "),";
59898
59977
  statement += `
@@ -59904,12 +59983,12 @@ import { sql } from "drizzle-orm"
59904
59983
  let statement = "";
59905
59984
  fks.forEach((it) => {
59906
59985
  const isSelf4 = it.tableTo === it.tableFrom;
59907
- const tableTo = isSelf4 ? "table" : `${withCasing3(it.tableTo, casing)}`;
59908
- statement += ` ${withCasing3(it.name, casing)}: foreignKey({
59986
+ const tableTo = isSelf4 ? "table" : `${casing(it.tableTo)}`;
59987
+ statement += ` ${casing(it.name)}: foreignKey({
59909
59988
  `;
59910
- statement += ` columns: [${it.columnsFrom.map((i) => `table.${withCasing3(i, casing)}`).join(", ")}],
59989
+ statement += ` columns: [${it.columnsFrom.map((i) => `table.${casing(i)}`).join(", ")}],
59911
59990
  `;
59912
- statement += ` foreignColumns: [${it.columnsTo.map((i) => `${tableTo}.${withCasing3(i, casing)}`).join(", ")}],
59991
+ statement += ` foreignColumns: [${it.columnsTo.map((i) => `${tableTo}.${casing(i)}`).join(", ")}],
59913
59992
  `;
59914
59993
  statement += ` name: "${it.name}"
59915
59994
  `;
@@ -59938,7 +60017,7 @@ var init_mysqlIntrospect = __esm({
59938
60017
  init_views();
59939
60018
  import_promise = __toESM(require_promise());
59940
60019
  init_mysqlSerializer();
59941
- init_mysql_introspect();
60020
+ init_introspect_mysql();
59942
60021
  init_global();
59943
60022
  init_mjs();
59944
60023
  connectToMySQL = async (config) => {
@@ -60141,7 +60220,7 @@ init_source();
60141
60220
  // package.json
60142
60221
  var package_default = {
60143
60222
  name: "drizzle-kit",
60144
- version: "0.20.3",
60223
+ version: "0.20.4",
60145
60224
  repository: "https://github.com/drizzle-team/drizzle-kit-mirror",
60146
60225
  author: "Drizzle Team",
60147
60226
  license: "MIT",
@@ -60182,7 +60261,7 @@ var package_default = {
60182
60261
  packit: "pnpm build && cp package.json dist/ && cd dist && pnpm pack",
60183
60262
  tsc: "tsc -p tsconfig.build.json",
60184
60263
  pub: "cp package.json readme.md dist/ && cd dist && npm publish",
60185
- studio: "./dist/index.cjs studio --verbose",
60264
+ studio: "tsx ./src/cli/index.ts studio --verbose --port=3000",
60186
60265
  "studio:dev": "tsx ./src/cli/index.ts studio --verbose"
60187
60266
  },
60188
60267
  ava: {
@@ -60197,7 +60276,7 @@ var package_default = {
60197
60276
  ]
60198
60277
  },
60199
60278
  dependencies: {
60200
- "@drizzle-team/studio": "^0.0.27",
60279
+ "@drizzle-team/studio": "^0.0.32",
60201
60280
  "@esbuild-kit/esm-loader": "^2.5.5",
60202
60281
  camelcase: "^7.0.1",
60203
60282
  chalk: "^5.2.0",
@@ -60887,6 +60966,7 @@ init_sqlgenerator();
60887
60966
 
60888
60967
  // src/cli/index.ts
60889
60968
  init_selector_ui();
60969
+ var import_studio = require("@drizzle-team/studio");
60890
60970
  init_global();
60891
60971
  var printVersions = async () => {
60892
60972
  const v = await versions();
@@ -61418,7 +61498,7 @@ var introspectPgCommand = new import_commander.Command("introspect:pg").option("
61418
61498
  schemasFilter
61419
61499
  );
61420
61500
  const schemaFile = import_path7.default.join(validatedConfig.out, "schema.ts");
61421
- (0, import_fs11.writeFileSync)(schemaFile, ts);
61501
+ (0, import_fs11.writeFileSync)(schemaFile, ts.file);
61422
61502
  console.log();
61423
61503
  if (snapshots.length === 0) {
61424
61504
  const { sqlStatements, _meta } = await prepareSQL(
@@ -61471,7 +61551,7 @@ var introspectMySqlCommand = new import_commander.Command("introspect:mysql").op
61471
61551
  const tablesFilter = filterConfig ? typeof filterConfig === "string" ? [filterConfig] : filterConfig : [];
61472
61552
  const { schema: schema4, ts } = await mysqlIntrospect2(res, tablesFilter);
61473
61553
  const schemaFile = import_path7.default.join(out, "schema.ts");
61474
- (0, import_fs11.writeFileSync)(schemaFile, ts);
61554
+ (0, import_fs11.writeFileSync)(schemaFile, ts.file);
61475
61555
  console.log();
61476
61556
  if (snapshots.length === 0) {
61477
61557
  const { sqlStatements, _meta } = await prepareSQL(
@@ -61524,7 +61604,7 @@ var introspectSQLiteCommand = new import_commander.Command("introspect:sqlite").
61524
61604
  const tablesFilter = filterConfig ? typeof filterConfig === "string" ? [filterConfig] : filterConfig : [];
61525
61605
  const { schema: schema4, ts } = await sqliteIntrospect2(res, tablesFilter);
61526
61606
  const schemaFile = import_path7.default.join(out, "schema.ts");
61527
- (0, import_fs11.writeFileSync)(schemaFile, ts);
61607
+ (0, import_fs11.writeFileSync)(schemaFile, ts.file);
61528
61608
  console.log();
61529
61609
  if (snapshots.length === 0) {
61530
61610
  const { sqlStatements, _meta } = await prepareSQL(
@@ -61591,33 +61671,63 @@ var studioCommand = new import_commander.Command("studio").option("--port <port>
61591
61671
  const { driver, schema: schemaPath } = drizzleConfig;
61592
61672
  let setup;
61593
61673
  if (driver === "pg") {
61674
+ const { schemaToTypeScript: schemaToTypeScript4 } = await Promise.resolve().then(() => (init_introspect_pg(), introspect_pg_exports));
61675
+ const { serializePg: serializePg2 } = await Promise.resolve().then(() => (init_serializer(), serializer_exports));
61594
61676
  const { schema: schema4, relations: relations4 } = await preparePgSchema2(schemaPath);
61677
+ const internalSchema = await serializePg2(schemaPath);
61678
+ const ts = schemaToTypeScript4(internalSchema, { casing: "camel" });
61595
61679
  setup = await drizzleForPostgres2(
61596
61680
  drizzleConfig,
61597
61681
  schema4,
61598
61682
  relations4,
61683
+ {
61684
+ imports: ts.imports,
61685
+ declarations: ts.decalrations,
61686
+ schemaEntry: ts.schemaEntry
61687
+ },
61599
61688
  Boolean(options.verbose)
61600
61689
  );
61601
61690
  } else if (driver === "mysql2") {
61691
+ const { schemaToTypeScript: schemaToTypeScript4 } = await Promise.resolve().then(() => (init_introspect_mysql(), introspect_mysql_exports));
61602
61692
  const { schema: schema4, relations: relations4 } = await prepareMySqlSchema2(schemaPath);
61693
+ const { serializeMySql: serializeMySql2 } = await Promise.resolve().then(() => (init_serializer(), serializer_exports));
61694
+ const internalSchema = await serializeMySql2(schemaPath);
61695
+ const ts = schemaToTypeScript4(internalSchema, "camel");
61603
61696
  setup = await drizzleForMySQL2(
61604
61697
  drizzleConfig,
61605
61698
  schema4,
61606
61699
  relations4,
61700
+ {
61701
+ imports: ts.imports,
61702
+ declarations: ts.decalrations,
61703
+ schemaEntry: ts.schemaEntry
61704
+ },
61607
61705
  Boolean(options.verbose)
61608
61706
  );
61609
61707
  } else if (driver === "better-sqlite" || driver === "d1" || driver === "libsql" || driver === "turso") {
61708
+ const { schemaToTypeScript: schemaToTypeScript4 } = await Promise.resolve().then(() => (init_introspect_sqlite(), introspect_sqlite_exports));
61610
61709
  const { schema: schema4, relations: relations4 } = await prepareSQLiteSchema2(schemaPath);
61710
+ const { serializeSQLite: serializeSQLite2 } = await Promise.resolve().then(() => (init_serializer(), serializer_exports));
61711
+ const internalSchema = await serializeSQLite2(schemaPath);
61712
+ const ts = schemaToTypeScript4(internalSchema, "camel");
61611
61713
  setup = await drizzleForSQLite2(
61612
61714
  drizzleConfig,
61613
61715
  schema4,
61614
61716
  relations4,
61717
+ {
61718
+ imports: ts.imports,
61719
+ declarations: ts.decalrations,
61720
+ schemaEntry: ts.schemaEntry
61721
+ },
61615
61722
  Boolean(options.verbose)
61616
61723
  );
61617
61724
  } else {
61618
61725
  assertUnreachable(driver);
61619
61726
  }
61620
- const server = await (0, import_server.prepareServer)(setup);
61727
+ const qeueryEngine = (0, import_studio.queryEngineForSetup)(setup);
61728
+ const server = await (0, import_server.prepareServer)((_) => {
61729
+ return qeueryEngine;
61730
+ });
61621
61731
  const port = options.port ?? 4983;
61622
61732
  const host = options.host ?? "127.0.0.1";
61623
61733
  console.log();