drizzle-kit 0.25.0-cd0b1a2 → 0.25.0-d1da3b8
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.js +24225 -17924
- package/api.mjs +24239 -17939
- package/bin.cjs +111 -74
- package/package.json +1 -1
package/bin.cjs
CHANGED
@@ -78956,11 +78956,13 @@ var init_pgIntrospect = __esm({
|
|
78956
78956
|
});
|
78957
78957
|
|
78958
78958
|
// src/introspect-sqlite.ts
|
78959
|
-
var sqliteImportsList, indexName3, objToStatement2, relations, escapeColumnKey, withCasing, schemaToTypeScript, isCyclic, isSelf, mapColumnDefault, column4, createTableColumns, createTableIndexes, createTableUniques, createTablePKs, createTableFKs;
|
78959
|
+
var import_casing, sqliteImportsList, indexName3, objToStatement2, relations, escapeColumnKey, withCasing, dbColumnName, schemaToTypeScript, isCyclic, isSelf, mapColumnDefault, column4, createTableColumns, createTableIndexes, createTableUniques, createTablePKs, createTableFKs;
|
78960
78960
|
var init_introspect_sqlite = __esm({
|
78961
78961
|
"src/introspect-sqlite.ts"() {
|
78962
78962
|
"use strict";
|
78963
|
+
import_casing = require("drizzle-orm/casing");
|
78963
78964
|
init_utils3();
|
78965
|
+
init_global();
|
78964
78966
|
sqliteImportsList = /* @__PURE__ */ new Set([
|
78965
78967
|
"sqliteTable",
|
78966
78968
|
"integer",
|
@@ -78998,6 +79000,15 @@ var init_introspect_sqlite = __esm({
|
|
78998
79000
|
}
|
78999
79001
|
return value;
|
79000
79002
|
};
|
79003
|
+
dbColumnName = ({ name, casing: casing2, withMode = false }) => {
|
79004
|
+
if (casing2 === "preserve") {
|
79005
|
+
return "";
|
79006
|
+
}
|
79007
|
+
if (casing2 === "camel") {
|
79008
|
+
return (0, import_casing.toCamelCase)(name) === name ? "" : withMode ? `"${name}", ` : `"${name}"`;
|
79009
|
+
}
|
79010
|
+
assertUnreachable(casing2);
|
79011
|
+
};
|
79001
79012
|
schemaToTypeScript = (schema5, casing2) => {
|
79002
79013
|
Object.values(schema5.tables).forEach((table4) => {
|
79003
79014
|
Object.values(table4.foreignKeys).forEach((fk4) => {
|
@@ -79117,13 +79128,14 @@ var init_introspect_sqlite = __esm({
|
|
79117
79128
|
};
|
79118
79129
|
column4 = (type, name, defaultValue, autoincrement, casing2) => {
|
79119
79130
|
let lowered = type;
|
79131
|
+
casing2 = casing2;
|
79120
79132
|
if (lowered === "integer") {
|
79121
|
-
let out = `${withCasing(name, casing2)}: integer(
|
79133
|
+
let out = `${withCasing(name, casing2)}: integer(${dbColumnName({ name, casing: casing2 })})`;
|
79122
79134
|
out += typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault(defaultValue)})` : "";
|
79123
79135
|
return out;
|
79124
79136
|
}
|
79125
79137
|
if (lowered === "real") {
|
79126
|
-
let out = `${withCasing(name, casing2)}: real(
|
79138
|
+
let out = `${withCasing(name, casing2)}: real(${dbColumnName({ name, casing: casing2 })})`;
|
79127
79139
|
out += defaultValue ? `.default(${mapColumnDefault(defaultValue)})` : "";
|
79128
79140
|
return out;
|
79129
79141
|
}
|
@@ -79131,20 +79143,20 @@ var init_introspect_sqlite = __esm({
|
|
79131
79143
|
const match2 = lowered.match(/\d+/);
|
79132
79144
|
let out;
|
79133
79145
|
if (match2) {
|
79134
|
-
out = `${withCasing(name, casing2)}: text(
|
79146
|
+
out = `${withCasing(name, casing2)}: text(${dbColumnName({ name, casing: casing2, withMode: true })}{ length: ${match2[0]} })`;
|
79135
79147
|
} else {
|
79136
|
-
out = `${withCasing(name, casing2)}: text(
|
79148
|
+
out = `${withCasing(name, casing2)}: text(${dbColumnName({ name, casing: casing2 })})`;
|
79137
79149
|
}
|
79138
79150
|
out += defaultValue ? `.default("${mapColumnDefault(defaultValue)}")` : "";
|
79139
79151
|
return out;
|
79140
79152
|
}
|
79141
79153
|
if (lowered === "blob") {
|
79142
|
-
let out = `${withCasing(name, casing2)}: blob(
|
79154
|
+
let out = `${withCasing(name, casing2)}: blob(${dbColumnName({ name, casing: casing2 })})`;
|
79143
79155
|
out += defaultValue ? `.default(${mapColumnDefault(defaultValue)})` : "";
|
79144
79156
|
return out;
|
79145
79157
|
}
|
79146
79158
|
if (lowered === "numeric") {
|
79147
|
-
let out = `${withCasing(name, casing2)}: numeric(
|
79159
|
+
let out = `${withCasing(name, casing2)}: numeric(${dbColumnName({ name, casing: casing2 })})`;
|
79148
79160
|
out += defaultValue ? `.default(${mapColumnDefault(defaultValue)})` : "";
|
79149
79161
|
return out;
|
79150
79162
|
}
|
@@ -80067,11 +80079,13 @@ var require_pluralize = __commonJS({
|
|
80067
80079
|
});
|
80068
80080
|
|
80069
80081
|
// src/introspect-mysql.ts
|
80070
|
-
var mysqlImportsList, objToStatement22, timeConfig, binaryConfig, importsPatch, relations2, escapeColumnKey2, prepareCasing, schemaToTypeScript2, isCyclic2, isSelf2, mapColumnDefault2, mapColumnDefaultForJson, column5, createTableColumns2, createTableIndexes2, createTableUniques2, createTablePKs2, createTableFKs2;
|
80082
|
+
var import_casing2, mysqlImportsList, objToStatement22, timeConfig, binaryConfig, importsPatch, relations2, escapeColumnKey2, prepareCasing, dbColumnName2, schemaToTypeScript2, isCyclic2, isSelf2, mapColumnDefault2, mapColumnDefaultForJson, column5, createTableColumns2, createTableIndexes2, createTableUniques2, createTablePKs2, createTableFKs2;
|
80071
80083
|
var init_introspect_mysql = __esm({
|
80072
80084
|
"src/introspect-mysql.ts"() {
|
80073
80085
|
"use strict";
|
80086
|
+
import_casing2 = require("drizzle-orm/casing");
|
80074
80087
|
init_utils3();
|
80088
|
+
init_global();
|
80075
80089
|
init_mysqlSerializer();
|
80076
80090
|
mysqlImportsList = /* @__PURE__ */ new Set([
|
80077
80091
|
"mysqlTable",
|
@@ -80151,7 +80165,16 @@ var init_introspect_mysql = __esm({
|
|
80151
80165
|
if (casing2 === "camel") {
|
80152
80166
|
return escapeColumnKey2(value.camelCase());
|
80153
80167
|
}
|
80154
|
-
|
80168
|
+
assertUnreachable(casing2);
|
80169
|
+
};
|
80170
|
+
dbColumnName2 = ({ name, casing: casing2, withMode = false }) => {
|
80171
|
+
if (casing2 === "preserve") {
|
80172
|
+
return "";
|
80173
|
+
}
|
80174
|
+
if (casing2 === "camel") {
|
80175
|
+
return (0, import_casing2.toCamelCase)(name) === name ? "" : withMode ? `"${name}", ` : `"${name}"`;
|
80176
|
+
}
|
80177
|
+
assertUnreachable(casing2);
|
80155
80178
|
};
|
80156
80179
|
schemaToTypeScript2 = (schema5, casing2) => {
|
80157
80180
|
const withCasing4 = prepareCasing(casing2);
|
@@ -80212,6 +80235,7 @@ var init_introspect_mysql = __esm({
|
|
80212
80235
|
Object.values(table4.columns),
|
80213
80236
|
Object.values(table4.foreignKeys),
|
80214
80237
|
withCasing4,
|
80238
|
+
casing2,
|
80215
80239
|
table4.name,
|
80216
80240
|
schema5
|
80217
80241
|
);
|
@@ -80291,51 +80315,51 @@ import { sql } from "drizzle-orm"
|
|
80291
80315
|
}
|
80292
80316
|
return defaultValue;
|
80293
80317
|
};
|
80294
|
-
column5 = (type, name, casing2, defaultValue, autoincrement, onUpdate, isExpression) => {
|
80318
|
+
column5 = (type, name, casing2, rawCasing, defaultValue, autoincrement, onUpdate, isExpression) => {
|
80295
80319
|
let lowered = type;
|
80296
80320
|
if (!type.startsWith("enum(")) {
|
80297
80321
|
lowered = type.toLowerCase();
|
80298
80322
|
}
|
80299
80323
|
if (lowered === "serial") {
|
80300
|
-
return `${casing2(name)}: serial(
|
80324
|
+
return `${casing2(name)}: serial(${dbColumnName2({ name, casing: rawCasing })})`;
|
80301
80325
|
}
|
80302
80326
|
if (lowered.startsWith("int")) {
|
80303
80327
|
const isUnsigned = lowered.startsWith("int unsigned");
|
80304
|
-
let out = `${casing2(name)}: int(
|
80328
|
+
let out = `${casing2(name)}: int(${dbColumnName2({ name, casing: rawCasing, withMode: isUnsigned })}${isUnsigned ? "{ unsigned: true }" : ""})`;
|
80305
80329
|
out += autoincrement ? `.autoincrement()` : "";
|
80306
80330
|
out += typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
|
80307
80331
|
return out;
|
80308
80332
|
}
|
80309
80333
|
if (lowered.startsWith("tinyint")) {
|
80310
80334
|
const isUnsigned = lowered.startsWith("tinyint unsigned");
|
80311
|
-
let out = `${casing2(name)}: tinyint(
|
80335
|
+
let out = `${casing2(name)}: tinyint(${dbColumnName2({ name, casing: rawCasing, withMode: isUnsigned })}${isUnsigned ? ", { unsigned: true }" : ""})`;
|
80312
80336
|
out += autoincrement ? `.autoincrement()` : "";
|
80313
80337
|
out += typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
|
80314
80338
|
return out;
|
80315
80339
|
}
|
80316
80340
|
if (lowered.startsWith("smallint")) {
|
80317
80341
|
const isUnsigned = lowered.startsWith("smallint unsigned");
|
80318
|
-
let out = `${casing2(name)}: smallint(
|
80342
|
+
let out = `${casing2(name)}: smallint(${dbColumnName2({ name, casing: rawCasing, withMode: isUnsigned })}${isUnsigned ? ", { unsigned: true }" : ""})`;
|
80319
80343
|
out += autoincrement ? `.autoincrement()` : "";
|
80320
80344
|
out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
|
80321
80345
|
return out;
|
80322
80346
|
}
|
80323
80347
|
if (lowered.startsWith("mediumint")) {
|
80324
80348
|
const isUnsigned = lowered.startsWith("mediumint unsigned");
|
80325
|
-
let out = `${casing2(name)}: mediumint(
|
80349
|
+
let out = `${casing2(name)}: mediumint(${dbColumnName2({ name, casing: rawCasing, withMode: isUnsigned })}${isUnsigned ? ", { unsigned: true }" : ""})`;
|
80326
80350
|
out += autoincrement ? `.autoincrement()` : "";
|
80327
80351
|
out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
|
80328
80352
|
return out;
|
80329
80353
|
}
|
80330
80354
|
if (lowered.startsWith("bigint")) {
|
80331
80355
|
const isUnsigned = lowered.startsWith("bigint unsigned");
|
80332
|
-
let out = `${casing2(name)}: bigint(
|
80356
|
+
let out = `${casing2(name)}: bigint(${dbColumnName2({ name, casing: rawCasing, withMode: true })}{ mode: "number"${isUnsigned ? ", unsigned: true" : ""} })`;
|
80333
80357
|
out += autoincrement ? `.autoincrement()` : "";
|
80334
80358
|
out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
|
80335
80359
|
return out;
|
80336
80360
|
}
|
80337
80361
|
if (lowered === "boolean") {
|
80338
|
-
let out = `${casing2(name)}: boolean(
|
80362
|
+
let out = `${casing2(name)}: boolean(${dbColumnName2({ name, casing: rawCasing })})`;
|
80339
80363
|
out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
|
80340
80364
|
return out;
|
80341
80365
|
}
|
@@ -80345,17 +80369,18 @@ import { sql } from "drizzle-orm"
|
|
80345
80369
|
const [precision, scale] = lowered.slice(7, lowered.length - 1).split(",");
|
80346
80370
|
params = { precision, scale };
|
80347
80371
|
}
|
80348
|
-
|
80372
|
+
const timeConfigParams = params ? timeConfig(params) : void 0;
|
80373
|
+
let out = params ? `${casing2(name)}: double(${dbColumnName2({ name, casing: rawCasing, withMode: timeConfigParams !== void 0 })}${timeConfig(params)})` : `${casing2(name)}: double(${dbColumnName2({ name, casing: rawCasing })})`;
|
80349
80374
|
out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
|
80350
80375
|
return out;
|
80351
80376
|
}
|
80352
80377
|
if (lowered === "float") {
|
80353
|
-
let out = `${casing2(name)}: float(
|
80378
|
+
let out = `${casing2(name)}: float(${dbColumnName2({ name, casing: rawCasing })})`;
|
80354
80379
|
out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
|
80355
80380
|
return out;
|
80356
80381
|
}
|
80357
80382
|
if (lowered === "real") {
|
80358
|
-
let out = `${casing2(name)}: real(
|
80383
|
+
let out = `${casing2(name)}: real(${dbColumnName2({ name, casing: rawCasing })})`;
|
80359
80384
|
out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
|
80360
80385
|
return out;
|
80361
80386
|
}
|
@@ -80364,7 +80389,7 @@ import { sql } from "drizzle-orm"
|
|
80364
80389
|
let fsp = lowered.length > keyLength ? Number(lowered.substring(keyLength, lowered.length - 1)) : null;
|
80365
80390
|
fsp = fsp ? fsp : null;
|
80366
80391
|
const params = timeConfig({ fsp, mode: "'string'" });
|
80367
|
-
let out = params ? `${casing2(name)}: timestamp(
|
80392
|
+
let out = params ? `${casing2(name)}: timestamp(${dbColumnName2({ name, casing: rawCasing, withMode: params !== void 0 })}${params})` : `${casing2(name)}: timestamp(${dbColumnName2({ name, casing: rawCasing })})`;
|
80368
80393
|
defaultValue = defaultValue === "now()" || defaultValue === "(CURRENT_TIMESTAMP)" ? ".defaultNow()" : defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
|
80369
80394
|
out += defaultValue;
|
80370
80395
|
let onUpdateNow = onUpdate ? ".onUpdateNow()" : "";
|
@@ -80376,7 +80401,7 @@ import { sql } from "drizzle-orm"
|
|
80376
80401
|
let fsp = lowered.length > keyLength ? Number(lowered.substring(keyLength, lowered.length - 1)) : null;
|
80377
80402
|
fsp = fsp ? fsp : null;
|
80378
80403
|
const params = timeConfig({ fsp });
|
80379
|
-
let out = params ? `${casing2(name)}: time(
|
80404
|
+
let out = params ? `${casing2(name)}: time(${dbColumnName2({ name, casing: rawCasing, withMode: params !== void 0 })}${params})` : `${casing2(name)}: time(${dbColumnName2({ name, casing: rawCasing })})`;
|
80380
80405
|
defaultValue = defaultValue === "now()" ? ".defaultNow()" : defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
|
80381
80406
|
out += defaultValue;
|
80382
80407
|
return out;
|
@@ -80385,45 +80410,45 @@ import { sql } from "drizzle-orm"
|
|
80385
80410
|
let out = `// you can use { mode: 'date' }, if you want to have Date as type for this column
|
80386
80411
|
${casing2(
|
80387
80412
|
name
|
80388
|
-
)}: date(
|
80413
|
+
)}: date(${dbColumnName2({ name, casing: rawCasing, withMode: true })}{ mode: 'string' })`;
|
80389
80414
|
defaultValue = defaultValue === "now()" ? ".defaultNow()" : defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
|
80390
80415
|
out += defaultValue;
|
80391
80416
|
return out;
|
80392
80417
|
}
|
80393
80418
|
if (lowered === "text") {
|
80394
|
-
let out = `${casing2(name)}: text(
|
80419
|
+
let out = `${casing2(name)}: text(${dbColumnName2({ name, casing: rawCasing })})`;
|
80395
80420
|
out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
|
80396
80421
|
return out;
|
80397
80422
|
}
|
80398
80423
|
if (lowered === "tinytext") {
|
80399
|
-
let out = `${casing2(name)}: tinytext(
|
80424
|
+
let out = `${casing2(name)}: tinytext(${dbColumnName2({ name, casing: rawCasing })})`;
|
80400
80425
|
out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
|
80401
80426
|
return out;
|
80402
80427
|
}
|
80403
80428
|
if (lowered === "mediumtext") {
|
80404
|
-
let out = `${casing2(name)}: mediumtext(
|
80429
|
+
let out = `${casing2(name)}: mediumtext(${dbColumnName2({ name, casing: rawCasing })})`;
|
80405
80430
|
out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
|
80406
80431
|
return out;
|
80407
80432
|
}
|
80408
80433
|
if (lowered === "longtext") {
|
80409
|
-
let out = `${casing2(name)}: longtext(
|
80434
|
+
let out = `${casing2(name)}: longtext(${dbColumnName2({ name, casing: rawCasing })})`;
|
80410
80435
|
out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
|
80411
80436
|
return out;
|
80412
80437
|
}
|
80413
80438
|
if (lowered === "year") {
|
80414
|
-
let out = `${casing2(name)}: year(
|
80439
|
+
let out = `${casing2(name)}: year(${dbColumnName2({ name, casing: rawCasing })})`;
|
80415
80440
|
out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
|
80416
80441
|
return out;
|
80417
80442
|
}
|
80418
80443
|
if (lowered === "json") {
|
80419
|
-
let out = `${casing2(name)}: json(
|
80444
|
+
let out = `${casing2(name)}: json(${dbColumnName2({ name, casing: rawCasing })})`;
|
80420
80445
|
out += defaultValue ? `.default(${mapColumnDefaultForJson(defaultValue)})` : "";
|
80421
80446
|
return out;
|
80422
80447
|
}
|
80423
80448
|
if (lowered.startsWith("varchar")) {
|
80424
80449
|
let out = `${casing2(
|
80425
80450
|
name
|
80426
|
-
)}: varchar(
|
80451
|
+
)}: varchar(${dbColumnName2({ name, casing: rawCasing, withMode: true })}{ length: ${lowered.substring(
|
80427
80452
|
"varchar".length + 1,
|
80428
80453
|
lowered.length - 1
|
80429
80454
|
)} })`;
|
@@ -80433,7 +80458,7 @@ import { sql } from "drizzle-orm"
|
|
80433
80458
|
if (lowered.startsWith("char")) {
|
80434
80459
|
let out = `${casing2(
|
80435
80460
|
name
|
80436
|
-
)}: char(
|
80461
|
+
)}: char(${dbColumnName2({ name, casing: rawCasing, withMode: true })}{ length: ${lowered.substring(
|
80437
80462
|
"char".length + 1,
|
80438
80463
|
lowered.length - 1
|
80439
80464
|
)} })`;
|
@@ -80446,10 +80471,10 @@ import { sql } from "drizzle-orm"
|
|
80446
80471
|
const fsp = lowered.startsWith("datetime(") ? lowered.substring("datetime".length + 1, lowered.length - 1) : void 0;
|
80447
80472
|
out = fsp ? `${casing2(
|
80448
80473
|
name
|
80449
|
-
)}: datetime(
|
80474
|
+
)}: datetime(${dbColumnName2({ name, casing: rawCasing, withMode: true })}{ mode: 'string', fsp: ${lowered.substring(
|
80450
80475
|
"datetime".length + 1,
|
80451
80476
|
lowered.length - 1
|
80452
|
-
)} })` : `${casing2(name)}: datetime(
|
80477
|
+
)} })` : `${casing2(name)}: datetime(${dbColumnName2({ name, casing: rawCasing, withMode: true })}{ mode: 'string'})`;
|
80453
80478
|
defaultValue = defaultValue === "now()" ? ".defaultNow()" : defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
|
80454
80479
|
out += defaultValue;
|
80455
80480
|
return out;
|
@@ -80460,7 +80485,8 @@ import { sql } from "drizzle-orm"
|
|
80460
80485
|
const [precision, scale] = lowered.slice(8, lowered.length - 1).split(",");
|
80461
80486
|
params = { precision, scale };
|
80462
80487
|
}
|
80463
|
-
|
80488
|
+
const timeConfigParams = params ? timeConfig(params) : void 0;
|
80489
|
+
let out = params ? `${casing2(name)}: decimal(${dbColumnName2({ name, casing: rawCasing, withMode: timeConfigParams !== void 0 })}${timeConfigParams})` : `${casing2(name)}: decimal(${dbColumnName2({ name, casing: rawCasing })})`;
|
80464
80490
|
defaultValue = typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
|
80465
80491
|
out += defaultValue;
|
80466
80492
|
return out;
|
@@ -80470,14 +80496,14 @@ import { sql } from "drizzle-orm"
|
|
80470
80496
|
let length = lowered.length > keyLength ? Number(lowered.substring(keyLength, lowered.length - 1)) : null;
|
80471
80497
|
length = length ? length : null;
|
80472
80498
|
const params = binaryConfig({ length });
|
80473
|
-
let out = params ? `${casing2(name)}: binary(
|
80499
|
+
let out = params ? `${casing2(name)}: binary(${dbColumnName2({ name, casing: rawCasing, withMode: params !== void 0 })}${params})` : `${casing2(name)}: binary(${dbColumnName2({ name, casing: rawCasing })})`;
|
80474
80500
|
defaultValue = defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
|
80475
80501
|
out += defaultValue;
|
80476
80502
|
return out;
|
80477
80503
|
}
|
80478
80504
|
if (lowered.startsWith("enum")) {
|
80479
80505
|
const values = lowered.substring("enum".length + 1, lowered.length - 1);
|
80480
|
-
let out = `${casing2(name)}: mysqlEnum(
|
80506
|
+
let out = `${casing2(name)}: mysqlEnum(${dbColumnName2({ name, casing: rawCasing, withMode: true })}[${values}])`;
|
80481
80507
|
out += defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
|
80482
80508
|
return out;
|
80483
80509
|
}
|
@@ -80486,7 +80512,7 @@ import { sql } from "drizzle-orm"
|
|
80486
80512
|
let length = lowered.length > keyLength ? Number(lowered.substring(keyLength, lowered.length - 1)) : null;
|
80487
80513
|
length = length ? length : null;
|
80488
80514
|
const params = binaryConfig({ length });
|
80489
|
-
let out = params ? `${casing2(name)}: varbinary(
|
80515
|
+
let out = params ? `${casing2(name)}: varbinary(${dbColumnName2({ name, casing: rawCasing, withMode: params !== void 0 })}${params})` : `${casing2(name)}: varbinary(${dbColumnName2({ name, casing: rawCasing })})`;
|
80490
80516
|
defaultValue = defaultValue ? `.default(${mapColumnDefault2(defaultValue, isExpression)})` : "";
|
80491
80517
|
out += defaultValue;
|
80492
80518
|
return out;
|
@@ -80495,7 +80521,7 @@ import { sql } from "drizzle-orm"
|
|
80495
80521
|
return `// Warning: Can't parse ${type} from database
|
80496
80522
|
// ${type}Type: ${type}("${name}")`;
|
80497
80523
|
};
|
80498
|
-
createTableColumns2 = (columns, fks, casing2, tableName, schema5) => {
|
80524
|
+
createTableColumns2 = (columns, fks, casing2, rawCasing, tableName, schema5) => {
|
80499
80525
|
let statement = "";
|
80500
80526
|
const oneColumnsFKs = Object.values(fks).filter((it) => {
|
80501
80527
|
return !isSelf2(it);
|
@@ -80513,6 +80539,7 @@ import { sql } from "drizzle-orm"
|
|
80513
80539
|
it.type,
|
80514
80540
|
it.name,
|
80515
80541
|
casing2,
|
80542
|
+
rawCasing,
|
80516
80543
|
it.default,
|
80517
80544
|
it.autoincrement,
|
80518
80545
|
it.onUpdate,
|
@@ -80643,13 +80670,14 @@ function generateIdentityParams(identity) {
|
|
80643
80670
|
}
|
80644
80671
|
return `.generatedByDefaultAsIdentity(${paramsObj})`;
|
80645
80672
|
}
|
80646
|
-
var import_drizzle_orm9, import_relations, pgImportsList, timeConfig2, possibleIntervals, intervalStrToObj, intervalConfig, mapColumnDefault3, importsPatch2, relations3, escapeColumnKey3, withCasing2, paramNameFor, schemaToTypeScript3, isCyclic3, isSelf3, buildArrayDefault, mapDefault, column6, dimensionsInArray, createTableColumns3, createTableIndexes3, createTablePKs3, createTableUniques3, createTableFKs3;
|
80673
|
+
var import_drizzle_orm9, import_relations, import_casing3, pgImportsList, timeConfig2, possibleIntervals, intervalStrToObj, intervalConfig, mapColumnDefault3, importsPatch2, relations3, escapeColumnKey3, withCasing2, dbColumnName3, paramNameFor, schemaToTypeScript3, isCyclic3, isSelf3, buildArrayDefault, mapDefault, column6, dimensionsInArray, createTableColumns3, createTableIndexes3, createTablePKs3, createTableUniques3, createTableFKs3;
|
80647
80674
|
var init_introspect_pg = __esm({
|
80648
80675
|
"src/introspect-pg.ts"() {
|
80649
80676
|
"use strict";
|
80650
80677
|
import_drizzle_orm9 = require("drizzle-orm");
|
80651
80678
|
import_relations = require("drizzle-orm/relations");
|
80652
80679
|
init_utils3();
|
80680
|
+
import_casing3 = require("drizzle-orm/casing");
|
80653
80681
|
init_vector();
|
80654
80682
|
init_global();
|
80655
80683
|
init_pgSerializer();
|
@@ -80775,6 +80803,15 @@ var init_introspect_pg = __esm({
|
|
80775
80803
|
}
|
80776
80804
|
assertUnreachable(casing2);
|
80777
80805
|
};
|
80806
|
+
dbColumnName3 = ({ name, casing: casing2, withMode = false }) => {
|
80807
|
+
if (casing2 === "preserve") {
|
80808
|
+
return "";
|
80809
|
+
}
|
80810
|
+
if (casing2 === "camel") {
|
80811
|
+
return (0, import_casing3.toCamelCase)(name) === name ? "" : withMode ? `"${name}", ` : `"${name}"`;
|
80812
|
+
}
|
80813
|
+
assertUnreachable(casing2);
|
80814
|
+
};
|
80778
80815
|
paramNameFor = (name, schema5) => {
|
80779
80816
|
const schemaSuffix = schema5 && schema5 !== "public" ? `In${schema5.capitalise()}` : "";
|
80780
80817
|
return `${name}${schemaSuffix}`;
|
@@ -81070,49 +81107,49 @@ var init_introspect_pg = __esm({
|
|
81070
81107
|
let out = `${withCasing2(name, casing2)}: ${withCasing2(
|
81071
81108
|
paramNameFor(type.replace("[]", ""), typeSchema),
|
81072
81109
|
casing2
|
81073
|
-
)}(
|
81110
|
+
)}(${dbColumnName3({ name, casing: casing2 })})`;
|
81074
81111
|
return out;
|
81075
81112
|
}
|
81076
81113
|
if (lowered.startsWith("serial")) {
|
81077
|
-
return `${withCasing2(name, casing2)}: serial(
|
81114
|
+
return `${withCasing2(name, casing2)}: serial(${dbColumnName3({ name, casing: casing2 })})`;
|
81078
81115
|
}
|
81079
81116
|
if (lowered.startsWith("smallserial")) {
|
81080
|
-
return `${withCasing2(name, casing2)}: smallserial(
|
81117
|
+
return `${withCasing2(name, casing2)}: smallserial(${dbColumnName3({ name, casing: casing2 })})`;
|
81081
81118
|
}
|
81082
81119
|
if (lowered.startsWith("bigserial")) {
|
81083
81120
|
return `${withCasing2(
|
81084
81121
|
name,
|
81085
81122
|
casing2
|
81086
|
-
)}: bigserial(
|
81123
|
+
)}: bigserial(${dbColumnName3({ name, casing: casing2, withMode: true })}{ mode: "bigint" })`;
|
81087
81124
|
}
|
81088
81125
|
if (lowered.startsWith("integer")) {
|
81089
|
-
let out = `${withCasing2(name, casing2)}: integer(
|
81126
|
+
let out = `${withCasing2(name, casing2)}: integer(${dbColumnName3({ name, casing: casing2 })})`;
|
81090
81127
|
return out;
|
81091
81128
|
}
|
81092
81129
|
if (lowered.startsWith("smallint")) {
|
81093
|
-
let out = `${withCasing2(name, casing2)}: smallint(
|
81130
|
+
let out = `${withCasing2(name, casing2)}: smallint(${dbColumnName3({ name, casing: casing2 })})`;
|
81094
81131
|
return out;
|
81095
81132
|
}
|
81096
81133
|
if (lowered.startsWith("bigint")) {
|
81097
81134
|
let out = `// You can use { mode: "bigint" } if numbers are exceeding js number limitations
|
81098
81135
|
`;
|
81099
|
-
out += `${withCasing2(name, casing2)}: bigint(
|
81136
|
+
out += `${withCasing2(name, casing2)}: bigint(${dbColumnName3({ name, casing: casing2, withMode: true })}{ mode: "number" })`;
|
81100
81137
|
return out;
|
81101
81138
|
}
|
81102
81139
|
if (lowered.startsWith("boolean")) {
|
81103
|
-
let out = `${withCasing2(name, casing2)}: boolean(
|
81140
|
+
let out = `${withCasing2(name, casing2)}: boolean(${dbColumnName3({ name, casing: casing2 })})`;
|
81104
81141
|
return out;
|
81105
81142
|
}
|
81106
81143
|
if (lowered.startsWith("double precision")) {
|
81107
|
-
let out = `${withCasing2(name, casing2)}: doublePrecision(
|
81144
|
+
let out = `${withCasing2(name, casing2)}: doublePrecision(${dbColumnName3({ name, casing: casing2 })})`;
|
81108
81145
|
return out;
|
81109
81146
|
}
|
81110
81147
|
if (lowered.startsWith("real")) {
|
81111
|
-
let out = `${withCasing2(name, casing2)}: real(
|
81148
|
+
let out = `${withCasing2(name, casing2)}: real(${dbColumnName3({ name, casing: casing2 })})`;
|
81112
81149
|
return out;
|
81113
81150
|
}
|
81114
81151
|
if (lowered.startsWith("uuid")) {
|
81115
|
-
let out = `${withCasing2(name, casing2)}: uuid(
|
81152
|
+
let out = `${withCasing2(name, casing2)}: uuid(${dbColumnName3({ name, casing: casing2 })})`;
|
81116
81153
|
return out;
|
81117
81154
|
}
|
81118
81155
|
if (lowered.startsWith("numeric")) {
|
@@ -81121,7 +81158,7 @@ var init_introspect_pg = __esm({
|
|
81121
81158
|
const [precision, scale] = lowered.slice(8, lowered.length - 1).split(",");
|
81122
81159
|
params = { precision, scale };
|
81123
81160
|
}
|
81124
|
-
let out = params ? `${withCasing2(name, casing2)}: numeric(
|
81161
|
+
let out = params ? `${withCasing2(name, casing2)}: numeric(${dbColumnName3({ name, casing: casing2, withMode: true })}${timeConfig2(params)})` : `${withCasing2(name, casing2)}: numeric(${dbColumnName3({ name, casing: casing2 })})`;
|
81125
81162
|
return out;
|
81126
81163
|
}
|
81127
81164
|
if (lowered.startsWith("timestamp")) {
|
@@ -81135,7 +81172,7 @@ var init_introspect_pg = __esm({
|
|
81135
81172
|
withTimezone,
|
81136
81173
|
mode: "'string'"
|
81137
81174
|
});
|
81138
|
-
let out = params ? `${withCasing2(name, casing2)}: timestamp(
|
81175
|
+
let out = params ? `${withCasing2(name, casing2)}: timestamp(${dbColumnName3({ name, casing: casing2, withMode: true })}${params})` : `${withCasing2(name, casing2)}: timestamp(${dbColumnName3({ name, casing: casing2 })})`;
|
81139
81176
|
return out;
|
81140
81177
|
}
|
81141
81178
|
if (lowered.startsWith("time")) {
|
@@ -81145,44 +81182,44 @@ var init_introspect_pg = __esm({
|
|
81145
81182
|
) : null;
|
81146
81183
|
precision = precision ? precision : null;
|
81147
81184
|
const params = timeConfig2({ precision, withTimezone });
|
81148
|
-
let out = params ? `${withCasing2(name, casing2)}: time(
|
81185
|
+
let out = params ? `${withCasing2(name, casing2)}: time(${dbColumnName3({ name, casing: casing2, withMode: true })}${params})` : `${withCasing2(name, casing2)}: time(${dbColumnName3({ name, casing: casing2 })})`;
|
81149
81186
|
return out;
|
81150
81187
|
}
|
81151
81188
|
if (lowered.startsWith("interval")) {
|
81152
81189
|
const params = intervalConfig(lowered);
|
81153
|
-
let out = params ? `${withCasing2(name, casing2)}: interval(
|
81190
|
+
let out = params ? `${withCasing2(name, casing2)}: interval(${dbColumnName3({ name, casing: casing2, withMode: true })}${params})` : `${withCasing2(name, casing2)}: interval(${dbColumnName3({ name, casing: casing2 })})`;
|
81154
81191
|
return out;
|
81155
81192
|
}
|
81156
81193
|
if (lowered === "date") {
|
81157
|
-
let out = `${withCasing2(name, casing2)}: date(
|
81194
|
+
let out = `${withCasing2(name, casing2)}: date(${dbColumnName3({ name, casing: casing2 })})`;
|
81158
81195
|
return out;
|
81159
81196
|
}
|
81160
81197
|
if (lowered.startsWith("text")) {
|
81161
|
-
let out = `${withCasing2(name, casing2)}: text(
|
81198
|
+
let out = `${withCasing2(name, casing2)}: text(${dbColumnName3({ name, casing: casing2 })})`;
|
81162
81199
|
return out;
|
81163
81200
|
}
|
81164
81201
|
if (lowered.startsWith("jsonb")) {
|
81165
|
-
let out = `${withCasing2(name, casing2)}: jsonb(
|
81202
|
+
let out = `${withCasing2(name, casing2)}: jsonb(${dbColumnName3({ name, casing: casing2 })})`;
|
81166
81203
|
return out;
|
81167
81204
|
}
|
81168
81205
|
if (lowered.startsWith("json")) {
|
81169
|
-
let out = `${withCasing2(name, casing2)}: json(
|
81206
|
+
let out = `${withCasing2(name, casing2)}: json(${dbColumnName3({ name, casing: casing2 })})`;
|
81170
81207
|
return out;
|
81171
81208
|
}
|
81172
81209
|
if (lowered.startsWith("inet")) {
|
81173
|
-
let out = `${withCasing2(name, casing2)}: inet(
|
81210
|
+
let out = `${withCasing2(name, casing2)}: inet(${dbColumnName3({ name, casing: casing2 })})`;
|
81174
81211
|
return out;
|
81175
81212
|
}
|
81176
81213
|
if (lowered.startsWith("cidr")) {
|
81177
|
-
let out = `${withCasing2(name, casing2)}: cidr(
|
81214
|
+
let out = `${withCasing2(name, casing2)}: cidr(${dbColumnName3({ name, casing: casing2 })})`;
|
81178
81215
|
return out;
|
81179
81216
|
}
|
81180
81217
|
if (lowered.startsWith("macaddr8")) {
|
81181
|
-
let out = `${withCasing2(name, casing2)}: macaddr8(
|
81218
|
+
let out = `${withCasing2(name, casing2)}: macaddr8(${dbColumnName3({ name, casing: casing2 })})`;
|
81182
81219
|
return out;
|
81183
81220
|
}
|
81184
81221
|
if (lowered.startsWith("macaddr")) {
|
81185
|
-
let out = `${withCasing2(name, casing2)}: macaddr(
|
81222
|
+
let out = `${withCasing2(name, casing2)}: macaddr(${dbColumnName3({ name, casing: casing2 })})`;
|
81186
81223
|
return out;
|
81187
81224
|
}
|
81188
81225
|
if (lowered.startsWith("varchar")) {
|
@@ -81191,21 +81228,21 @@ var init_introspect_pg = __esm({
|
|
81191
81228
|
out = `${withCasing2(
|
81192
81229
|
name,
|
81193
81230
|
casing2
|
81194
|
-
)}: varchar(
|
81231
|
+
)}: varchar(${dbColumnName3({ name, casing: casing2, withMode: true })}{ length: ${lowered.substring(
|
81195
81232
|
8,
|
81196
81233
|
lowered.length - 1
|
81197
81234
|
)} })`;
|
81198
81235
|
} else {
|
81199
|
-
out = `${withCasing2(name, casing2)}: varchar(
|
81236
|
+
out = `${withCasing2(name, casing2)}: varchar(${dbColumnName3({ name, casing: casing2 })})`;
|
81200
81237
|
}
|
81201
81238
|
return out;
|
81202
81239
|
}
|
81203
81240
|
if (lowered.startsWith("point")) {
|
81204
|
-
let out = `${withCasing2(name, casing2)}: point(
|
81241
|
+
let out = `${withCasing2(name, casing2)}: point(${dbColumnName3({ name, casing: casing2 })})`;
|
81205
81242
|
return out;
|
81206
81243
|
}
|
81207
81244
|
if (lowered.startsWith("line")) {
|
81208
|
-
let out = `${withCasing2(name, casing2)}: point(
|
81245
|
+
let out = `${withCasing2(name, casing2)}: point(${dbColumnName3({ name, casing: casing2 })})`;
|
81209
81246
|
return out;
|
81210
81247
|
}
|
81211
81248
|
if (lowered.startsWith("geometry")) {
|
@@ -81214,14 +81251,14 @@ var init_introspect_pg = __esm({
|
|
81214
81251
|
if (lowered.length !== 8) {
|
81215
81252
|
const geometryOptions = lowered.slice(9, -1).split(",");
|
81216
81253
|
if (geometryOptions.length === 1 && geometryOptions[0] !== "") {
|
81217
|
-
out = `${withCasing2(name, casing2)}: geometry(
|
81254
|
+
out = `${withCasing2(name, casing2)}: geometry(${dbColumnName3({ name, casing: casing2, withMode: true })}{ type: "${geometryOptions[0]}" })`;
|
81218
81255
|
} else if (geometryOptions.length === 2) {
|
81219
|
-
out = `${withCasing2(name, casing2)}: geometry(
|
81256
|
+
out = `${withCasing2(name, casing2)}: geometry(${dbColumnName3({ name, casing: casing2, withMode: true })}{ type: "${geometryOptions[0]}", srid: ${geometryOptions[1]} })`;
|
81220
81257
|
} else {
|
81221
81258
|
isGeoUnknown = true;
|
81222
81259
|
}
|
81223
81260
|
} else {
|
81224
|
-
out = `${withCasing2(name, casing2)}: geometry(
|
81261
|
+
out = `${withCasing2(name, casing2)}: geometry(${dbColumnName3({ name, casing: casing2 })})`;
|
81225
81262
|
}
|
81226
81263
|
if (isGeoUnknown) {
|
81227
81264
|
let unknown2 = `// TODO: failed to parse geometry type because found more than 2 options inside geometry function '${type}'
|
@@ -81238,12 +81275,12 @@ var init_introspect_pg = __esm({
|
|
81238
81275
|
out = `${withCasing2(
|
81239
81276
|
name,
|
81240
81277
|
casing2
|
81241
|
-
)}: vector(
|
81278
|
+
)}: vector(${dbColumnName3({ name, casing: casing2, withMode: true })}{ dimensions: ${lowered.substring(
|
81242
81279
|
7,
|
81243
81280
|
lowered.length - 1
|
81244
81281
|
)} })`;
|
81245
81282
|
} else {
|
81246
|
-
out = `${withCasing2(name, casing2)}: vector(
|
81283
|
+
out = `${withCasing2(name, casing2)}: vector(${dbColumnName3({ name, casing: casing2 })})`;
|
81247
81284
|
}
|
81248
81285
|
return out;
|
81249
81286
|
}
|
@@ -81253,12 +81290,12 @@ var init_introspect_pg = __esm({
|
|
81253
81290
|
out = `${withCasing2(
|
81254
81291
|
name,
|
81255
81292
|
casing2
|
81256
|
-
)}: char(
|
81293
|
+
)}: char(${dbColumnName3({ name, casing: casing2, withMode: true })}{ length: ${lowered.substring(
|
81257
81294
|
5,
|
81258
81295
|
lowered.length - 1
|
81259
81296
|
)} })`;
|
81260
81297
|
} else {
|
81261
|
-
out = `${withCasing2(name, casing2)}: char(
|
81298
|
+
out = `${withCasing2(name, casing2)}: char(${dbColumnName3({ name, casing: casing2 })})`;
|
81262
81299
|
}
|
81263
81300
|
return out;
|
81264
81301
|
}
|
@@ -85222,7 +85259,7 @@ init_utils2();
|
|
85222
85259
|
var version2 = async () => {
|
85223
85260
|
const { npmVersion } = await ormCoreVersions();
|
85224
85261
|
const ormVersion = npmVersion ? `drizzle-orm: v${npmVersion}` : "";
|
85225
|
-
const envVersion = "0.25.0-
|
85262
|
+
const envVersion = "0.25.0-d1da3b8";
|
85226
85263
|
const kitVersion = envVersion ? `v${envVersion}` : "--";
|
85227
85264
|
const versions = `drizzle-kit: ${kitVersion}
|
85228
85265
|
${ormVersion}`;
|