drizzle-kit 1.0.0-beta.1-d21cc85 → 1.0.0-beta.1-ac4ce44

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.
Files changed (4) hide show
  1. package/api.js +3 -2
  2. package/api.mjs +3 -2
  3. package/bin.cjs +92 -47
  4. package/package.json +1 -1
package/api.js CHANGED
@@ -43907,6 +43907,7 @@ var init_studio = __esm({
43907
43907
  "use strict";
43908
43908
  init_esm();
43909
43909
  init_schemaValidator();
43910
+ init_common();
43910
43911
  init_mysql();
43911
43912
  init_postgres();
43912
43913
  init_sqlite();
@@ -43922,7 +43923,8 @@ var init_studio = __esm({
43922
43923
  });
43923
43924
  studioConfig = objectType({
43924
43925
  dialect: dialect4,
43925
- schema: unionType([stringType(), stringType().array()]).optional()
43926
+ schema: unionType([stringType(), stringType().array()]).optional(),
43927
+ casing: casingType.optional()
43926
43928
  });
43927
43929
  }
43928
43930
  });
@@ -43955,7 +43957,6 @@ var init_utils9 = __esm({
43955
43957
  init_cli();
43956
43958
  init_common();
43957
43959
  init_gel();
43958
- init_gel();
43959
43960
  init_libsql();
43960
43961
  init_mysql();
43961
43962
  init_outputs();
package/api.mjs CHANGED
@@ -43912,6 +43912,7 @@ var init_studio = __esm({
43912
43912
  "use strict";
43913
43913
  init_esm();
43914
43914
  init_schemaValidator();
43915
+ init_common();
43915
43916
  init_mysql();
43916
43917
  init_postgres();
43917
43918
  init_sqlite();
@@ -43927,7 +43928,8 @@ var init_studio = __esm({
43927
43928
  });
43928
43929
  studioConfig = objectType({
43929
43930
  dialect: dialect4,
43930
- schema: unionType([stringType(), stringType().array()]).optional()
43931
+ schema: unionType([stringType(), stringType().array()]).optional(),
43932
+ casing: casingType.optional()
43931
43933
  });
43932
43934
  }
43933
43935
  });
@@ -43960,7 +43962,6 @@ var init_utils9 = __esm({
43960
43962
  init_cli();
43961
43963
  init_common();
43962
43964
  init_gel();
43963
- init_gel();
43964
43965
  init_libsql();
43965
43966
  init_mysql();
43966
43967
  init_outputs();
package/bin.cjs CHANGED
@@ -11290,6 +11290,7 @@ var init_studio = __esm({
11290
11290
  "use strict";
11291
11291
  init_esm();
11292
11292
  init_schemaValidator();
11293
+ init_common();
11293
11294
  init_mysql();
11294
11295
  init_postgres();
11295
11296
  init_sqlite();
@@ -11305,7 +11306,8 @@ var init_studio = __esm({
11305
11306
  });
11306
11307
  studioConfig = objectType({
11307
11308
  dialect: dialect4,
11308
- schema: unionType([stringType(), stringType().array()]).optional()
11309
+ schema: unionType([stringType(), stringType().array()]).optional(),
11310
+ casing: casingType.optional()
11309
11311
  });
11310
11312
  }
11311
11313
  });
@@ -16966,7 +16968,6 @@ var init_utils3 = __esm({
16966
16968
  init_cli();
16967
16969
  init_common();
16968
16970
  init_gel();
16969
- init_gel();
16970
16971
  init_libsql();
16971
16972
  init_mysql();
16972
16973
  init_outputs();
@@ -17382,7 +17383,7 @@ var init_utils3 = __esm({
17382
17383
  process.exit(1);
17383
17384
  }
17384
17385
  const { host, port } = params;
17385
- const { dialect: dialect6, schema: schema6 } = result.data;
17386
+ const { dialect: dialect6, schema: schema6, casing: casing2 } = result.data;
17386
17387
  const flattened = flattenDatabaseCredentials(config);
17387
17388
  if (dialect6 === "postgresql") {
17388
17389
  const parsed = postgresCredentials.safeParse(flattened);
@@ -17396,7 +17397,8 @@ var init_utils3 = __esm({
17396
17397
  schema: schema6,
17397
17398
  host,
17398
17399
  port,
17399
- credentials: credentials2
17400
+ credentials: credentials2,
17401
+ casing: casing2
17400
17402
  };
17401
17403
  }
17402
17404
  if (dialect6 === "mysql") {
@@ -17411,7 +17413,8 @@ var init_utils3 = __esm({
17411
17413
  schema: schema6,
17412
17414
  host,
17413
17415
  port,
17414
- credentials: credentials2
17416
+ credentials: credentials2,
17417
+ casing: casing2
17415
17418
  };
17416
17419
  }
17417
17420
  if (dialect6 === "singlestore") {
@@ -17426,7 +17429,8 @@ var init_utils3 = __esm({
17426
17429
  schema: schema6,
17427
17430
  host,
17428
17431
  port,
17429
- credentials: credentials2
17432
+ credentials: credentials2,
17433
+ casing: casing2
17430
17434
  };
17431
17435
  }
17432
17436
  if (dialect6 === "sqlite") {
@@ -17441,7 +17445,8 @@ var init_utils3 = __esm({
17441
17445
  schema: schema6,
17442
17446
  host,
17443
17447
  port,
17444
- credentials: credentials2
17448
+ credentials: credentials2,
17449
+ casing: casing2
17445
17450
  };
17446
17451
  }
17447
17452
  if (dialect6 === "turso") {
@@ -17456,7 +17461,8 @@ var init_utils3 = __esm({
17456
17461
  schema: schema6,
17457
17462
  host,
17458
17463
  port,
17459
- credentials: credentials2
17464
+ credentials: credentials2,
17465
+ casing: casing2
17460
17466
  };
17461
17467
  }
17462
17468
  if (dialect6 === "gel") {
@@ -93162,6 +93168,7 @@ var init_studio2 = __esm({
93162
93168
  init_esm();
93163
93169
  init_utils3();
93164
93170
  init_serializer();
93171
+ init_utils4();
93165
93172
  preparePgSchema = async (path4) => {
93166
93173
  const imports = prepareFilenames(path4);
93167
93174
  const pgSchema2 = {};
@@ -93277,7 +93284,7 @@ var init_studio2 = __esm({
93277
93284
  unregister();
93278
93285
  return { schema: singlestoreSchema2, relations: relations5, files };
93279
93286
  };
93280
- getCustomDefaults = (schema6) => {
93287
+ getCustomDefaults = (schema6, casing2) => {
93281
93288
  const customDefaults = [];
93282
93289
  Object.entries(schema6).map(([schema7, tables]) => {
93283
93290
  Object.entries(tables).map(([, table6]) => {
@@ -93296,7 +93303,7 @@ var init_studio2 = __esm({
93296
93303
  customDefaults.push({
93297
93304
  schema: schema7,
93298
93305
  table: tableConfig.name,
93299
- column: column11.name,
93306
+ column: getColumnCasing(column11, casing2),
93300
93307
  func: column11.defaultFn
93301
93308
  });
93302
93309
  }
@@ -93305,10 +93312,10 @@ var init_studio2 = __esm({
93305
93312
  });
93306
93313
  return customDefaults;
93307
93314
  };
93308
- drizzleForPostgres = async (credentials2, pgSchema2, relations5, schemaFiles) => {
93315
+ drizzleForPostgres = async (credentials2, pgSchema2, relations5, schemaFiles, casing2) => {
93309
93316
  const { preparePostgresDB: preparePostgresDB2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
93310
93317
  const db = await preparePostgresDB2(credentials2);
93311
- const customDefaults = getCustomDefaults(pgSchema2);
93318
+ const customDefaults = getCustomDefaults(pgSchema2, casing2);
93312
93319
  let dbUrl;
93313
93320
  if ("driver" in credentials2) {
93314
93321
  const { driver: driver2 } = credentials2;
@@ -93335,13 +93342,14 @@ var init_studio2 = __esm({
93335
93342
  customDefaults,
93336
93343
  schema: pgSchema2,
93337
93344
  relations: relations5,
93338
- schemaFiles
93345
+ schemaFiles,
93346
+ casing: casing2
93339
93347
  };
93340
93348
  };
93341
- drizzleForMySQL = async (credentials2, mysqlSchema3, relations5, schemaFiles) => {
93349
+ drizzleForMySQL = async (credentials2, mysqlSchema3, relations5, schemaFiles, casing2) => {
93342
93350
  const { connectToMySQL: connectToMySQL2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
93343
93351
  const { proxy, transactionProxy, database, packageName } = await connectToMySQL2(credentials2);
93344
- const customDefaults = getCustomDefaults(mysqlSchema3);
93352
+ const customDefaults = getCustomDefaults(mysqlSchema3, casing2);
93345
93353
  let dbUrl;
93346
93354
  if ("url" in credentials2) {
93347
93355
  dbUrl = credentials2.url;
@@ -93359,13 +93367,14 @@ var init_studio2 = __esm({
93359
93367
  customDefaults,
93360
93368
  schema: mysqlSchema3,
93361
93369
  relations: relations5,
93362
- schemaFiles
93370
+ schemaFiles,
93371
+ casing: casing2
93363
93372
  };
93364
93373
  };
93365
- drizzleForSQLite = async (credentials2, sqliteSchema2, relations5, schemaFiles) => {
93374
+ drizzleForSQLite = async (credentials2, sqliteSchema2, relations5, schemaFiles, casing2) => {
93366
93375
  const { connectToSQLite: connectToSQLite2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
93367
93376
  const sqliteDB = await connectToSQLite2(credentials2);
93368
- const customDefaults = getCustomDefaults(sqliteSchema2);
93377
+ const customDefaults = getCustomDefaults(sqliteSchema2, casing2);
93369
93378
  let dbUrl;
93370
93379
  if ("driver" in credentials2) {
93371
93380
  const { driver: driver2 } = credentials2;
@@ -93388,13 +93397,14 @@ var init_studio2 = __esm({
93388
93397
  customDefaults,
93389
93398
  schema: sqliteSchema2,
93390
93399
  relations: relations5,
93391
- schemaFiles
93400
+ schemaFiles,
93401
+ casing: casing2
93392
93402
  };
93393
93403
  };
93394
- drizzleForLibSQL = async (credentials2, sqliteSchema2, relations5, schemaFiles) => {
93404
+ drizzleForLibSQL = async (credentials2, sqliteSchema2, relations5, schemaFiles, casing2) => {
93395
93405
  const { connectToLibSQL: connectToLibSQL2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
93396
93406
  const sqliteDB = await connectToLibSQL2(credentials2);
93397
- const customDefaults = getCustomDefaults(sqliteSchema2);
93407
+ const customDefaults = getCustomDefaults(sqliteSchema2, casing2);
93398
93408
  let dbUrl = `turso://${credentials2.url}/${credentials2.authToken}`;
93399
93409
  const dbHash = (0, import_crypto9.createHash)("sha256").update(dbUrl).digest("hex");
93400
93410
  return {
@@ -93407,13 +93417,14 @@ var init_studio2 = __esm({
93407
93417
  customDefaults,
93408
93418
  schema: sqliteSchema2,
93409
93419
  relations: relations5,
93410
- schemaFiles
93420
+ schemaFiles,
93421
+ casing: casing2
93411
93422
  };
93412
93423
  };
93413
- drizzleForSingleStore = async (credentials2, singlestoreSchema2, relations5, schemaFiles) => {
93424
+ drizzleForSingleStore = async (credentials2, singlestoreSchema2, relations5, schemaFiles, casing2) => {
93414
93425
  const { connectToSingleStore: connectToSingleStore2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
93415
93426
  const { proxy, transactionProxy, database, packageName } = await connectToSingleStore2(credentials2);
93416
- const customDefaults = getCustomDefaults(singlestoreSchema2);
93427
+ const customDefaults = getCustomDefaults(singlestoreSchema2, casing2);
93417
93428
  let dbUrl;
93418
93429
  if ("url" in credentials2) {
93419
93430
  dbUrl = credentials2.url;
@@ -93431,10 +93442,11 @@ var init_studio2 = __esm({
93431
93442
  customDefaults,
93432
93443
  schema: singlestoreSchema2,
93433
93444
  relations: relations5,
93434
- schemaFiles
93445
+ schemaFiles,
93446
+ casing: casing2
93435
93447
  };
93436
93448
  };
93437
- extractRelations = (tablesConfig) => {
93449
+ extractRelations = (tablesConfig, casing2) => {
93438
93450
  const relations5 = Object.values(tablesConfig.tables).map(
93439
93451
  (it) => Object.entries(it.relations).map(([name, relation]) => {
93440
93452
  try {
@@ -93446,8 +93458,8 @@ var init_studio2 = __esm({
93446
93458
  const rel = relation;
93447
93459
  const refTableName = rel.referencedTableName;
93448
93460
  const refTable = rel.referencedTable;
93449
- const fields = normalized.fields.map((it2) => it2.name).flat();
93450
- const refColumns = normalized.references.map((it2) => it2.name).flat();
93461
+ const fields = normalized.fields.map((it2) => getColumnCasing(it2, casing2)).flat();
93462
+ const refColumns = normalized.references.map((it2) => getColumnCasing(it2, casing2)).flat();
93451
93463
  let refSchema;
93452
93464
  if ((0, import_drizzle_orm11.is)(refTable, import_pg_core3.PgTable)) {
93453
93465
  refSchema = (0, import_pg_core3.getTableConfig)(refTable).schema;
@@ -93497,14 +93509,26 @@ var init_studio2 = __esm({
93497
93509
  params: external_exports.array(external_exports.any()).optional(),
93498
93510
  typings: external_exports.string().array().optional(),
93499
93511
  mode: external_exports.enum(["array", "object"]).default("object"),
93500
- method: external_exports.union([external_exports.literal("values"), external_exports.literal("get"), external_exports.literal("all"), external_exports.literal("run"), external_exports.literal("execute")])
93512
+ method: external_exports.union([
93513
+ external_exports.literal("values"),
93514
+ external_exports.literal("get"),
93515
+ external_exports.literal("all"),
93516
+ external_exports.literal("run"),
93517
+ external_exports.literal("execute")
93518
+ ])
93501
93519
  })
93502
93520
  });
93503
93521
  transactionProxySchema = external_exports.object({
93504
93522
  type: external_exports.literal("tproxy"),
93505
93523
  data: external_exports.object({
93506
93524
  sql: external_exports.string(),
93507
- method: external_exports.union([external_exports.literal("values"), external_exports.literal("get"), external_exports.literal("all"), external_exports.literal("run"), external_exports.literal("execute")]).optional()
93525
+ method: external_exports.union([
93526
+ external_exports.literal("values"),
93527
+ external_exports.literal("get"),
93528
+ external_exports.literal("all"),
93529
+ external_exports.literal("run"),
93530
+ external_exports.literal("execute")
93531
+ ]).optional()
93508
93532
  }).array()
93509
93533
  });
93510
93534
  defaultsSchema = external_exports.object({
@@ -93517,7 +93541,12 @@ var init_studio2 = __esm({
93517
93541
  })
93518
93542
  ).min(1)
93519
93543
  });
93520
- schema5 = external_exports.union([init, proxySchema, transactionProxySchema, defaultsSchema]);
93544
+ schema5 = external_exports.union([
93545
+ init,
93546
+ proxySchema,
93547
+ transactionProxySchema,
93548
+ defaultsSchema
93549
+ ]);
93521
93550
  jsonStringify = (data) => {
93522
93551
  return JSON.stringify(data, (_key, value) => {
93523
93552
  if (value instanceof Error) {
@@ -93545,6 +93574,7 @@ var init_studio2 = __esm({
93545
93574
  schema: drizzleSchema,
93546
93575
  relations: relations5,
93547
93576
  dbHash,
93577
+ casing: casing2,
93548
93578
  schemaFiles
93549
93579
  }, app) => {
93550
93580
  app = app !== void 0 ? app : new Hono2();
@@ -93564,15 +93594,20 @@ var init_studio2 = __esm({
93564
93594
  const relationalSchema = {
93565
93595
  ...Object.fromEntries(
93566
93596
  Object.entries(drizzleSchema).map(([schemaName, schema6]) => {
93567
- const mappedTableEntries = Object.entries(schema6).map(([tableName, table6]) => {
93568
- return [`__${schemaName}__.${tableName}`, table6];
93569
- });
93597
+ const mappedTableEntries = Object.entries(schema6).map(
93598
+ ([tableName, table6]) => {
93599
+ return [`__${schemaName}__.${tableName}`, table6];
93600
+ }
93601
+ );
93570
93602
  return mappedTableEntries;
93571
93603
  }).flat()
93572
93604
  ),
93573
93605
  ...relations5
93574
93606
  };
93575
- const relationsConfig = (0, import_relations2.extractTablesRelationalConfig)(relationalSchema, import_relations2.createTableRelationsHelpers);
93607
+ const relationsConfig = (0, import_relations2.extractTablesRelationalConfig)(
93608
+ relationalSchema,
93609
+ import_relations2.createTableRelationsHelpers
93610
+ );
93576
93611
  app.post("/", zValidator("json", schema5), async (c3) => {
93577
93612
  const body = c3.req.valid("json");
93578
93613
  const { type } = body;
@@ -93584,11 +93619,17 @@ var init_studio2 = __esm({
93584
93619
  }));
93585
93620
  let relations6 = [];
93586
93621
  try {
93587
- relations6 = extractRelations(relationsConfig);
93622
+ relations6 = extractRelations(relationsConfig, casing2);
93588
93623
  } catch (error2) {
93589
- console.warn("Failed to extract relations. This is likely due to ambiguous or misconfigured relations.");
93590
- console.warn("Please check your schema and ensure that all relations are correctly defined.");
93591
- console.warn("See: https://orm.drizzle.team/docs/relations#disambiguating-relations");
93624
+ console.warn(
93625
+ "Failed to extract relations. This is likely due to ambiguous or misconfigured relations."
93626
+ );
93627
+ console.warn(
93628
+ "Please check your schema and ensure that all relations are correctly defined."
93629
+ );
93630
+ console.warn(
93631
+ "See: https://orm.drizzle.team/docs/relations#disambiguating-relations"
93632
+ );
93592
93633
  console.warn("Error message:", error2.message);
93593
93634
  }
93594
93635
  return c3.json({
@@ -93621,7 +93662,9 @@ var init_studio2 = __esm({
93621
93662
  return d3.schema === column11.schema && d3.table === column11.table && d3.column === column11.column;
93622
93663
  });
93623
93664
  if (!found) {
93624
- throw new Error(`Custom default not found for ${column11.schema}.${column11.table}.${column11.column}`);
93665
+ throw new Error(
93666
+ `Custom default not found for ${column11.schema}.${column11.table}.${column11.column}`
93667
+ );
93625
93668
  }
93626
93669
  const value = found.func();
93627
93670
  return {
@@ -96005,7 +96048,8 @@ var studio = command2({
96005
96048
  schema: schemaPath,
96006
96049
  port,
96007
96050
  host,
96008
- credentials: credentials2
96051
+ credentials: credentials2,
96052
+ casing: casing2
96009
96053
  } = await prepareStudioConfig(opts);
96010
96054
  const {
96011
96055
  drizzleForPostgres: drizzleForPostgres2,
@@ -96042,23 +96086,24 @@ var studio = command2({
96042
96086
  }
96043
96087
  }
96044
96088
  const { schema: schema6, relations: relations5, files } = schemaPath ? await preparePgSchema2(schemaPath) : { schema: {}, relations: {}, files: [] };
96045
- setup = await drizzleForPostgres2(credentials2, schema6, relations5, files);
96089
+ setup = await drizzleForPostgres2(credentials2, schema6, relations5, files, casing2);
96046
96090
  } else if (dialect6 === "mysql") {
96047
96091
  const { schema: schema6, relations: relations5, files } = schemaPath ? await prepareMySqlSchema2(schemaPath) : { schema: {}, relations: {}, files: [] };
96048
- setup = await drizzleForMySQL2(credentials2, schema6, relations5, files);
96092
+ setup = await drizzleForMySQL2(credentials2, schema6, relations5, files, casing2);
96049
96093
  } else if (dialect6 === "sqlite") {
96050
96094
  const { schema: schema6, relations: relations5, files } = schemaPath ? await prepareSQLiteSchema2(schemaPath) : { schema: {}, relations: {}, files: [] };
96051
- setup = await drizzleForSQLite2(credentials2, schema6, relations5, files);
96095
+ setup = await drizzleForSQLite2(credentials2, schema6, relations5, files, casing2);
96052
96096
  } else if (dialect6 === "turso") {
96053
96097
  const { schema: schema6, relations: relations5, files } = schemaPath ? await prepareSQLiteSchema2(schemaPath) : { schema: {}, relations: {}, files: [] };
96054
- setup = await drizzleForLibSQL2(credentials2, schema6, relations5, files);
96098
+ setup = await drizzleForLibSQL2(credentials2, schema6, relations5, files, casing2);
96055
96099
  } else if (dialect6 === "singlestore") {
96056
96100
  const { schema: schema6, relations: relations5, files } = schemaPath ? await prepareSingleStoreSchema2(schemaPath) : { schema: {}, relations: {}, files: [] };
96057
96101
  setup = await drizzleForSingleStore2(
96058
96102
  credentials2,
96059
96103
  schema6,
96060
96104
  relations5,
96061
- files
96105
+ files,
96106
+ casing2
96062
96107
  );
96063
96108
  } else if (dialect6 === "gel") {
96064
96109
  console.log(
@@ -96165,7 +96210,7 @@ init_utils5();
96165
96210
  var version2 = async () => {
96166
96211
  const { npmVersion } = await ormCoreVersions();
96167
96212
  const ormVersion = npmVersion ? `drizzle-orm: v${npmVersion}` : "";
96168
- const envVersion = "1.0.0-beta.1-d21cc85";
96213
+ const envVersion = "1.0.0-beta.1-ac4ce44";
96169
96214
  const kitVersion = envVersion ? `v${envVersion}` : "--";
96170
96215
  const versions = `drizzle-kit: ${kitVersion}
96171
96216
  ${ormVersion}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drizzle-kit",
3
- "version": "1.0.0-beta.1-d21cc85",
3
+ "version": "1.0.0-beta.1-ac4ce44",
4
4
  "homepage": "https://orm.drizzle.team",
5
5
  "keywords": [
6
6
  "drizzle",