drizzle-kit 0.22.0-12a1bf8 → 0.22.0-18d9643

Sign up to get free protection for your applications and to get access to all the features.
package/bin.cjs CHANGED
@@ -1092,7 +1092,7 @@ var init_views = __esm({
1092
1092
  return source_default.grey(msg);
1093
1093
  };
1094
1094
  error = (error2, greyMsg = "") => {
1095
- return `${source_default.red.bold("Err:")} ${error2} ${greyMsg ? source_default.grey(greyMsg) : ""}`.trim();
1095
+ return `${source_default.bgRed.bold(" Error ")} ${error2} ${greyMsg ? source_default.grey(greyMsg) : ""}`.trim();
1096
1096
  };
1097
1097
  schema = (schema5) => {
1098
1098
  const tables = Object.values(schema5.tables);
@@ -1451,6 +1451,9 @@ Is ${source_default.bold.blue(
1451
1451
  function assertUnreachable(x3) {
1452
1452
  throw new Error("Didn't expect to get here");
1453
1453
  }
1454
+ function softAssertUnreachable(x3) {
1455
+ return null;
1456
+ }
1454
1457
  var originUUID, snapshotVersion, mapValues, mapKeys, mapEntries;
1455
1458
  var init_global = __esm({
1456
1459
  "src/global.ts"() {
@@ -5474,7 +5477,16 @@ var init_mysqlSchema = __esm({
5474
5477
  objectType({ isDefaultAnExpression: booleanType().optional() }).optional()
5475
5478
  )
5476
5479
  }).optional()
5477
- )
5480
+ ).optional(),
5481
+ indexes: recordType(
5482
+ stringType(),
5483
+ objectType({
5484
+ columns: recordType(
5485
+ stringType(),
5486
+ objectType({ isExpression: booleanType().optional() }).optional()
5487
+ )
5488
+ }).optional()
5489
+ ).optional()
5478
5490
  }).optional();
5479
5491
  dialect = literalType("mysql");
5480
5492
  schemaHash = objectType({
@@ -6139,7 +6151,7 @@ var init_pgSchema = __esm({
6139
6151
  });
6140
6152
 
6141
6153
  // src/serializer/sqliteSchema.ts
6142
- var index3, fk3, compositePK3, column3, tableV33, uniqueConstraint3, table3, dialect2, schemaHash3, schemaInternalV32, schemaInternalV42, schemaInternalV52, latestVersion, schemaInternal2, schemaV32, schemaV42, schemaV52, schema3, tableSquashed3, schemaSquashed2, SQLiteSquasher, squashSqliteScheme, drySQLite, sqliteSchemaV5, sqliteSchema, SQLiteSchemaSquashed, backwardCompatibleSqliteSchema;
6154
+ var index3, fk3, compositePK3, column3, tableV33, uniqueConstraint3, table3, dialect2, schemaHash3, schemaInternalV32, schemaInternalV42, schemaInternalV52, kitInternals3, latestVersion, schemaInternal2, schemaV32, schemaV42, schemaV52, schema3, tableSquashed3, schemaSquashed2, SQLiteSquasher, squashSqliteScheme, drySQLite, sqliteSchemaV5, sqliteSchema, SQLiteSchemaSquashed, backwardCompatibleSqliteSchema;
6143
6155
  var init_sqliteSchema = __esm({
6144
6156
  "src/serializer/sqliteSchema.ts"() {
6145
6157
  "use strict";
@@ -6217,6 +6229,17 @@ var init_sqliteSchema = __esm({
6217
6229
  columns: recordType(stringType(), stringType())
6218
6230
  })
6219
6231
  }).strict();
6232
+ kitInternals3 = objectType({
6233
+ indexes: recordType(
6234
+ stringType(),
6235
+ objectType({
6236
+ columns: recordType(
6237
+ stringType(),
6238
+ objectType({ isExpression: booleanType().optional() }).optional()
6239
+ )
6240
+ }).optional()
6241
+ ).optional()
6242
+ }).optional();
6220
6243
  latestVersion = literalType("6");
6221
6244
  schemaInternal2 = objectType({
6222
6245
  version: latestVersion,
@@ -6226,7 +6249,8 @@ var init_sqliteSchema = __esm({
6226
6249
  _meta: objectType({
6227
6250
  tables: recordType(stringType(), stringType()),
6228
6251
  columns: recordType(stringType(), stringType())
6229
- })
6252
+ }),
6253
+ internal: kitInternals3
6230
6254
  }).strict();
6231
6255
  schemaV32 = schemaInternalV32.merge(schemaHash3).strict();
6232
6256
  schemaV42 = schemaInternalV42.merge(schemaHash3).strict();
@@ -7281,7 +7305,7 @@ var require_coerce = __commonJS({
7281
7305
  var SemVer = require_semver();
7282
7306
  var parse7 = require_parse();
7283
7307
  var { safeRe: re2, t: t2 } = require_re();
7284
- var coerce3 = (version2, options) => {
7308
+ var coerce2 = (version2, options) => {
7285
7309
  if (version2 instanceof SemVer) {
7286
7310
  return version2;
7287
7311
  }
@@ -7316,7 +7340,7 @@ var require_coerce = __commonJS({
7316
7340
  const build = options.includePrerelease && match2[6] ? `+${match2[6]}` : "";
7317
7341
  return parse7(`${major}.${minor}.${patch}${prerelease}${build}`, options);
7318
7342
  };
7319
- module2.exports = coerce3;
7343
+ module2.exports = coerce2;
7320
7344
  }
7321
7345
  });
7322
7346
 
@@ -8317,7 +8341,7 @@ var require_semver2 = __commonJS({
8317
8341
  var gte = require_gte();
8318
8342
  var lte = require_lte();
8319
8343
  var cmp = require_cmp();
8320
- var coerce3 = require_coerce();
8344
+ var coerce2 = require_coerce();
8321
8345
  var Comparator = require_comparator();
8322
8346
  var Range = require_range();
8323
8347
  var satisfies = require_satisfies();
@@ -8355,7 +8379,7 @@ var require_semver2 = __commonJS({
8355
8379
  gte,
8356
8380
  lte,
8357
8381
  cmp,
8358
- coerce: coerce3,
8382
+ coerce: coerce2,
8359
8383
  Comparator,
8360
8384
  Range,
8361
8385
  satisfies,
@@ -8575,12 +8599,137 @@ var init_utils3 = __esm({
8575
8599
  }
8576
8600
  });
8577
8601
 
8602
+ // src/schemaValidator.ts
8603
+ var dialect3, commonSquashedSchema, commonSchema;
8604
+ var init_schemaValidator = __esm({
8605
+ "src/schemaValidator.ts"() {
8606
+ "use strict";
8607
+ init_lib();
8608
+ init_mysqlSchema();
8609
+ init_pgSchema();
8610
+ init_sqliteSchema();
8611
+ dialect3 = enumType(["postgresql", "mysql", "sqlite"]);
8612
+ commonSquashedSchema = unionType([
8613
+ pgSchemaSquashed,
8614
+ mysqlSchemaSquashed,
8615
+ SQLiteSchemaSquashed
8616
+ ]);
8617
+ commonSchema = unionType([
8618
+ pgSchema,
8619
+ mysqlSchema,
8620
+ sqliteSchema
8621
+ ]);
8622
+ }
8623
+ });
8624
+
8625
+ // src/cli/validations/common.ts
8626
+ var assertCollisions, sqliteDriversLiterals, sqliteDriver, postgresDriver, mysqlDriver, driver, configCommonSchema, casing, introspectParams, configIntrospectCliSchema, configGenerateSchema, configPushSchema, wrapParam;
8627
+ var init_common = __esm({
8628
+ "src/cli/validations/common.ts"() {
8629
+ "use strict";
8630
+ init_outputs();
8631
+ init_lib();
8632
+ init_schemaValidator();
8633
+ init_source();
8634
+ assertCollisions = (options, command, inputWhitelist = []) => {
8635
+ const { config, ...rest } = options;
8636
+ let atLeastOneParam = false;
8637
+ for (const key of Object.keys(rest)) {
8638
+ if (inputWhitelist.includes(key))
8639
+ continue;
8640
+ atLeastOneParam = true;
8641
+ }
8642
+ if (!atLeastOneParam && typeof config !== "undefined") {
8643
+ return "config";
8644
+ }
8645
+ if (typeof config === "undefined" && atLeastOneParam) {
8646
+ return "cli";
8647
+ }
8648
+ if (typeof config === "undefined" && !atLeastOneParam) {
8649
+ return "config";
8650
+ }
8651
+ console.log(outputs.common.ambiguousParams(command));
8652
+ process.exit(1);
8653
+ };
8654
+ sqliteDriversLiterals = [
8655
+ literalType("turso"),
8656
+ literalType("d1-http"),
8657
+ literalType("expo")
8658
+ ];
8659
+ sqliteDriver = unionType(sqliteDriversLiterals);
8660
+ postgresDriver = literalType("aws-data-api");
8661
+ mysqlDriver = literalType("mysql2");
8662
+ driver = unionType([sqliteDriver, postgresDriver, mysqlDriver]);
8663
+ configCommonSchema = objectType({
8664
+ dialect: dialect3,
8665
+ schema: unionType([stringType(), stringType().array()]).optional(),
8666
+ out: stringType().optional(),
8667
+ breakpoints: booleanType().optional().default(true),
8668
+ driver: driver.optional(),
8669
+ tablesFilter: unionType([stringType(), stringType().array()]).optional(),
8670
+ schemaFilter: unionType([stringType(), stringType().array()]).default(["public"])
8671
+ });
8672
+ casing = unionType([literalType("camel"), literalType("preserve")]).default(
8673
+ "preserve"
8674
+ );
8675
+ introspectParams = objectType({
8676
+ schema: unionType([stringType(), stringType().array()]).optional(),
8677
+ out: stringType().optional().default("./drizzle"),
8678
+ breakpoints: booleanType().default(true),
8679
+ tablesFilter: unionType([stringType(), stringType().array()]).optional(),
8680
+ schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
8681
+ introspect: objectType({
8682
+ casing
8683
+ }).default({ casing: "camel" })
8684
+ });
8685
+ configIntrospectCliSchema = objectType({
8686
+ schema: unionType([stringType(), stringType().array()]).optional(),
8687
+ out: stringType().optional().default("./drizzle"),
8688
+ breakpoints: booleanType().default(true),
8689
+ tablesFilter: unionType([stringType(), stringType().array()]).optional(),
8690
+ schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
8691
+ introspectCasing: unionType([literalType("camel"), literalType("preserve")]).default(
8692
+ "camel"
8693
+ )
8694
+ });
8695
+ configGenerateSchema = objectType({
8696
+ schema: unionType([stringType(), stringType().array()]),
8697
+ out: stringType().optional().default("./drizzle"),
8698
+ breakpoints: booleanType().default(true)
8699
+ });
8700
+ configPushSchema = objectType({
8701
+ dialect: dialect3,
8702
+ schema: unionType([stringType(), stringType().array()]),
8703
+ tablesFilter: unionType([stringType(), stringType().array()]).optional(),
8704
+ schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
8705
+ verbose: booleanType().default(false),
8706
+ strict: booleanType().default(false),
8707
+ out: stringType().optional()
8708
+ });
8709
+ wrapParam = (name, param, optional = false) => {
8710
+ const check = `[${source_default.green("\u2713")}]`;
8711
+ const cross = `[${source_default.red("x")}]`;
8712
+ if (typeof param === "string") {
8713
+ if (param.length === 0) {
8714
+ return ` ${cross} ${name}: ''`;
8715
+ }
8716
+ return ` ${check} ${name}: '${param}'`;
8717
+ }
8718
+ if (optional) {
8719
+ return source_default.gray(` ${name}?: `);
8720
+ }
8721
+ return ` ${cross} ${name}: ${source_default.gray("undefined")}`;
8722
+ };
8723
+ }
8724
+ });
8725
+
8578
8726
  // src/cli/validations/outputs.ts
8579
8727
  var withStyle, outputs;
8580
8728
  var init_outputs = __esm({
8581
8729
  "src/cli/validations/outputs.ts"() {
8582
8730
  "use strict";
8583
8731
  init_source();
8732
+ init_common();
8584
8733
  withStyle = {
8585
8734
  error: (str) => `${source_default.red(`${source_default.white.bgRed(" Invalid input ")} ${str}`)}`,
8586
8735
  warning: (str) => `${source_default.white.bgGray(" Warning ")} ${str}`,
@@ -8630,14 +8779,17 @@ var init_outputs = __esm({
8630
8779
  },
8631
8780
  sqlite: {
8632
8781
  connection: {
8633
- driver: () => withStyle.error(
8634
- `Either "turso", "libsql", "better-sqlite" are available options for "--driver"`
8635
- ),
8636
- url: (driver2) => withStyle.error(
8637
- `"url" is a required option for driver "${driver2}". You can read more about drizzle.config: https://orm.drizzle.team/kit-docs/config-reference`
8782
+ driver: () => {
8783
+ const listOfDrivers = sqliteDriversLiterals.map((it) => `'${it.value}'`).join(", ");
8784
+ return withStyle.error(
8785
+ `Either ${listOfDrivers} are available options for 'driver' param`
8786
+ );
8787
+ },
8788
+ url: (driver3) => withStyle.error(
8789
+ `"url" is a required option for driver "${driver3}". You can read more about drizzle.config: https://orm.drizzle.team/kit-docs/config-reference`
8638
8790
  ),
8639
- authToken: (driver2) => withStyle.error(
8640
- `"authToken" is a required option for driver "${driver2}". You can read more about drizzle.config: https://orm.drizzle.team/kit-docs/config-reference`
8791
+ authToken: (driver3) => withStyle.error(
8792
+ `"authToken" is a required option for driver "${driver3}". You can read more about drizzle.config: https://orm.drizzle.team/kit-docs/config-reference`
8641
8793
  )
8642
8794
  },
8643
8795
  introspect: {},
@@ -8654,13 +8806,15 @@ var init_mysql = __esm({
8654
8806
  "use strict";
8655
8807
  init_lib();
8656
8808
  init_outputs();
8809
+ init_common();
8810
+ init_views();
8657
8811
  mysqlCredentials = unionType([
8658
8812
  objectType({
8659
- host: stringType(),
8660
- port: coerce.number().optional(),
8661
- user: stringType().default("mysql"),
8662
- password: stringType().optional(),
8663
- database: stringType(),
8813
+ host: stringType().min(1),
8814
+ port: coerce.number().min(1).optional(),
8815
+ user: stringType().min(1).optional(),
8816
+ password: stringType().min(1).optional(),
8817
+ database: stringType().min(1),
8664
8818
  ssl: unionType([
8665
8819
  stringType(),
8666
8820
  objectType({
@@ -8676,35 +8830,47 @@ var init_mysql = __esm({
8676
8830
  ]).optional()
8677
8831
  }),
8678
8832
  objectType({
8679
- url: stringType()
8833
+ url: stringType().min(1)
8680
8834
  })
8681
8835
  ]);
8682
8836
  printConfigConnectionIssues = (options) => {
8683
- if (options.driver !== "mysql2") {
8684
- console.log(outputs.mysql.connection.driver());
8685
- }
8686
- const { uri, connectionString, url, host, database } = options;
8687
- if (!uri && !connectionString && !url && (!host || !database)) {
8688
- console.log(outputs.mysql.connection.required());
8837
+ if ("url" in options) {
8838
+ let text2 = `Please provide required params for MySQL driver:
8839
+ `;
8840
+ console.log(error(text2));
8841
+ console.log(wrapParam("url", options.url));
8842
+ process.exit(1);
8689
8843
  }
8844
+ let text = `Please provide required params for MySQL driver:
8845
+ `;
8846
+ console.log(error(text));
8847
+ console.log(wrapParam("host", options.host));
8848
+ console.log(wrapParam("port", options.port, true));
8849
+ console.log(wrapParam("user", options.user, true));
8850
+ console.log(wrapParam("password", options.password, true));
8851
+ console.log(wrapParam("database", options.database));
8852
+ console.log(wrapParam("ssl", options.ssl, true));
8853
+ process.exit(1);
8690
8854
  };
8691
8855
  }
8692
8856
  });
8693
8857
 
8694
- // src/cli/validations/pg.ts
8858
+ // src/cli/validations/postgres.ts
8695
8859
  var postgresCredentials, printConfigConnectionIssues2;
8696
- var init_pg = __esm({
8697
- "src/cli/validations/pg.ts"() {
8860
+ var init_postgres = __esm({
8861
+ "src/cli/validations/postgres.ts"() {
8698
8862
  "use strict";
8699
8863
  init_lib();
8700
- init_outputs();
8864
+ init_common();
8865
+ init_views();
8701
8866
  postgresCredentials = unionType([
8702
8867
  objectType({
8703
- host: stringType(),
8704
- port: coerce.number().optional(),
8705
- user: stringType().default("postgres"),
8706
- password: stringType().optional(),
8707
- database: stringType(),
8868
+ driver: undefinedType(),
8869
+ host: stringType().min(1),
8870
+ port: coerce.number().min(1).optional(),
8871
+ user: stringType().min(1).optional(),
8872
+ password: stringType().min(1).optional(),
8873
+ database: stringType().min(1),
8708
8874
  ssl: unionType([
8709
8875
  literalType("require"),
8710
8876
  literalType("allow"),
@@ -8712,26 +8878,60 @@ var init_pg = __esm({
8712
8878
  literalType("verify-full"),
8713
8879
  booleanType(),
8714
8880
  objectType({}).passthrough()
8715
- ])
8881
+ ]).optional()
8882
+ }).transform((o) => {
8883
+ delete o.driver;
8884
+ return o;
8716
8885
  }),
8717
8886
  objectType({
8718
- url: stringType()
8887
+ driver: undefinedType(),
8888
+ url: stringType().min(1)
8889
+ }).transform((o) => {
8890
+ delete o.driver;
8891
+ return o;
8719
8892
  }),
8720
8893
  objectType({
8721
8894
  driver: literalType("aws-data-api"),
8722
- database: stringType(),
8723
- secretArn: stringType(),
8724
- resourceArn: stringType()
8895
+ database: stringType().min(1),
8896
+ secretArn: stringType().min(1),
8897
+ resourceArn: stringType().min(1)
8725
8898
  })
8726
8899
  ]);
8727
8900
  printConfigConnectionIssues2 = (options) => {
8728
8901
  if (options.driver === "aws-data-api") {
8729
- console.log(outputs.postgres.connection.awsDataApi());
8730
- return;
8902
+ let text = `Please provide required params for AWS Data API driver:
8903
+ `;
8904
+ console.log(error(text));
8905
+ console.log(wrapParam("database", options.database));
8906
+ console.log(wrapParam("secretArn", options.secretArn));
8907
+ console.log(wrapParam("resourceArn", options.resourceArn));
8908
+ process.exit(1);
8731
8909
  }
8732
- if (!("url" in options) && !("host" in options || "database" in options)) {
8733
- console.log(outputs.postgres.connection.required());
8910
+ if ("url" in options) {
8911
+ let text = `Please provide required params for Postgres driver:
8912
+ `;
8913
+ console.log(error(text));
8914
+ console.log(wrapParam("url", options.url));
8915
+ process.exit(1);
8916
+ }
8917
+ if ("host" in options || "database" in options) {
8918
+ let text = `Please provide required params for Postgres driver:
8919
+ `;
8920
+ console.log(error(text));
8921
+ console.log(wrapParam("host", options.host));
8922
+ console.log(wrapParam("port", options.port, true));
8923
+ console.log(wrapParam("user", options.user, true));
8924
+ console.log(wrapParam("password", options.password, true));
8925
+ console.log(wrapParam("database", options.database));
8926
+ console.log(wrapParam("ssl", options.ssl, true));
8927
+ process.exit(1);
8734
8928
  }
8929
+ console.log(
8930
+ error(
8931
+ `Either connection "url" or "host", "database" are required for database connection`
8932
+ )
8933
+ );
8934
+ process.exit(1);
8735
8935
  };
8736
8936
  }
8737
8937
  });
@@ -8742,154 +8942,77 @@ var init_sqlite = __esm({
8742
8942
  "src/cli/validations/sqlite.ts"() {
8743
8943
  "use strict";
8744
8944
  init_lib();
8745
- init_outputs();
8945
+ init_common();
8946
+ init_views();
8947
+ init_global();
8746
8948
  sqliteCredentials = unionType([
8747
8949
  objectType({
8748
8950
  driver: literalType("turso"),
8749
- url: stringType(),
8750
- authToken: stringType()
8951
+ url: stringType().min(1),
8952
+ authToken: stringType().min(1).optional()
8751
8953
  }),
8752
8954
  objectType({
8753
8955
  driver: literalType("d1-http"),
8754
- accountId: stringType(),
8755
- databaseId: stringType(),
8756
- token: stringType()
8956
+ accountId: stringType().min(1),
8957
+ databaseId: stringType().min(1),
8958
+ token: stringType().min(1)
8757
8959
  }),
8758
8960
  objectType({
8759
- url: stringType()
8961
+ driver: undefinedType(),
8962
+ url: stringType().min(1)
8963
+ }).transform((o) => {
8964
+ delete o.driver;
8965
+ return o;
8760
8966
  })
8761
8967
  ]);
8762
- printConfigConnectionIssues3 = (options) => {
8763
- if (options.driver === "turso") {
8764
- if (!options.url) {
8765
- console.log(outputs.sqlite.connection.url("turso"));
8766
- }
8767
- if (!options.authToken) {
8768
- console.log(outputs.sqlite.connection.authToken("turso"));
8769
- }
8770
- } else if (options.driver === "libsql") {
8771
- if (!options.url) {
8772
- console.log(outputs.sqlite.connection.url("libsql"));
8773
- }
8774
- } else if (options.driver === "better-sqlite") {
8775
- if (!options.url) {
8776
- console.log(outputs.sqlite.connection.url("better-sqlite"));
8968
+ printConfigConnectionIssues3 = (options, command) => {
8969
+ const parsedDriver = sqliteDriver.safeParse(options.driver);
8970
+ const driver3 = parsedDriver.success ? parsedDriver.data : "";
8971
+ if (driver3 === "expo") {
8972
+ if (command === "migrate") {
8973
+ console.log(
8974
+ error(
8975
+ `You can't use 'migrate' command with Expo SQLite, please follow migration instructions in our docs - https://orm.drizzle.team/docs/get-started-sqlite#expo-sqlite`
8976
+ )
8977
+ );
8978
+ } else if (command === "studio") {
8979
+ console.log(
8980
+ error(
8981
+ `You can't use 'studio' command with Expo SQLite, please use Expo Plugin https://www.npmjs.com/package/expo-drizzle-studio-plugin`
8982
+ )
8983
+ );
8984
+ } else if (command === "pull") {
8985
+ console.log(error("You can't use 'pull' command with Expo SQLite"));
8986
+ } else if (command === "push") {
8987
+ console.log(error("You can't use 'push' command with Expo SQLite"));
8988
+ } else {
8989
+ console.log(error("Unexpected error with expo driver \u{1F914}"));
8777
8990
  }
8991
+ process.exit(1);
8992
+ } else if (driver3 === "d1-http") {
8993
+ let text2 = `Please provide required params for D1 HTTP driver:
8994
+ `;
8995
+ console.log(error(text2));
8996
+ console.log(wrapParam("accountId", options.accountId));
8997
+ console.log(wrapParam("databaseId", options.databaseId));
8998
+ console.log(wrapParam("token", options.token));
8999
+ process.exit(1);
9000
+ } else if (driver3 === "turso") {
9001
+ let text2 = `Please provide required params for Turso driver:
9002
+ `;
9003
+ console.log(error(text2));
9004
+ console.log(wrapParam("url", options.url));
9005
+ console.log(wrapParam("authToken", options.authToken));
9006
+ return;
8778
9007
  } else {
8779
- console.log(outputs.sqlite.connection.driver());
8780
- }
8781
- };
8782
- }
8783
- });
8784
-
8785
- // src/schemaValidator.ts
8786
- var dialect3, commonSquashedSchema, commonSchema;
8787
- var init_schemaValidator = __esm({
8788
- "src/schemaValidator.ts"() {
8789
- "use strict";
8790
- init_lib();
8791
- init_mysqlSchema();
8792
- init_pgSchema();
8793
- init_sqliteSchema();
8794
- dialect3 = enumType(["postgresql", "mysql", "sqlite"]);
8795
- commonSquashedSchema = unionType([
8796
- pgSchemaSquashed,
8797
- mysqlSchemaSquashed,
8798
- SQLiteSchemaSquashed
8799
- ]);
8800
- commonSchema = unionType([
8801
- pgSchema,
8802
- mysqlSchema,
8803
- sqliteSchema
8804
- ]);
8805
- }
8806
- });
8807
-
8808
- // src/cli/validations/common.ts
8809
- var assertCollisions, sqliteDriver, postgresDriver, mysqlDriver, driver, configCommonSchema, casing, introspectParams, configIntrospectCliSchema, configGenerateSchema, configPushSchema;
8810
- var init_common = __esm({
8811
- "src/cli/validations/common.ts"() {
8812
- "use strict";
8813
- init_outputs();
8814
- init_lib();
8815
- init_schemaValidator();
8816
- assertCollisions = (options, command, inputWhitelist = []) => {
8817
- const { config, ...rest } = options;
8818
- let atLeastOneParam = false;
8819
- for (const key of Object.keys(rest)) {
8820
- if (inputWhitelist.includes(key))
8821
- continue;
8822
- atLeastOneParam = true;
8823
- }
8824
- if (!atLeastOneParam && typeof config !== "undefined") {
8825
- return "config";
9008
+ softAssertUnreachable(driver3);
8826
9009
  }
8827
- if (typeof config === "undefined" && atLeastOneParam) {
8828
- return "cli";
8829
- }
8830
- if (typeof config === "undefined" && !atLeastOneParam) {
8831
- return "config";
8832
- }
8833
- console.log(outputs.common.ambiguousParams(command));
9010
+ let text = `Please provide required params:
9011
+ `;
9012
+ console.log(error(text));
9013
+ console.log(wrapParam("url", options.url));
8834
9014
  process.exit(1);
8835
9015
  };
8836
- sqliteDriver = unionType([
8837
- literalType("better-sqlite"),
8838
- literalType("turso"),
8839
- literalType("libsql"),
8840
- literalType("d1"),
8841
- literalType("d1-http"),
8842
- literalType("expo")
8843
- ]);
8844
- postgresDriver = literalType("aws-data-api");
8845
- mysqlDriver = literalType("mysql2");
8846
- driver = unionType([sqliteDriver, postgresDriver, mysqlDriver]);
8847
- configCommonSchema = objectType({
8848
- dialect: dialect3,
8849
- schema: unionType([stringType(), stringType().array()]).optional(),
8850
- out: stringType().optional(),
8851
- breakpoints: booleanType().optional().default(true),
8852
- driver: driver.optional(),
8853
- tablesFilter: unionType([stringType(), stringType().array()]).optional(),
8854
- schemaFilter: unionType([stringType(), stringType().array()]).default(["public"])
8855
- });
8856
- casing = unionType([literalType("camel"), literalType("preserve")]).default(
8857
- "preserve"
8858
- );
8859
- introspectParams = objectType({
8860
- schema: unionType([stringType(), stringType().array()]).optional(),
8861
- out: stringType().optional().default("./drizzle"),
8862
- breakpoints: booleanType().default(true),
8863
- tablesFilter: unionType([stringType(), stringType().array()]).optional(),
8864
- schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
8865
- introspect: objectType({
8866
- casing
8867
- }).default({ casing: "camel" })
8868
- });
8869
- configIntrospectCliSchema = objectType({
8870
- schema: unionType([stringType(), stringType().array()]).optional(),
8871
- out: stringType().optional().default("./drizzle"),
8872
- breakpoints: booleanType().default(true),
8873
- tablesFilter: unionType([stringType(), stringType().array()]).optional(),
8874
- schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
8875
- introspectCasing: unionType([literalType("camel"), literalType("preserve")]).default(
8876
- "camel"
8877
- )
8878
- });
8879
- configGenerateSchema = objectType({
8880
- schema: unionType([stringType(), stringType().array()]),
8881
- out: stringType().optional().default("./drizzle"),
8882
- breakpoints: booleanType().default(true)
8883
- });
8884
- configPushSchema = objectType({
8885
- dialect: dialect3,
8886
- schema: unionType([stringType(), stringType().array()]),
8887
- tablesFilter: unionType([stringType(), stringType().array()]).optional(),
8888
- schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
8889
- verbose: booleanType().default(false),
8890
- strict: booleanType().default(false),
8891
- out: stringType().optional()
8892
- });
8893
9016
  }
8894
9017
  });
8895
9018
 
@@ -8951,7 +9074,7 @@ var init_studio = __esm({
8951
9074
  init_mysql();
8952
9075
  init_sqlite();
8953
9076
  init_schemaValidator();
8954
- init_pg();
9077
+ init_postgres();
8955
9078
  credentials = intersectionType(
8956
9079
  postgresCredentials,
8957
9080
  mysqlCredentials,
@@ -9105,7 +9228,7 @@ var require_common = __commonJS({
9105
9228
  function setup(env3) {
9106
9229
  createDebug.debug = createDebug;
9107
9230
  createDebug.default = createDebug;
9108
- createDebug.coerce = coerce3;
9231
+ createDebug.coerce = coerce2;
9109
9232
  createDebug.disable = disable;
9110
9233
  createDebug.enable = enable;
9111
9234
  createDebug.enabled = enabled;
@@ -9246,7 +9369,7 @@ var require_common = __commonJS({
9246
9369
  function toNamespace(regexp) {
9247
9370
  return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, "*");
9248
9371
  }
9249
- function coerce3(val2) {
9372
+ function coerce2(val2) {
9250
9373
  if (val2 instanceof Error) {
9251
9374
  return val2.stack || val2.message;
9252
9375
  }
@@ -14601,7 +14724,7 @@ var init_utils4 = __esm({
14601
14724
  import_hanji2 = __toESM(require_hanji());
14602
14725
  init_global();
14603
14726
  init_mysql();
14604
- init_pg();
14727
+ init_postgres();
14605
14728
  init_sqlite();
14606
14729
  init_common();
14607
14730
  init_schemaValidator();
@@ -14777,7 +14900,7 @@ var init_utils4 = __esm({
14777
14900
  if (dialect7 === "sqlite") {
14778
14901
  const parsed = sqliteCredentials.safeParse(config);
14779
14902
  if (!parsed.success) {
14780
- printConfigConnectionIssues3(config);
14903
+ printConfigConnectionIssues3(config, "pull");
14781
14904
  process.exit(1);
14782
14905
  }
14783
14906
  return {
@@ -14852,7 +14975,7 @@ var init_utils4 = __esm({
14852
14975
  if (dialect7 === "sqlite") {
14853
14976
  const parsed = sqliteCredentials.safeParse(config);
14854
14977
  if (!parsed.success) {
14855
- printConfigConnectionIssues3(config);
14978
+ printConfigConnectionIssues3(config, "pull");
14856
14979
  process.exit(1);
14857
14980
  }
14858
14981
  return {
@@ -14917,7 +15040,7 @@ var init_utils4 = __esm({
14917
15040
  if (dialect7 === "sqlite") {
14918
15041
  const parsed = sqliteCredentials.safeParse(flattened);
14919
15042
  if (!parsed.success) {
14920
- printConfigConnectionIssues3(flattened);
15043
+ printConfigConnectionIssues3(flattened, "studio");
14921
15044
  process.exit(1);
14922
15045
  }
14923
15046
  const credentials2 = parsed.data;
@@ -14992,7 +15115,7 @@ var init_utils4 = __esm({
14992
15115
  if (dialect7 === "sqlite") {
14993
15116
  const parsed = sqliteCredentials.safeParse(flattened);
14994
15117
  if (!parsed.success) {
14995
- printConfigConnectionIssues3(flattened);
15118
+ printConfigConnectionIssues3(flattened, "migrate");
14996
15119
  process.exit(1);
14997
15120
  }
14998
15121
  const credentials2 = parsed.data;
@@ -15053,8 +15176,9 @@ var init_utils4 = __esm({
15053
15176
  unregister();
15054
15177
  const res = configCommonSchema.safeParse(content);
15055
15178
  if (!res.success) {
15056
- console.error(res.error);
15057
- console.log("Missing required params");
15179
+ if (!("dialect" in content)) {
15180
+ console.log(error("Please specify 'dialect' param"));
15181
+ }
15058
15182
  process.exit(1);
15059
15183
  }
15060
15184
  return res.data;
@@ -15165,6 +15289,7 @@ var init_mysqlSerializer = __esm({
15165
15289
  };
15166
15290
  generateMySqlSnapshot = (tables) => {
15167
15291
  const result = {};
15292
+ const internal = { tables: {}, indexes: {} };
15168
15293
  for (const table4 of tables) {
15169
15294
  const {
15170
15295
  name: tableName,
@@ -15315,10 +15440,29 @@ The unique constraint ${source_default.underline.blue(
15315
15440
  const columns2 = value.config.columns;
15316
15441
  const name = value.config.name;
15317
15442
  let indexColumns = columns2.map((it) => {
15443
+ var _a;
15318
15444
  if ((0, import_drizzle_orm2.is)(it, import_drizzle_orm3.SQL)) {
15319
- return dialect4.sqlToQuery(it, "indexes").sql;
15445
+ const sql2 = dialect4.sqlToQuery(it, "indexes").sql;
15446
+ if (typeof internal.indexes[name] === "undefined") {
15447
+ internal.indexes[name] = {
15448
+ columns: {
15449
+ [sql2]: {
15450
+ isExpression: true
15451
+ }
15452
+ }
15453
+ };
15454
+ } else {
15455
+ if (typeof ((_a = internal.indexes[name]) == null ? void 0 : _a.columns[sql2]) === "undefined") {
15456
+ internal.indexes[name].columns[sql2] = {
15457
+ isExpression: true
15458
+ };
15459
+ } else {
15460
+ internal.indexes[name].columns[sql2].isExpression = true;
15461
+ }
15462
+ }
15463
+ return sql2;
15320
15464
  } else {
15321
- return it.name;
15465
+ return `${it.name}`;
15322
15466
  }
15323
15467
  });
15324
15468
  if (value.config.unique) {
@@ -15385,12 +15529,13 @@ We have encountered a collision between the index name on columns ${source_defau
15385
15529
  _meta: {
15386
15530
  tables: {},
15387
15531
  columns: {}
15388
- }
15532
+ },
15533
+ internal
15389
15534
  };
15390
15535
  };
15391
15536
  fromDatabase = async (db2, inputSchema, tablesFilter = (table4) => true, progressCallback) => {
15392
15537
  const result = {};
15393
- const internals = { tables: {} };
15538
+ const internals = { tables: {}, indexes: {} };
15394
15539
  const columns = await db2.query(`select * from information_schema.columns
15395
15540
  where table_schema = '${inputSchema}' and table_name != '__drizzle_migrations'
15396
15541
  order by table_name, ordinal_position;`);
@@ -16605,6 +16750,7 @@ var init_sqliteSerializer = __esm({
16605
16750
  dialect6 = new import_sqlite_core2.SQLiteSyncDialect();
16606
16751
  generateSqliteSnapshot = (tables) => {
16607
16752
  const result = {};
16753
+ const internal = { indexes: {} };
16608
16754
  for (const table4 of tables) {
16609
16755
  const columnsObject = {};
16610
16756
  const indexesObject = {};
@@ -16690,8 +16836,27 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
16690
16836
  const columns2 = value.config.columns;
16691
16837
  const name = value.config.name;
16692
16838
  let indexColumns = columns2.map((it) => {
16839
+ var _a;
16693
16840
  if ((0, import_drizzle_orm7.is)(it, import_drizzle_orm7.SQL)) {
16694
- return dialect6.sqlToQuery(it, "indexes").sql;
16841
+ const sql2 = dialect6.sqlToQuery(it, "indexes").sql;
16842
+ if (typeof internal.indexes[name] === "undefined") {
16843
+ internal.indexes[name] = {
16844
+ columns: {
16845
+ [sql2]: {
16846
+ isExpression: true
16847
+ }
16848
+ }
16849
+ };
16850
+ } else {
16851
+ if (typeof ((_a = internal.indexes[name]) == null ? void 0 : _a.columns[sql2]) === "undefined") {
16852
+ internal.indexes[name].columns[sql2] = {
16853
+ isExpression: true
16854
+ };
16855
+ } else {
16856
+ internal.indexes[name].columns[sql2].isExpression = true;
16857
+ }
16858
+ }
16859
+ return sql2;
16695
16860
  } else {
16696
16861
  return it.name;
16697
16862
  }
@@ -16765,7 +16930,8 @@ The unique constraint ${source_default.underline.blue(
16765
16930
  _meta: {
16766
16931
  tables: {},
16767
16932
  columns: {}
16768
- }
16933
+ },
16934
+ internal
16769
16935
  };
16770
16936
  };
16771
16937
  fromDatabase3 = async (db2, tablesFilter = (table4) => true, progressCallback) => {
@@ -17268,7 +17434,14 @@ var init_sqlgenerator = __esm({
17268
17434
  return statement.type === "create_table" && dialect7 === "mysql";
17269
17435
  }
17270
17436
  convert(st) {
17271
- const { tableName, columns, schema: schema5, compositePKs, uniqueConstraints } = st;
17437
+ const {
17438
+ tableName,
17439
+ columns,
17440
+ schema: schema5,
17441
+ compositePKs,
17442
+ uniqueConstraints,
17443
+ internals
17444
+ } = st;
17272
17445
  let statement = "";
17273
17446
  statement += `CREATE TABLE \`${tableName}\` (
17274
17447
  `;
@@ -17291,7 +17464,11 @@ var init_sqlgenerator = __esm({
17291
17464
  for (const uniqueConstraint4 of uniqueConstraints) {
17292
17465
  statement += ",\n";
17293
17466
  const unsquashedUnique = MySqlSquasher.unsquashUnique(uniqueConstraint4);
17294
- statement += ` CONSTRAINT \`${unsquashedUnique.name}\` UNIQUE(\`${unsquashedUnique.columns.join(`\`,\``)}\`)`;
17467
+ const uniqueString = unsquashedUnique.columns.map((it) => {
17468
+ var _a, _b;
17469
+ return (internals == null ? void 0 : internals.indexes) ? ((_b = (_a = internals == null ? void 0 : internals.indexes[unsquashedUnique.name]) == null ? void 0 : _a.columns[it]) == null ? void 0 : _b.isExpression) ? it : `\`${it}\`` : `\`${it}\``;
17470
+ }).join(",");
17471
+ statement += ` CONSTRAINT \`${unsquashedUnique.name}\` UNIQUE(${uniqueString})`;
17295
17472
  }
17296
17473
  }
17297
17474
  statement += `
@@ -18220,8 +18397,11 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
18220
18397
  statement.data
18221
18398
  );
18222
18399
  const indexPart = isUnique ? "UNIQUE INDEX" : "INDEX";
18223
- const value = columns.map((it) => `\`${it}\``).join(",");
18224
- return `CREATE ${indexPart} \`${name}\` ON \`${statement.tableName}\` (${value});`;
18400
+ const uniqueString = columns.map((it) => {
18401
+ var _a, _b, _c, _d;
18402
+ return ((_a = statement.internal) == null ? void 0 : _a.indexes) ? ((_d = (_c = (_b = statement.internal) == null ? void 0 : _b.indexes[name]) == null ? void 0 : _c.columns[it]) == null ? void 0 : _d.isExpression) ? it : `\`${it}\`` : `\`${it}\``;
18403
+ }).join(",");
18404
+ return `CREATE ${indexPart} \`${name}\` ON \`${statement.tableName}\` (${uniqueString});`;
18225
18405
  }
18226
18406
  };
18227
18407
  CreateSqliteIndexConvertor = class extends Convertor {
@@ -18234,8 +18414,11 @@ ${BREAKPOINT}ALTER TABLE ${tableNameWithSchema} ADD CONSTRAINT ${statement.newCo
18234
18414
  );
18235
18415
  const indexPart = isUnique ? "UNIQUE INDEX" : "INDEX";
18236
18416
  const whereStatement = where ? ` WHERE ${where}` : "";
18237
- const value = columns.map((it) => `\`${it}\``).join(",");
18238
- return `CREATE ${indexPart} \`${name}\` ON \`${statement.tableName}\` (${value})${whereStatement};`;
18417
+ const uniqueString = columns.map((it) => {
18418
+ var _a, _b, _c, _d;
18419
+ return ((_a = statement.internal) == null ? void 0 : _a.indexes) ? ((_d = (_c = (_b = statement.internal) == null ? void 0 : _b.indexes[name]) == null ? void 0 : _c.columns[it]) == null ? void 0 : _d.isExpression) ? it : `\`${it}\`` : `\`${it}\``;
18420
+ }).join(",");
18421
+ return `CREATE ${indexPart} \`${name}\` ON \`${statement.tableName}\` (${uniqueString})${whereStatement};`;
18239
18422
  }
18240
18423
  };
18241
18424
  PgDropIndexConvertor = class extends Convertor {
@@ -18883,7 +19066,7 @@ var init_jsonStatements = __esm({
18883
19066
  uniqueConstraints: Object.values(uniqueConstraints)
18884
19067
  };
18885
19068
  };
18886
- prepareMySqlCreateTableJson = (table4, json2) => {
19069
+ prepareMySqlCreateTableJson = (table4, json2, internals) => {
18887
19070
  const { name, schema: schema5, columns, compositePrimaryKeys, uniqueConstraints } = table4;
18888
19071
  return {
18889
19072
  type: "create_table",
@@ -18892,7 +19075,8 @@ var init_jsonStatements = __esm({
18892
19075
  columns: Object.values(columns),
18893
19076
  compositePKs: Object.values(compositePrimaryKeys),
18894
19077
  compositePkName: Object.values(compositePrimaryKeys).length > 0 ? json2.tables[name].compositePrimaryKeys[MySqlSquasher.unsquashPK(Object.values(compositePrimaryKeys)[0]).name].name : "",
18895
- uniqueConstraints: Object.values(uniqueConstraints)
19078
+ uniqueConstraints: Object.values(uniqueConstraints),
19079
+ internals
18896
19080
  };
18897
19081
  };
18898
19082
  prepareSQLiteCreateTable = (table4) => {
@@ -19649,13 +19833,14 @@ var init_jsonStatements = __esm({
19649
19833
  };
19650
19834
  });
19651
19835
  };
19652
- prepareCreateIndexesJson = (tableName, schema5, indexes) => {
19836
+ prepareCreateIndexesJson = (tableName, schema5, indexes, internal) => {
19653
19837
  return Object.values(indexes).map((indexData) => {
19654
19838
  return {
19655
19839
  type: "create_index",
19656
19840
  tableName,
19657
19841
  data: indexData,
19658
- schema: schema5
19842
+ schema: schema5,
19843
+ internal
19659
19844
  };
19660
19845
  });
19661
19846
  };
@@ -20560,7 +20745,12 @@ var init_snapshotsDiffer = __esm({
20560
20745
  const typedResult = diffResultSchemeMysql.parse(diffResult);
20561
20746
  const jsonStatements = [];
20562
20747
  const jsonCreateIndexesForCreatedTables = createdTables.map((it) => {
20563
- return prepareCreateIndexesJson(it.name, it.schema, it.indexes);
20748
+ return prepareCreateIndexesJson(
20749
+ it.name,
20750
+ it.schema,
20751
+ it.indexes,
20752
+ curFull.internal
20753
+ );
20564
20754
  }).flat();
20565
20755
  const jsonDropTables = deletedTables.map((it) => {
20566
20756
  return prepareDropTableJson(it);
@@ -20659,7 +20849,8 @@ var init_snapshotsDiffer = __esm({
20659
20849
  return prepareCreateIndexesJson(
20660
20850
  it.name,
20661
20851
  it.schema,
20662
- it.addedIndexes || {}
20852
+ it.addedIndexes || {},
20853
+ curFull.internal
20663
20854
  );
20664
20855
  }).flat();
20665
20856
  const jsonDropIndexesForAllAlteredTables = alteredTables.map((it) => {
@@ -20719,7 +20910,11 @@ var init_snapshotsDiffer = __esm({
20719
20910
  (t2) => t2.type === "delete_reference"
20720
20911
  );
20721
20912
  const jsonMySqlCreateTables = createdTables.map((it) => {
20722
- return prepareMySqlCreateTableJson(it, curFull);
20913
+ return prepareMySqlCreateTableJson(
20914
+ it,
20915
+ curFull,
20916
+ curFull.internal
20917
+ );
20723
20918
  });
20724
20919
  jsonStatements.push(...jsonMySqlCreateTables);
20725
20920
  jsonStatements.push(...jsonDropTables);
@@ -20759,7 +20954,7 @@ var init_snapshotsDiffer = __esm({
20759
20954
  _meta
20760
20955
  };
20761
20956
  };
20762
- applySqliteSnapshotsDiff = async (json1, json2, tablesResolver2, columnsResolver2) => {
20957
+ applySqliteSnapshotsDiff = async (json1, json2, tablesResolver2, columnsResolver2, prevFull, curFull) => {
20763
20958
  const tablesDiff = diffSchemasOrTables(json1.tables, json2.tables);
20764
20959
  const {
20765
20960
  created: createdTables,
@@ -20839,7 +21034,12 @@ var init_snapshotsDiffer = __esm({
20839
21034
  return prepareSQLiteCreateTable(it);
20840
21035
  });
20841
21036
  const jsonCreateIndexesForCreatedTables = createdTables.map((it) => {
20842
- return prepareCreateIndexesJson(it.name, it.schema, it.indexes);
21037
+ return prepareCreateIndexesJson(
21038
+ it.name,
21039
+ it.schema,
21040
+ it.indexes,
21041
+ curFull.internal
21042
+ );
20843
21043
  }).flat();
20844
21044
  const jsonDropTables = deletedTables.map((it) => {
20845
21045
  return prepareDropTableJson(it);
@@ -20941,7 +21141,8 @@ var init_snapshotsDiffer = __esm({
20941
21141
  return prepareCreateIndexesJson(
20942
21142
  it.name,
20943
21143
  it.schema,
20944
- it.addedIndexes || {}
21144
+ it.addedIndexes || {},
21145
+ curFull.internal
20945
21146
  );
20946
21147
  }).flat();
20947
21148
  const jsonDropIndexesForAllAlteredTables = allAltered.map((it) => {
@@ -22632,7 +22833,9 @@ var init_migrate = __esm({
22632
22833
  squashedPrev,
22633
22834
  squashedCur,
22634
22835
  tablesResolver,
22635
- columnsResolver
22836
+ columnsResolver,
22837
+ validatedPrev,
22838
+ validatedCur
22636
22839
  );
22637
22840
  writeResult({
22638
22841
  cur,
@@ -22658,7 +22861,9 @@ var init_migrate = __esm({
22658
22861
  squashedPrev,
22659
22862
  squashedCur,
22660
22863
  tablesResolver,
22661
- columnsResolver
22864
+ columnsResolver,
22865
+ validatedPrev,
22866
+ validatedCur
22662
22867
  );
22663
22868
  return {
22664
22869
  sqlStatements,
@@ -24928,14 +25133,14 @@ var require_to_regex_range = __commonJS({
24928
25133
  }
24929
25134
  return tokens;
24930
25135
  }
24931
- function filterPatterns(arr, comparison, prefix, intersection2, options) {
25136
+ function filterPatterns(arr, comparison, prefix, intersection, options) {
24932
25137
  let result = [];
24933
25138
  for (let ele of arr) {
24934
25139
  let { string } = ele;
24935
- if (!intersection2 && !contains(comparison, "string", string)) {
25140
+ if (!intersection && !contains(comparison, "string", string)) {
24936
25141
  result.push(prefix + string);
24937
25142
  }
24938
- if (intersection2 && contains(comparison, "string", string)) {
25143
+ if (intersection && contains(comparison, "string", string)) {
24939
25144
  result.push(prefix + string);
24940
25145
  }
24941
25146
  }
@@ -111934,11 +112139,11 @@ var init_connections = __esm({
111934
112139
  );
111935
112140
  process.exit(1);
111936
112141
  };
111937
- prepareSqliteParams = (params, driver2) => {
112142
+ prepareSqliteParams = (params, driver3) => {
111938
112143
  return params.map((param) => {
111939
112144
  if (param && typeof param === "object" && "type" in param && "value" in param && param.type === "binary") {
111940
112145
  const value = typeof param.value === "object" ? JSON.stringify(param.value) : param.value;
111941
- if (driver2 === "d1-http") {
112146
+ if (driver3 === "d1-http") {
111942
112147
  return value;
111943
112148
  }
111944
112149
  return Buffer.from(value);
@@ -111948,8 +112153,8 @@ var init_connections = __esm({
111948
112153
  };
111949
112154
  connectToSQLite = async (credentials2) => {
111950
112155
  if ("driver" in credentials2) {
111951
- const { driver: driver2 } = credentials2;
111952
- if (driver2 === "turso") {
112156
+ const { driver: driver3 } = credentials2;
112157
+ if (driver3 === "turso") {
111953
112158
  assertPackages("@libsql/client");
111954
112159
  const { createClient: createClient2 } = await import("@libsql/client");
111955
112160
  const { drizzle } = await import("drizzle-orm/libsql");
@@ -111986,7 +112191,7 @@ var init_connections = __esm({
111986
112191
  }
111987
112192
  };
111988
112193
  return { ...db2, ...proxy, migrate: migrateFn };
111989
- } else if (driver2 === "d1-http") {
112194
+ } else if (driver3 === "d1-http") {
111990
112195
  const { drizzle } = await import("drizzle-orm/sqlite-proxy");
111991
112196
  const { migrate } = await import("drizzle-orm/sqlite-proxy/migrator");
111992
112197
  const remoteCallback = async (sql2, params, method) => {
@@ -112046,7 +112251,7 @@ var init_connections = __esm({
112046
112251
  };
112047
112252
  return { ...db2, ...proxy, migrate: migrateFn };
112048
112253
  } else {
112049
- assertUnreachable(driver2);
112254
+ assertUnreachable(driver3);
112050
112255
  }
112051
112256
  }
112052
112257
  if (await checkPackage("@libsql/client")) {
@@ -116820,7 +117025,9 @@ var init_introspect = __esm({
116820
117025
  squashSqliteScheme(drySQLite),
116821
117026
  squashSqliteScheme(schema5),
116822
117027
  tablesResolver,
116823
- columnsResolver
117028
+ columnsResolver,
117029
+ drySQLite,
117030
+ schema5
116824
117031
  );
116825
117032
  writeResult({
116826
117033
  cur: schema5,
@@ -120347,13 +120554,13 @@ var init_studio2 = __esm({
120347
120554
  const customDefaults = getCustomDefaults(sqliteSchema2);
120348
120555
  let dbUrl;
120349
120556
  if ("driver" in credentials2) {
120350
- const { driver: driver2 } = credentials2;
120351
- if (driver2 === "d1-http") {
120557
+ const { driver: driver3 } = credentials2;
120558
+ if (driver3 === "d1-http") {
120352
120559
  dbUrl = `d1-http://${credentials2.accountId}/${credentials2.databaseId}/${credentials2.token}`;
120353
- } else if (driver2 === "turso") {
120560
+ } else if (driver3 === "turso") {
120354
120561
  dbUrl = `turso://${credentials2.url}/${credentials2.authToken}`;
120355
120562
  } else {
120356
- assertUnreachable(driver2);
120563
+ assertUnreachable(driver3);
120357
120564
  }
120358
120565
  } else {
120359
120566
  dbUrl = credentials2.url;
@@ -120465,7 +120672,7 @@ var init_studio2 = __esm({
120465
120672
  };
120466
120673
  prepareServer = async ({
120467
120674
  dialect: dialect7,
120468
- driver: driver2,
120675
+ driver: driver3,
120469
120676
  proxy,
120470
120677
  customDefaults,
120471
120678
  schema: drizzleSchema,
@@ -120515,7 +120722,7 @@ var init_studio2 = __esm({
120515
120722
  return c.json({
120516
120723
  version: "6",
120517
120724
  dialect: dialect7,
120518
- driver: driver2,
120725
+ driver: driver3,
120519
120726
  schemaFiles,
120520
120727
  customDefaults: preparedDefaults,
120521
120728
  relations: extractRelations(relationsConfig),