drizzle-kit 0.22.0-ed86dfa → 0.22.0

Sign up to get free protection for your applications and to get access to all the features.
package/utils.js CHANGED
@@ -569,6 +569,7 @@ __export(utils_exports, {
569
569
  copy: () => copy,
570
570
  dryJournal: () => dryJournal,
571
571
  kloudMeta: () => kloudMeta,
572
+ normaliseSQLiteUrl: () => normaliseSQLiteUrl,
572
573
  objectValues: () => objectValues,
573
574
  prepareMigrationFolder: () => prepareMigrationFolder,
574
575
  prepareMigrationMeta: () => prepareMigrationMeta,
@@ -1078,6 +1079,9 @@ var info = (msg, greyMsg = "") => {
1078
1079
  // src/global.ts
1079
1080
  var originUUID = "00000000-0000-0000-0000-000000000000";
1080
1081
  var snapshotVersion = "7";
1082
+ function assertUnreachable(x) {
1083
+ throw new Error("Didn't expect to get here");
1084
+ }
1081
1085
 
1082
1086
  // node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/index.mjs
1083
1087
  var util;
@@ -4910,7 +4914,16 @@ var kitInternals = objectType({
4910
4914
  objectType({ isDefaultAnExpression: booleanType().optional() }).optional()
4911
4915
  )
4912
4916
  }).optional()
4913
- )
4917
+ ).optional(),
4918
+ indexes: recordType(
4919
+ stringType(),
4920
+ objectType({
4921
+ columns: recordType(
4922
+ stringType(),
4923
+ objectType({ isExpression: booleanType().optional() }).optional()
4924
+ )
4925
+ }).optional()
4926
+ ).optional()
4914
4927
  }).optional();
4915
4928
  var dialect = literalType("mysql");
4916
4929
  var schemaHash = objectType({
@@ -5391,6 +5404,17 @@ var schemaInternalV52 = objectType({
5391
5404
  columns: recordType(stringType(), stringType())
5392
5405
  })
5393
5406
  }).strict();
5407
+ var kitInternals3 = objectType({
5408
+ indexes: recordType(
5409
+ stringType(),
5410
+ objectType({
5411
+ columns: recordType(
5412
+ stringType(),
5413
+ objectType({ isExpression: booleanType().optional() }).optional()
5414
+ )
5415
+ }).optional()
5416
+ ).optional()
5417
+ }).optional();
5394
5418
  var latestVersion = literalType("6");
5395
5419
  var schemaInternal2 = objectType({
5396
5420
  version: latestVersion,
@@ -5400,7 +5424,8 @@ var schemaInternal2 = objectType({
5400
5424
  _meta: objectType({
5401
5425
  tables: recordType(stringType(), stringType()),
5402
5426
  columns: recordType(stringType(), stringType())
5403
- })
5427
+ }),
5428
+ internal: kitInternals3
5404
5429
  }).strict();
5405
5430
  var schemaV32 = schemaInternalV32.merge(schemaHash3).strict();
5406
5431
  var schemaV42 = schemaInternalV42.merge(schemaHash3).strict();
@@ -5437,6 +5462,7 @@ var backwardCompatibleSqliteSchema = unionType([sqliteSchemaV5, schema2]);
5437
5462
 
5438
5463
  // src/utils.ts
5439
5464
  var import_path = require("path");
5465
+ var import_url = require("url");
5440
5466
  var copy = (it) => {
5441
5467
  return JSON.parse(JSON.stringify(it));
5442
5468
  };
@@ -5605,6 +5631,29 @@ var kloudMeta = () => {
5605
5631
  sqlite: []
5606
5632
  };
5607
5633
  };
5634
+ var normaliseSQLiteUrl = (it, type) => {
5635
+ if (type === "libsql") {
5636
+ if (it.startsWith("file:")) {
5637
+ return it;
5638
+ }
5639
+ try {
5640
+ const url = (0, import_url.parse)(it);
5641
+ if (url.protocol === null) {
5642
+ return `file:${it}`;
5643
+ }
5644
+ return it;
5645
+ } catch (e) {
5646
+ return `file:${it}`;
5647
+ }
5648
+ }
5649
+ if (type === "better-sqlite") {
5650
+ if (it.startsWith("file:")) {
5651
+ return it.substring(5);
5652
+ }
5653
+ return it;
5654
+ }
5655
+ assertUnreachable(type);
5656
+ };
5608
5657
  // Annotate the CommonJS export names for ESM import in node:
