drizzle-kit 0.21.4 → 0.22.0-407e2e6

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,
@@ -1077,7 +1078,10 @@ var info = (msg, greyMsg = "") => {
1077
1078
 
1078
1079
  // src/global.ts
1079
1080
  var originUUID = "00000000-0000-0000-0000-000000000000";
1080
- var snapshotVersion = "6";
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;
@@ -5060,10 +5064,48 @@ var pgSchemaV1 = objectType({
5060
5064
  tables: recordType(stringType(), tableV1),
5061
5065
  enums: recordType(stringType(), enumSchemaV1)
5062
5066
  }).strict();
5067
+ var indexColumn = objectType({
5068
+ expression: stringType(),
5069
+ isExpression: booleanType(),
5070
+ asc: booleanType(),
5071
+ nulls: stringType().optional(),
5072
+ opclass: stringType().optional()
5073
+ });
5063
5074
  var index2 = objectType({
5075
+ name: stringType(),
5076
+ columns: indexColumn.array(),
5077
+ isUnique: booleanType(),
5078
+ with: recordType(stringType(), anyType()).optional(),
5079
+ method: stringType().default("btree"),
5080
+ where: stringType().optional(),
5081
+ concurrently: booleanType().default(false)
5082
+ }).strict();
5083
+ var indexV4 = objectType({
5064
5084
  name: stringType(),
5065
5085
  columns: stringType().array(),
5066
- isUnique: booleanType()
5086
+ isUnique: booleanType(),
5087
+ with: recordType(stringType(), stringType()).optional(),
5088
+ method: stringType().default("btree"),
5089
+ where: stringType().optional(),
5090
+ concurrently: booleanType().default(false)
5091
+ }).strict();
5092
+ var indexV5 = objectType({
5093
+ name: stringType(),
5094
+ columns: stringType().array(),
5095
+ isUnique: booleanType(),
5096
+ with: recordType(stringType(), stringType()).optional(),
5097
+ method: stringType().default("btree"),
5098
+ where: stringType().optional(),
5099
+ concurrently: booleanType().default(false)
5100
+ }).strict();
5101
+ var indexV6 = objectType({
5102
+ name: stringType(),
5103
+ columns: stringType().array(),
5104
+ isUnique: booleanType(),
5105
+ with: recordType(stringType(), stringType()).optional(),
5106
+ method: stringType().default("btree"),
5107
+ where: stringType().optional(),
5108
+ concurrently: booleanType().default(false)
5067
5109
  }).strict();
5068
5110
  var fk2 = objectType({
5069
5111
  name: stringType(),
@@ -5105,9 +5147,27 @@ var tableV42 = objectType({
5105
5147
  name: stringType(),
5106
5148
  schema: stringType(),
5107
5149
  columns: recordType(stringType(), column2),
5108
- indexes: recordType(stringType(), index2),
5150
+ indexes: recordType(stringType(), indexV4),
5109
5151
  foreignKeys: recordType(stringType(), fk2)
5110
5152
  }).strict();
5153
+ var tableV6 = objectType({
5154
+ name: stringType(),
5155
+ schema: stringType(),
5156
+ columns: recordType(stringType(), column2),
5157
+ indexes: recordType(stringType(), indexV6),
5158
+ foreignKeys: recordType(stringType(), fk2),
5159
+ compositePrimaryKeys: recordType(stringType(), compositePK2),
5160
+ uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
5161
+ }).strict();
5162
+ var tableV5 = objectType({
5163
+ name: stringType(),
5164
+ schema: stringType(),
5165
+ columns: recordType(stringType(), column2),
5166
+ indexes: recordType(stringType(), indexV5),
5167
+ foreignKeys: recordType(stringType(), fk2),
5168
+ compositePrimaryKeys: recordType(stringType(), compositePK2),
5169
+ uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
5170
+ }).strict();
5111
5171
  var table2 = objectType({
5112
5172
  name: stringType(),
5113
5173
  schema: stringType(),
@@ -5152,7 +5212,7 @@ var pgSchemaInternalV4 = objectType({
5152
5212
  var pgSchemaInternalV5 = objectType({
5153
5213
  version: literalType("5"),
5154
5214
  dialect: literalType("pg"),
5155
- tables: recordType(stringType(), table2),
5215
+ tables: recordType(stringType(), tableV5),
5156
5216
  enums: recordType(stringType(), enumSchemaV1),
5157
5217
  schemas: recordType(stringType(), stringType()),
5158
5218
  _meta: objectType({
@@ -5162,6 +5222,19 @@ var pgSchemaInternalV5 = objectType({
5162
5222
  }),
5163
5223
  internal: kitInternals2
5164
5224
  }).strict();
5225
+ var pgSchemaInternalV6 = objectType({
5226
+ version: literalType("6"),
5227
+ dialect: literalType("postgresql"),
5228
+ tables: recordType(stringType(), tableV6),
5229
+ enums: recordType(stringType(), enumSchema),
5230
+ schemas: recordType(stringType(), stringType()),
5231
+ _meta: objectType({
5232
+ schemas: recordType(stringType(), stringType()),
5233
+ tables: recordType(stringType(), stringType()),
5234
+ columns: recordType(stringType(), stringType())
5235
+ }),
5236
+ internal: kitInternals2
5237
+ }).strict();
5165
5238
  var pgSchemaExternal = objectType({
5166
5239
  version: literalType("5"),
5167
5240
  dialect: literalType("pg"),
@@ -5175,7 +5248,7 @@ var pgSchemaExternal = objectType({
5175
5248
  })
5176
5249
  }).strict();
5177
5250
  var pgSchemaInternal = objectType({
5178
- version: literalType("6"),
5251
+ version: literalType("7"),
5179
5252
  dialect: literalType("postgresql"),
5180
5253
  tables: recordType(stringType(), table2),
5181
5254
  enums: recordType(stringType(), enumSchema),
@@ -5210,18 +5283,30 @@ var pgSchemaSquashedV4 = objectType({
5210
5283
  enums: recordType(stringType(), enumSchemaV1),
5211
5284
  schemas: recordType(stringType(), stringType())
5212
5285
  }).strict();
5213
- var pgSchemaSquashed = objectType({
5286
+ var pgSchemaSquashedV6 = objectType({
5214
5287
  version: literalType("6"),
5215
5288
  dialect: literalType("postgresql"),
5216
5289
  tables: recordType(stringType(), tableSquashed2),
5217
5290
  enums: recordType(stringType(), enumSchema),
5218
5291
  schemas: recordType(stringType(), stringType())
5219
5292
  }).strict();
5293
+ var pgSchemaSquashed = objectType({
5294
+ version: literalType("7"),
5295
+ dialect: literalType("postgresql"),
5296
+ tables: recordType(stringType(), tableSquashed2),
5297
+ enums: recordType(stringType(), enumSchema),
5298
+ schemas: recordType(stringType(), stringType())
5299
+ }).strict();
5220
5300
  var pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash2);
5221
5301
  var pgSchemaV4 = pgSchemaInternalV4.merge(schemaHash2);
5222
5302
  var pgSchemaV5 = pgSchemaInternalV5.merge(schemaHash2);
5303
+ var pgSchemaV6 = pgSchemaInternalV6.merge(schemaHash2);
5223
5304
  var pgSchema = pgSchemaInternal.merge(schemaHash2);
5224
- var backwardCompatiblePgSchema = unionType([pgSchemaV5, pgSchema]);
5305
+ var backwardCompatiblePgSchema = unionType([
5306
+ pgSchemaV5,
5307
+ pgSchemaV6,
5308
+ pgSchema
5309
+ ]);
5225
5310
  var dryPg = pgSchema.parse({
5226
5311
  version: snapshotVersion,
5227
5312
  dialect: "postgresql",
@@ -5356,6 +5441,7 @@ var backwardCompatibleSqliteSchema = unionType([sqliteSchemaV5, schema2]);
5356
5441
 
5357
5442
  // src/utils.ts
5358
5443
  var import_path = require("path");
5444
+ var import_url = require("url");
5359
5445
  var copy = (it) => {
5360
5446
  return JSON.parse(JSON.stringify(it));
5361
5447
  };
@@ -5399,7 +5485,7 @@ var prepareOutFolder = (out, dialect3) => {
5399
5485
  var validatorForDialect = (dialect3) => {
5400
5486
  switch (dialect3) {
5401
5487
  case "postgresql":
5402
- return { validator: backwardCompatiblePgSchema, version: 6 };
5488
+ return { validator: backwardCompatiblePgSchema, version: 7 };
5403
5489
  case "sqlite":
5404
5490
  return { validator: backwardCompatibleSqliteSchema, version: 6 };
5405
5491
  case "mysql":
@@ -5524,6 +5610,29 @@ var kloudMeta = () => {
5524
5610
  sqlite: []
5525
5611
  };
5526
5612
  };
5613
+ var normaliseSQLiteUrl = (it, type) => {
5614
+ if (type === "libsql") {
5615
+ if (it.startsWith("file:")) {
5616
+ return it;
5617
+ }
5618
+ try {
5619
+ const url = (0, import_url.parse)(it);
5620
+ if (url.protocol === null) {
5621
+ return `file:${it}`;
5622
+ }
5623
+ return it;
5624
+ } catch (e) {
5625
+ return `file:${it}`;
5626
+ }
5627
+ }
5628
+ if (type === "better-sqlite") {
5629
+ if (it.startsWith("file:")) {
5630
+ return it.substring(5);
5631
+ }
5632
+ return it;
5633
+ }
5634
+ assertUnreachable(type);
5635
+ };
5527
5636
  // Annotate the CommonJS export names for ESM import in node:
5528
5637
  0 && (module.exports = {
5529
5638
  assertV1OutFolder,
@@ -5531,6 +5640,7 @@ var kloudMeta = () => {
5531
5640
  copy,
5532
5641
  dryJournal,
5533
5642
  kloudMeta,
5643
+ normaliseSQLiteUrl,
5534
5644
  objectValues,
5535
5645
  prepareMigrationFolder,
5536
5646
  prepareMigrationMeta,
package/utils.mjs CHANGED
@@ -1068,7 +1068,10 @@ var info = (msg, greyMsg = "") => {
1068
1068
 
1069
1069
  // src/global.ts
1070
1070
  var originUUID = "00000000-0000-0000-0000-000000000000";
1071
- var snapshotVersion = "6";
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;
@@ -5051,10 +5054,48 @@ var pgSchemaV1 = objectType({
5051
5054
  tables: recordType(stringType(), tableV1),
5052
5055
  enums: recordType(stringType(), enumSchemaV1)
5053
5056
  }).strict();
5057
+ var indexColumn = objectType({
5058
+ expression: stringType(),
5059
+ isExpression: booleanType(),
5060
+ asc: booleanType(),
5061
+ nulls: stringType().optional(),
5062
+ opclass: stringType().optional()
5063
+ });
5054
5064
  var index2 = objectType({
5065
+ name: stringType(),
5066
+ columns: indexColumn.array(),
5067
+ isUnique: booleanType(),
5068
+ with: recordType(stringType(), anyType()).optional(),
5069
+ method: stringType().default("btree"),
5070
+ where: stringType().optional(),
5071
+ concurrently: booleanType().default(false)
5072
+ }).strict();
5073
+ var indexV4 = objectType({
5055
5074
  name: stringType(),
5056
5075
  columns: stringType().array(),
5057
- isUnique: booleanType()
5076
+ isUnique: booleanType(),
5077
+ with: recordType(stringType(), stringType()).optional(),
5078
+ method: stringType().default("btree"),
5079
+ where: stringType().optional(),
5080
+ concurrently: booleanType().default(false)
5081
+ }).strict();
5082
+ var indexV5 = objectType({
5083
+ name: stringType(),
5084
+ columns: stringType().array(),
5085
+ isUnique: booleanType(),
5086
+ with: recordType(stringType(), stringType()).optional(),
5087
+ method: stringType().default("btree"),
5088
+ where: stringType().optional(),
5089
+ concurrently: booleanType().default(false)
5090
+ }).strict();
5091
+ var indexV6 = objectType({
5092
+ name: stringType(),
5093
+ columns: stringType().array(),
5094
+ isUnique: booleanType(),
5095
+ with: recordType(stringType(), stringType()).optional(),
5096
+ method: stringType().default("btree"),
5097
+ where: stringType().optional(),
5098
+ concurrently: booleanType().default(false)
5058
5099
  }).strict();
5059
5100
  var fk2 = objectType({
5060
5101
  name: stringType(),
@@ -5096,9 +5137,27 @@ var tableV42 = objectType({
5096
5137
  name: stringType(),
5097
5138
  schema: stringType(),
5098
5139
  columns: recordType(stringType(), column2),
5099
- indexes: recordType(stringType(), index2),
5140
+ indexes: recordType(stringType(), indexV4),
5100
5141
  foreignKeys: recordType(stringType(), fk2)
5101
5142
  }).strict();
5143
+ var tableV6 = objectType({
5144
+ name: stringType(),
5145
+ schema: stringType(),
5146
+ columns: recordType(stringType(), column2),
5147
+ indexes: recordType(stringType(), indexV6),
5148
+ foreignKeys: recordType(stringType(), fk2),
5149
+ compositePrimaryKeys: recordType(stringType(), compositePK2),
5150
+ uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
5151
+ }).strict();
5152
+ var tableV5 = objectType({
5153
+ name: stringType(),
5154
+ schema: stringType(),
5155
+ columns: recordType(stringType(), column2),
5156
+ indexes: recordType(stringType(), indexV5),
5157
+ foreignKeys: recordType(stringType(), fk2),
5158
+ compositePrimaryKeys: recordType(stringType(), compositePK2),
5159
+ uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
5160
+ }).strict();
5102
5161
  var table2 = objectType({
5103
5162
  name: stringType(),
5104
5163
  schema: stringType(),
@@ -5143,7 +5202,7 @@ var pgSchemaInternalV4 = objectType({
5143
5202
  var pgSchemaInternalV5 = objectType({
5144
5203
  version: literalType("5"),
5145
5204
  dialect: literalType("pg"),
5146
- tables: recordType(stringType(), table2),
5205
+ tables: recordType(stringType(), tableV5),
5147
5206
  enums: recordType(stringType(), enumSchemaV1),
5148
5207
  schemas: recordType(stringType(), stringType()),
5149
5208
  _meta: objectType({
@@ -5153,6 +5212,19 @@ var pgSchemaInternalV5 = objectType({
5153
5212
  }),
5154
5213
  internal: kitInternals2
5155
5214
  }).strict();
5215
+ var pgSchemaInternalV6 = objectType({
5216
+ version: literalType("6"),
5217
+ dialect: literalType("postgresql"),
5218
+ tables: recordType(stringType(), tableV6),
5219
+ enums: recordType(stringType(), enumSchema),
5220
+ schemas: recordType(stringType(), stringType()),
5221
+ _meta: objectType({
5222
+ schemas: recordType(stringType(), stringType()),
5223
+ tables: recordType(stringType(), stringType()),
5224
+ columns: recordType(stringType(), stringType())
5225
+ }),
5226
+ internal: kitInternals2
5227
+ }).strict();
5156
5228
  var pgSchemaExternal = objectType({
5157
5229
  version: literalType("5"),
5158
5230
  dialect: literalType("pg"),
@@ -5166,7 +5238,7 @@ var pgSchemaExternal = objectType({
5166
5238
  })
5167
5239
  }).strict();
5168
5240
  var pgSchemaInternal = objectType({
5169
- version: literalType("6"),
5241
+ version: literalType("7"),
5170
5242
  dialect: literalType("postgresql"),
5171
5243
  tables: recordType(stringType(), table2),
5172
5244
  enums: recordType(stringType(), enumSchema),
@@ -5201,18 +5273,30 @@ var pgSchemaSquashedV4 = objectType({
5201
5273
  enums: recordType(stringType(), enumSchemaV1),
5202
5274
  schemas: recordType(stringType(), stringType())
5203
5275
  }).strict();
5204
- var pgSchemaSquashed = objectType({
5276
+ var pgSchemaSquashedV6 = objectType({
5205
5277
  version: literalType("6"),
5206
5278
  dialect: literalType("postgresql"),
5207
5279
  tables: recordType(stringType(), tableSquashed2),
5208
5280
  enums: recordType(stringType(), enumSchema),
5209
5281
  schemas: recordType(stringType(), stringType())
5210
5282
  }).strict();
5283
+ var pgSchemaSquashed = objectType({
5284
+ version: literalType("7"),
5285
+ dialect: literalType("postgresql"),
5286
+ tables: recordType(stringType(), tableSquashed2),
5287
+ enums: recordType(stringType(), enumSchema),
5288
+ schemas: recordType(stringType(), stringType())
5289
+ }).strict();
5211
5290
  var pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash2);
5212
5291
  var pgSchemaV4 = pgSchemaInternalV4.merge(schemaHash2);
5213
5292
  var pgSchemaV5 = pgSchemaInternalV5.merge(schemaHash2);
5293
+ var pgSchemaV6 = pgSchemaInternalV6.merge(schemaHash2);
5214
5294
  var pgSchema = pgSchemaInternal.merge(schemaHash2);
5215
- var backwardCompatiblePgSchema = unionType([pgSchemaV5, pgSchema]);
5295
+ var backwardCompatiblePgSchema = unionType([
5296
+ pgSchemaV5,
5297
+ pgSchemaV6,
5298
+ pgSchema
5299
+ ]);
5216
5300
  var dryPg = pgSchema.parse({
5217
5301
  version: snapshotVersion,
5218
5302
  dialect: "postgresql",
@@ -5347,6 +5431,7 @@ var backwardCompatibleSqliteSchema = unionType([sqliteSchemaV5, schema2]);
5347
5431
 
5348
5432
  // src/utils.ts
5349
5433
  import { join } from "path";
5434
+ import { parse } from "url";
5350
5435
  var copy = (it) => {
5351
5436
  return JSON.parse(JSON.stringify(it));
5352
5437
  };
@@ -5390,7 +5475,7 @@ var prepareOutFolder = (out, dialect3) => {
5390
5475
  var validatorForDialect = (dialect3) => {
5391
5476
  switch (dialect3) {
5392
5477
  case "postgresql":
5393
- return { validator: backwardCompatiblePgSchema, version: 6 };
5478
+ return { validator: backwardCompatiblePgSchema, version: 7 };
5394
5479
  case "sqlite":
5395
5480
  return { validator: backwardCompatibleSqliteSchema, version: 6 };
5396
5481
  case "mysql":
@@ -5515,12 +5600,36 @@ var kloudMeta = () => {
5515
5600
  sqlite: []
5516
5601
  };
5517
5602
  };
5603
+ var normaliseSQLiteUrl = (it, type) => {
5604
+ if (type === "libsql") {
5605
+ if (it.startsWith("file:")) {
5606
+ return it;
5607
+ }
5608
+ try {
5609
+ const url = parse(it);
5610
+ if (url.protocol === null) {
5611
+ return `file:${it}`;
5612
+ }
5613
+ return it;
5614
+ } catch (e) {
5615
+ return `file:${it}`;
5616
+ }
5617
+ }
5618
+ if (type === "better-sqlite") {
5619
+ if (it.startsWith("file:")) {
5620
+ return it.substring(5);
5621
+ }
5622
+ return it;
5623
+ }
5624
+ assertUnreachable(type);
5625
+ };
5518
5626
  export {
5519
5627
  assertV1OutFolder,
5520
5628
  columnRenameKey,
5521
5629
  copy,
5522
5630
  dryJournal,
5523
5631
  kloudMeta,
5632
+ normaliseSQLiteUrl,
5524
5633
  objectValues,
5525
5634
  prepareMigrationFolder,
5526
5635
  prepareMigrationMeta,