drizzle-kit 1.0.0-beta.1-d21cc85 → 1.0.0-beta.1-f77460a
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.
- package/api.d.mts +265 -1
- package/api.d.ts +265 -1
- package/api.js +163348 -44381
- package/api.mjs +163306 -44349
- package/bin.cjs +131 -72
- package/package.json +1 -1
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") {
|
|
@@ -18451,11 +18457,12 @@ __export(pgImports_exports, {
|
|
|
18451
18457
|
prepareFromExports: () => prepareFromExports2,
|
|
18452
18458
|
prepareFromPgImports: () => prepareFromPgImports
|
|
18453
18459
|
});
|
|
18454
|
-
var import_drizzle_orm3, import_pg_core, prepareFromExports2, prepareFromPgImports;
|
|
18460
|
+
var import_drizzle_orm3, import_relations, import_pg_core, prepareFromExports2, prepareFromPgImports;
|
|
18455
18461
|
var init_pgImports = __esm({
|
|
18456
18462
|
"src/serializer/pgImports.ts"() {
|
|
18457
18463
|
"use strict";
|
|
18458
18464
|
import_drizzle_orm3 = require("drizzle-orm");
|
|
18465
|
+
import_relations = require("drizzle-orm/_relations");
|
|
18459
18466
|
import_pg_core = require("drizzle-orm/pg-core");
|
|
18460
18467
|
init_utils3();
|
|
18461
18468
|
prepareFromExports2 = (exports2) => {
|
|
@@ -18467,6 +18474,7 @@ var init_pgImports = __esm({
|
|
|
18467
18474
|
const policies = [];
|
|
18468
18475
|
const views = [];
|
|
18469
18476
|
const matViews = [];
|
|
18477
|
+
const relations5 = [];
|
|
18470
18478
|
const i0values = Object.values(exports2);
|
|
18471
18479
|
i0values.forEach((t4) => {
|
|
18472
18480
|
if ((0, import_pg_core.isPgEnum)(t4)) {
|
|
@@ -18494,8 +18502,11 @@ var init_pgImports = __esm({
|
|
|
18494
18502
|
if ((0, import_drizzle_orm3.is)(t4, import_pg_core.PgPolicy)) {
|
|
18495
18503
|
policies.push(t4);
|
|
18496
18504
|
}
|
|
18505
|
+
if ((0, import_drizzle_orm3.is)(t4, import_relations.Relations)) {
|
|
18506
|
+
relations5.push(t4);
|
|
18507
|
+
}
|
|
18497
18508
|
});
|
|
18498
|
-
return { tables, enums, schemas, sequences, views, matViews, roles, policies };
|
|
18509
|
+
return { tables, enums, schemas, sequences, views, matViews, roles, policies, relations: relations5 };
|
|
18499
18510
|
};
|
|
18500
18511
|
prepareFromPgImports = async (imports) => {
|
|
18501
18512
|
const tables = [];
|
|
@@ -18506,6 +18517,7 @@ var init_pgImports = __esm({
|
|
|
18506
18517
|
const roles = [];
|
|
18507
18518
|
const policies = [];
|
|
18508
18519
|
const matViews = [];
|
|
18520
|
+
const relations5 = [];
|
|
18509
18521
|
const { unregister } = await safeRegister();
|
|
18510
18522
|
for (let i4 = 0; i4 < imports.length; i4++) {
|
|
18511
18523
|
const it = imports[i4];
|
|
@@ -18519,9 +18531,20 @@ var init_pgImports = __esm({
|
|
|
18519
18531
|
matViews.push(...prepared.matViews);
|
|
18520
18532
|
roles.push(...prepared.roles);
|
|
18521
18533
|
policies.push(...prepared.policies);
|
|
18534
|
+
relations5.push(...prepared.relations);
|
|
18522
18535
|
}
|
|
18523
18536
|
unregister();
|
|
18524
|
-
return {
|
|
18537
|
+
return {
|
|
18538
|
+
tables: Array.from(new Set(tables)),
|
|
18539
|
+
enums,
|
|
18540
|
+
schemas,
|
|
18541
|
+
sequences,
|
|
18542
|
+
views,
|
|
18543
|
+
matViews,
|
|
18544
|
+
roles,
|
|
18545
|
+
policies,
|
|
18546
|
+
relations: relations5
|
|
18547
|
+
};
|
|
18525
18548
|
};
|
|
18526
18549
|
}
|
|
18527
18550
|
});
|
|
@@ -21491,7 +21514,7 @@ ${filenames.join("\n")}
|
|
|
21491
21514
|
});
|
|
21492
21515
|
|
|
21493
21516
|
// src/migrationPreparator.ts
|
|
21494
|
-
var import_crypto, import_fs5, prepareMySqlDbPushSnapshot, prepareSingleStoreDbPushSnapshot, prepareSQLiteDbPushSnapshot, prepareMySqlMigrationSnapshot, prepareSingleStoreMigrationSnapshot, prepareSqliteMigrationSnapshot,
|
|
21517
|
+
var import_crypto, import_fs5, prepareMySqlDbPushSnapshot, prepareSingleStoreDbPushSnapshot, prepareSQLiteDbPushSnapshot, prepareMySqlMigrationSnapshot, prepareSingleStoreMigrationSnapshot, prepareSqliteMigrationSnapshot, preparePgMigrationSnapshot, preparePrevSnapshot;
|
|
21495
21518
|
var init_migrationPreparator = __esm({
|
|
21496
21519
|
"src/migrationPreparator.ts"() {
|
|
21497
21520
|
"use strict";
|
|
@@ -21589,13 +21612,6 @@ var init_migrationPreparator = __esm({
|
|
|
21589
21612
|
};
|
|
21590
21613
|
return { prev: prevSnapshot, cur: result, custom: custom2 };
|
|
21591
21614
|
};
|
|
21592
|
-
fillPgSnapshot = ({
|
|
21593
|
-
serialized,
|
|
21594
|
-
id,
|
|
21595
|
-
idPrev
|
|
21596
|
-
}) => {
|
|
21597
|
-
return { id, prevId: idPrev, ...serialized };
|
|
21598
|
-
};
|
|
21599
21615
|
preparePgMigrationSnapshot = async (snapshots, schemaPath, casing2) => {
|
|
21600
21616
|
const prevSnapshot = pgSchema.parse(preparePrevSnapshot(snapshots, dryPg));
|
|
21601
21617
|
const serialized = await serializePg(schemaPath, casing2);
|
|
@@ -21603,7 +21619,11 @@ var init_migrationPreparator = __esm({
|
|
|
21603
21619
|
const idPrev = prevSnapshot.id;
|
|
21604
21620
|
const result = { id, prevId: idPrev, ...serialized };
|
|
21605
21621
|
const { id: _ignoredId, prevId: _ignoredPrevId, ...prevRest } = prevSnapshot;
|
|
21606
|
-
const custom2 =
|
|
21622
|
+
const custom2 = {
|
|
21623
|
+
id,
|
|
21624
|
+
prevId: idPrev,
|
|
21625
|
+
...prevRest
|
|
21626
|
+
};
|
|
21607
21627
|
return { prev: prevSnapshot, cur: result, custom: custom2 };
|
|
21608
21628
|
};
|
|
21609
21629
|
preparePrevSnapshot = (snapshots, defaultPrev) => {
|
|
@@ -82261,7 +82281,7 @@ var init_connections = __esm({
|
|
|
82261
82281
|
const { PGlite, types: types3 } = await import("@electric-sql/pglite");
|
|
82262
82282
|
const { drizzle } = await import("drizzle-orm/pglite");
|
|
82263
82283
|
const { migrate: migrate2 } = await import("drizzle-orm/pglite/migrator");
|
|
82264
|
-
const pglite = new PGlite(normalisePGliteUrl(credentials2.url));
|
|
82284
|
+
const pglite = "client" in credentials2 ? credentials2.client : new PGlite(normalisePGliteUrl(credentials2.url));
|
|
82265
82285
|
await pglite.waitReady;
|
|
82266
82286
|
const drzl = drizzle(pglite);
|
|
82267
82287
|
const migrateFn = async (config) => {
|
|
@@ -88489,12 +88509,12 @@ function generateIdentityParams2(identity) {
|
|
|
88489
88509
|
}
|
|
88490
88510
|
return `.generatedByDefaultAsIdentity(${paramsObj})`;
|
|
88491
88511
|
}
|
|
88492
|
-
var import_drizzle_orm10,
|
|
88512
|
+
var import_drizzle_orm10, import_relations2, import_casing5, pgImportsList, timeConfig2, possibleIntervals, intervalStrToObj, intervalConfig, mapColumnDefault4, importsPatch2, relations4, escapeColumnKey4, withCasing3, dbColumnName4, paramNameFor2, schemaToTypeScript4, isCyclic4, isSelf4, buildArrayDefault2, mapDefault2, column9, dimensionsInArray2, createTableColumns4, createTableIndexes4, createTablePKs4, createTablePolicies2, createTableUniques4, createTableChecks4, createTableFKs4;
|
|
88493
88513
|
var init_introspect_pg = __esm({
|
|
88494
88514
|
"src/introspect-pg.ts"() {
|
|
88495
88515
|
"use strict";
|
|
88496
88516
|
import_drizzle_orm10 = require("drizzle-orm");
|
|
88497
|
-
|
|
88517
|
+
import_relations2 = require("drizzle-orm/_relations");
|
|
88498
88518
|
init_utils();
|
|
88499
88519
|
import_casing5 = require("drizzle-orm/casing");
|
|
88500
88520
|
init_global();
|
|
@@ -93140,7 +93160,7 @@ __export(studio_exports, {
|
|
|
93140
93160
|
prepareServer: () => prepareServer,
|
|
93141
93161
|
prepareSingleStoreSchema: () => prepareSingleStoreSchema
|
|
93142
93162
|
});
|
|
93143
|
-
var import_crypto9, import_drizzle_orm11,
|
|
93163
|
+
var import_crypto9, import_drizzle_orm11, import_relations3, import_mysql_core3, import_pg_core3, import_singlestore_core3, import_sqlite_core3, import_fs12, import_node_https2, preparePgSchema, prepareMySqlSchema, prepareSQLiteSchema, prepareSingleStoreSchema, getCustomDefaults, drizzleForPostgres, drizzleForMySQL, drizzleForSQLite, drizzleForLibSQL, drizzleForSingleStore, extractRelations, init, proxySchema, transactionProxySchema, defaultsSchema, schema5, jsonStringify, prepareServer;
|
|
93144
93164
|
var init_studio2 = __esm({
|
|
93145
93165
|
"src/serializer/studio.ts"() {
|
|
93146
93166
|
"use strict";
|
|
@@ -93148,7 +93168,7 @@ var init_studio2 = __esm({
|
|
|
93148
93168
|
init_esm2();
|
|
93149
93169
|
import_crypto9 = require("crypto");
|
|
93150
93170
|
import_drizzle_orm11 = require("drizzle-orm");
|
|
93151
|
-
|
|
93171
|
+
import_relations3 = require("drizzle-orm/_relations");
|
|
93152
93172
|
import_mysql_core3 = require("drizzle-orm/mysql-core");
|
|
93153
93173
|
import_pg_core3 = require("drizzle-orm/pg-core");
|
|
93154
93174
|
import_singlestore_core3 = require("drizzle-orm/singlestore-core");
|
|
@@ -93162,6 +93182,7 @@ var init_studio2 = __esm({
|
|
|
93162
93182
|
init_esm();
|
|
93163
93183
|
init_utils3();
|
|
93164
93184
|
init_serializer();
|
|
93185
|
+
init_utils4();
|
|
93165
93186
|
preparePgSchema = async (path4) => {
|
|
93166
93187
|
const imports = prepareFilenames(path4);
|
|
93167
93188
|
const pgSchema2 = {};
|
|
@@ -93182,7 +93203,7 @@ var init_studio2 = __esm({
|
|
|
93182
93203
|
pgSchema2[schema6] = pgSchema2[schema6] || {};
|
|
93183
93204
|
pgSchema2[schema6][k3] = t4;
|
|
93184
93205
|
}
|
|
93185
|
-
if ((0, import_drizzle_orm11.is)(t4,
|
|
93206
|
+
if ((0, import_drizzle_orm11.is)(t4, import_relations3.Relations)) {
|
|
93186
93207
|
relations5[k3] = t4;
|
|
93187
93208
|
}
|
|
93188
93209
|
});
|
|
@@ -93211,7 +93232,7 @@ var init_studio2 = __esm({
|
|
|
93211
93232
|
const schema6 = (0, import_mysql_core3.getTableConfig)(t4).schema || "public";
|
|
93212
93233
|
mysqlSchema3[schema6][k3] = t4;
|
|
93213
93234
|
}
|
|
93214
|
-
if ((0, import_drizzle_orm11.is)(t4,
|
|
93235
|
+
if ((0, import_drizzle_orm11.is)(t4, import_relations3.Relations)) {
|
|
93215
93236
|
relations5[k3] = t4;
|
|
93216
93237
|
}
|
|
93217
93238
|
});
|
|
@@ -93240,7 +93261,7 @@ var init_studio2 = __esm({
|
|
|
93240
93261
|
const schema6 = "public";
|
|
93241
93262
|
sqliteSchema2[schema6][k3] = t4;
|
|
93242
93263
|
}
|
|
93243
|
-
if ((0, import_drizzle_orm11.is)(t4,
|
|
93264
|
+
if ((0, import_drizzle_orm11.is)(t4, import_relations3.Relations)) {
|
|
93244
93265
|
relations5[k3] = t4;
|
|
93245
93266
|
}
|
|
93246
93267
|
});
|
|
@@ -93269,7 +93290,7 @@ var init_studio2 = __esm({
|
|
|
93269
93290
|
const schema6 = (0, import_singlestore_core3.getTableConfig)(t4).schema || "public";
|
|
93270
93291
|
singlestoreSchema2[schema6][k3] = t4;
|
|
93271
93292
|
}
|
|
93272
|
-
if ((0, import_drizzle_orm11.is)(t4,
|
|
93293
|
+
if ((0, import_drizzle_orm11.is)(t4, import_relations3.Relations)) {
|
|
93273
93294
|
relations5[k3] = t4;
|
|
93274
93295
|
}
|
|
93275
93296
|
});
|
|
@@ -93277,7 +93298,7 @@ var init_studio2 = __esm({
|
|
|
93277
93298
|
unregister();
|
|
93278
93299
|
return { schema: singlestoreSchema2, relations: relations5, files };
|
|
93279
93300
|
};
|
|
93280
|
-
getCustomDefaults = (schema6) => {
|
|
93301
|
+
getCustomDefaults = (schema6, casing2) => {
|
|
93281
93302
|
const customDefaults = [];
|
|
93282
93303
|
Object.entries(schema6).map(([schema7, tables]) => {
|
|
93283
93304
|
Object.entries(tables).map(([, table6]) => {
|
|
@@ -93296,7 +93317,7 @@ var init_studio2 = __esm({
|
|
|
93296
93317
|
customDefaults.push({
|
|
93297
93318
|
schema: schema7,
|
|
93298
93319
|
table: tableConfig.name,
|
|
93299
|
-
column: column11
|
|
93320
|
+
column: getColumnCasing(column11, casing2),
|
|
93300
93321
|
func: column11.defaultFn
|
|
93301
93322
|
});
|
|
93302
93323
|
}
|
|
@@ -93305,17 +93326,17 @@ var init_studio2 = __esm({
|
|
|
93305
93326
|
});
|
|
93306
93327
|
return customDefaults;
|
|
93307
93328
|
};
|
|
93308
|
-
drizzleForPostgres = async (credentials2, pgSchema2, relations5, schemaFiles) => {
|
|
93329
|
+
drizzleForPostgres = async (credentials2, pgSchema2, relations5, schemaFiles, casing2) => {
|
|
93309
93330
|
const { preparePostgresDB: preparePostgresDB2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
|
|
93310
93331
|
const db = await preparePostgresDB2(credentials2);
|
|
93311
|
-
const customDefaults = getCustomDefaults(pgSchema2);
|
|
93332
|
+
const customDefaults = getCustomDefaults(pgSchema2, casing2);
|
|
93312
93333
|
let dbUrl;
|
|
93313
93334
|
if ("driver" in credentials2) {
|
|
93314
93335
|
const { driver: driver2 } = credentials2;
|
|
93315
93336
|
if (driver2 === "aws-data-api") {
|
|
93316
93337
|
dbUrl = `aws-data-api://${credentials2.database}/${credentials2.secretArn}/${credentials2.resourceArn}`;
|
|
93317
93338
|
} else if (driver2 === "pglite") {
|
|
93318
|
-
dbUrl = credentials2.url;
|
|
93339
|
+
dbUrl = "client" in credentials2 ? credentials2.client.dataDir || "pglite://custom-client" : credentials2.url;
|
|
93319
93340
|
} else {
|
|
93320
93341
|
assertUnreachable(driver2);
|
|
93321
93342
|
}
|
|
@@ -93335,13 +93356,14 @@ var init_studio2 = __esm({
|
|
|
93335
93356
|
customDefaults,
|
|
93336
93357
|
schema: pgSchema2,
|
|
93337
93358
|
relations: relations5,
|
|
93338
|
-
schemaFiles
|
|
93359
|
+
schemaFiles,
|
|
93360
|
+
casing: casing2
|
|
93339
93361
|
};
|
|
93340
93362
|
};
|
|
93341
|
-
drizzleForMySQL = async (credentials2, mysqlSchema3, relations5, schemaFiles) => {
|
|
93363
|
+
drizzleForMySQL = async (credentials2, mysqlSchema3, relations5, schemaFiles, casing2) => {
|
|
93342
93364
|
const { connectToMySQL: connectToMySQL2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
|
|
93343
93365
|
const { proxy, transactionProxy, database, packageName } = await connectToMySQL2(credentials2);
|
|
93344
|
-
const customDefaults = getCustomDefaults(mysqlSchema3);
|
|
93366
|
+
const customDefaults = getCustomDefaults(mysqlSchema3, casing2);
|
|
93345
93367
|
let dbUrl;
|
|
93346
93368
|
if ("url" in credentials2) {
|
|
93347
93369
|
dbUrl = credentials2.url;
|
|
@@ -93359,13 +93381,14 @@ var init_studio2 = __esm({
|
|
|
93359
93381
|
customDefaults,
|
|
93360
93382
|
schema: mysqlSchema3,
|
|
93361
93383
|
relations: relations5,
|
|
93362
|
-
schemaFiles
|
|
93384
|
+
schemaFiles,
|
|
93385
|
+
casing: casing2
|
|
93363
93386
|
};
|
|
93364
93387
|
};
|
|
93365
|
-
drizzleForSQLite = async (credentials2, sqliteSchema2, relations5, schemaFiles) => {
|
|
93388
|
+
drizzleForSQLite = async (credentials2, sqliteSchema2, relations5, schemaFiles, casing2) => {
|
|
93366
93389
|
const { connectToSQLite: connectToSQLite2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
|
|
93367
93390
|
const sqliteDB = await connectToSQLite2(credentials2);
|
|
93368
|
-
const customDefaults = getCustomDefaults(sqliteSchema2);
|
|
93391
|
+
const customDefaults = getCustomDefaults(sqliteSchema2, casing2);
|
|
93369
93392
|
let dbUrl;
|
|
93370
93393
|
if ("driver" in credentials2) {
|
|
93371
93394
|
const { driver: driver2 } = credentials2;
|
|
@@ -93388,13 +93411,14 @@ var init_studio2 = __esm({
|
|
|
93388
93411
|
customDefaults,
|
|
93389
93412
|
schema: sqliteSchema2,
|
|
93390
93413
|
relations: relations5,
|
|
93391
|
-
schemaFiles
|
|
93414
|
+
schemaFiles,
|
|
93415
|
+
casing: casing2
|
|
93392
93416
|
};
|
|
93393
93417
|
};
|
|
93394
|
-
drizzleForLibSQL = async (credentials2, sqliteSchema2, relations5, schemaFiles) => {
|
|
93418
|
+
drizzleForLibSQL = async (credentials2, sqliteSchema2, relations5, schemaFiles, casing2) => {
|
|
93395
93419
|
const { connectToLibSQL: connectToLibSQL2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
|
|
93396
93420
|
const sqliteDB = await connectToLibSQL2(credentials2);
|
|
93397
|
-
const customDefaults = getCustomDefaults(sqliteSchema2);
|
|
93421
|
+
const customDefaults = getCustomDefaults(sqliteSchema2, casing2);
|
|
93398
93422
|
let dbUrl = `turso://${credentials2.url}/${credentials2.authToken}`;
|
|
93399
93423
|
const dbHash = (0, import_crypto9.createHash)("sha256").update(dbUrl).digest("hex");
|
|
93400
93424
|
return {
|
|
@@ -93407,13 +93431,14 @@ var init_studio2 = __esm({
|
|
|
93407
93431
|
customDefaults,
|
|
93408
93432
|
schema: sqliteSchema2,
|
|
93409
93433
|
relations: relations5,
|
|
93410
|
-
schemaFiles
|
|
93434
|
+
schemaFiles,
|
|
93435
|
+
casing: casing2
|
|
93411
93436
|
};
|
|
93412
93437
|
};
|
|
93413
|
-
drizzleForSingleStore = async (credentials2, singlestoreSchema2, relations5, schemaFiles) => {
|
|
93438
|
+
drizzleForSingleStore = async (credentials2, singlestoreSchema2, relations5, schemaFiles, casing2) => {
|
|
93414
93439
|
const { connectToSingleStore: connectToSingleStore2 } = await Promise.resolve().then(() => (init_connections(), connections_exports));
|
|
93415
93440
|
const { proxy, transactionProxy, database, packageName } = await connectToSingleStore2(credentials2);
|
|
93416
|
-
const customDefaults = getCustomDefaults(singlestoreSchema2);
|
|
93441
|
+
const customDefaults = getCustomDefaults(singlestoreSchema2, casing2);
|
|
93417
93442
|
let dbUrl;
|
|
93418
93443
|
if ("url" in credentials2) {
|
|
93419
93444
|
dbUrl = credentials2.url;
|
|
@@ -93431,14 +93456,15 @@ var init_studio2 = __esm({
|
|
|
93431
93456
|
customDefaults,
|
|
93432
93457
|
schema: singlestoreSchema2,
|
|
93433
93458
|
relations: relations5,
|
|
93434
|
-
schemaFiles
|
|
93459
|
+
schemaFiles,
|
|
93460
|
+
casing: casing2
|
|
93435
93461
|
};
|
|
93436
93462
|
};
|
|
93437
|
-
extractRelations = (tablesConfig) => {
|
|
93463
|
+
extractRelations = (tablesConfig, casing2) => {
|
|
93438
93464
|
const relations5 = Object.values(tablesConfig.tables).map(
|
|
93439
93465
|
(it) => Object.entries(it.relations).map(([name, relation]) => {
|
|
93440
93466
|
try {
|
|
93441
|
-
const normalized = (0,
|
|
93467
|
+
const normalized = (0, import_relations3.normalizeRelation)(
|
|
93442
93468
|
tablesConfig.tables,
|
|
93443
93469
|
tablesConfig.tableNamesMap,
|
|
93444
93470
|
relation
|
|
@@ -93446,8 +93472,8 @@ var init_studio2 = __esm({
|
|
|
93446
93472
|
const rel = relation;
|
|
93447
93473
|
const refTableName = rel.referencedTableName;
|
|
93448
93474
|
const refTable = rel.referencedTable;
|
|
93449
|
-
const fields = normalized.fields.map((it2) => it2
|
|
93450
|
-
const refColumns = normalized.references.map((it2) => it2
|
|
93475
|
+
const fields = normalized.fields.map((it2) => getColumnCasing(it2, casing2)).flat();
|
|
93476
|
+
const refColumns = normalized.references.map((it2) => getColumnCasing(it2, casing2)).flat();
|
|
93451
93477
|
let refSchema;
|
|
93452
93478
|
if ((0, import_drizzle_orm11.is)(refTable, import_pg_core3.PgTable)) {
|
|
93453
93479
|
refSchema = (0, import_pg_core3.getTableConfig)(refTable).schema;
|
|
@@ -93461,9 +93487,9 @@ var init_studio2 = __esm({
|
|
|
93461
93487
|
throw new Error("unsupported dialect");
|
|
93462
93488
|
}
|
|
93463
93489
|
let type;
|
|
93464
|
-
if ((0, import_drizzle_orm11.is)(rel,
|
|
93490
|
+
if ((0, import_drizzle_orm11.is)(rel, import_relations3.One)) {
|
|
93465
93491
|
type = "one";
|
|
93466
|
-
} else if ((0, import_drizzle_orm11.is)(rel,
|
|
93492
|
+
} else if ((0, import_drizzle_orm11.is)(rel, import_relations3.Many)) {
|
|
93467
93493
|
type = "many";
|
|
93468
93494
|
} else {
|
|
93469
93495
|
throw new Error("unsupported relation type");
|
|
@@ -93497,14 +93523,26 @@ var init_studio2 = __esm({
|
|
|
93497
93523
|
params: external_exports.array(external_exports.any()).optional(),
|
|
93498
93524
|
typings: external_exports.string().array().optional(),
|
|
93499
93525
|
mode: external_exports.enum(["array", "object"]).default("object"),
|
|
93500
|
-
method: external_exports.union([
|
|
93526
|
+
method: external_exports.union([
|
|
93527
|
+
external_exports.literal("values"),
|
|
93528
|
+
external_exports.literal("get"),
|
|
93529
|
+
external_exports.literal("all"),
|
|
93530
|
+
external_exports.literal("run"),
|
|
93531
|
+
external_exports.literal("execute")
|
|
93532
|
+
])
|
|
93501
93533
|
})
|
|
93502
93534
|
});
|
|
93503
93535
|
transactionProxySchema = external_exports.object({
|
|
93504
93536
|
type: external_exports.literal("tproxy"),
|
|
93505
93537
|
data: external_exports.object({
|
|
93506
93538
|
sql: external_exports.string(),
|
|
93507
|
-
method: external_exports.union([
|
|
93539
|
+
method: external_exports.union([
|
|
93540
|
+
external_exports.literal("values"),
|
|
93541
|
+
external_exports.literal("get"),
|
|
93542
|
+
external_exports.literal("all"),
|
|
93543
|
+
external_exports.literal("run"),
|
|
93544
|
+
external_exports.literal("execute")
|
|
93545
|
+
]).optional()
|
|
93508
93546
|
}).array()
|
|
93509
93547
|
});
|
|
93510
93548
|
defaultsSchema = external_exports.object({
|
|
@@ -93517,7 +93555,12 @@ var init_studio2 = __esm({
|
|
|
93517
93555
|
})
|
|
93518
93556
|
).min(1)
|
|
93519
93557
|
});
|
|
93520
|
-
schema5 = external_exports.union([
|
|
93558
|
+
schema5 = external_exports.union([
|
|
93559
|
+
init,
|
|
93560
|
+
proxySchema,
|
|
93561
|
+
transactionProxySchema,
|
|
93562
|
+
defaultsSchema
|
|
93563
|
+
]);
|
|
93521
93564
|
jsonStringify = (data) => {
|
|
93522
93565
|
return JSON.stringify(data, (_key, value) => {
|
|
93523
93566
|
if (value instanceof Error) {
|
|
@@ -93545,6 +93588,7 @@ var init_studio2 = __esm({
|
|
|
93545
93588
|
schema: drizzleSchema,
|
|
93546
93589
|
relations: relations5,
|
|
93547
93590
|
dbHash,
|
|
93591
|
+
casing: casing2,
|
|
93548
93592
|
schemaFiles
|
|
93549
93593
|
}, app) => {
|
|
93550
93594
|
app = app !== void 0 ? app : new Hono2();
|
|
@@ -93564,15 +93608,20 @@ var init_studio2 = __esm({
|
|
|
93564
93608
|
const relationalSchema = {
|
|
93565
93609
|
...Object.fromEntries(
|
|
93566
93610
|
Object.entries(drizzleSchema).map(([schemaName, schema6]) => {
|
|
93567
|
-
const mappedTableEntries = Object.entries(schema6).map(
|
|
93568
|
-
|
|
93569
|
-
|
|
93611
|
+
const mappedTableEntries = Object.entries(schema6).map(
|
|
93612
|
+
([tableName, table6]) => {
|
|
93613
|
+
return [`__${schemaName}__.${tableName}`, table6];
|
|
93614
|
+
}
|
|
93615
|
+
);
|
|
93570
93616
|
return mappedTableEntries;
|
|
93571
93617
|
}).flat()
|
|
93572
93618
|
),
|
|
93573
93619
|
...relations5
|
|
93574
93620
|
};
|
|
93575
|
-
const relationsConfig = (0,
|
|
93621
|
+
const relationsConfig = (0, import_relations3.extractTablesRelationalConfig)(
|
|
93622
|
+
relationalSchema,
|
|
93623
|
+
import_relations3.createTableRelationsHelpers
|
|
93624
|
+
);
|
|
93576
93625
|
app.post("/", zValidator("json", schema5), async (c3) => {
|
|
93577
93626
|
const body = c3.req.valid("json");
|
|
93578
93627
|
const { type } = body;
|
|
@@ -93584,11 +93633,17 @@ var init_studio2 = __esm({
|
|
|
93584
93633
|
}));
|
|
93585
93634
|
let relations6 = [];
|
|
93586
93635
|
try {
|
|
93587
|
-
relations6 = extractRelations(relationsConfig);
|
|
93636
|
+
relations6 = extractRelations(relationsConfig, casing2);
|
|
93588
93637
|
} catch (error2) {
|
|
93589
|
-
console.warn(
|
|
93590
|
-
|
|
93591
|
-
|
|
93638
|
+
console.warn(
|
|
93639
|
+
"Failed to extract relations. This is likely due to ambiguous or misconfigured relations."
|
|
93640
|
+
);
|
|
93641
|
+
console.warn(
|
|
93642
|
+
"Please check your schema and ensure that all relations are correctly defined."
|
|
93643
|
+
);
|
|
93644
|
+
console.warn(
|
|
93645
|
+
"See: https://orm.drizzle.team/docs/relations#disambiguating-relations"
|
|
93646
|
+
);
|
|
93592
93647
|
console.warn("Error message:", error2.message);
|
|
93593
93648
|
}
|
|
93594
93649
|
return c3.json({
|
|
@@ -93621,7 +93676,9 @@ var init_studio2 = __esm({
|
|
|
93621
93676
|
return d3.schema === column11.schema && d3.table === column11.table && d3.column === column11.column;
|
|
93622
93677
|
});
|
|
93623
93678
|
if (!found) {
|
|
93624
|
-
throw new Error(
|
|
93679
|
+
throw new Error(
|
|
93680
|
+
`Custom default not found for ${column11.schema}.${column11.table}.${column11.column}`
|
|
93681
|
+
);
|
|
93625
93682
|
}
|
|
93626
93683
|
const value = found.func();
|
|
93627
93684
|
return {
|
|
@@ -96005,7 +96062,8 @@ var studio = command2({
|
|
|
96005
96062
|
schema: schemaPath,
|
|
96006
96063
|
port,
|
|
96007
96064
|
host,
|
|
96008
|
-
credentials: credentials2
|
|
96065
|
+
credentials: credentials2,
|
|
96066
|
+
casing: casing2
|
|
96009
96067
|
} = await prepareStudioConfig(opts);
|
|
96010
96068
|
const {
|
|
96011
96069
|
drizzleForPostgres: drizzleForPostgres2,
|
|
@@ -96042,23 +96100,24 @@ var studio = command2({
|
|
|
96042
96100
|
}
|
|
96043
96101
|
}
|
|
96044
96102
|
const { schema: schema6, relations: relations5, files } = schemaPath ? await preparePgSchema2(schemaPath) : { schema: {}, relations: {}, files: [] };
|
|
96045
|
-
setup = await drizzleForPostgres2(credentials2, schema6, relations5, files);
|
|
96103
|
+
setup = await drizzleForPostgres2(credentials2, schema6, relations5, files, casing2);
|
|
96046
96104
|
} else if (dialect6 === "mysql") {
|
|
96047
96105
|
const { schema: schema6, relations: relations5, files } = schemaPath ? await prepareMySqlSchema2(schemaPath) : { schema: {}, relations: {}, files: [] };
|
|
96048
|
-
setup = await drizzleForMySQL2(credentials2, schema6, relations5, files);
|
|
96106
|
+
setup = await drizzleForMySQL2(credentials2, schema6, relations5, files, casing2);
|
|
96049
96107
|
} else if (dialect6 === "sqlite") {
|
|
96050
96108
|
const { schema: schema6, relations: relations5, files } = schemaPath ? await prepareSQLiteSchema2(schemaPath) : { schema: {}, relations: {}, files: [] };
|
|
96051
|
-
setup = await drizzleForSQLite2(credentials2, schema6, relations5, files);
|
|
96109
|
+
setup = await drizzleForSQLite2(credentials2, schema6, relations5, files, casing2);
|
|
96052
96110
|
} else if (dialect6 === "turso") {
|
|
96053
96111
|
const { schema: schema6, relations: relations5, files } = schemaPath ? await prepareSQLiteSchema2(schemaPath) : { schema: {}, relations: {}, files: [] };
|
|
96054
|
-
setup = await drizzleForLibSQL2(credentials2, schema6, relations5, files);
|
|
96112
|
+
setup = await drizzleForLibSQL2(credentials2, schema6, relations5, files, casing2);
|
|
96055
96113
|
} else if (dialect6 === "singlestore") {
|
|
96056
96114
|
const { schema: schema6, relations: relations5, files } = schemaPath ? await prepareSingleStoreSchema2(schemaPath) : { schema: {}, relations: {}, files: [] };
|
|
96057
96115
|
setup = await drizzleForSingleStore2(
|
|
96058
96116
|
credentials2,
|
|
96059
96117
|
schema6,
|
|
96060
96118
|
relations5,
|
|
96061
|
-
files
|
|
96119
|
+
files,
|
|
96120
|
+
casing2
|
|
96062
96121
|
);
|
|
96063
96122
|
} else if (dialect6 === "gel") {
|
|
96064
96123
|
console.log(
|
|
@@ -96165,7 +96224,7 @@ init_utils5();
|
|
|
96165
96224
|
var version2 = async () => {
|
|
96166
96225
|
const { npmVersion } = await ormCoreVersions();
|
|
96167
96226
|
const ormVersion = npmVersion ? `drizzle-orm: v${npmVersion}` : "";
|
|
96168
|
-
const envVersion = "1.0.0-beta.1-
|
|
96227
|
+
const envVersion = "1.0.0-beta.1-f77460a";
|
|
96169
96228
|
const kitVersion = envVersion ? `v${envVersion}` : "--";
|
|
96170
96229
|
const versions = `drizzle-kit: ${kitVersion}
|
|
96171
96230
|
${ormVersion}`;
|