5609
5658
  0 && (module.exports = {
5610
5659
  assertV1OutFolder,
@@ -5612,6 +5661,7 @@ var kloudMeta = () => {
5612
5661
  copy,
5613
5662
  dryJournal,
5614
5663
  kloudMeta,
5664
+ normaliseSQLiteUrl,
5615
5665
  objectValues,
5616
5666
  prepareMigrationFolder,
5617
5667
  prepareMigrationMeta,
package/utils.mjs CHANGED
@@ -1069,6 +1069,9 @@ var info = (msg, greyMsg = "") => {
1069
1069
  // src/global.ts
1070
1070
  var originUUID = "00000000-0000-0000-0000-000000000000";
1071
1071
  var snapshotVersion = "7";
1072
+ function assertUnreachable(x) {
1073
+ throw new Error("Didn't expect to get here");
1074
+ }
1072
1075
 
1073
1076
  // node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/index.mjs
1074
1077
  var util;
@@ -4901,7 +4904,16 @@ var kitInternals = objectType({
4901
4904
  objectType({ isDefaultAnExpression: booleanType().optional() }).optional()
4902
4905
  )
4903
4906
  }).optional()
4904
- )
4907
+ ).optional(),
4908
+ indexes: recordType(
4909
+ stringType(),
4910
+ objectType({
4911
+ columns: recordType(
4912
+ stringType(),
4913
+ objectType({ isExpression: booleanType().optional() }).optional()
4914
+ )
4915
+ }).optional()
4916
+ ).optional()
4905
4917
  }).optional();
4906
4918
  var dialect = literalType("mysql");
4907
4919
  var schemaHash = objectType({
@@ -5382,6 +5394,17 @@ var schemaInternalV52 = objectType({
5382
5394
  columns: recordType(stringType(), stringType())
5383
5395
  })
5384
5396
  }).strict();
5397
+ var kitInternals3 = objectType({
5398
+ indexes: recordType(
5399
+ stringType(),
5400
+ objectType({
5401
+ columns: recordType(
5402
+ stringType(),
5403
+ objectType({ isExpression: booleanType().optional() }).optional()
5404
+ )
5405
+ }).optional()
5406
+ ).optional()
5407
+ }).optional();
5385
5408
  var latestVersion = literalType("6");
5386
5409
  var schemaInternal2 = objectType({
5387
5410
  version: latestVersion,
@@ -5391,7 +5414,8 @@ var schemaInternal2 = objectType({
5391
5414
  _meta: objectType({
5392
5415
  tables: recordType(stringType(), stringType()),
5393
5416
  columns: recordType(stringType(), stringType())
5394
- })
5417
+ }),
5418
+ internal: kitInternals3
5395
5419
  }).strict();
5396
5420
  var schemaV32 = schemaInternalV32.merge(schemaHash3).strict();
5397
5421
  var schemaV42 = schemaInternalV42.merge(schemaHash3).strict();
@@ -5428,6 +5452,7 @@ var backwardCompatibleSqliteSchema = unionType([sqliteSchemaV5, schema2]);
5428
5452
 
5429
5453
  // src/utils.ts
5430
5454
  import { join } from "path";
5455
+ import { parse } from "url";
5431
5456
  var copy = (it) => {
5432
5457
  return JSON.parse(JSON.stringify(it));
5433
5458
  };
@@ -5596,12 +5621,36 @@ var kloudMeta = () => {
5596
5621
  sqlite: []
5597
5622
  };
5598
5623
  };
5624
+ var normaliseSQLiteUrl = (it, type) => {
5625
+ if (type === "libsql") {
5626
+ if (it.startsWith("file:")) {
5627
+ return it;
5628
+ }
5629
+ try {
5630
+ const url = parse(it);
5631
+ if (url.protocol === null) {
5632
+ return `file:${it}`;
5633
+ }
5634
+ return it;
5635
+ } catch (e) {
5636
+ return `file:${it}`;
5637
+ }
5638
+ }
5639
+ if (type === "better-sqlite") {
5640
+ if (it.startsWith("file:")) {
5641
+ return it.substring(5);
5642
+ }
5643
+ return it;
5644
+ }
5645
+ assertUnreachable(type);
5646
+ };
5599
5647
  export {
5600
5648
  assertV1OutFolder,
5601
5649
  columnRenameKey,
5602
5650
  copy,
5603
5651
  dryJournal,
5604
5652
  kloudMeta,
5653
+ normaliseSQLiteUrl,
5605
5654
  objectValues,
5606
5655
  prepareMigrationFolder,
5607
5656
  prepareMigrationMeta,