drizzle-kit 0.24.0 → 0.24.1-781dea0
Sign up to get free protection for your applications and to get access to all the features.
- package/api.d.mts +10 -0
- package/api.d.ts +10 -0
- package/api.js +159 -107
- package/api.mjs +159 -107
- package/bin.cjs +1018 -478
- package/package.json +3 -3
- package/utils.js +2 -1
- package/utils.mjs +2 -1
package/api.mjs
CHANGED
@@ -7469,11 +7469,30 @@ var init_mysqlSchema = __esm({
|
|
7469
7469
|
}
|
7470
7470
|
});
|
7471
7471
|
|
7472
|
+
// src/extensions/vector.ts
|
7473
|
+
var vectorOps;
|
7474
|
+
var init_vector = __esm({
|
7475
|
+
"src/extensions/vector.ts"() {
|
7476
|
+
"use strict";
|
7477
|
+
vectorOps = [
|
7478
|
+
"vector_l2_ops",
|
7479
|
+
"vector_ip_ops",
|
7480
|
+
"vector_cosine_ops",
|
7481
|
+
"vector_l1_ops",
|
7482
|
+
"bit_hamming_ops",
|
7483
|
+
"bit_jaccard_ops",
|
7484
|
+
"halfvec_l2_ops",
|
7485
|
+
"sparsevec_l2_ops"
|
7486
|
+
];
|
7487
|
+
}
|
7488
|
+
});
|
7489
|
+
|
7472
7490
|
// src/serializer/pgSchema.ts
|
7473
7491
|
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;
|
7474
7492
|
var init_pgSchema = __esm({
|
7475
7493
|
"src/serializer/pgSchema.ts"() {
|
7476
7494
|
"use strict";
|
7495
|
+
init_vector();
|
7477
7496
|
init_global();
|
7478
7497
|
init_lib();
|
7479
7498
|
indexV2 = objectType({
|
@@ -7720,7 +7739,8 @@ var init_pgSchema = __esm({
|
|
7720
7739
|
objectType({
|
7721
7740
|
isArray: booleanType().optional(),
|
7722
7741
|
dimensions: numberType().optional(),
|
7723
|
-
rawType: stringType().optional()
|
7742
|
+
rawType: stringType().optional(),
|
7743
|
+
isDefaultAnExpression: booleanType().optional()
|
7724
7744
|
}).optional()
|
7725
7745
|
)
|
7726
7746
|
}).optional()
|
@@ -7858,7 +7878,7 @@ var init_pgSchema = __esm({
|
|
7858
7878
|
squashIdx: (idx) => {
|
7859
7879
|
index2.parse(idx);
|
7860
7880
|
return `${idx.name};${idx.columns.map(
|
7861
|
-
(c) => `${c.expression}--${c.isExpression}--${c.asc}--${c.nulls}--${c.opclass}`
|
7881
|
+
(c) => `${c.expression}--${c.isExpression}--${c.asc}--${c.nulls}--${c.opclass && vectorOps.includes(c.opclass) ? c.opclass : ""}`
|
7862
7882
|
).join(",,")};${idx.isUnique};${idx.concurrently};${idx.method};${idx.where};${JSON.stringify(idx.with)}`;
|
7863
7883
|
},
|
7864
7884
|
unsquashIdx: (input) => {
|
@@ -11507,7 +11527,7 @@ var init_sqlgenerator = __esm({
|
|
11507
11527
|
isPgNativeType = (it) => {
|
11508
11528
|
if (pgNativeTypes.has(it)) return true;
|
11509
11529
|
const toCheck = it.replace(/ /g, "");
|
11510
|
-
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);
|
11530
|
+
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);
|
11511
11531
|
};
|
11512
11532
|
Convertor = class {
|
11513
11533
|
};
|
@@ -19378,7 +19398,7 @@ function jaccardDistance(column4, value) {
|
|
19378
19398
|
}
|
19379
19399
|
return sql`${column4} <%> ${value}`;
|
19380
19400
|
}
|
19381
|
-
var
|
19401
|
+
var init_vector2 = __esm({
|
19382
19402
|
"../drizzle-orm/dist/sql/functions/vector.js"() {
|
19383
19403
|
"use strict";
|
19384
19404
|
init_sql();
|
@@ -19390,7 +19410,7 @@ var init_functions = __esm({
|
|
19390
19410
|
"../drizzle-orm/dist/sql/functions/index.js"() {
|
19391
19411
|
"use strict";
|
19392
19412
|
init_aggregate();
|
19393
|
-
|
19413
|
+
init_vector2();
|
19394
19414
|
}
|
19395
19415
|
});
|
19396
19416
|
|
@@ -21054,7 +21074,7 @@ var init_sparsevec = __esm({
|
|
21054
21074
|
|
21055
21075
|
// ../drizzle-orm/dist/pg-core/columns/vector_extension/vector.js
|
21056
21076
|
var _a122, _b95, PgVectorBuilder, _a123, _b96, PgVector;
|
21057
|
-
var
|
21077
|
+
var init_vector3 = __esm({
|
21058
21078
|
"../drizzle-orm/dist/pg-core/columns/vector_extension/vector.js"() {
|
21059
21079
|
"use strict";
|
21060
21080
|
init_entity();
|
@@ -21126,7 +21146,7 @@ var init_columns = __esm({
|
|
21126
21146
|
init_bit();
|
21127
21147
|
init_halfvec();
|
21128
21148
|
init_sparsevec();
|
21129
|
-
|
21149
|
+
init_vector3();
|
21130
21150
|
}
|
21131
21151
|
});
|
21132
21152
|
|
@@ -24624,24 +24644,6 @@ var init_pg_core = __esm({
|
|
24624
24644
|
}
|
24625
24645
|
});
|
24626
24646
|
|
24627
|
-
// src/extensions/vector.ts
|
24628
|
-
var vectorOps;
|
24629
|
-
var init_vector3 = __esm({
|
24630
|
-
"src/extensions/vector.ts"() {
|
24631
|
-
"use strict";
|
24632
|
-
vectorOps = [
|
24633
|
-
"vector_l2_ops",
|
24634
|
-
"vector_ip_ops",
|
24635
|
-
"vector_cosine_ops",
|
24636
|
-
"vector_l1_ops",
|
24637
|
-
"bit_hamming_ops",
|
24638
|
-
"bit_jaccard_ops",
|
24639
|
-
"halfvec_l2_ops",
|
24640
|
-
"sparsevec_l2_ops"
|
24641
|
-
];
|
24642
|
-
}
|
24643
|
-
});
|
24644
|
-
|
24645
24647
|
// src/serializer/pgSerializer.ts
|
24646
24648
|
function stringFromIdentityProperty(field) {
|
24647
24649
|
return typeof field === "string" ? field : typeof field === "undefined" ? void 0 : String(field);
|
@@ -24679,7 +24681,7 @@ function buildArrayString(array, sqlType) {
|
|
24679
24681
|
}).join(",");
|
24680
24682
|
return `{${values}}`;
|
24681
24683
|
}
|
24682
|
-
var dialect4, indexName, generatePgSnapshot, trimChar, fromDatabase,
|
24684
|
+
var dialect4, indexName, generatePgSnapshot, trimChar, fromDatabase, defaultForColumn;
|
24683
24685
|
var init_pgSerializer = __esm({
|
24684
24686
|
"src/serializer/pgSerializer.ts"() {
|
24685
24687
|
"use strict";
|
@@ -24687,7 +24689,7 @@ var init_pgSerializer = __esm({
|
|
24687
24689
|
init_dist();
|
24688
24690
|
init_pg_core();
|
24689
24691
|
init_pg_core();
|
24690
|
-
|
24692
|
+
init_vector();
|
24691
24693
|
init_outputs();
|
24692
24694
|
init_utils();
|
24693
24695
|
init_serializer();
|
@@ -24800,7 +24802,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
24800
24802
|
columnToSet.default = `'${buildArrayString(
|
24801
24803
|
column4.default,
|
24802
24804
|
sqlTypeLowered
|
24803
|
-
)}'
|
24805
|
+
)}'`;
|
24804
24806
|
} else {
|
24805
24807
|
columnToSet.default = column4.default;
|
24806
24808
|
}
|
@@ -25147,7 +25149,7 @@ ${withStyle.errorWarning(
|
|
25147
25149
|
WHEN 'int2'::regtype THEN 'smallserial'
|
25148
25150
|
END
|
25149
25151
|
ELSE format_type(a.atttypid, a.atttypmod)
|
25150
|
-
END AS data_type, INFORMATION_SCHEMA.COLUMNS.table_name,
|
25152
|
+
END AS data_type, INFORMATION_SCHEMA.COLUMNS.table_name, ns.nspname as type_schema,
|
25151
25153
|
pg_get_serial_sequence('"${tableSchema}"."${tableName}"', a.attname)::regclass as seq_name, INFORMATION_SCHEMA.COLUMNS.column_name,
|
25152
25154
|
INFORMATION_SCHEMA.COLUMNS.column_default, INFORMATION_SCHEMA.COLUMNS.data_type as additional_dt,
|
25153
25155
|
INFORMATION_SCHEMA.COLUMNS.udt_name as enum_name,
|
@@ -25158,6 +25160,7 @@ ${withStyle.errorWarning(
|
|
25158
25160
|
INFORMATION_SCHEMA.COLUMNS.identity_cycle
|
25159
25161
|
FROM pg_attribute a
|
25160
25162
|
JOIN INFORMATION_SCHEMA.COLUMNS ON INFORMATION_SCHEMA.COLUMNS.column_name = a.attname
|
25163
|
+
JOIN pg_type t ON t.oid = a.atttypid LEFT JOIN pg_namespace ns ON ns.oid = t.typnamespace
|
25161
25164
|
WHERE a.attrelid = '"${tableSchema}"."${tableName}"'::regclass and INFORMATION_SCHEMA.COLUMNS.table_name = '${tableName}' and INFORMATION_SCHEMA.COLUMNS.table_schema = '${tableSchema}'
|
25162
25165
|
AND a.attnum > 0
|
25163
25166
|
AND NOT a.attisdropped
|
@@ -25177,30 +25180,42 @@ ${withStyle.errorWarning(
|
|
25177
25180
|
}
|
25178
25181
|
const tableForeignKeys = await db.query(
|
25179
25182
|
`SELECT
|
25180
|
-
|
25181
|
-
|
25182
|
-
|
25183
|
-
|
25184
|
-
|
25185
|
-
|
25186
|
-
|
25187
|
-
|
25188
|
-
|
25189
|
-
|
25190
|
-
|
25191
|
-
|
25192
|
-
|
25193
|
-
|
25194
|
-
|
25195
|
-
|
25196
|
-
|
25197
|
-
|
25198
|
-
|
25199
|
-
|
25200
|
-
|
25201
|
-
|
25202
|
-
|
25203
|
-
|
25183
|
+
con.contype AS constraint_type,
|
25184
|
+
nsp.nspname AS constraint_schema,
|
25185
|
+
con.conname AS constraint_name,
|
25186
|
+
rel.relname AS table_name,
|
25187
|
+
att.attname AS column_name,
|
25188
|
+
fnsp.nspname AS foreign_table_schema,
|
25189
|
+
frel.relname AS foreign_table_name,
|
25190
|
+
fatt.attname AS foreign_column_name,
|
25191
|
+
CASE con.confupdtype
|
25192
|
+
WHEN 'a' THEN 'NO ACTION'
|
25193
|
+
WHEN 'r' THEN 'RESTRICT'
|
25194
|
+
WHEN 'n' THEN 'SET NULL'
|
25195
|
+
WHEN 'c' THEN 'CASCADE'
|
25196
|
+
WHEN 'd' THEN 'SET DEFAULT'
|
25197
|
+
END AS update_rule,
|
25198
|
+
CASE con.confdeltype
|
25199
|
+
WHEN 'a' THEN 'NO ACTION'
|
25200
|
+
WHEN 'r' THEN 'RESTRICT'
|
25201
|
+
WHEN 'n' THEN 'SET NULL'
|
25202
|
+
WHEN 'c' THEN 'CASCADE'
|
25203
|
+
WHEN 'd' THEN 'SET DEFAULT'
|
25204
|
+
END AS delete_rule
|
25205
|
+
FROM
|
25206
|
+
pg_catalog.pg_constraint con
|
25207
|
+
JOIN pg_catalog.pg_class rel ON rel.oid = con.conrelid
|
25208
|
+
JOIN pg_catalog.pg_namespace nsp ON nsp.oid = con.connamespace
|
25209
|
+
LEFT JOIN pg_catalog.pg_attribute att ON att.attnum = ANY (con.conkey)
|
25210
|
+
AND att.attrelid = con.conrelid
|
25211
|
+
LEFT JOIN pg_catalog.pg_class frel ON frel.oid = con.confrelid
|
25212
|
+
LEFT JOIN pg_catalog.pg_namespace fnsp ON fnsp.oid = frel.relnamespace
|
25213
|
+
LEFT JOIN pg_catalog.pg_attribute fatt ON fatt.attnum = ANY (con.confkey)
|
25214
|
+
AND fatt.attrelid = con.confrelid
|
25215
|
+
WHERE
|
25216
|
+
nsp.nspname = '${tableSchema}'
|
25217
|
+
AND rel.relname = '${tableName}'
|
25218
|
+
AND con.contype IN ('f');`
|
25204
25219
|
);
|
25205
25220
|
foreignKeysCount += tableForeignKeys.length;
|
25206
25221
|
if (progressCallback) {
|
@@ -25212,8 +25227,8 @@ ${withStyle.errorWarning(
|
|
25212
25227
|
const columnTo = fk4.foreign_column_name;
|
25213
25228
|
const schemaTo = fk4.foreign_table_schema;
|
25214
25229
|
const foreignKeyName = fk4.constraint_name;
|
25215
|
-
const onUpdate = fk4.update_rule
|
25216
|
-
const onDelete = fk4.delete_rule
|
25230
|
+
const onUpdate = fk4.update_rule?.toLowerCase();
|
25231
|
+
const onDelete = fk4.delete_rule?.toLowerCase();
|
25217
25232
|
if (typeof foreignKeysToReturn[foreignKeyName] !== "undefined") {
|
25218
25233
|
foreignKeysToReturn[foreignKeyName].columnsFrom.push(columnFrom);
|
25219
25234
|
foreignKeysToReturn[foreignKeyName].columnsTo.push(columnTo);
|
@@ -25258,6 +25273,8 @@ ${withStyle.errorWarning(
|
|
25258
25273
|
const columnDimensions = columnResponse.array_dimensions;
|
25259
25274
|
const enumType2 = columnResponse.enum_name;
|
25260
25275
|
let columnType = columnResponse.data_type;
|
25276
|
+
const typeSchema = columnResponse.type_schema;
|
25277
|
+
const defaultValueRes = columnResponse.column_default;
|
25261
25278
|
const isGenerated = columnResponse.is_generated === "ALWAYS";
|
25262
25279
|
const generationExpression = columnResponse.generation_expression;
|
25263
25280
|
const isIdentity = columnResponse.is_identity === "YES";
|
@@ -25288,12 +25305,7 @@ ${withStyle.errorWarning(
|
|
25288
25305
|
columns: cprimaryKey.map((c) => c.column_name)
|
25289
25306
|
};
|
25290
25307
|
}
|
25291
|
-
const defaultValue = defaultForColumn(columnResponse);
|
25292
|
-
const isSerial = columnType === "serial";
|
25293
25308
|
let columnTypeMapped = columnType;
|
25294
|
-
if (columnTypeMapped.startsWith("numeric(")) {
|
25295
|
-
columnTypeMapped = columnTypeMapped.replace(",", ", ");
|
25296
|
-
}
|
25297
25309
|
if (columnAdditionalDT === "ARRAY") {
|
25298
25310
|
if (typeof internals.tables[tableName] === "undefined") {
|
25299
25311
|
internals.tables[tableName] = {
|
@@ -25321,6 +25333,34 @@ ${withStyle.errorWarning(
|
|
25321
25333
|
}
|
25322
25334
|
}
|
25323
25335
|
}
|
25336
|
+
const defaultValue = defaultForColumn(
|
25337
|
+
columnResponse,
|
25338
|
+
internals,
|
25339
|
+
tableName
|
25340
|
+
);
|
25341
|
+
if (defaultValue === "NULL" || defaultValueRes && defaultValueRes.startsWith("(") && defaultValueRes.endsWith(")")) {
|
25342
|
+
if (typeof internals.tables[tableName] === "undefined") {
|
25343
|
+
internals.tables[tableName] = {
|
25344
|
+
columns: {
|
25345
|
+
[columnName]: {
|
25346
|
+
isDefaultAnExpression: true
|
25347
|
+
}
|
25348
|
+
}
|
25349
|
+
};
|
25350
|
+
} else {
|
25351
|
+
if (typeof internals.tables[tableName].columns[columnName] === "undefined") {
|
25352
|
+
internals.tables[tableName].columns[columnName] = {
|
25353
|
+
isDefaultAnExpression: true
|
25354
|
+
};
|
25355
|
+
} else {
|
25356
|
+
internals.tables[tableName].columns[columnName].isDefaultAnExpression = true;
|
25357
|
+
}
|
25358
|
+
}
|
25359
|
+
}
|
25360
|
+
const isSerial = columnType === "serial";
|
25361
|
+
if (columnTypeMapped.startsWith("numeric(")) {
|
25362
|
+
columnTypeMapped = columnTypeMapped.replace(",", ", ");
|
25363
|
+
}
|
25324
25364
|
if (columnAdditionalDT === "ARRAY") {
|
25325
25365
|
for (let i = 1; i < Number(columnDimensions); i++) {
|
25326
25366
|
columnTypeMapped += "[]";
|
@@ -25334,7 +25374,7 @@ ${withStyle.errorWarning(
|
|
25334
25374
|
// filter vectors, but in future we should filter any extension that was installed by user
|
25335
25375
|
columnAdditionalDT === "USER-DEFINED" && !["vector", "geometry"].includes(enumType2) ? enumType2 : columnTypeMapped
|
25336
25376
|
),
|
25337
|
-
typeSchema: enumsToReturn[`${
|
25377
|
+
typeSchema: enumsToReturn[`${typeSchema}.${enumType2}`] !== void 0 ? enumsToReturn[`${typeSchema}.${enumType2}`].schema : void 0,
|
25338
25378
|
primaryKey: primaryKey.length === 1 && cprimaryKey.length < 2,
|
25339
25379
|
// default: isSerial ? undefined : defaultValue,
|
25340
25380
|
notNull: columnResponse.is_nullable === "NO",
|
@@ -25352,7 +25392,7 @@ ${withStyle.errorWarning(
|
|
25352
25392
|
} : void 0
|
25353
25393
|
};
|
25354
25394
|
if (identityName) {
|
25355
|
-
delete sequencesToReturn[`${tableSchema}.${identityName}`];
|
25395
|
+
delete sequencesToReturn[`${tableSchema}.${identityName.startsWith('"') && identityName.endsWith('"') ? identityName.slice(1, -1) : identityName}`];
|
25356
25396
|
delete sequencesToReturn[identityName];
|
25357
25397
|
}
|
25358
25398
|
if (!isSerial && typeof defaultValue !== "undefined") {
|
@@ -25505,59 +25545,71 @@ ${withStyle.errorWarning(
|
|
25505
25545
|
internal: internals
|
25506
25546
|
};
|
25507
25547
|
};
|
25508
|
-
|
25509
|
-
|
25510
|
-
|
25511
|
-
// "character varying": "::character varying",
|
25512
|
-
// "double precision": "::double precision",
|
25513
|
-
// "time with time zone": "::time with time zone",
|
25514
|
-
"time without time zone": "::time without time zone",
|
25515
|
-
// "timestamp with time zone": "::timestamp with time zone",
|
25516
|
-
"timestamp without time zone": "::timestamp without time zone",
|
25517
|
-
"timestamp(": "::timestamp without time zone",
|
25518
|
-
// date: "::date",
|
25519
|
-
// interval: "::interval",
|
25520
|
-
// character: "::bpchar",
|
25521
|
-
// macaddr8: "::macaddr8",
|
25522
|
-
// macaddr: "::macaddr",
|
25523
|
-
// inet: "::inet",
|
25524
|
-
// cidr: "::cidr",
|
25525
|
-
// jsonb: "::jsonb",
|
25526
|
-
// json: "::json",
|
25527
|
-
"character(": "::bpchar"
|
25528
|
-
};
|
25529
|
-
defaultForColumn = (column4) => {
|
25548
|
+
defaultForColumn = (column4, internals, tableName) => {
|
25549
|
+
const columnName = column4.attname;
|
25550
|
+
const isArray = internals?.tables[tableName]?.columns[columnName]?.isArray ?? false;
|
25530
25551
|
if (column4.column_default === null) {
|
25531
25552
|
return void 0;
|
25532
25553
|
}
|
25533
25554
|
if (column4.data_type === "serial" || column4.data_type === "smallserial" || column4.data_type === "bigserial") {
|
25534
25555
|
return void 0;
|
25535
25556
|
}
|
25536
|
-
|
25557
|
+
if (column4.column_default.endsWith("[]")) {
|
25558
|
+
column4.column_default = column4.column_default.slice(0, -2);
|
25559
|
+
}
|
25560
|
+
column4.column_default = column4.column_default.replace(/::(.*?)(?<![^\w"])(?=$)/, "");
|
25537
25561
|
const columnDefaultAsString = column4.column_default.toString();
|
25538
|
-
if (
|
25539
|
-
|
25540
|
-
|
25541
|
-
|
25542
|
-
|
25543
|
-
|
25544
|
-
|
25545
|
-
|
25546
|
-
|
25547
|
-
|
25548
|
-
|
25549
|
-
|
25550
|
-
|
25551
|
-
|
25552
|
-
|
25553
|
-
|
25554
|
-
|
25562
|
+
if (isArray) {
|
25563
|
+
return `'{${columnDefaultAsString.slice(2, -2).split(/\s*,\s*/g).map((value) => {
|
25564
|
+
if (["integer", "smallint", "bigint", "double precision", "real"].includes(column4.data_type.slice(0, -2))) {
|
25565
|
+
return value;
|
25566
|
+
} else if (column4.data_type.startsWith("timestamp")) {
|
25567
|
+
return `${value}`;
|
25568
|
+
} else if (column4.data_type.slice(0, -2) === "interval") {
|
25569
|
+
return value.replaceAll('"', `"`);
|
25570
|
+
} else if (column4.data_type.slice(0, -2) === "boolean") {
|
25571
|
+
return value === "t" ? "true" : "false";
|
25572
|
+
} else if (["json", "jsonb"].includes(column4.data_type.slice(0, -2))) {
|
25573
|
+
return JSON.stringify(JSON.stringify(JSON.parse(JSON.parse(value)), null, 0));
|
25574
|
+
} else {
|
25575
|
+
return `"${value}"`;
|
25576
|
+
}
|
25577
|
+
}).join(",")}}'`;
|
25578
|
+
}
|
25579
|
+
if (["integer", "smallint", "bigint", "double precision", "real"].includes(column4.data_type)) {
|
25580
|
+
if (/^-?[\d.]+(?:e-?\d+)?$/.test(columnDefaultAsString)) {
|
25555
25581
|
return Number(columnDefaultAsString);
|
25556
|
-
} else if (column4.data_type === "boolean") {
|
25557
|
-
return column4.column_default === "true";
|
25558
25582
|
} else {
|
25559
|
-
|
25583
|
+
if (typeof internals.tables[tableName] === "undefined") {
|
25584
|
+
internals.tables[tableName] = {
|
25585
|
+
columns: {
|
25586
|
+
[columnName]: {
|
25587
|
+
isDefaultAnExpression: true
|
25588
|
+
}
|
25589
|
+
}
|
25590
|
+
};
|
25591
|
+
} else {
|
25592
|
+
if (typeof internals.tables[tableName].columns[columnName] === "undefined") {
|
25593
|
+
internals.tables[tableName].columns[columnName] = {
|
25594
|
+
isDefaultAnExpression: true
|
25595
|
+
};
|
25596
|
+
} else {
|
25597
|
+
internals.tables[tableName].columns[columnName].isDefaultAnExpression = true;
|
25598
|
+
}
|
25599
|
+
}
|
25600
|
+
return columnDefaultAsString;
|
25560
25601
|
}
|
25602
|
+
} else if (column4.data_type === "json" || column4.data_type === "jsonb") {
|
25603
|
+
const jsonWithoutSpaces = JSON.stringify(JSON.parse(columnDefaultAsString.slice(1, -1)));
|
25604
|
+
return `'${jsonWithoutSpaces}'::${column4.data_type}`;
|
25605
|
+
} else if (column4.data_type === "boolean") {
|
25606
|
+
return column4.column_default === "true";
|
25607
|
+
} else if (columnDefaultAsString === "NULL") {
|
25608
|
+
return `NULL`;
|
25609
|
+
} else if (columnDefaultAsString.startsWith("'") && columnDefaultAsString.endsWith("'")) {
|
25610
|
+
return columnDefaultAsString;
|
25611
|
+
} else {
|
25612
|
+
return `${columnDefaultAsString.replace(/\\/g, "`\\")}`;
|
25561
25613
|
}
|
25562
25614
|
};
|
25563
25615
|
}
|
@@ -33885,9 +33937,9 @@ var init_cli = __esm({
|
|
33885
33937
|
tablesFilter: unionType([stringType(), stringType().array()]).optional(),
|
33886
33938
|
schemaFilter: unionType([stringType(), stringType().array()]).optional().default(["public"]),
|
33887
33939
|
extensionsFilters: literalType("postgis").array().optional(),
|
33888
|
-
|
33940
|
+
casing,
|
33889
33941
|
breakpoints: booleanType().optional().default(true),
|
33890
|
-
|
33942
|
+
migrations: objectType({
|
33891
33943
|
prefix: prefix.optional().default("index")
|
33892
33944
|
}).optional()
|
33893
33945
|
}).passthrough();
|