drizzle-kit 0.25.0-5a1c5d3 → 0.25.0-662aa35

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.
@@ -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,9 +1,5 @@
1
1
  import { ConnectionOptions } from 'tls';
2
-
3
- declare const prefixes: readonly ["index", "timestamp", "supabase", "unix", "none"];
4
- type Prefix = (typeof prefixes)[number];
5
- declare const drivers: readonly ["d1-http", "expo", "aws-data-api", "pglite"];
6
- type Driver = (typeof drivers)[number];
2
+ import { P as Prefix, D as Driver } from './common-DYjgLS6u.mjs';
7
3
 
8
4
  declare const dialects: readonly ["postgresql", "mysql", "sqlite", "turso"];
9
5
  type Dialect = (typeof dialects)[number];
@@ -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;
@@ -127,6 +124,13 @@ type Config = {
127
124
  introspect?: {
128
125
  casing: 'camel' | 'preserve';
129
126
  };
127
+ entities?: {
128
+ roles?: boolean | {
129
+ provider?: string;
130
+ exclude?: string[];
131
+ include?: string[];
132
+ }[];
133
+ };
130
134
  } & ({
131
135
  dialect: Verify<Dialect, 'turso'>;
132
136
  dbCredentials: {
package/index.d.ts CHANGED
@@ -1,9 +1,5 @@
1
1
  import { ConnectionOptions } from 'tls';
2
-
3
- declare const prefixes: readonly ["index", "timestamp", "supabase", "unix", "none"];
4
- type Prefix = (typeof prefixes)[number];
5
- declare const drivers: readonly ["d1-http", "expo", "aws-data-api", "pglite"];
6
- type Driver = (typeof drivers)[number];
2
+ import { P as Prefix, D as Driver } from './common-DYjgLS6u.js';
7
3
 
8
4
  declare const dialects: readonly ["postgresql", "mysql", "sqlite", "turso"];
9
5
  type Dialect = (typeof dialects)[number];
@@ -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;
@@ -127,6 +124,13 @@ type Config = {
127
124
  introspect?: {
128
125
  casing: 'camel' | 'preserve';
129
126
  };
127
+ entities?: {
128
+ roles?: boolean | {
129
+ provider?: string;
130
+ exclude?: string[];
131
+ include?: string[];
132
+ }[];
133
+ };
130
134
  } & ({
131
135
  dialect: Verify<Dialect, 'turso'>;
132
136
  dbCredentials: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drizzle-kit",
3
- "version": "0.25.0-5a1c5d3",
3
+ "version": "0.25.0-662aa35",
4
4
  "homepage": "https://orm.drizzle.team",
5
5
  "keywords": [
6
6
  "drizzle",
@@ -51,7 +51,7 @@
51
51
  "@arethetypeswrong/cli": "^0.15.3",
52
52
  "@aws-sdk/client-rds-data": "^3.556.0",
53
53
  "@cloudflare/workers-types": "^4.20230518.0",
54
- "@electric-sql/pglite": "^0.1.5",
54
+ "@electric-sql/pglite": "^0.2.5",
55
55
  "@hono/node-server": "^1.9.0",
56
56
  "@hono/zod-validator": "^0.2.1",
57
57
  "@libsql/client": "^0.10.0",
@@ -80,7 +80,7 @@
80
80
  "commander": "^12.1.0",
81
81
  "dockerode": "^3.3.4",
82
82
  "dotenv": "^16.0.3",
83
- "drizzle-kit": "0.21.2",
83
+ "drizzle-kit": "0.25.0-b1faa33",
84
84
  "drizzle-orm": "workspace:./drizzle-orm/dist",
85
85
  "env-paths": "^3.0.0",
86
86
  "esbuild-node-externals": "^1.9.0",
package/utils.js CHANGED
@@ -569,6 +569,7 @@ __export(utils_exports, {
569
569
  copy: () => copy,
570
570
  dryJournal: () => dryJournal,
571
571
  findAddedAndRemoved: () => findAddedAndRemoved,
572
+ getColumnCasing: () => getColumnCasing,
572
573
  isPgArrayType: () => isPgArrayType,
573
574
  kloudMeta: () => kloudMeta,
574
575
  normalisePGliteUrl: () => normalisePGliteUrl,
@@ -1073,6 +1074,7 @@ var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
1073
1074
  var source_default = chalk;
1074
1075
 
1075
1076
  // src/utils.ts
1077
+ var import_casing = require("drizzle-orm/casing");
1076
1078
  var import_fs = require("fs");
1077
1079
  var import_path = require("path");
1078
1080
  var import_url = require("url");
@@ -4901,10 +4903,6 @@ var uniqueConstraint = objectType({
4901
4903
  name: stringType(),
4902
4904
  columns: stringType().array()
4903
4905
  }).strict();
4904
- var checkConstraint = objectType({
4905
- name: stringType(),
4906
- value: stringType()
4907
- }).strict();
4908
4906
  var tableV4 = objectType({
4909
4907
  name: stringType(),
4910
4908
  schema: stringType().optional(),
@@ -4918,8 +4916,7 @@ var table = objectType({
4918
4916
  indexes: recordType(stringType(), index),
4919
4917
  foreignKeys: recordType(stringType(), fk),
4920
4918
  compositePrimaryKeys: recordType(stringType(), compositePK),
4921
- uniqueConstraints: recordType(stringType(), uniqueConstraint).default({}),
4922
- checkConstraint: recordType(stringType(), checkConstraint).default({})
4919
+ uniqueConstraints: recordType(stringType(), uniqueConstraint).default({})
4923
4920
  }).strict();
4924
4921
  var kitInternals = objectType({
4925
4922
  tables: recordType(
@@ -4996,8 +4993,7 @@ var tableSquashed = objectType({
4996
4993
  indexes: recordType(stringType(), stringType()),
4997
4994
  foreignKeys: recordType(stringType(), stringType()),
4998
4995
  compositePrimaryKeys: recordType(stringType(), stringType()),
4999
- uniqueConstraints: recordType(stringType(), stringType()).default({}),
5000
- checkConstraints: recordType(stringType(), stringType()).default({})
4996
+ uniqueConstraints: recordType(stringType(), stringType()).default({})
5001
4997
  }).strict();
5002
4998
  var schemaSquashed = objectType({
5003
4999
  version: literalType("5"),
@@ -5153,6 +5149,12 @@ var sequenceSchema = objectType({
5153
5149
  cycle: booleanType().optional(),
5154
5150
  schema: stringType()
5155
5151
  }).strict();
5152
+ var roleSchema = objectType({
5153
+ name: stringType(),
5154
+ createDb: booleanType().optional(),
5155
+ createRole: booleanType().optional(),
5156
+ inherit: booleanType().optional()
5157
+ }).strict();
5156
5158
  var sequenceSquashed = objectType({
5157
5159
  name: stringType(),
5158
5160
  schema: stringType(),
@@ -5185,10 +5187,6 @@ var column2 = objectType({
5185
5187
  }).optional(),
5186
5188
  identity: sequenceSchema.merge(objectType({ type: enumType(["always", "byDefault"]) })).optional()
5187
5189
  }).strict();
5188
- var checkConstraint2 = objectType({
5189
- name: stringType(),
5190
- value: stringType()
5191
- }).strict();
5192
5190
  var columnSquashed = objectType({
5193
5191
  name: stringType(),
5194
5192
  type: stringType(),
@@ -5220,6 +5218,14 @@ var uniqueConstraint2 = objectType({
5220
5218
  columns: stringType().array(),
5221
5219
  nullsNotDistinct: booleanType()
5222
5220
  }).strict();
5221
+ var policy = objectType({
5222
+ name: stringType(),
5223
+ as: enumType(["PERMISSIVE", "RESTRICTIVE"]).optional(),
5224
+ for: enumType(["ALL", "SELECT", "INSERT", "UPDATE", "DELETE"]).optional(),
5225
+ to: stringType().array().optional(),
5226
+ using: stringType().optional(),
5227
+ withCheck: stringType().optional()
5228
+ }).strict();
5223
5229
  var tableV42 = objectType({
5224
5230
  name: stringType(),
5225
5231
  schema: stringType(),
@@ -5262,7 +5268,7 @@ var table2 = objectType({
5262
5268
  foreignKeys: recordType(stringType(), fk2),
5263
5269
  compositePrimaryKeys: recordType(stringType(), compositePK2),
5264
5270
  uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({}),
5265
- checkConstraints: recordType(stringType(), checkConstraint2).default({})
5271
+ policies: recordType(stringType(), policy).default({})
5266
5272
  }).strict();
5267
5273
  var schemaHash2 = objectType({
5268
5274
  id: stringType(),
@@ -5356,6 +5362,7 @@ var pgSchemaInternal = objectType({
5356
5362
  enums: recordType(stringType(), enumSchema),
5357
5363
  schemas: recordType(stringType(), stringType()),
5358
5364
  sequences: recordType(stringType(), sequenceSchema).default({}),
5365
+ roles: recordType(stringType(), roleSchema).default({}),
5359
5366
  _meta: objectType({
5360
5367
  schemas: recordType(stringType(), stringType()),
5361
5368
  tables: recordType(stringType(), stringType()),
@@ -5371,7 +5378,7 @@ var tableSquashed2 = objectType({
5371
5378
  foreignKeys: recordType(stringType(), stringType()),
5372
5379
  compositePrimaryKeys: recordType(stringType(), stringType()),
5373
5380
  uniqueConstraints: recordType(stringType(), stringType()),
5374
- checkConstraints: recordType(stringType(), stringType())
5381
+ policies: recordType(stringType(), stringType())
5375
5382
  }).strict();
5376
5383
  var tableSquashedV42 = objectType({
5377
5384
  name: stringType(),
@@ -5400,7 +5407,8 @@ var pgSchemaSquashed = objectType({
5400
5407
  tables: recordType(stringType(), tableSquashed2),
5401
5408
  enums: recordType(stringType(), enumSchema),
5402
5409
  schemas: recordType(stringType(), stringType()),
5403
- sequences: recordType(stringType(), sequenceSquashed)
5410
+ sequences: recordType(stringType(), sequenceSquashed),
5411
+ roles: recordType(stringType(), roleSchema).default({})
5404
5412
  }).strict();
5405
5413
  var pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash2);
5406
5414
  var pgSchemaV4 = pgSchemaInternalV4.merge(schemaHash2);
@@ -5471,18 +5479,13 @@ var uniqueConstraint3 = objectType({
5471
5479
  name: stringType(),
5472
5480
  columns: stringType().array()
5473
5481
  }).strict();
5474
- var checkConstraint3 = objectType({
5475
- name: stringType(),
5476
- value: stringType()
5477
- }).strict();
5478
5482
  var table3 = objectType({
5479
5483
  name: stringType(),
5480
5484
  columns: recordType(stringType(), column3),
5481
5485
  indexes: recordType(stringType(), index3),
5482
5486
  foreignKeys: recordType(stringType(), fk3),
5483
5487
  compositePrimaryKeys: recordType(stringType(), compositePK3),
5484
- uniqueConstraints: recordType(stringType(), uniqueConstraint3).default({}),
5485
- checkConstraints: recordType(stringType(), checkConstraint3).default({})
5488
+ uniqueConstraints: recordType(stringType(), uniqueConstraint3).default({})
5486
5489
  }).strict();
5487
5490
  var dialect2 = enumType(["sqlite"]);
5488
5491
  var schemaHash3 = objectType({
@@ -5544,8 +5547,7 @@ var tableSquashed3 = objectType({
5544
5547
  indexes: recordType(stringType(), stringType()),
5545
5548
  foreignKeys: recordType(stringType(), stringType()),
5546
5549
  compositePrimaryKeys: recordType(stringType(), stringType()),
5547
- uniqueConstraints: recordType(stringType(), stringType()).default({}),
5548
- checkConstraints: recordType(stringType(), stringType()).default({})
5550
+ uniqueConstraints: recordType(stringType(), stringType()).default({})
5549
5551
  }).strict();
5550
5552
  var schemaSquashed2 = objectType({
5551
5553
  version: latestVersion,
@@ -5778,6 +5780,11 @@ function findAddedAndRemoved(columnNames1, columnNames2) {
5778
5780
  const removedColumns = columnNames1.filter((it) => !set2.has(it));
5779
5781
  return { addedColumns, removedColumns };
5780
5782
  }
5783
+ function getColumnCasing(column4, casing) {
5784
+ if (!column4.name)
5785
+ return "";
5786
+ return !column4.keyAsName || casing === void 0 ? column4.name : casing === "camelCase" ? (0, import_casing.toCamelCase)(column4.name) : (0, import_casing.toSnakeCase)(column4.name);
5787
+ }
5781
5788
  // Annotate the CommonJS export names for ESM import in node:
5782
5789
  0 && (module.exports = {
5783
5790
  assertV1OutFolder,
@@ -5785,6 +5792,7 @@ function findAddedAndRemoved(columnNames1, columnNames2) {
5785
5792
  copy,
5786
5793
  dryJournal,
5787
5794
  findAddedAndRemoved,
5795
+ getColumnCasing,
5788
5796
  isPgArrayType,
5789
5797
  kloudMeta,
5790
5798
  normalisePGliteUrl,
package/utils.mjs CHANGED
@@ -1052,6 +1052,7 @@ var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
1052
1052
  var source_default = chalk;
1053
1053
 
1054
1054
  // src/utils.ts
1055
+ import { toCamelCase, toSnakeCase } from "drizzle-orm/casing";
1055
1056
  import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "fs";
1056
1057
  import { join } from "path";
1057
1058
  import { parse } from "url";
@@ -4880,10 +4881,6 @@ var uniqueConstraint = objectType({
4880
4881
  name: stringType(),
4881
4882
  columns: stringType().array()
4882
4883
  }).strict();
4883
- var checkConstraint = objectType({
4884
- name: stringType(),
4885
- value: stringType()
4886
- }).strict();
4887
4884
  var tableV4 = objectType({
4888
4885
  name: stringType(),
4889
4886
  schema: stringType().optional(),
@@ -4897,8 +4894,7 @@ var table = objectType({
4897
4894
  indexes: recordType(stringType(), index),
4898
4895
  foreignKeys: recordType(stringType(), fk),
4899
4896
  compositePrimaryKeys: recordType(stringType(), compositePK),
4900
- uniqueConstraints: recordType(stringType(), uniqueConstraint).default({}),
4901
- checkConstraint: recordType(stringType(), checkConstraint).default({})
4897
+ uniqueConstraints: recordType(stringType(), uniqueConstraint).default({})
4902
4898
  }).strict();
4903
4899
  var kitInternals = objectType({
4904
4900
  tables: recordType(
@@ -4975,8 +4971,7 @@ var tableSquashed = objectType({
4975
4971
  indexes: recordType(stringType(), stringType()),
4976
4972
  foreignKeys: recordType(stringType(), stringType()),
4977
4973
  compositePrimaryKeys: recordType(stringType(), stringType()),
4978
- uniqueConstraints: recordType(stringType(), stringType()).default({}),
4979
- checkConstraints: recordType(stringType(), stringType()).default({})
4974
+ uniqueConstraints: recordType(stringType(), stringType()).default({})
4980
4975
  }).strict();
4981
4976
  var schemaSquashed = objectType({
4982
4977
  version: literalType("5"),
@@ -5132,6 +5127,12 @@ var sequenceSchema = objectType({
5132
5127
  cycle: booleanType().optional(),
5133
5128
  schema: stringType()
5134
5129
  }).strict();
5130
+ var roleSchema = objectType({
5131
+ name: stringType(),
5132
+ createDb: booleanType().optional(),
5133
+ createRole: booleanType().optional(),
5134
+ inherit: booleanType().optional()
5135
+ }).strict();
5135
5136
  var sequenceSquashed = objectType({
5136
5137
  name: stringType(),
5137
5138
  schema: stringType(),
@@ -5164,10 +5165,6 @@ var column2 = objectType({
5164
5165
  }).optional(),
5165
5166
  identity: sequenceSchema.merge(objectType({ type: enumType(["always", "byDefault"]) })).optional()
5166
5167
  }).strict();
5167
- var checkConstraint2 = objectType({
5168
- name: stringType(),
5169
- value: stringType()
5170
- }).strict();
5171
5168
  var columnSquashed = objectType({
5172
5169
  name: stringType(),
5173
5170
  type: stringType(),
@@ -5199,6 +5196,14 @@ var uniqueConstraint2 = objectType({
5199
5196
  columns: stringType().array(),
5200
5197
  nullsNotDistinct: booleanType()
5201
5198
  }).strict();
5199
+ var policy = objectType({
5200
+ name: stringType(),
5201
+ as: enumType(["PERMISSIVE", "RESTRICTIVE"]).optional(),
5202
+ for: enumType(["ALL", "SELECT", "INSERT", "UPDATE", "DELETE"]).optional(),
5203
+ to: stringType().array().optional(),
5204
+ using: stringType().optional(),
5205
+ withCheck: stringType().optional()
5206
+ }).strict();
5202
5207
  var tableV42 = objectType({
5203
5208
  name: stringType(),
5204
5209
  schema: stringType(),
@@ -5241,7 +5246,7 @@ var table2 = objectType({
5241
5246
  foreignKeys: recordType(stringType(), fk2),
5242
5247
  compositePrimaryKeys: recordType(stringType(), compositePK2),
5243
5248
  uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({}),
5244
- checkConstraints: recordType(stringType(), checkConstraint2).default({})
5249
+ policies: recordType(stringType(), policy).default({})
5245
5250
  }).strict();
5246
5251
  var schemaHash2 = objectType({
5247
5252
  id: stringType(),
@@ -5335,6 +5340,7 @@ var pgSchemaInternal = objectType({
5335
5340
  enums: recordType(stringType(), enumSchema),
5336
5341
  schemas: recordType(stringType(), stringType()),
5337
5342
  sequences: recordType(stringType(), sequenceSchema).default({}),
5343
+ roles: recordType(stringType(), roleSchema).default({}),
5338
5344
  _meta: objectType({
5339
5345
  schemas: recordType(stringType(), stringType()),
5340
5346
  tables: recordType(stringType(), stringType()),
@@ -5350,7 +5356,7 @@ var tableSquashed2 = objectType({
5350
5356
  foreignKeys: recordType(stringType(), stringType()),
5351
5357
  compositePrimaryKeys: recordType(stringType(), stringType()),
5352
5358
  uniqueConstraints: recordType(stringType(), stringType()),
5353
- checkConstraints: recordType(stringType(), stringType())
5359
+ policies: recordType(stringType(), stringType())
5354
5360
  }).strict();
5355
5361
  var tableSquashedV42 = objectType({
5356
5362
  name: stringType(),
@@ -5379,7 +5385,8 @@ var pgSchemaSquashed = objectType({
5379
5385
  tables: recordType(stringType(), tableSquashed2),
5380
5386
  enums: recordType(stringType(), enumSchema),
5381
5387
  schemas: recordType(stringType(), stringType()),
5382
- sequences: recordType(stringType(), sequenceSquashed)
5388
+ sequences: recordType(stringType(), sequenceSquashed),
5389
+ roles: recordType(stringType(), roleSchema).default({})
5383
5390
  }).strict();
5384
5391
  var pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash2);
5385
5392
  var pgSchemaV4 = pgSchemaInternalV4.merge(schemaHash2);
@@ -5450,18 +5457,13 @@ var uniqueConstraint3 = objectType({
5450
5457
  name: stringType(),
5451
5458
  columns: stringType().array()
5452
5459
  }).strict();
5453
- var checkConstraint3 = objectType({
5454
- name: stringType(),
5455
- value: stringType()
5456
- }).strict();
5457
5460
  var table3 = objectType({
5458
5461
  name: stringType(),
5459
5462
  columns: recordType(stringType(), column3),
5460
5463
  indexes: recordType(stringType(), index3),
5461
5464
  foreignKeys: recordType(stringType(), fk3),
5462
5465
  compositePrimaryKeys: recordType(stringType(), compositePK3),
5463
- uniqueConstraints: recordType(stringType(), uniqueConstraint3).default({}),
5464
- checkConstraints: recordType(stringType(), checkConstraint3).default({})
5466
+ uniqueConstraints: recordType(stringType(), uniqueConstraint3).default({})
5465
5467
  }).strict();
5466
5468
  var dialect2 = enumType(["sqlite"]);
5467
5469
  var schemaHash3 = objectType({
@@ -5523,8 +5525,7 @@ var tableSquashed3 = objectType({
5523
5525
  indexes: recordType(stringType(), stringType()),
5524
5526
  foreignKeys: recordType(stringType(), stringType()),
5525
5527
  compositePrimaryKeys: recordType(stringType(), stringType()),
5526
- uniqueConstraints: recordType(stringType(), stringType()).default({}),
5527
- checkConstraints: recordType(stringType(), stringType()).default({})
5528
+ uniqueConstraints: recordType(stringType(), stringType()).default({})
5528
5529
  }).strict();
5529
5530
  var schemaSquashed2 = objectType({
5530
5531
  version: latestVersion,
@@ -5757,12 +5758,18 @@ function findAddedAndRemoved(columnNames1, columnNames2) {
5757
5758
  const removedColumns = columnNames1.filter((it) => !set2.has(it));
5758
5759
  return { addedColumns, removedColumns };
5759
5760
  }
5761
+ function getColumnCasing(column4, casing) {
5762
+ if (!column4.name)
5763
+ return "";
5764
+ return !column4.keyAsName || casing === void 0 ? column4.name : casing === "camelCase" ? toCamelCase(column4.name) : toSnakeCase(column4.name);
5765
+ }
5760
5766
  export {
5761
5767
  assertV1OutFolder,
5762
5768
  columnRenameKey,
5763
5769
  copy,
5764
5770
  dryJournal,
5765
5771
  findAddedAndRemoved,
5772
+ getColumnCasing,
5766
5773
  isPgArrayType,
5767
5774
  kloudMeta,
5768
5775
  normalisePGliteUrl,