drizzle-kit 0.24.2 → 0.25.0-00e689e

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,8 @@
1
+ declare const prefixes: readonly ["index", "timestamp", "supabase", "unix", "none"];
2
+ type Prefix = (typeof prefixes)[number];
3
+ declare const casingTypes: readonly ["snake_case", "camelCase"];
4
+ type CasingType = (typeof casingTypes)[number];
5
+ declare const drivers: readonly ["d1-http", "expo", "aws-data-api", "pglite"];
6
+ type Driver = (typeof drivers)[number];
7
+
8
+ export type { CasingType as C, Driver as D, Prefix as P };
@@ -0,0 +1,8 @@
1
+ declare const prefixes: readonly ["index", "timestamp", "supabase", "unix", "none"];
2
+ type Prefix = (typeof prefixes)[number];
3
+ declare const casingTypes: readonly ["snake_case", "camelCase"];
4
+ type CasingType = (typeof casingTypes)[number];
5
+ declare const drivers: readonly ["d1-http", "expo", "aws-data-api", "pglite"];
6
+ type Driver = (typeof drivers)[number];
7
+
8
+ export type { CasingType as C, Driver as D, Prefix as P };
package/index.d.mts CHANGED
@@ -1,11 +1,7 @@
1
1
  import { ConnectionOptions } from 'tls';
2
+ import { P as Prefix, D as Driver } from './common-DYjgLS6u.mjs';
2
3
 
3
- declare const prefixes: readonly ["index", "timestamp", "supabase", "unix", "none"];
4
- type Prefix = (typeof prefixes)[number];
5
- declare const drivers: readonly ["turso", "d1-http", "expo", "aws-data-api", "pglite"];
6
- type Driver = (typeof drivers)[number];
7
-
8
- declare const dialects: readonly ["postgresql", "mysql", "sqlite"];
4
+ declare const dialects: readonly ["postgresql", "mysql", "sqlite", "turso"];
9
5
  type Dialect = (typeof dialects)[number];
10
6
 
