drizzle-kit 0.23.2 → 0.24.0-5df8253
Sign up to get free protection for your applications and to get access to all the features.
- package/api.d.mts +30 -4
- package/api.d.ts +30 -4
- package/api.js +252 -120
- package/api.mjs +252 -120
- package/bin.cjs +439 -251
- package/package.json +2 -1
- package/utils.js +7 -1
- package/utils.mjs +6 -1
package/bin.cjs
CHANGED
@@ -5687,11 +5687,30 @@ var init_mysqlSchema = __esm({
|
|
5687
5687
|
}
|
5688
5688
|
});
|
5689
5689
|
|
5690
|
+
// src/extensions/vector.ts
|
5691
|
+
var vectorOps;
|
5692
|
+
var init_vector = __esm({
|
5693
|
+
"src/extensions/vector.ts"() {
|
5694
|
+
"use strict";
|
5695
|
+
vectorOps = [
|
5696
|
+
"vector_l2_ops",
|
5697
|
+
"vector_ip_ops",
|
5698
|
+
"vector_cosine_ops",
|
5699
|
+
"vector_l1_ops",
|
5700
|
+
"bit_hamming_ops",
|
5701
|
+
"bit_jaccard_ops",
|
5702
|
+
"halfvec_l2_ops",
|
5703
|
+
"sparsevec_l2_ops"
|
5704
|
+
];
|
5705
|
+
}
|
5706
|
+
});
|
5707
|
+
|
5690
5708
|
// src/serializer/pgSchema.ts
|
5691
5709
|
var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, indexColumn, index2, indexV4, indexV5, indexV6, fk2, sequenceSchema, sequenceSquashed, columnV7, column2, columnSquashed, tableV32, compositePK2, uniqueConstraint2, tableV42, tableV5, tableV6, tableV7, table2, schemaHash2, kitInternals2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternalV5, pgSchemaInternalV6, pgSchemaExternal, pgSchemaInternalV7, pgSchemaInternal, tableSquashed2, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashedV6, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchemaV5, pgSchemaV6, pgSchemaV7, pgSchema, backwardCompatiblePgSchema, PgSquasher, squashPgScheme, dryPg;
|
5692
5710
|
var init_pgSchema = __esm({
|
5693
5711
|
"src/serializer/pgSchema.ts"() {
|
5694
5712
|
"use strict";
|
5713
|
+
init_vector();
|
5695
5714
|
init_global();
|
5696
5715
|
init_lib();
|
5697
5716
|
indexV2 = objectType({
|
@@ -5938,7 +5957,8 @@ var init_pgSchema = __esm({
|
|
5938
5957
|
objectType({
|
5939
5958
|
isArray: booleanType().optional(),
|
5940
5959
|
dimensions: numberType().optional(),
|
5941
|
-
rawType: stringType().optional()
|
5960
|
+
rawType: stringType().optional(),
|
5961
|
+
isDefaultAnExpression: booleanType().optional()
|
5942
5962
|
}).optional()
|
5943
5963
|
)
|
5944
5964
|
}).optional()
|
@@ -6076,7 +6096,7 @@ var init_pgSchema = __esm({
|
|
6076
6096
|
squashIdx: (idx) => {
|
6077
6097
|
index2.parse(idx);
|
6078
6098
|
return `${idx.name};${idx.columns.map(
|
6079
|
-
(c) => `${c.expression}--${c.isExpression}--${c.asc}--${c.nulls}--${c.opclass}`
|
6099
|
+
(c) => `${c.expression}--${c.isExpression}--${c.asc}--${c.nulls}--${c.opclass && vectorOps.includes(c.opclass) ? c.opclass : ""}`
|
6080
6100
|
).join(",,")};${idx.isUnique};${idx.concurrently};${idx.method};${idx.where};${JSON.stringify(idx.with)}`;
|
6081
6101
|
},
|
6082
6102
|
unsquashIdx: (input) => {
|
@@ -6561,6 +6581,9 @@ var init_sqliteSchema = __esm({
|
|
6561
6581
|
});
|
6562
6582
|
|
6563
6583
|
// src/utils.ts
|
6584
|
+
function isPgArrayType(sqlType) {
|
6585
|
+
return sqlType.match(/.*\[\d*\].*|.*\[\].*/g) !== null;
|
6586
|
+
}
|
6564
6587
|
var import_fs, import_path, import_url, copy, objectValues, assertV1OutFolder, dryJournal, prepareOutFolder, validatorForDialect, validateWithReport, prepareMigrationFolder, prepareMigrationMeta, schemaRenameKey, tableRenameKey, columnRenameKey, normaliseSQLiteUrl;
|
6565
6588
|
var init_utils = __esm({
|
6566
6589
|
"src/utils.ts"() {
|
@@ -11369,7 +11392,7 @@ var init_cli = __esm({
|
|
11369
11392
|
extensionsFilters: literalType("postgis").array().optional(),
|
11370
11393
|
introspectCasing: casing,
|
11371
11394
|
breakpoints: booleanType().optional().default(true),
|
11372
|
-
|
11395
|
+
migrations: objectType({
|
11373
11396
|
prefix: prefix.optional().default("index")
|
11374
11397
|
}).optional()
|
11375
11398
|
}).passthrough();
|
@@ -17507,7 +17530,7 @@ var init_utils4 = __esm({
|
|
17507
17530
|
credentials: parsed2.data,
|
17508
17531
|
tablesFilter,
|
17509
17532
|
schemasFilter,
|
17510
|
-
prefix: ((_a = config.
|
17533
|
+
prefix: ((_a = config.migrations) == null ? void 0 : _a.prefix) || "index"
|
17511
17534
|
};
|
17512
17535
|
}
|
17513
17536
|
if (dialect7 === "mysql") {
|
@@ -17524,7 +17547,7 @@ var init_utils4 = __esm({
|
|
17524
17547
|
credentials: parsed2.data,
|
17525
17548
|
tablesFilter,
|
17526
17549
|
schemasFilter,
|
17527
|
-
prefix: ((_b = config.
|
17550
|
+
prefix: ((_b = config.migrations) == null ? void 0 : _b.prefix) || "index"
|
17528
17551
|
};
|
17529
17552
|
}
|
17530
17553
|
if (dialect7 === "sqlite") {
|
@@ -17541,7 +17564,7 @@ var init_utils4 = __esm({
|
|
17541
17564
|
credentials: parsed2.data,
|
17542
17565
|
tablesFilter,
|
17543
17566
|
schemasFilter,
|
17544
|
-
prefix: ((_c = config.
|
17567
|
+
prefix: ((_c = config.migrations) == null ? void 0 : _c.prefix) || "index"
|
17545
17568
|
};
|
17546
17569
|
}
|
17547
17570
|
assertUnreachable(dialect7);
|
@@ -18107,7 +18130,7 @@ We have encountered a collision between the index name on columns ${source_defau
|
|
18107
18130
|
onUpdate = true;
|
18108
18131
|
}
|
18109
18132
|
const newColumn = {
|
18110
|
-
default: columnDefault === null ? void 0 : /^-?[\d.]+(?:e-?\d+)?$/.test(columnDefault) && !columnType.startsWith(
|
18133
|
+
default: columnDefault === null ? void 0 : /^-?[\d.]+(?:e-?\d+)?$/.test(columnDefault) && !["decimal", "char", "varchar"].some((type) => columnType.startsWith(type)) ? Number(columnDefault) : isDefaultAnExpression ? clearDefaults(columnDefault, collation) : `'${columnDefault}'`,
|
18111
18134
|
autoincrement: isAutoincrement,
|
18112
18135
|
name: columnName,
|
18113
18136
|
type: changedType,
|
@@ -18369,24 +18392,6 @@ var init_pgImports = __esm({
|
|
18369
18392
|
}
|
18370
18393
|
});
|
18371
18394
|
|
18372
|
-
// src/extensions/vector.ts
|
18373
|
-
var vectorOps;
|
18374
|
-
var init_vector = __esm({
|
18375
|
-
"src/extensions/vector.ts"() {
|
18376
|
-
"use strict";
|
18377
|
-
vectorOps = [
|
18378
|
-
"vector_l2_ops",
|
18379
|
-
"vector_ip_ops",
|
18380
|
-
"vector_cosine_ops",
|
18381
|
-
"vector_l1_ops",
|
18382
|
-
"bit_hamming_ops",
|
18383
|
-
"bit_jaccard_ops",
|
18384
|
-
"halfvec_l2_ops",
|
18385
|
-
"sparsevec_l2_ops"
|
18386
|
-
];
|
18387
|
-
}
|
18388
|
-
});
|
18389
|
-
|
18390
18395
|
// src/serializer/pgSerializer.ts
|
18391
18396
|
var pgSerializer_exports = {};
|
18392
18397
|
__export(pgSerializer_exports, {
|
@@ -18406,7 +18411,31 @@ function minRangeForIdentityBasedOn(columnType) {
|
|
18406
18411
|
function stringFromDatabaseIdentityProperty(field) {
|
18407
18412
|
return typeof field === "string" ? field : typeof field === "undefined" ? void 0 : typeof field === "bigint" ? field.toString() : String(field);
|
18408
18413
|
}
|
18409
|
-
|
18414
|
+
function buildArrayString(array, sqlType) {
|
18415
|
+
sqlType = sqlType.split("[")[0];
|
18416
|
+
const values = array.map((value) => {
|
18417
|
+
if (typeof value === "number" || typeof value === "bigint") {
|
18418
|
+
return value.toString();
|
18419
|
+
} else if (typeof value === "boolean") {
|
18420
|
+
return value ? "true" : "false";
|
18421
|
+
} else if (Array.isArray(value)) {
|
18422
|
+
return buildArrayString(value, sqlType);
|
18423
|
+
} else if (value instanceof Date) {
|
18424
|
+
if (sqlType === "date") {
|
18425
|
+
return `"${value.toISOString().split("T")[0]}"`;
|
18426
|
+
} else if (sqlType === "timestamp") {
|
18427
|
+
return `"${value.toISOString().replace("T", " ").slice(0, 23)}"`;
|
18428
|
+
} else {
|
18429
|
+
return `"${value.toISOString()}"`;
|
18430
|
+
}
|
18431
|
+
} else if (typeof value === "object") {
|
18432
|
+
return `"${JSON.stringify(value).replaceAll('"', '\\"')}"`;
|
18433
|
+
}
|
18434
|
+
return `"${value}"`;
|
18435
|
+
}).join(",");
|
18436
|
+
return `{${values}}`;
|
18437
|
+
}
|
18438
|
+
var import_drizzle_orm5, import_pg_core2, import_pg_core3, dialect5, indexName2, generatePgSnapshot, trimChar, fromDatabase2, defaultForColumn;
|
18410
18439
|
var init_pgSerializer = __esm({
|
18411
18440
|
"src/serializer/pgSerializer.ts"() {
|
18412
18441
|
"use strict";
|
@@ -18416,6 +18445,7 @@ var init_pgSerializer = __esm({
|
|
18416
18445
|
import_pg_core3 = require("drizzle-orm/pg-core");
|
18417
18446
|
init_vector();
|
18418
18447
|
init_outputs();
|
18448
|
+
init_utils();
|
18419
18449
|
init_serializer();
|
18420
18450
|
dialect5 = new import_pg_core2.PgDialect();
|
18421
18451
|
indexName2 = (tableName, columns) => {
|
@@ -18524,6 +18554,11 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
18524
18554
|
} else {
|
18525
18555
|
columnToSet.default = `'${column7.default.toISOString()}'`;
|
18526
18556
|
}
|
18557
|
+
} else if (isPgArrayType(sqlTypeLowered) && Array.isArray(column7.default)) {
|
18558
|
+
columnToSet.default = `'${buildArrayString(
|
18559
|
+
column7.default,
|
18560
|
+
sqlTypeLowered
|
18561
|
+
)}'`;
|
18527
18562
|
} else {
|
18528
18563
|
columnToSet.default = column7.default;
|
18529
18564
|
}
|
@@ -18875,7 +18910,7 @@ ${withStyle.errorWarning(
|
|
18875
18910
|
WHEN 'int2'::regtype THEN 'smallserial'
|
18876
18911
|
END
|
18877
18912
|
ELSE format_type(a.atttypid, a.atttypmod)
|
18878
|
-
END AS data_type, INFORMATION_SCHEMA.COLUMNS.table_name,
|
18913
|
+
END AS data_type, INFORMATION_SCHEMA.COLUMNS.table_name, ns.nspname as type_schema,
|
18879
18914
|
pg_get_serial_sequence('"${tableSchema}"."${tableName}"', a.attname)::regclass as seq_name, INFORMATION_SCHEMA.COLUMNS.column_name,
|
18880
18915
|
INFORMATION_SCHEMA.COLUMNS.column_default, INFORMATION_SCHEMA.COLUMNS.data_type as additional_dt,
|
18881
18916
|
INFORMATION_SCHEMA.COLUMNS.udt_name as enum_name,
|
@@ -18886,6 +18921,7 @@ ${withStyle.errorWarning(
|
|
18886
18921
|
INFORMATION_SCHEMA.COLUMNS.identity_cycle
|
18887
18922
|
FROM pg_attribute a
|
18888
18923
|
JOIN INFORMATION_SCHEMA.COLUMNS ON INFORMATION_SCHEMA.COLUMNS.column_name = a.attname
|
18924
|
+
JOIN pg_type t ON t.oid = a.atttypid LEFT JOIN pg_namespace ns ON ns.oid = t.typnamespace
|
18889
18925
|
WHERE a.attrelid = '"${tableSchema}"."${tableName}"'::regclass and INFORMATION_SCHEMA.COLUMNS.table_name = '${tableName}' and INFORMATION_SCHEMA.COLUMNS.table_schema = '${tableSchema}'
|
18890
18926
|
AND a.attnum > 0
|
18891
18927
|
AND NOT a.attisdropped
|
@@ -18905,30 +18941,42 @@ ${withStyle.errorWarning(
|
|
18905
18941
|
}
|
18906
18942
|
const tableForeignKeys = await db.query(
|
18907
18943
|
`SELECT
|
18908
|
-
|
18909
|
-
|
18910
|
-
|
18911
|
-
|
18912
|
-
|
18913
|
-
|
18914
|
-
|
18915
|
-
|
18916
|
-
|
18917
|
-
|
18918
|
-
|
18919
|
-
|
18920
|
-
|
18921
|
-
|
18922
|
-
|
18923
|
-
|
18924
|
-
|
18925
|
-
|
18926
|
-
|
18927
|
-
|
18928
|
-
|
18929
|
-
|
18930
|
-
|
18931
|
-
|
18944
|
+
con.contype AS constraint_type,
|
18945
|
+
nsp.nspname AS constraint_schema,
|
18946
|
+
con.conname AS constraint_name,
|
18947
|
+
rel.relname AS table_name,
|
18948
|
+
att.attname AS column_name,
|
18949
|
+
fnsp.nspname AS foreign_table_schema,
|
18950
|
+
frel.relname AS foreign_table_name,
|
18951
|
+
fatt.attname AS foreign_column_name,
|
18952
|
+
CASE con.confupdtype
|
18953
|
+
WHEN 'a' THEN 'NO ACTION'
|
18954
|
+
WHEN 'r' THEN 'RESTRICT'
|
18955
|
+
WHEN 'n' THEN 'SET NULL'
|
18956
|
+
WHEN 'c' THEN 'CASCADE'
|
18957
|
+
WHEN 'd' THEN 'SET DEFAULT'
|
18958
|
+
END AS update_rule,
|
18959
|
+
CASE con.confdeltype
|
18960
|
+
WHEN 'a' THEN 'NO ACTION'
|
18961
|
+
WHEN 'r' THEN 'RESTRICT'
|
18962
|
+
WHEN 'n' THEN 'SET NULL'
|
18963
|
+
WHEN 'c' THEN 'CASCADE'
|
18964
|
+
WHEN 'd' THEN 'SET DEFAULT'
|
18965
|
+
END AS delete_rule
|
18966
|
+
FROM
|
18967
|
+
pg_catalog.pg_constraint con
|
18968
|
+
JOIN pg_catalog.pg_class rel ON rel.oid = con.conrelid
|
18969
|
+
JOIN pg_catalog.pg_namespace nsp ON nsp.oid = con.connamespace
|
18970
|
+
LEFT JOIN pg_catalog.pg_attribute att ON att.attnum = ANY (con.conkey)
|
18971
|
+
AND att.attrelid = con.conrelid
|
18972
|
+
LEFT JOIN pg_catalog.pg_class frel ON frel.oid = con.confrelid
|
18973
|
+
LEFT JOIN pg_catalog.pg_namespace fnsp ON fnsp.oid = frel.relnamespace
|
18974
|
+
LEFT JOIN pg_catalog.pg_attribute fatt ON fatt.attnum = ANY (con.confkey)
|
18975
|
+
AND fatt.attrelid = con.confrelid
|
18976
|
+
WHERE
|
18977
|
+
nsp.nspname = '${tableSchema}'
|
18978
|
+
AND rel.relname = '${tableName}'
|
18979
|
+
AND con.contype IN ('f');`
|
18932
18980
|
);
|
18933
18981
|
foreignKeysCount += tableForeignKeys.length;
|
18934
18982
|
if (progressCallback) {
|
@@ -18986,6 +19034,8 @@ ${withStyle.errorWarning(
|
|
18986
19034
|
const columnDimensions = columnResponse.array_dimensions;
|
18987
19035
|
const enumType2 = columnResponse.enum_name;
|
18988
19036
|
let columnType = columnResponse.data_type;
|
19037
|
+
const typeSchema = columnResponse.type_schema;
|
19038
|
+
const defaultValueRes = columnResponse.column_default;
|
18989
19039
|
const isGenerated = columnResponse.is_generated === "ALWAYS";
|
18990
19040
|
const generationExpression = columnResponse.generation_expression;
|
18991
19041
|
const isIdentity = columnResponse.is_identity === "YES";
|
@@ -19016,12 +19066,7 @@ ${withStyle.errorWarning(
|
|
19016
19066
|
columns: cprimaryKey.map((c) => c.column_name)
|
19017
19067
|
};
|
19018
19068
|
}
|
19019
|
-
const defaultValue = defaultForColumn(columnResponse);
|
19020
|
-
const isSerial = columnType === "serial";
|
19021
19069
|
let columnTypeMapped = columnType;
|
19022
|
-
if (columnTypeMapped.startsWith("numeric(")) {
|
19023
|
-
columnTypeMapped = columnTypeMapped.replace(",", ", ");
|
19024
|
-
}
|
19025
19070
|
if (columnAdditionalDT === "ARRAY") {
|
19026
19071
|
if (typeof internals.tables[tableName] === "undefined") {
|
19027
19072
|
internals.tables[tableName] = {
|
@@ -19049,6 +19094,34 @@ ${withStyle.errorWarning(
|
|
19049
19094
|
}
|
19050
19095
|
}
|
19051
19096
|
}
|
19097
|
+
const defaultValue = defaultForColumn(
|
19098
|
+
columnResponse,
|
19099
|
+
internals,
|
19100
|
+
tableName
|
19101
|
+
);
|
19102
|
+
if (defaultValue === "NULL" || defaultValueRes && defaultValueRes.startsWith("(") && defaultValueRes.endsWith(")")) {
|
19103
|
+
if (typeof internals.tables[tableName] === "undefined") {
|
19104
|
+
internals.tables[tableName] = {
|
19105
|
+
columns: {
|
19106
|
+
[columnName]: {
|
19107
|
+
isDefaultAnExpression: true
|
19108
|
+
}
|
19109
|
+
}
|
19110
|
+
};
|
19111
|
+
} else {
|
19112
|
+
if (typeof internals.tables[tableName].columns[columnName] === "undefined") {
|
19113
|
+
internals.tables[tableName].columns[columnName] = {
|
19114
|
+
isDefaultAnExpression: true
|
19115
|
+
};
|
19116
|
+
} else {
|
19117
|
+
internals.tables[tableName].columns[columnName].isDefaultAnExpression = true;
|
19118
|
+
}
|
19119
|
+
}
|
19120
|
+
}
|
19121
|
+
const isSerial = columnType === "serial";
|
19122
|
+
if (columnTypeMapped.startsWith("numeric(")) {
|
19123
|
+
columnTypeMapped = columnTypeMapped.replace(",", ", ");
|
19124
|
+
}
|
19052
19125
|
if (columnAdditionalDT === "ARRAY") {
|
19053
19126
|
for (let i2 = 1; i2 < Number(columnDimensions); i2++) {
|
19054
19127
|
columnTypeMapped += "[]";
|
@@ -19062,7 +19135,7 @@ ${withStyle.errorWarning(
|
|
19062
19135
|
// filter vectors, but in future we should filter any extension that was installed by user
|
19063
19136
|
columnAdditionalDT === "USER-DEFINED" && !["vector", "geometry"].includes(enumType2) ? enumType2 : columnTypeMapped
|
19064
19137
|
),
|
19065
|
-
typeSchema: enumsToReturn[`${
|
19138
|
+
typeSchema: enumsToReturn[`${typeSchema}.${enumType2}`] !== void 0 ? enumsToReturn[`${typeSchema}.${enumType2}`].schema : void 0,
|
19066
19139
|
primaryKey: primaryKey.length === 1 && cprimaryKey.length < 2,
|
19067
19140
|
// default: isSerial ? undefined : defaultValue,
|
19068
19141
|
notNull: columnResponse.is_nullable === "NO",
|
@@ -19234,59 +19307,72 @@ ${withStyle.errorWarning(
|
|
19234
19307
|
internal: internals
|
19235
19308
|
};
|
19236
19309
|
};
|
19237
|
-
|
19238
|
-
|
19239
|
-
|
19240
|
-
|
19241
|
-
// "double precision": "::double precision",
|
19242
|
-
// "time with time zone": "::time with time zone",
|
19243
|
-
"time without time zone": "::time without time zone",
|
19244
|
-
// "timestamp with time zone": "::timestamp with time zone",
|
19245
|
-
"timestamp without time zone": "::timestamp without time zone",
|
19246
|
-
"timestamp(": "::timestamp without time zone",
|
19247
|
-
// date: "::date",
|
19248
|
-
// interval: "::interval",
|
19249
|
-
// character: "::bpchar",
|
19250
|
-
// macaddr8: "::macaddr8",
|
19251
|
-
// macaddr: "::macaddr",
|
19252
|
-
// inet: "::inet",
|
19253
|
-
// cidr: "::cidr",
|
19254
|
-
// jsonb: "::jsonb",
|
19255
|
-
// json: "::json",
|
19256
|
-
"character(": "::bpchar"
|
19257
|
-
};
|
19258
|
-
defaultForColumn = (column7) => {
|
19310
|
+
defaultForColumn = (column7, internals, tableName) => {
|
19311
|
+
var _a, _b;
|
19312
|
+
const columnName = column7.attname;
|
19313
|
+
const isArray3 = ((_b = (_a = internals == null ? void 0 : internals.tables[tableName]) == null ? void 0 : _a.columns[columnName]) == null ? void 0 : _b.isArray) ?? false;
|
19259
19314
|
if (column7.column_default === null) {
|
19260
19315
|
return void 0;
|
19261
19316
|
}
|
19262
19317
|
if (column7.data_type === "serial" || column7.data_type === "smallserial" || column7.data_type === "bigserial") {
|
19263
19318
|
return void 0;
|
19264
19319
|
}
|
19265
|
-
|
19320
|
+
if (column7.column_default.endsWith("[]")) {
|
19321
|
+
column7.column_default = column7.column_default.slice(0, -2);
|
19322
|
+
}
|
19323
|
+
column7.column_default = column7.column_default.replace(/::(.*?)(?<![^\w"])(?=$)/, "");
|
19266
19324
|
const columnDefaultAsString = column7.column_default.toString();
|
19267
|
-
if (
|
19268
|
-
|
19269
|
-
|
19270
|
-
|
19271
|
-
|
19272
|
-
|
19273
|
-
|
19274
|
-
|
19275
|
-
|
19276
|
-
|
19277
|
-
|
19278
|
-
|
19279
|
-
|
19280
|
-
|
19281
|
-
|
19282
|
-
|
19283
|
-
|
19325
|
+
if (isArray3) {
|
19326
|
+
return `'{${columnDefaultAsString.slice(2, -2).split(/\s*,\s*/g).map((value) => {
|
19327
|
+
if (["integer", "smallint", "bigint", "double precision", "real"].includes(column7.data_type.slice(0, -2))) {
|
19328
|
+
return value;
|
19329
|
+
} else if (column7.data_type.startsWith("timestamp")) {
|
19330
|
+
return `${value}`;
|
19331
|
+
} else if (column7.data_type.slice(0, -2) === "interval") {
|
19332
|
+
return value.replaceAll('"', `"`);
|
19333
|
+
} else if (column7.data_type.slice(0, -2) === "boolean") {
|
19334
|
+
return value === "t" ? "true" : "false";
|
19335
|
+
} else if (["json", "jsonb"].includes(column7.data_type.slice(0, -2))) {
|
19336
|
+
return JSON.stringify(JSON.stringify(JSON.parse(JSON.parse(value)), null, 0));
|
19337
|
+
} else {
|
19338
|
+
return `"${value}"`;
|
19339
|
+
}
|
19340
|
+
}).join(",")}}'`;
|
19341
|
+
}
|
19342
|
+
if (["integer", "smallint", "bigint", "double precision", "real"].includes(column7.data_type)) {
|
19343
|
+
if (/^-?[\d.]+(?:e-?\d+)?$/.test(columnDefaultAsString)) {
|
19284
19344
|
return Number(columnDefaultAsString);
|
19285
|
-
} else if (column7.data_type === "boolean") {
|
19286
|
-
return column7.column_default === "true";
|
19287
19345
|
} else {
|
19288
|
-
|
19346
|
+
if (typeof internals.tables[tableName] === "undefined") {
|
19347
|
+
internals.tables[tableName] = {
|
19348
|
+
columns: {
|
19349
|
+
[columnName]: {
|
19350
|
+
isDefaultAnExpression: true
|
19351
|
+
}
|
19352
|
+
}
|
19353
|
+
};
|
19354
|
+
} else {
|
19355
|
+
if (typeof internals.tables[tableName].columns[columnName] === "undefined") {
|
19356
|
+
internals.tables[tableName].columns[columnName] = {
|
19357
|
+
isDefaultAnExpression: true
|
19358
|
+
};
|
19359
|
+
} else {
|
19360
|
+
internals.tables[tableName].columns[columnName].isDefaultAnExpression = true;
|
19361
|
+
}
|
19362
|
+
}
|
19363
|
+
return columnDefaultAsString;
|
19289
19364
|
}
|
19365
|
+
} else if (column7.data_type === "json" || column7.data_type === "jsonb") {
|
19366
|
+
const jsonWithoutSpaces = JSON.stringify(JSON.parse(columnDefaultAsString.slice(1, -1)));
|
19367
|
+
return `'${jsonWithoutSpaces}'::${column7.data_type}`;
|
19368
|
+
} else if (column7.data_type === "boolean") {
|
19369
|
+
return column7.column_default === "true";
|
19370
|
+
} else if (columnDefaultAsString === "NULL") {
|
19371
|
+
return `NULL`;
|
19372
|
+
} else if (columnDefaultAsString.startsWith("'") && columnDefaultAsString.endsWith("'")) {
|
19373
|
+
return columnDefaultAsString;
|
19374
|
+
} else {
|
19375
|
+
return `${columnDefaultAsString.replace(/\\/g, "`\\")}`;
|
19290
19376
|
}
|
19291
19377
|
};
|
19292
19378
|
}
|
@@ -19570,7 +19656,7 @@ The unique constraint ${source_default.underline.blue(
|
|
19570
19656
|
primaryKeys.forEach((it) => {
|
19571
19657
|
if (it.columns.length > 1) {
|
19572
19658
|
primaryKeysObject[it.getName()] = {
|
19573
|
-
columns: it.columns.map((it2) => it2.name)
|
19659
|
+
columns: it.columns.map((it2) => it2.name),
|
19574
19660
|
name: it.getName()
|
19575
19661
|
};
|
19576
19662
|
} else {
|
@@ -19696,7 +19782,6 @@ The unique constraint ${source_default.underline.blue(
|
|
19696
19782
|
}
|
19697
19783
|
for (const [key, value] of Object.entries(tableToPk)) {
|
19698
19784
|
if (value.length > 1) {
|
19699
|
-
value.sort();
|
19700
19785
|
result[key].compositePrimaryKeys = {
|
19701
19786
|
[`${key}_${value.join("_")}_pk`]: {
|
19702
19787
|
columns: value,
|
@@ -22873,7 +22958,7 @@ var init_sqlgenerator = __esm({
|
|
22873
22958
|
if (pgNativeTypes.has(it))
|
22874
22959
|
return true;
|
22875
22960
|
const toCheck = it.replace(/ /g, "");
|
22876
|
-
return toCheck.startsWith("varchar(") || toCheck.startsWith("char(") || toCheck.startsWith("numeric(") || toCheck.startsWith("timestamp(") || toCheck.startsWith("intervalyear(") || toCheck.startsWith("intervalmonth(") || toCheck.startsWith("intervalday(") || toCheck.startsWith("intervalhour(") || toCheck.startsWith("intervalminute(") || toCheck.startsWith("intervalsecond(") || toCheck.startsWith("intervalyeartomonth(") || toCheck.startsWith("intervaldaytohour(") || toCheck.startsWith("intervaldaytominute(") || toCheck.startsWith("intervaldaytosecond(") || toCheck.startsWith("intervalhourtominute(") || toCheck.startsWith("intervalhourtosecond(") || toCheck.startsWith("intervalminutetosecond(") || toCheck.startsWith("vector(") || toCheck.startsWith("geometry(") || /^(\w+)(\[\d*])+$/.test(it);
|
22961
|
+
return toCheck.startsWith("varchar(") || toCheck.startsWith("char(") || toCheck.startsWith("numeric(") || toCheck.startsWith("timestamp(") || toCheck.startsWith("doubleprecision[") || toCheck.startsWith("intervalyear(") || toCheck.startsWith("intervalmonth(") || toCheck.startsWith("intervalday(") || toCheck.startsWith("intervalhour(") || toCheck.startsWith("intervalminute(") || toCheck.startsWith("intervalsecond(") || toCheck.startsWith("intervalyeartomonth(") || toCheck.startsWith("intervaldaytohour(") || toCheck.startsWith("intervaldaytominute(") || toCheck.startsWith("intervaldaytosecond(") || toCheck.startsWith("intervalhourtominute(") || toCheck.startsWith("intervalhourtosecond(") || toCheck.startsWith("intervalminutetosecond(") || toCheck.startsWith("vector(") || toCheck.startsWith("geometry(") || /^(\w+)(\[\d*])+$/.test(it);
|
22877
22962
|
};
|
22878
22963
|
Convertor = class {
|
22879
22964
|
};
|
@@ -74122,7 +74207,7 @@ var init_pgIntrospect = __esm({
|
|
74122
74207
|
});
|
74123
74208
|
|
74124
74209
|
// src/introspect-sqlite.ts
|
74125
|
-
var sqliteImportsList, indexName3, objToStatement2, relations, withCasing, schemaToTypeScript, isCyclic, isSelf, mapColumnDefault, column4, createTableColumns, createTableIndexes, createTableUniques, createTablePKs, createTableFKs;
|
74210
|
+
var sqliteImportsList, indexName3, objToStatement2, relations, escapeColumnKey, withCasing, schemaToTypeScript, isCyclic, isSelf, mapColumnDefault, column4, createTableColumns, createTableIndexes, createTableUniques, createTablePKs, createTableFKs;
|
74126
74211
|
var init_introspect_sqlite = __esm({
|
74127
74212
|
"src/introspect-sqlite.ts"() {
|
74128
74213
|
"use strict";
|
@@ -74149,12 +74234,18 @@ var init_introspect_sqlite = __esm({
|
|
74149
74234
|
return statement;
|
74150
74235
|
};
|
74151
74236
|
relations = /* @__PURE__ */ new Set();
|
74237
|
+
escapeColumnKey = (value) => {
|
74238
|
+
if (/^(?![a-zA-Z_$][a-zA-Z0-9_$]*$).+$/.test(value)) {
|
74239
|
+
return `"${value}"`;
|
74240
|
+
}
|
74241
|
+
return value;
|
74242
|
+
};
|
74152
74243
|
withCasing = (value, casing2) => {
|
74153
|
-
if (
|
74154
|
-
return value;
|
74244
|
+
if (casing2 === "preserve") {
|
74245
|
+
return escapeColumnKey(value);
|
74155
74246
|
}
|
74156
74247
|
if (casing2 === "camel") {
|
74157
|
-
return value.camelCase();
|
74248
|
+
return escapeColumnKey(value.camelCase());
|
74158
74249
|
}
|
74159
74250
|
return value;
|
74160
74251
|
};
|
@@ -75152,7 +75243,7 @@ var require_pluralize = __commonJS({
|
|
75152
75243
|
});
|
75153
75244
|
|
75154
75245
|
// src/introspect-mysql.ts
|
75155
|
-
var mysqlImportsList, objToStatement22, timeConfig, binaryConfig, importsPatch, relations2, prepareCasing, schemaToTypeScript2, isCyclic2, isSelf2, mapColumnDefault2, mapColumnDefaultForJson, column5, createTableColumns2, createTableIndexes2, createTableUniques2, createTablePKs2, createTableFKs2;
|
75246
|
+
var mysqlImportsList, objToStatement22, timeConfig, binaryConfig, importsPatch, relations2, escapeColumnKey2, prepareCasing, schemaToTypeScript2, isCyclic2, isSelf2, mapColumnDefault2, mapColumnDefaultForJson, column5, createTableColumns2, createTableIndexes2, createTableUniques2, createTablePKs2, createTableFKs2;
|
75156
75247
|
var init_introspect_mysql = __esm({
|
75157
75248
|
"src/introspect-mysql.ts"() {
|
75158
75249
|
"use strict";
|
@@ -75223,14 +75314,20 @@ var init_introspect_mysql = __esm({
|
|
75223
75314
|
"timestamp without time zone": "timestamp"
|
75224
75315
|
};
|
75225
75316
|
relations2 = /* @__PURE__ */ new Set();
|
75317
|
+
escapeColumnKey2 = (value) => {
|
75318
|
+
if (/^(?![a-zA-Z_$][a-zA-Z0-9_$]*$).+$/.test(value)) {
|
75319
|
+
return `"${value}"`;
|
75320
|
+
}
|
75321
|
+
return value;
|
75322
|
+
};
|
75226
75323
|
prepareCasing = (casing2) => (value) => {
|
75227
|
-
if (
|
75228
|
-
return value;
|
75324
|
+
if (casing2 === "preserve") {
|
75325
|
+
return escapeColumnKey2(value);
|
75229
75326
|
}
|
75230
75327
|
if (casing2 === "camel") {
|
75231
|
-
return value.camelCase();
|
75328
|
+
return escapeColumnKey2(value.camelCase());
|
75232
75329
|
}
|
75233
|
-
return value;
|
75330
|
+
return escapeColumnKey2(value);
|
75234
75331
|
};
|
75235
75332
|
schemaToTypeScript2 = (schema5, casing2) => {
|
75236
75333
|
const withCasing4 = prepareCasing(casing2);
|
@@ -75265,6 +75362,7 @@ var init_introspect_mysql = __esm({
|
|
75265
75362
|
patched = patched.startsWith("datetime(") ? "datetime" : patched;
|
75266
75363
|
patched = patched.startsWith("varbinary(") ? "varbinary" : patched;
|
75267
75364
|
patched = patched.startsWith("int(") ? "int" : patched;
|
75365
|
+
patched = patched.startsWith("double(") ? "double" : patched;
|
75268
75366
|
return patched;
|
75269
75367
|
}).filter((type) => {
|
75270
75368
|
return mysqlImportsList.has(type);
|
@@ -75695,7 +75793,33 @@ import { sql } from "drizzle-orm"
|
|
75695
75793
|
});
|
75696
75794
|
|
75697
75795
|
// src/introspect-pg.ts
|
75698
|
-
|
75796
|
+
function generateIdentityParams(identity) {
|
75797
|
+
let paramsObj = `{ name: "${identity.name}"`;
|
75798
|
+
if (identity == null ? void 0 : identity.startWith) {
|
75799
|
+
paramsObj += `, startWith: ${identity.startWith}`;
|
75800
|
+
}
|
75801
|
+
if (identity == null ? void 0 : identity.increment) {
|
75802
|
+
paramsObj += `, increment: ${identity.increment}`;
|
75803
|
+
}
|
75804
|
+
if (identity == null ? void 0 : identity.minValue) {
|
75805
|
+
paramsObj += `, minValue: ${identity.minValue}`;
|
75806
|
+
}
|
75807
|
+
if (identity == null ? void 0 : identity.maxValue) {
|
75808
|
+
paramsObj += `, maxValue: ${identity.maxValue}`;
|
75809
|
+
}
|
75810
|
+
if (identity == null ? void 0 : identity.cache) {
|
75811
|
+
paramsObj += `, cache: ${identity.cache}`;
|
75812
|
+
}
|
75813
|
+
if (identity == null ? void 0 : identity.cycle) {
|
75814
|
+
paramsObj += `, cycle: true`;
|
75815
|
+
}
|
75816
|
+
paramsObj += " }";
|
75817
|
+
if ((identity == null ? void 0 : identity.type) === "always") {
|
75818
|
+
return `.generatedAlwaysAsIdentity(${paramsObj})`;
|
75819
|
+
}
|
75820
|
+
return `.generatedByDefaultAsIdentity(${paramsObj})`;
|
75821
|
+
}
|
75822
|
+
var import_drizzle_orm8, 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;
|
75699
75823
|
var init_introspect_pg = __esm({
|
75700
75824
|
"src/introspect-pg.ts"() {
|
75701
75825
|
"use strict";
|
@@ -75739,16 +75863,6 @@ var init_introspect_pg = __esm({
|
|
75739
75863
|
"line",
|
75740
75864
|
"geometry"
|
75741
75865
|
]);
|
75742
|
-
objToStatement23 = (json) => {
|
75743
|
-
json = Object.fromEntries(Object.entries(json).filter((it) => it[1]));
|
75744
|
-
const keys = Object.keys(json);
|
75745
|
-
if (keys.length === 0)
|
75746
|
-
return;
|
75747
|
-
let statement = "{ ";
|
75748
|
-
statement += keys.map((it) => `${it}: "${json[it]}"`).join(", ");
|
75749
|
-
statement += " }";
|
75750
|
-
return statement;
|
75751
|
-
};
|
75752
75866
|
timeConfig2 = (json) => {
|
75753
75867
|
json = Object.fromEntries(Object.entries(json).filter((it) => it[1]));
|
75754
75868
|
const keys = Object.keys(json);
|
@@ -75808,6 +75922,12 @@ var init_introspect_pg = __esm({
|
|
75808
75922
|
statement += " }";
|
75809
75923
|
return statement;
|
75810
75924
|
};
|
75925
|
+
mapColumnDefault3 = (defaultValue, isExpression) => {
|
75926
|
+
if (isExpression) {
|
75927
|
+
return `sql\`${defaultValue}\``;
|
75928
|
+
}
|
75929
|
+
return defaultValue;
|
75930
|
+
};
|
75811
75931
|
importsPatch2 = {
|
75812
75932
|
"double precision": "doublePrecision",
|
75813
75933
|
"timestamp without time zone": "timestamp",
|
@@ -75816,12 +75936,18 @@ var init_introspect_pg = __esm({
|
|
75816
75936
|
"time with time zone": "time"
|
75817
75937
|
};
|
75818
75938
|
relations3 = /* @__PURE__ */ new Set();
|
75939
|
+
escapeColumnKey3 = (value) => {
|
75940
|
+
if (/^(?![a-zA-Z_$][a-zA-Z0-9_$]*$).+$/.test(value)) {
|
75941
|
+
return `"${value}"`;
|
75942
|
+
}
|
75943
|
+
return value;
|
75944
|
+
};
|
75819
75945
|
withCasing2 = (value, casing2) => {
|
75820
75946
|
if (casing2 === "preserve") {
|
75821
|
-
return value;
|
75947
|
+
return escapeColumnKey3(value);
|
75822
75948
|
}
|
75823
75949
|
if (casing2 === "camel") {
|
75824
|
-
return value.camelCase();
|
75950
|
+
return escapeColumnKey3(value.camelCase());
|
75825
75951
|
}
|
75826
75952
|
assertUnreachable(casing2);
|
75827
75953
|
};
|
@@ -75841,7 +75967,13 @@ var init_introspect_pg = __esm({
|
|
75841
75967
|
return [it[0], withCasing2(it[1], casing2)];
|
75842
75968
|
})
|
75843
75969
|
);
|
75844
|
-
const enumTypes =
|
75970
|
+
const enumTypes = Object.values(schema5.enums).reduce(
|
75971
|
+
(acc, cur) => {
|
75972
|
+
acc.add(`${cur.schema}.${cur.name}`);
|
75973
|
+
return acc;
|
75974
|
+
},
|
75975
|
+
/* @__PURE__ */ new Set()
|
75976
|
+
);
|
75845
75977
|
const imports = Object.values(schema5.tables).reduce(
|
75846
75978
|
(res, it) => {
|
75847
75979
|
const idxImports = Object.values(it.indexes).map((idx) => idx.isUnique ? "uniqueIndex" : "index");
|
@@ -75862,11 +75994,9 @@ var init_introspect_pg = __esm({
|
|
75862
75994
|
res.pg.push(...fkImpots);
|
75863
75995
|
res.pg.push(...pkImports);
|
75864
75996
|
res.pg.push(...uniqueImports);
|
75865
|
-
if (enumTypes.size > 0) {
|
75866
|
-
res.pg.push("pgEnum");
|
75867
|
-
}
|
75868
75997
|
const columnImports = Object.values(it.columns).map((col) => {
|
75869
|
-
let patched = importsPatch2[col.type] || col.type;
|
75998
|
+
let patched = (importsPatch2[col.type] || col.type).replace("[]", "");
|
75999
|
+
patched = patched === "double precision" ? "doublePrecision" : patched;
|
75870
76000
|
patched = patched.startsWith("varchar(") ? "varchar" : patched;
|
75871
76001
|
patched = patched.startsWith("char(") ? "char" : patched;
|
75872
76002
|
patched = patched.startsWith("numeric(") ? "numeric" : patched;
|
@@ -75883,12 +76013,54 @@ var init_introspect_pg = __esm({
|
|
75883
76013
|
},
|
75884
76014
|
{ pg: [] }
|
75885
76015
|
);
|
76016
|
+
Object.values(schema5.sequences).forEach((it) => {
|
76017
|
+
if (it.schema && it.schema !== "public" && it.schema !== "") {
|
76018
|
+
imports.pg.push("pgSchema");
|
76019
|
+
} else if (it.schema === "public") {
|
76020
|
+
imports.pg.push("pgSequence");
|
76021
|
+
}
|
76022
|
+
});
|
76023
|
+
Object.values(schema5.enums).forEach((it) => {
|
76024
|
+
if (it.schema && it.schema !== "public" && it.schema !== "") {
|
76025
|
+
imports.pg.push("pgSchema");
|
76026
|
+
} else if (it.schema === "public") {
|
76027
|
+
imports.pg.push("pgEnum");
|
76028
|
+
}
|
76029
|
+
});
|
75886
76030
|
const enumStatements = Object.values(schema5.enums).map((it) => {
|
75887
76031
|
const enumSchema3 = schemas[it.schema];
|
75888
76032
|
const paramName = paramNameFor(it.name, enumSchema3);
|
75889
76033
|
const func = enumSchema3 ? `${enumSchema3}.enum` : "pgEnum";
|
75890
76034
|
const values = Object.values(it.values).map((it2) => `'${it2}'`).join(", ");
|
75891
76035
|
return `export const ${withCasing2(paramName, casing2)} = ${func}("${it.name}", [${values}])
|
76036
|
+
`;
|
76037
|
+
}).join("").concat("\n");
|
76038
|
+
const sequencesStatements = Object.values(schema5.sequences).map((it) => {
|
76039
|
+
const seqSchema = schemas[it.schema];
|
76040
|
+
const paramName = paramNameFor(it.name, seqSchema);
|
76041
|
+
const func = seqSchema ? `${seqSchema}.sequence` : "pgSequence";
|
76042
|
+
let params = "";
|
76043
|
+
if (it.startWith) {
|
76044
|
+
params += `, startWith: "${it.startWith}"`;
|
76045
|
+
}
|
76046
|
+
if (it.increment) {
|
76047
|
+
params += `, increment: "${it.increment}"`;
|
76048
|
+
}
|
76049
|
+
if (it.minValue) {
|
76050
|
+
params += `, minValue: "${it.minValue}"`;
|
76051
|
+
}
|
76052
|
+
if (it.maxValue) {
|
76053
|
+
params += `, maxValue: "${it.maxValue}"`;
|
76054
|
+
}
|
76055
|
+
if (it.cache) {
|
76056
|
+
params += `, cache: "${it.cache}"`;
|
76057
|
+
}
|
76058
|
+
if (it.cycle) {
|
76059
|
+
params += `, cycle: true`;
|
76060
|
+
} else {
|
76061
|
+
params += `, cycle: false`;
|
76062
|
+
}
|
76063
|
+
return `export const ${withCasing2(paramName, casing2)} = ${func}("${it.name}"${params ? `, { ${params.trimChar(",")} }` : ""})
|
75892
76064
|
`;
|
75893
76065
|
}).join("").concat("\n");
|
75894
76066
|
const schemaStatements = Object.entries(schemas).map((it) => {
|
@@ -75911,10 +76083,7 @@ var init_introspect_pg = __esm({
|
|
75911
76083
|
schema5.internal
|
75912
76084
|
);
|
75913
76085
|
statement += "}";
|
75914
|
-
|
75915
|
-
return it.columnsFrom.length > 1 || isSelf3(it);
|
75916
|
-
});
|
75917
|
-
if (Object.keys(table4.indexes).length > 0 || filteredFKs.length > 0 || Object.keys(table4.compositePrimaryKeys).length > 0 || Object.keys(table4.uniqueConstraints).length > 0) {
|
76086
|
+
if (Object.keys(table4.indexes).length > 0 || Object.values(table4.foreignKeys).length > 0 || Object.keys(table4.compositePrimaryKeys).length > 0 || Object.keys(table4.uniqueConstraints).length > 0) {
|
75918
76087
|
statement += ",\n";
|
75919
76088
|
statement += "(table) => {\n";
|
75920
76089
|
statement += " return {\n";
|
@@ -75923,7 +76092,7 @@ var init_introspect_pg = __esm({
|
|
75923
76092
|
Object.values(table4.indexes),
|
75924
76093
|
casing2
|
75925
76094
|
);
|
75926
|
-
statement += createTableFKs3(Object.values(
|
76095
|
+
statement += createTableFKs3(Object.values(table4.foreignKeys), schemas, casing2);
|
75927
76096
|
statement += createTablePKs3(
|
75928
76097
|
Object.values(table4.compositePrimaryKeys),
|
75929
76098
|
casing2
|
@@ -75947,6 +76116,7 @@ var init_introspect_pg = __esm({
|
|
75947
76116
|
`;
|
75948
76117
|
let decalrations = schemaStatements;
|
75949
76118
|
decalrations += enumStatements;
|
76119
|
+
decalrations += sequencesStatements;
|
75950
76120
|
decalrations += "\n";
|
75951
76121
|
decalrations += tableStatements.join("\n\n");
|
75952
76122
|
const file = importsTs + decalrations;
|
@@ -75965,9 +76135,120 @@ var init_introspect_pg = __esm({
|
|
75965
76135
|
isSelf3 = (fk4) => {
|
75966
76136
|
return fk4.tableFrom === fk4.tableTo;
|
75967
76137
|
};
|
75968
|
-
|
75969
|
-
|
75970
|
-
|
76138
|
+
buildArrayDefault = (defaultValue, typeName) => {
|
76139
|
+
if (typeof defaultValue === "string" && !(defaultValue.startsWith("{") || defaultValue.startsWith("'{"))) {
|
76140
|
+
return `sql\`${defaultValue}\``;
|
76141
|
+
}
|
76142
|
+
defaultValue = defaultValue.substring(2, defaultValue.length - 2);
|
76143
|
+
return `[${defaultValue.split(/\s*,\s*/g).map((value) => {
|
76144
|
+
if (typeName === "json" || typeName === "jsonb") {
|
76145
|
+
return value.substring(1, value.length - 1).replaceAll("\\", "");
|
76146
|
+
}
|
76147
|
+
return value;
|
76148
|
+
}).join(", ")}]`;
|
76149
|
+
};
|
76150
|
+
mapDefault = (tableName, type, name, enumTypes, typeSchema, defaultValue, internals) => {
|
76151
|
+
var _a, _b, _c, _d;
|
76152
|
+
const isExpression = ((_b = (_a = internals == null ? void 0 : internals.tables[tableName]) == null ? void 0 : _a.columns[name]) == null ? void 0 : _b.isDefaultAnExpression) ?? false;
|
76153
|
+
const isArray3 = ((_d = (_c = internals == null ? void 0 : internals.tables[tableName]) == null ? void 0 : _c.columns[name]) == null ? void 0 : _d.isArray) ?? false;
|
76154
|
+
const lowered = type.toLowerCase().replace("[]", "");
|
76155
|
+
if (isArray3) {
|
76156
|
+
return typeof defaultValue !== "undefined" ? `.default(${buildArrayDefault(defaultValue, lowered)})` : "";
|
76157
|
+
}
|
76158
|
+
if (enumTypes.has(`${typeSchema}.${type.replace("[]", "")}`)) {
|
76159
|
+
return typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault3(defaultValue, isExpression)})` : "";
|
76160
|
+
}
|
76161
|
+
if (lowered.startsWith("integer")) {
|
76162
|
+
return typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault3(defaultValue, isExpression)})` : "";
|
76163
|
+
}
|
76164
|
+
if (lowered.startsWith("smallint")) {
|
76165
|
+
return typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault3(defaultValue, isExpression)})` : "";
|
76166
|
+
}
|
76167
|
+
if (lowered.startsWith("bigint")) {
|
76168
|
+
return typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault3(defaultValue, isExpression)})` : "";
|
76169
|
+
}
|
76170
|
+
if (lowered.startsWith("boolean")) {
|
76171
|
+
return typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault3(defaultValue, isExpression)})` : "";
|
76172
|
+
}
|
76173
|
+
if (lowered.startsWith("double precision")) {
|
76174
|
+
return typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault3(defaultValue, isExpression)})` : "";
|
76175
|
+
}
|
76176
|
+
if (lowered.startsWith("real")) {
|
76177
|
+
return typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault3(defaultValue, isExpression)})` : "";
|
76178
|
+
}
|
76179
|
+
if (lowered.startsWith("uuid")) {
|
76180
|
+
return defaultValue === "gen_random_uuid()" ? ".defaultRandom()" : defaultValue ? `.default(sql\`${defaultValue}\`)` : "";
|
76181
|
+
}
|
76182
|
+
if (lowered.startsWith("numeric")) {
|
76183
|
+
defaultValue = defaultValue ? defaultValue.startsWith(`'`) && defaultValue.endsWith(`'`) ? defaultValue.substring(1, defaultValue.length - 1) : defaultValue : void 0;
|
76184
|
+
return defaultValue ? `.default('${mapColumnDefault3(defaultValue, isExpression)}')` : "";
|
76185
|
+
}
|
76186
|
+
if (lowered.startsWith("timestamp")) {
|
76187
|
+
return defaultValue === "now()" ? ".defaultNow()" : defaultValue === "CURRENT_TIMESTAMP" ? ".default(sql`CURRENT_TIMESTAMP`)" : defaultValue ? `.default(${mapColumnDefault3(defaultValue, isExpression)})` : "";
|
76188
|
+
}
|
76189
|
+
if (lowered.startsWith("time")) {
|
76190
|
+
return defaultValue === "now()" ? ".defaultNow()" : defaultValue ? `.default(${mapColumnDefault3(defaultValue, isExpression)})` : "";
|
76191
|
+
}
|
76192
|
+
if (lowered.startsWith("interval")) {
|
76193
|
+
return defaultValue ? `.default(${mapColumnDefault3(defaultValue, isExpression)})` : "";
|
76194
|
+
}
|
76195
|
+
if (lowered === "date") {
|
76196
|
+
return defaultValue === "now()" ? ".defaultNow()" : defaultValue === "CURRENT_DATE" ? `.default(sql\`${defaultValue}\`)` : defaultValue ? `.default(${defaultValue})` : "";
|
76197
|
+
}
|
76198
|
+
if (lowered.startsWith("text")) {
|
76199
|
+
return typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault3(defaultValue, isExpression)})` : "";
|
76200
|
+
}
|
76201
|
+
if (lowered.startsWith("jsonb")) {
|
76202
|
+
const def = typeof defaultValue !== "undefined" ? defaultValue.replace(/::(.*?)(?<![^\w"])(?=$)/, "").slice(1, -1) : null;
|
76203
|
+
return defaultValue ? `.default(${def})` : "";
|
76204
|
+
}
|
76205
|
+
if (lowered.startsWith("json")) {
|
76206
|
+
const def = defaultValue ? defaultValue.replace(/::(.*?)(?<![^\w"])(?=$)/, "").slice(1, -1) : null;
|
76207
|
+
return typeof defaultValue !== "undefined" ? `.default(${def})` : "";
|
76208
|
+
}
|
76209
|
+
if (lowered.startsWith("inet")) {
|
76210
|
+
return typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault3(defaultValue, isExpression)})` : "";
|
76211
|
+
}
|
76212
|
+
if (lowered.startsWith("cidr")) {
|
76213
|
+
return typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault3(defaultValue, isExpression)})` : "";
|
76214
|
+
}
|
76215
|
+
if (lowered.startsWith("macaddr8")) {
|
76216
|
+
return typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault3(defaultValue, isExpression)})` : "";
|
76217
|
+
}
|
76218
|
+
if (lowered.startsWith("macaddr")) {
|
76219
|
+
return typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault3(defaultValue, isExpression)})` : "";
|
76220
|
+
}
|
76221
|
+
if (lowered.startsWith("varchar")) {
|
76222
|
+
return typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault3(defaultValue, isExpression)})` : "";
|
76223
|
+
}
|
76224
|
+
if (lowered.startsWith("point")) {
|
76225
|
+
return typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault3(defaultValue, isExpression)})` : "";
|
76226
|
+
}
|
76227
|
+
if (lowered.startsWith("line")) {
|
76228
|
+
return typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault3(defaultValue, isExpression)})` : "";
|
76229
|
+
}
|
76230
|
+
if (lowered.startsWith("geometry")) {
|
76231
|
+
return typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault3(defaultValue, isExpression)})` : "";
|
76232
|
+
}
|
76233
|
+
if (lowered.startsWith("vector")) {
|
76234
|
+
return typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault3(defaultValue, isExpression)})` : "";
|
76235
|
+
}
|
76236
|
+
if (lowered.startsWith("char")) {
|
76237
|
+
return typeof defaultValue !== "undefined" ? `.default(${mapColumnDefault3(defaultValue, isExpression)})` : "";
|
76238
|
+
}
|
76239
|
+
return "";
|
76240
|
+
};
|
76241
|
+
column6 = (tableName, type, name, enumTypes, typeSchema, casing2, defaultValue, internals) => {
|
76242
|
+
var _a, _b;
|
76243
|
+
const isExpression = ((_b = (_a = internals == null ? void 0 : internals.tables[tableName]) == null ? void 0 : _a.columns[name]) == null ? void 0 : _b.isDefaultAnExpression) ?? false;
|
76244
|
+
const lowered = type.toLowerCase().replace("[]", "");
|
76245
|
+
if (enumTypes.has(`${typeSchema}.${type.replace("[]", "")}`)) {
|
76246
|
+
let out = `${withCasing2(name, casing2)}: ${withCasing2(
|
76247
|
+
paramNameFor(type.replace("[]", ""), typeSchema),
|
76248
|
+
casing2
|
76249
|
+
)}("${name}")`;
|
76250
|
+
return out;
|
76251
|
+
}
|
75971
76252
|
if (lowered.startsWith("serial")) {
|
75972
76253
|
return `${withCasing2(name, casing2)}: serial("${name}")`;
|
75973
76254
|
}
|
@@ -75982,39 +76263,32 @@ var init_introspect_pg = __esm({
|
|
75982
76263
|
}
|
75983
76264
|
if (lowered.startsWith("integer")) {
|
75984
76265
|
let out = `${withCasing2(name, casing2)}: integer("${name}")`;
|
75985
|
-
out += typeof defaultValue !== "undefined" ? `.default(${defaultValue})` : "";
|
75986
76266
|
return out;
|
75987
76267
|
}
|
75988
76268
|
if (lowered.startsWith("smallint")) {
|
75989
76269
|
let out = `${withCasing2(name, casing2)}: smallint("${name}")`;
|
75990
|
-
out += typeof defaultValue !== "undefined" ? `.default(${defaultValue})` : "";
|
75991
76270
|
return out;
|
75992
76271
|
}
|
75993
76272
|
if (lowered.startsWith("bigint")) {
|
75994
76273
|
let out = `// You can use { mode: "bigint" } if numbers are exceeding js number limitations
|
75995
76274
|
`;
|
75996
76275
|
out += `${withCasing2(name, casing2)}: bigint("${name}", { mode: "number" })`;
|
75997
|
-
out += typeof defaultValue !== "undefined" ? `.default(${defaultValue})` : "";
|
75998
76276
|
return out;
|
75999
76277
|
}
|
76000
76278
|
if (lowered.startsWith("boolean")) {
|
76001
76279
|
let out = `${withCasing2(name, casing2)}: boolean("${name}")`;
|
76002
|
-
out += typeof defaultValue !== "undefined" ? `.default(${defaultValue})` : "";
|
76003
76280
|
return out;
|
76004
76281
|
}
|
76005
76282
|
if (lowered.startsWith("double precision")) {
|
76006
76283
|
let out = `${withCasing2(name, casing2)}: doublePrecision("${name}")`;
|
76007
|
-
out += defaultValue ? `.default(${defaultValue})` : "";
|
76008
76284
|
return out;
|
76009
76285
|
}
|
76010
76286
|
if (lowered.startsWith("real")) {
|
76011
76287
|
let out = `${withCasing2(name, casing2)}: real("${name}")`;
|
76012
|
-
out += defaultValue ? `.default(${defaultValue})` : "";
|
76013
76288
|
return out;
|
76014
76289
|
}
|
76015
76290
|
if (lowered.startsWith("uuid")) {
|
76016
76291
|
let out = `${withCasing2(name, casing2)}: uuid("${name}")`;
|
76017
|
-
out += defaultValue === "gen_random_uuid()" ? ".defaultRandom()" : defaultValue ? `.default(sql\`${defaultValue}\`)` : "";
|
76018
76292
|
return out;
|
76019
76293
|
}
|
76020
76294
|
if (lowered.startsWith("numeric")) {
|
@@ -76024,8 +76298,6 @@ var init_introspect_pg = __esm({
|
|
76024
76298
|
params = { precision, scale };
|
76025
76299
|
}
|
76026
76300
|
let out = params ? `${withCasing2(name, casing2)}: numeric("${name}", ${timeConfig2(params)})` : `${withCasing2(name, casing2)}: numeric("${name}")`;
|
76027
|
-
defaultValue = defaultValue ? defaultValue.startsWith(`'`) && defaultValue.endsWith(`'`) ? defaultValue.substring(1, defaultValue.length - 1) : defaultValue : void 0;
|
76028
|
-
out += defaultValue ? `.default('${defaultValue}')` : "";
|
76029
76301
|
return out;
|
76030
76302
|
}
|
76031
76303
|
if (lowered.startsWith("timestamp")) {
|
@@ -76040,8 +76312,6 @@ var init_introspect_pg = __esm({
|
|
76040
76312
|
mode: "'string'"
|
76041
76313
|
});
|
76042
76314
|
let out = params ? `${withCasing2(name, casing2)}: timestamp("${name}", ${params})` : `${withCasing2(name, casing2)}: timestamp("${name}")`;
|
76043
|
-
defaultValue = defaultValue === "now()" || defaultValue === "CURRENT_TIMESTAMP" ? ".defaultNow()" : defaultValue ? `.default(${defaultValue})` : "";
|
76044
|
-
out += defaultValue;
|
76045
76315
|
return out;
|
76046
76316
|
}
|
76047
76317
|
if (lowered.startsWith("time")) {
|
@@ -76052,63 +76322,46 @@ var init_introspect_pg = __esm({
|
|
76052
76322
|
precision = precision ? precision : null;
|
76053
76323
|
const params = timeConfig2({ precision, withTimezone });
|
76054
76324
|
let out = params ? `${withCasing2(name, casing2)}: time("${name}", ${params})` : `${withCasing2(name, casing2)}: time("${name}")`;
|
76055
|
-
defaultValue = defaultValue === "now()" ? ".defaultNow()" : defaultValue ? `.default(${defaultValue})` : "";
|
76056
|
-
out += defaultValue;
|
76057
76325
|
return out;
|
76058
76326
|
}
|
76059
76327
|
if (lowered.startsWith("interval")) {
|
76060
76328
|
const params = intervalConfig(lowered);
|
76061
76329
|
let out = params ? `${withCasing2(name, casing2)}: interval("${name}", ${params})` : `${withCasing2(name, casing2)}: interval("${name}")`;
|
76062
|
-
out += defaultValue ? `.default(${defaultValue})` : "";
|
76063
76330
|
return out;
|
76064
76331
|
}
|
76065
76332
|
if (lowered === "date") {
|
76066
76333
|
let out = `${withCasing2(name, casing2)}: date("${name}")`;
|
76067
|
-
defaultValue = defaultValue === "now()" ? ".defaultNow()" : defaultValue === "CURRENT_DATE" ? `.default(sql\`${defaultValue}\`)` : defaultValue ? `.default(${defaultValue})` : "";
|
76068
|
-
out += defaultValue;
|
76069
76334
|
return out;
|
76070
76335
|
}
|
76071
76336
|
if (lowered.startsWith("text")) {
|
76072
76337
|
let out = `${withCasing2(name, casing2)}: text("${name}")`;
|
76073
|
-
out += typeof defaultValue !== "undefined" ? `.default(${defaultValue})` : "";
|
76074
76338
|
return out;
|
76075
76339
|
}
|
76076
|
-
if (lowered
|
76077
|
-
let out = `${withCasing2(name, casing2)}:
|
76078
|
-
defaultValue = (defaultValue == null ? void 0 : defaultValue.endsWith("::json")) ? defaultValue.substring(1, defaultValue.length - 7) : defaultValue;
|
76079
|
-
const def = defaultValue ? defaultValue : null;
|
76080
|
-
out += typeof defaultValue !== "undefined" ? `.default(${def})` : "";
|
76340
|
+
if (lowered.startsWith("jsonb")) {
|
76341
|
+
let out = `${withCasing2(name, casing2)}: jsonb("${name}")`;
|
76081
76342
|
return out;
|
76082
76343
|
}
|
76083
|
-
if (lowered
|
76084
|
-
let out = `${withCasing2(name, casing2)}:
|
76085
|
-
defaultValue = (defaultValue == null ? void 0 : defaultValue.endsWith("::jsonb")) ? defaultValue.substring(1, defaultValue.length - 8) : defaultValue;
|
76086
|
-
const def = typeof defaultValue !== "undefined" ? defaultValue : null;
|
76087
|
-
out += defaultValue ? `.default(${def})` : "";
|
76344
|
+
if (lowered.startsWith("json")) {
|
76345
|
+
let out = `${withCasing2(name, casing2)}: json("${name}")`;
|
76088
76346
|
return out;
|
76089
76347
|
}
|
76090
76348
|
if (lowered.startsWith("inet")) {
|
76091
76349
|
let out = `${withCasing2(name, casing2)}: inet("${name}")`;
|
76092
|
-
out += typeof defaultValue !== "undefined" ? `.default(${defaultValue})` : "";
|
76093
76350
|
return out;
|
76094
76351
|
}
|
76095
76352
|
if (lowered.startsWith("cidr")) {
|
76096
76353
|
let out = `${withCasing2(name, casing2)}: cidr("${name}")`;
|
76097
|
-
out += typeof defaultValue !== "undefined" ? `.default(${defaultValue})` : "";
|
76098
|
-
return out;
|
76099
|
-
}
|
76100
|
-
if (lowered.startsWith("macaddr")) {
|
76101
|
-
let out = `${withCasing2(name, casing2)}: macaddr("${name}")`;
|
76102
|
-
out += typeof defaultValue !== "undefined" ? `.default(${defaultValue})` : "";
|
76103
76354
|
return out;
|
76104
76355
|
}
|
76105
76356
|
if (lowered.startsWith("macaddr8")) {
|
76106
76357
|
let out = `${withCasing2(name, casing2)}: macaddr8("${name}")`;
|
76107
|
-
out
|
76358
|
+
return out;
|
76359
|
+
}
|
76360
|
+
if (lowered.startsWith("macaddr")) {
|
76361
|
+
let out = `${withCasing2(name, casing2)}: macaddr("${name}")`;
|
76108
76362
|
return out;
|
76109
76363
|
}
|
76110
76364
|
if (lowered.startsWith("varchar")) {
|
76111
|
-
const split = lowered.split(" ");
|
76112
76365
|
let out;
|
76113
76366
|
if (lowered.length !== 7) {
|
76114
76367
|
out = `${withCasing2(
|
@@ -76121,17 +76374,14 @@ var init_introspect_pg = __esm({
|
|
76121
76374
|
} else {
|
76122
76375
|
out = `${withCasing2(name, casing2)}: varchar("${name}")`;
|
76123
76376
|
}
|
76124
|
-
out += typeof defaultValue !== "undefined" ? `.default(${defaultValue})` : "";
|
76125
76377
|
return out;
|
76126
76378
|
}
|
76127
76379
|
if (lowered.startsWith("point")) {
|
76128
76380
|
let out = `${withCasing2(name, casing2)}: point("${name}")`;
|
76129
|
-
out += typeof defaultValue !== "undefined" ? `.default(${defaultValue})` : "";
|
76130
76381
|
return out;
|
76131
76382
|
}
|
76132
76383
|
if (lowered.startsWith("line")) {
|
76133
76384
|
let out = `${withCasing2(name, casing2)}: point("${name}")`;
|
76134
|
-
out += typeof defaultValue !== "undefined" ? `.default(${defaultValue})` : "";
|
76135
76385
|
return out;
|
76136
76386
|
}
|
76137
76387
|
if (lowered.startsWith("geometry")) {
|
@@ -76149,7 +76399,6 @@ var init_introspect_pg = __esm({
|
|
76149
76399
|
} else {
|
76150
76400
|
out = `${withCasing2(name, casing2)}: geometry("${name}")`;
|
76151
76401
|
}
|
76152
|
-
out += typeof defaultValue !== "undefined" ? `.default(${defaultValue})` : "";
|
76153
76402
|
if (isGeoUnknown) {
|
76154
76403
|
let unknown2 = `// TODO: failed to parse geometry type because found more than 2 options inside geometry function '${type}'
|
76155
76404
|
// Introspect is currently supporting only type and srid options
|
@@ -76160,7 +76409,6 @@ var init_introspect_pg = __esm({
|
|
76160
76409
|
return out;
|
76161
76410
|
}
|
76162
76411
|
if (lowered.startsWith("vector")) {
|
76163
|
-
const split = lowered.split(" ");
|
76164
76412
|
let out;
|
76165
76413
|
if (lowered.length !== 6) {
|
76166
76414
|
out = `${withCasing2(
|
@@ -76173,7 +76421,6 @@ var init_introspect_pg = __esm({
|
|
76173
76421
|
} else {
|
76174
76422
|
out = `${withCasing2(name, casing2)}: vector("${name}")`;
|
76175
76423
|
}
|
76176
|
-
out += typeof defaultValue !== "undefined" ? `.default(${defaultValue})` : "";
|
76177
76424
|
return out;
|
76178
76425
|
}
|
76179
76426
|
if (lowered.startsWith("char")) {
|
@@ -76189,26 +76436,6 @@ var init_introspect_pg = __esm({
|
|
76189
76436
|
} else {
|
76190
76437
|
out = `${withCasing2(name, casing2)}: char("${name}")`;
|
76191
76438
|
}
|
76192
|
-
out += typeof defaultValue !== "undefined" ? `.default(${defaultValue})` : "";
|
76193
|
-
return out;
|
76194
|
-
}
|
76195
|
-
const columnInternals = (_a = internals == null ? void 0 : internals.tables[tableName]) == null ? void 0 : _a.columns[name];
|
76196
|
-
if (typeof columnInternals !== "undefined") {
|
76197
|
-
if (columnInternals.isArray && columnInternals.rawType && enumTypes.has(columnInternals.rawType)) {
|
76198
|
-
let out = `${withCasing2(columnInternals.rawType, casing2)}: ${withCasing2(
|
76199
|
-
columnInternals.rawType,
|
76200
|
-
casing2
|
76201
|
-
)}("${name}")`;
|
76202
|
-
out += typeof defaultValue !== "undefined" ? `.default(${defaultValue})` : "";
|
76203
|
-
return out;
|
76204
|
-
}
|
76205
|
-
}
|
76206
|
-
if (enumTypes.has(type)) {
|
76207
|
-
let out = `${withCasing2(name, casing2)}: ${withCasing2(
|
76208
|
-
type,
|
76209
|
-
casing2
|
76210
|
-
)}("${name}")`;
|
76211
|
-
out += typeof defaultValue !== "undefined" ? `.default(${defaultValue})` : "";
|
76212
76439
|
return out;
|
76213
76440
|
}
|
76214
76441
|
let unknown = `// TODO: failed to parse database type '${type}'
|
@@ -76243,6 +76470,7 @@ var init_introspect_pg = __esm({
|
|
76243
76470
|
it.type,
|
76244
76471
|
it.name,
|
76245
76472
|
enumTypes,
|
76473
|
+
it.typeSchema ?? "public",
|
76246
76474
|
casing2,
|
76247
76475
|
it.default,
|
76248
76476
|
internals
|
@@ -76254,59 +76482,19 @@ var init_introspect_pg = __esm({
|
|
76254
76482
|
(_d = (_c = internals == null ? void 0 : internals.tables[tableName]) == null ? void 0 : _c.columns[it.name]) == null ? void 0 : _d.dimensions
|
76255
76483
|
);
|
76256
76484
|
}
|
76485
|
+
statement += mapDefault(
|
76486
|
+
tableName,
|
76487
|
+
it.type,
|
76488
|
+
it.name,
|
76489
|
+
enumTypes,
|
76490
|
+
it.typeSchema ?? "public",
|
76491
|
+
it.default,
|
76492
|
+
internals
|
76493
|
+
);
|
76257
76494
|
statement += it.primaryKey ? ".primaryKey()" : "";
|
76258
76495
|
statement += it.notNull && !it.identity ? ".notNull()" : "";
|
76259
|
-
function generateIdentityParams(identity) {
|
76260
|
-
let paramsObj = `{ name: "${identity.name}"`;
|
76261
|
-
if (identity == null ? void 0 : identity.startWith) {
|
76262
|
-
paramsObj += `, startWith: ${identity.startWith}`;
|
76263
|
-
}
|
76264
|
-
if (identity == null ? void 0 : identity.increment) {
|
76265
|
-
paramsObj += `, increment: ${identity.increment}`;
|
76266
|
-
}
|
76267
|
-
if (identity == null ? void 0 : identity.minValue) {
|
76268
|
-
paramsObj += `, minValue: ${identity.minValue}`;
|
76269
|
-
}
|
76270
|
-
if (identity == null ? void 0 : identity.maxValue) {
|
76271
|
-
paramsObj += `, maxValue: ${identity.maxValue}`;
|
76272
|
-
}
|
76273
|
-
if (identity == null ? void 0 : identity.cache) {
|
76274
|
-
paramsObj += `, cache: ${identity.cache}`;
|
76275
|
-
}
|
76276
|
-
if (identity == null ? void 0 : identity.cycle) {
|
76277
|
-
paramsObj += `, cycle: true`;
|
76278
|
-
}
|
76279
|
-
paramsObj += " }";
|
76280
|
-
if ((identity == null ? void 0 : identity.type) === "always") {
|
76281
|
-
return `.generatedAlwaysAsIdentity(${paramsObj})`;
|
76282
|
-
}
|
76283
|
-
return `.generatedByDefaultAsIdentity(${paramsObj})`;
|
76284
|
-
}
|
76285
76496
|
statement += it.identity ? generateIdentityParams(it.identity) : "";
|
76286
76497
|
statement += it.generated ? `.generatedAlwaysAs(sql\`${it.generated.as}\`)` : "";
|
76287
|
-
const fks2 = fkByColumnName[it.name];
|
76288
|
-
if (fks2) {
|
76289
|
-
const fksStatement = fks2.map((it2) => {
|
76290
|
-
const onDelete = it2.onDelete && it2.onDelete !== "no action" ? it2.onDelete : null;
|
76291
|
-
const onUpdate = it2.onUpdate && it2.onUpdate !== "no action" ? it2.onUpdate : null;
|
76292
|
-
const params = { onDelete, onUpdate };
|
76293
|
-
const typeSuffix = isCyclic3(it2) ? ": AnyPgColumn" : "";
|
76294
|
-
const paramsStr = objToStatement23(params);
|
76295
|
-
const tableSchema = schemas[it2.schemaTo || ""];
|
76296
|
-
const paramName = paramNameFor(it2.tableTo, tableSchema);
|
76297
|
-
if (paramsStr) {
|
76298
|
-
return `.references(()${typeSuffix} => ${withCasing2(
|
76299
|
-
paramName,
|
76300
|
-
casing2
|
76301
|
-
)}.${withCasing2(it2.columnsTo[0], casing2)}, ${paramsStr} )`;
|
76302
|
-
}
|
76303
|
-
return `.references(()${typeSuffix} => ${withCasing2(
|
76304
|
-
paramName,
|
76305
|
-
casing2
|
76306
|
-
)}.${withCasing2(it2.columnsTo[0], casing2)})`;
|
76307
|
-
}).join("");
|
76308
|
-
statement += fksStatement;
|
76309
|
-
}
|
76310
76498
|
statement += ",\n";
|
76311
76499
|
});
|
76312
76500
|
return statement;
|
@@ -76330,7 +76518,7 @@ var init_introspect_pg = __esm({
|
|
76330
76518
|
if (it2.isExpression) {
|
76331
76519
|
return `sql\`${it2.expression}\``;
|
76332
76520
|
} else {
|
76333
|
-
return `table.${withCasing2(it2.expression, casing2)}${it2.opclass && vectorOps.includes(it2.opclass) ? `.op("${it2.opclass}")` : ""}`;
|
76521
|
+
return `table.${withCasing2(it2.expression, casing2)}${it2.asc ? ".asc()" : ".desc()"}${it2.nulls === "first" ? ".nullsFirst()" : ".nullsLast()"}${it2.opclass && vectorOps.includes(it2.opclass) ? `.op("${it2.opclass}")` : ""}`;
|
76334
76522
|
}
|
76335
76523
|
}).join(", ")})`;
|
76336
76524
|
statement += it.where ? `.where(sql\`${it.where}\`)` : "";
|
@@ -83369,7 +83557,7 @@ init_utils2();
|
|
83369
83557
|
var version2 = async () => {
|
83370
83558
|
const { npmVersion } = await ormCoreVersions();
|
83371
83559
|
const ormVersion = npmVersion ? `drizzle-orm: v${npmVersion}` : "";
|
83372
|
-
const envVersion = "0.
|
83560
|
+
const envVersion = "0.24.0-5df8253";
|
83373
83561
|
const kitVersion = envVersion ? `v${envVersion}` : "--";
|
83374
83562
|
const versions = `drizzle-kit: ${kitVersion}
|
83375
83563
|
${ormVersion}`;
|