11
7
  type SslOptions = {
@@ -119,6 +115,7 @@ type Config = {
119
115
  schema?: string | string[];
120
116
  verbose?: boolean;
121
117
  strict?: boolean;
118
+ casing?: 'camelCase' | 'snake_case';
122
119
  migrations?: {
123
120
  table?: string;
124
121
  schema?: string;
@@ -128,8 +125,7 @@ type Config = {
128
125
  casing: 'camel' | 'preserve';
129
126
  };
130
127
  } & ({
131
- dialect: Verify<Dialect, 'sqlite'>;
132
- driver: Verify<Driver, 'turso'>;
128
+ dialect: Verify<Dialect, 'turso'>;
133
129
  dbCredentials: {
134
130
  url: string;
135
131
  authToken?: string;
package/index.d.ts CHANGED
@@ -1,11 +1,7 @@
1
1
  import { ConnectionOptions } from 'tls';
2
+ import { P as Prefix, D as Driver } from './common-DYjgLS6u.js';
2
3
 
3
- declare const prefixes: readonly ["index", "timestamp", "supabase", "unix", "none"];
4
- type Prefix = (typeof prefixes)[number];
5
- declare const drivers: readonly ["turso", "d1-http", "expo", "aws-data-api", "pglite"];
6
- type Driver = (typeof drivers)[number];
7
-
8
- declare const dialects: readonly ["postgresql", "mysql", "sqlite"];
4
+ declare const dialects: readonly ["postgresql", "mysql", "sqlite", "turso"];
9
5
  type Dialect = (typeof dialects)[number];
10
6
 
11
7
  type SslOptions = {
@@ -119,6 +115,7 @@ type Config = {
119
115
  schema?: string | string[];
120
116
  verbose?: boolean;
121
117
  strict?: boolean;
118
+ casing?: 'camelCase' | 'snake_case';
122
119
  migrations?: {
123
120
  table?: string;
124
121
  schema?: string;
@@ -128,8 +125,7 @@ type Config = {
128
125
  casing: 'camel' | 'preserve';
129
126
  };
130
127
  } & ({
131
- dialect: Verify<Dialect, 'sqlite'>;
132
- driver: Verify<Driver, 'turso'>;
128
+ dialect: Verify<Dialect, 'turso'>;
133
129
  dbCredentials: {
134
130
  url: string;
135
131
  authToken?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drizzle-kit",
3
- "version": "0.24.2",
3
+ "version": "0.25.0-00e689e",
4
4
  "homepage": "https://orm.drizzle.team",
5
5
  "keywords": [
6
6
  "drizzle",
@@ -54,7 +54,7 @@
54
54
  "@electric-sql/pglite": "^0.1.5",
55
55
  "@hono/node-server": "^1.9.0",
56
56
  "@hono/zod-validator": "^0.2.1",
57
- "@libsql/client": "^0.4.2",
57
+ "@libsql/client": "^0.10.0",
58
58
  "@neondatabase/serverless": "^0.9.1",
59
59
  "@originjs/vite-plugin-commonjs": "^1.0.3",
60
60
  "@planetscale/database": "^1.16.0",
@@ -74,12 +74,13 @@
74
74
  "@vercel/postgres": "^0.8.0",
75
75
  "ava": "^5.1.0",
76
76
  "better-sqlite3": "^9.4.3",
77
+ "bun-types": "^0.6.6",
77
78
  "camelcase": "^7.0.1",
78
79
  "chalk": "^5.2.0",
79
80
  "commander": "^12.1.0",
80
81
  "dockerode": "^3.3.4",
81
82
  "dotenv": "^16.0.3",
82
- "drizzle-kit": "0.21.2",
83
+ "drizzle-kit": "0.25.0-b1faa33",
83
84
  "drizzle-orm": "workspace:./drizzle-orm/dist",
84
85
  "env-paths": "^3.0.0",
85
86
  "esbuild-node-externals": "^1.9.0",
package/utils.js CHANGED
@@ -409,8 +409,8 @@ var require_hanji = __commonJS({
409
409
  };
410
410
  exports2.deferred = deferred;
411
411
  var Terminal = class {
412
- constructor(view, stdin, stdout, closable) {
413
- this.view = view;
412
+ constructor(view4, stdin, stdout, closable) {
413
+ this.view = view4;
414
414
  this.stdin = stdin;
415
415
  this.stdout = stdout;
416
416
  this.closable = closable;
@@ -448,7 +448,7 @@ var require_hanji = __commonJS({
448
448
  this.resolve({ status: "submitted", data: this.view.result() });
449
449
  return;
450
450
  }
451
- view.input(str, key);
451
+ view4.input(str, key);
452
452
  };
453
453
  this.stdin.on("keypress", keypress);
454
454
  this.view.attach(this);
@@ -510,8 +510,8 @@ var require_hanji = __commonJS({
510
510
  };
511
511
  exports2.TaskView = TaskView2;
512
512
  var TaskTerminal = class {
513
- constructor(view, stdout) {
514
- this.view = view;
513
+ constructor(view4, stdout) {
514
+ this.view = view4;
515
515
  this.stdout = stdout;
516
516
  this.text = "";
517
517
  this.view.attach(this);
@@ -530,22 +530,22 @@ var require_hanji = __commonJS({
530
530
  }
531
531
  };
532
532
  exports2.TaskTerminal = TaskTerminal;
533
- function render2(view) {
533
+ function render2(view4) {
534
534
  const { stdin, stdout, closable } = (0, readline_1.prepareReadLine)();
535
- if (view instanceof Prompt2) {
536
- const terminal = new Terminal(view, stdin, stdout, closable);
535
+ if (view4 instanceof Prompt2) {
536
+ const terminal = new Terminal(view4, stdin, stdout, closable);
537
537
  terminal.requestLayout();
538
538
  return terminal.result();
539
539
  }
540
- stdout.write(`${view}
540
+ stdout.write(`${view4}
541
541
  `);
542
542
  closable.close();
543
543
  return;
544
544
  }
545
545
  exports2.render = render2;
546
- function renderWithTask(view, task) {
546
+ function renderWithTask(view4, task) {
547
547
  return __awaiter(this, void 0, void 0, function* () {
548
- const terminal = new TaskTerminal(view, process.stdout);
548
+ const terminal = new TaskTerminal(view4, process.stdout);
549
549
  terminal.requestLayout();
550
550
  const result = yield task;
551
551
  terminal.clear();
@@ -568,6 +568,8 @@ __export(utils_exports, {
568
568
  columnRenameKey: () => columnRenameKey,
569
569
  copy: () => copy,
570
570
  dryJournal: () => dryJournal,
571
+ findAddedAndRemoved: () => findAddedAndRemoved,
572
+ getColumnCasing: () => getColumnCasing,
571
573
  isPgArrayType: () => isPgArrayType,
572
574
  kloudMeta: () => kloudMeta,
573
575
  normalisePGliteUrl: () => normalisePGliteUrl,
@@ -1072,6 +1074,7 @@ var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
1072
1074
  var source_default = chalk;
1073
1075
 
1074
1076
  // src/utils.ts
1077
+ var import_casing = require("drizzle-orm/casing");
1075
1078
  var import_fs = require("fs");
1076
1079
  var import_path = require("path");
1077
1080
  var import_url = require("url");
@@ -4900,6 +4903,10 @@ var uniqueConstraint = objectType({
4900
4903
  name: stringType(),
4901
4904
  columns: stringType().array()
4902
4905
  }).strict();
4906
+ var checkConstraint = objectType({
4907
+ name: stringType(),
4908
+ value: stringType()
4909
+ }).strict();
4903
4910
  var tableV4 = objectType({
4904
4911
  name: stringType(),
4905
4912
  schema: stringType().optional(),
@@ -4913,8 +4920,20 @@ var table = objectType({
4913
4920
  indexes: recordType(stringType(), index),
4914
4921
  foreignKeys: recordType(stringType(), fk),
4915
4922
  compositePrimaryKeys: recordType(stringType(), compositePK),
4916
- uniqueConstraints: recordType(stringType(), uniqueConstraint).default({})
4923
+ uniqueConstraints: recordType(stringType(), uniqueConstraint).default({}),
4924
+ checkConstraint: recordType(stringType(), checkConstraint).default({})
4925
+ }).strict();
4926
+ var viewMeta = objectType({
4927
+ algorithm: enumType(["undefined", "merge", "temptable"]),
4928
+ sqlSecurity: enumType(["definer", "invoker"]),
4929
+ withCheckOption: enumType(["local", "cascaded"]).optional()
4917
4930
  }).strict();
4931
+ var view = objectType({
4932
+ name: stringType(),
4933
+ columns: recordType(stringType(), column),
4934
+ definition: stringType().optional(),
4935
+ isExisting: booleanType()
4936
+ }).strict().merge(viewMeta);
4918
4937
  var kitInternals = objectType({
4919
4938
  tables: recordType(
4920
4939
  stringType(),
@@ -4967,6 +4986,7 @@ var schemaInternal = objectType({
4967
4986
  version: literalType("5"),
4968
4987
  dialect,
4969
4988
  tables: recordType(stringType(), table),
4989
+ views: recordType(stringType(), view),
4970
4990
  _meta: objectType({
4971
4991
  tables: recordType(stringType(), stringType()),
4972
4992
  columns: recordType(stringType(), stringType())
@@ -4990,12 +5010,19 @@ var tableSquashed = objectType({
4990
5010
  indexes: recordType(stringType(), stringType()),
4991
5011
  foreignKeys: recordType(stringType(), stringType()),
4992
5012
  compositePrimaryKeys: recordType(stringType(), stringType()),
4993
- uniqueConstraints: recordType(stringType(), stringType()).default({})
5013
+ uniqueConstraints: recordType(stringType(), stringType()).default({}),
5014
+ checkConstraints: recordType(stringType(), stringType()).default({})
4994
5015
  }).strict();
5016
+ var viewSquashed = view.omit({
5017
+ algorithm: true,
5018
+ sqlSecurity: true,
5019
+ withCheckOption: true
5020
+ }).extend({ meta: stringType() });
4995
5021
  var schemaSquashed = objectType({
4996
5022
  version: literalType("5"),
4997
5023
  dialect,
4998
- tables: recordType(stringType(), tableSquashed)
5024
+ tables: recordType(stringType(), tableSquashed),
5025
+ views: recordType(stringType(), viewSquashed)
4999
5026
  }).strict();
5000
5027
  var schemaSquashedV4 = objectType({
5001
5028
  version: literalType("4"),
@@ -5013,6 +5040,7 @@ var dryMySql = mysqlSchema.parse({
5013
5040
  prevId: "",
5014
5041
  tables: {},
5015
5042
  schemas: {},
5043
+ views: {},
5016
5044
  _meta: {
5017
5045
  schemas: {},
5018
5046
  tables: {},
@@ -5178,6 +5206,10 @@ var column2 = objectType({
5178
5206
  }).optional(),
5179
5207
  identity: sequenceSchema.merge(objectType({ type: enumType(["always", "byDefault"]) })).optional()
5180
5208
  }).strict();
5209
+ var checkConstraint2 = objectType({
5210
+ name: stringType(),
5211
+ value: stringType()
5212
+ }).strict();
5181
5213
  var columnSquashed = objectType({
5182
5214
  name: stringType(),
5183
5215
  type: stringType(),
@@ -5209,6 +5241,44 @@ var uniqueConstraint2 = objectType({
5209
5241
  columns: stringType().array(),
5210
5242
  nullsNotDistinct: booleanType()
5211
5243
  }).strict();
5244
+ var viewWithOption = objectType({
5245
+ checkOption: enumType(["local", "cascaded"]).optional(),
5246
+ securityBarrier: booleanType().optional(),
5247
+ securityInvoker: booleanType().optional()
5248
+ }).strict();
5249
+ var matViewWithOption = objectType({
5250
+ fillfactor: numberType().optional(),
5251
+ toastTupleTarget: numberType().optional(),
5252
+ parallelWorkers: numberType().optional(),
5253
+ autovacuumEnabled: booleanType().optional(),
5254
+ vacuumIndexCleanup: enumType(["auto", "off", "on"]).optional(),
5255
+ vacuumTruncate: booleanType().optional(),
5256
+ autovacuumVacuumThreshold: numberType().optional(),
5257
+ autovacuumVacuumScaleFactor: numberType().optional(),
5258
+ autovacuumVacuumCostDelay: numberType().optional(),
5259
+ autovacuumVacuumCostLimit: numberType().optional(),
5260
+ autovacuumFreezeMinAge: numberType().optional(),
5261
+ autovacuumFreezeMaxAge: numberType().optional(),
5262
+ autovacuumFreezeTableAge: numberType().optional(),
5263
+ autovacuumMultixactFreezeMinAge: numberType().optional(),
5264
+ autovacuumMultixactFreezeMaxAge: numberType().optional(),
5265
+ autovacuumMultixactFreezeTableAge: numberType().optional(),
5266
+ logAutovacuumMinDuration: numberType().optional(),
5267
+ userCatalogTable: booleanType().optional()
5268
+ }).strict();
5269
+ var mergedViewWithOption = viewWithOption.merge(matViewWithOption).strict();
5270
+ var view2 = objectType({
5271
+ name: stringType(),
5272
+ schema: stringType(),
5273
+ columns: recordType(stringType(), column2),
5274
+ definition: stringType().optional(),
5275
+ materialized: booleanType(),
5276
+ with: mergedViewWithOption.optional(),
5277
+ isExisting: booleanType(),
5278
+ withNoData: booleanType().optional(),
5279
+ using: stringType().optional(),
5280
+ tablespace: stringType().optional()
5281
+ }).strict();
5212
5282
  var tableV42 = objectType({
5213
5283
  name: stringType(),
5214
5284
  schema: stringType(),
@@ -5250,7 +5320,8 @@ var table2 = objectType({
5250
5320
  indexes: recordType(stringType(), index2),
5251
5321
  foreignKeys: recordType(stringType(), fk2),
5252
5322
  compositePrimaryKeys: recordType(stringType(), compositePK2),
5253
- uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
5323
+ uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({}),
5324
+ checkConstraints: recordType(stringType(), checkConstraint2).default({})
5254
5325
  }).strict();
5255
5326
  var schemaHash2 = objectType({
5256
5327
  id: stringType(),
@@ -5343,6 +5414,7 @@ var pgSchemaInternal = objectType({
5343
5414
  tables: recordType(stringType(), table2),
5344
5415
  enums: recordType(stringType(), enumSchema),
5345
5416
  schemas: recordType(stringType(), stringType()),
5417
+ views: recordType(stringType(), view2).default({}),
5346
5418
  sequences: recordType(stringType(), sequenceSchema).default({}),
5347
5419
  _meta: objectType({
5348
5420
  schemas: recordType(stringType(), stringType()),
@@ -5358,7 +5430,8 @@ var tableSquashed2 = objectType({
5358
5430
  indexes: recordType(stringType(), stringType()),
5359
5431
  foreignKeys: recordType(stringType(), stringType()),
5360
5432
  compositePrimaryKeys: recordType(stringType(), stringType()),
5361
- uniqueConstraints: recordType(stringType(), stringType())
5433
+ uniqueConstraints: recordType(stringType(), stringType()),
5434
+ checkConstraints: recordType(stringType(), stringType())
5362
5435
  }).strict();
5363
5436
  var tableSquashedV42 = objectType({
5364
5437
  name: stringType(),
@@ -5387,6 +5460,7 @@ var pgSchemaSquashed = objectType({
5387
5460
  tables: recordType(stringType(), tableSquashed2),
5388
5461
  enums: recordType(stringType(), enumSchema),
5389
5462
  schemas: recordType(stringType(), stringType()),
5463
+ views: recordType(stringType(), view2),
5390
5464
  sequences: recordType(stringType(), sequenceSquashed)
5391
5465
  }).strict();
5392
5466
  var pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash2);
@@ -5458,13 +5532,24 @@ var uniqueConstraint3 = objectType({
5458
5532
  name: stringType(),
5459
5533
  columns: stringType().array()
5460
5534
  }).strict();
5535
+ var checkConstraint3 = objectType({
5536
+ name: stringType(),
5537
+ value: stringType()
5538
+ }).strict();
5461
5539
  var table3 = objectType({
5462
5540
  name: stringType(),
5463
5541
  columns: recordType(stringType(), column3),
5464
5542
  indexes: recordType(stringType(), index3),
5465
5543
  foreignKeys: recordType(stringType(), fk3),
5466
5544
  compositePrimaryKeys: recordType(stringType(), compositePK3),
5467
- uniqueConstraints: recordType(stringType(), uniqueConstraint3).default({})
5545
+ uniqueConstraints: recordType(stringType(), uniqueConstraint3).default({}),
5546
+ checkConstraints: recordType(stringType(), checkConstraint3).default({})
5547
+ }).strict();
5548
+ var view3 = objectType({
5549
+ name: stringType(),
5550
+ columns: recordType(stringType(), column3),
5551
+ definition: stringType().optional(),
5552
+ isExisting: booleanType()
5468
5553
  }).strict();
5469
5554
  var dialect2 = enumType(["sqlite"]);
5470
5555
  var schemaHash3 = objectType({
@@ -5481,6 +5566,7 @@ var schemaInternalV42 = objectType({
5481
5566
  version: literalType("4"),
5482
5567
  dialect: dialect2,
5483
5568
  tables: recordType(stringType(), table3),
5569
+ views: recordType(stringType(), view3),
5484
5570
  enums: objectType({})
5485
5571
  }).strict();
5486
5572
  var schemaInternalV52 = objectType({
@@ -5509,6 +5595,7 @@ var schemaInternal2 = objectType({
5509
5595
  version: latestVersion,
5510
5596
  dialect: dialect2,
5511
5597
  tables: recordType(stringType(), table3),
5598
+ views: recordType(stringType(), view3),
5512
5599
  enums: objectType({}),
5513
5600
  _meta: objectType({
5514
5601
  tables: recordType(stringType(), stringType()),
@@ -5526,12 +5613,14 @@ var tableSquashed3 = objectType({
5526
5613
  indexes: recordType(stringType(), stringType()),
5527
5614
  foreignKeys: recordType(stringType(), stringType()),
5528
5615
  compositePrimaryKeys: recordType(stringType(), stringType()),
5529
- uniqueConstraints: recordType(stringType(), stringType()).default({})
5616
+ uniqueConstraints: recordType(stringType(), stringType()).default({}),
5617
+ checkConstraints: recordType(stringType(), stringType()).default({})
5530
5618
  }).strict();
5531
5619
  var schemaSquashed2 = objectType({
5532
5620
  version: latestVersion,
5533
5621
  dialect: dialect2,
5534
5622
  tables: recordType(stringType(), tableSquashed3),
5623
+ views: recordType(stringType(), view3),
5535
5624
  enums: anyType()
5536
5625
  }).strict();
5537
5626
  var drySQLite = schema2.parse({
@@ -5540,6 +5629,7 @@ var drySQLite = schema2.parse({
5540
5629
  id: originUUID,
5541
5630
  prevId: "",
5542
5631
  tables: {},
5632
+ views: {},
5543
5633
  enums: {},
5544
5634
  _meta: {
5545
5635
  tables: {},
@@ -5596,6 +5686,8 @@ var validatorForDialect = (dialect3) => {
5596
5686
  return { validator: backwardCompatiblePgSchema, version: 7 };
5597
5687
  case "sqlite":
5598
5688
  return { validator: backwardCompatibleSqliteSchema, version: 6 };
5689
+ case "turso":
5690
+ return { validator: backwardCompatibleSqliteSchema, version: 6 };
5599
5691
  case "mysql":
5600
5692
  return { validator: backwardCompatibleMysqlSchema, version: 5 };
5601
5693
  }
@@ -5750,12 +5842,26 @@ var normalisePGliteUrl = (it) => {
5750
5842
  function isPgArrayType(sqlType) {
5751
5843
  return sqlType.match(/.*\[\d*\].*|.*\[\].*/g) !== null;
5752
5844
  }
5845
+ function findAddedAndRemoved(columnNames1, columnNames2) {
5846
+ const set1 = new Set(columnNames1);
5847
+ const set2 = new Set(columnNames2);
5848
+ const addedColumns = columnNames2.filter((it) => !set1.has(it));
5849
+ const removedColumns = columnNames1.filter((it) => !set2.has(it));
5850
+ return { addedColumns, removedColumns };
5851
+ }
5852
+ function getColumnCasing(column4, casing) {
5853
+ if (!column4.name)
5854
+ return "";
5855
+ return !column4.keyAsName || casing === void 0 ? column4.name : casing === "camelCase" ? (0, import_casing.toCamelCase)(column4.name) : (0, import_casing.toSnakeCase)(column4.name);
5856
+ }
5753
5857
  // Annotate the CommonJS export names for ESM import in node:
5754
5858
  0 && (module.exports = {
5755
5859
  assertV1OutFolder,
5756
5860
  columnRenameKey,
5757
5861
  copy,
5758
5862
  dryJournal,
5863
+ findAddedAndRemoved,
5864
+ getColumnCasing,
5759
5865
  isPgArrayType,
5760
5866
  kloudMeta,
5761
5867
  normalisePGliteUrl,