drizzle-kit 0.21.4 → 0.22.0-407e2e6
Sign up to get free protection for your applications and to get access to all the features.
- package/bin.cjs +672 -241
- package/package.json +3 -3
- package/payload.d.mts +96 -10
- package/payload.d.ts +96 -10
- package/payload.js +1675 -1156
- package/payload.mjs +1675 -1156
- package/utils-studio.js +175 -23
- package/utils-studio.mjs +175 -23
- package/utils.js +118 -8
- package/utils.mjs +117 -8
package/utils-studio.js
CHANGED
@@ -1079,7 +1079,7 @@ var init_global = __esm({
|
|
1079
1079
|
"src/global.ts"() {
|
1080
1080
|
"use strict";
|
1081
1081
|
originUUID = "00000000-0000-0000-0000-000000000000";
|
1082
|
-
snapshotVersion = "
|
1082
|
+
snapshotVersion = "7";
|
1083
1083
|
}
|
1084
1084
|
});
|
1085
1085
|
|
@@ -5008,7 +5008,7 @@ var init_mysqlSchema = __esm({
|
|
5008
5008
|
});
|
5009
5009
|
|
5010
5010
|
// src/serializer/pgSchema.ts
|
5011
|
-
var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, index2, fk2, column2, tableV32, compositePK2, uniqueConstraint2, tableV42, table2, schemaHash2, kitInternals2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternalV5, pgSchemaExternal, pgSchemaInternal, tableSquashed2, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchemaV5, pgSchema2, backwardCompatiblePgSchema, dryPg;
|
5011
|
+
var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, indexColumn, index2, indexV4, indexV5, indexV6, fk2, column2, tableV32, compositePK2, uniqueConstraint2, tableV42, tableV6, tableV5, table2, schemaHash2, kitInternals2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternalV5, pgSchemaInternalV6, pgSchemaExternal, pgSchemaInternal, tableSquashed2, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashedV6, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchemaV5, pgSchemaV6, pgSchema2, backwardCompatiblePgSchema, dryPg;
|
5012
5012
|
var init_pgSchema = __esm({
|
5013
5013
|
"src/serializer/pgSchema.ts"() {
|
5014
5014
|
"use strict";
|
@@ -5076,10 +5076,48 @@ var init_pgSchema = __esm({
|
|
5076
5076
|
tables: recordType(stringType(), tableV1),
|
5077
5077
|
enums: recordType(stringType(), enumSchemaV1)
|
5078
5078
|
}).strict();
|
5079
|
+
indexColumn = objectType({
|
5080
|
+
expression: stringType(),
|
5081
|
+
isExpression: booleanType(),
|
5082
|
+
asc: booleanType(),
|
5083
|
+
nulls: stringType().optional(),
|
5084
|
+
opclass: stringType().optional()
|
5085
|
+
});
|
5079
5086
|
index2 = objectType({
|
5087
|
+
name: stringType(),
|
5088
|
+
columns: indexColumn.array(),
|
5089
|
+
isUnique: booleanType(),
|
5090
|
+
with: recordType(stringType(), anyType()).optional(),
|
5091
|
+
method: stringType().default("btree"),
|
5092
|
+
where: stringType().optional(),
|
5093
|
+
concurrently: booleanType().default(false)
|
5094
|
+
}).strict();
|
5095
|
+
indexV4 = objectType({
|
5080
5096
|
name: stringType(),
|
5081
5097
|
columns: stringType().array(),
|
5082
|
-
isUnique: booleanType()
|
5098
|
+
isUnique: booleanType(),
|
5099
|
+
with: recordType(stringType(), stringType()).optional(),
|
5100
|
+
method: stringType().default("btree"),
|
5101
|
+
where: stringType().optional(),
|
5102
|
+
concurrently: booleanType().default(false)
|
5103
|
+
}).strict();
|
5104
|
+
indexV5 = objectType({
|
5105
|
+
name: stringType(),
|
5106
|
+
columns: stringType().array(),
|
5107
|
+
isUnique: booleanType(),
|
5108
|
+
with: recordType(stringType(), stringType()).optional(),
|
5109
|
+
method: stringType().default("btree"),
|
5110
|
+
where: stringType().optional(),
|
5111
|
+
concurrently: booleanType().default(false)
|
5112
|
+
}).strict();
|
5113
|
+
indexV6 = objectType({
|
5114
|
+
name: stringType(),
|
5115
|
+
columns: stringType().array(),
|
5116
|
+
isUnique: booleanType(),
|
5117
|
+
with: recordType(stringType(), stringType()).optional(),
|
5118
|
+
method: stringType().default("btree"),
|
5119
|
+
where: stringType().optional(),
|
5120
|
+
concurrently: booleanType().default(false)
|
5083
5121
|
}).strict();
|
5084
5122
|
fk2 = objectType({
|
5085
5123
|
name: stringType(),
|
@@ -5121,9 +5159,27 @@ var init_pgSchema = __esm({
|
|
5121
5159
|
name: stringType(),
|
5122
5160
|
schema: stringType(),
|
5123
5161
|
columns: recordType(stringType(), column2),
|
5124
|
-
indexes: recordType(stringType(),
|
5162
|
+
indexes: recordType(stringType(), indexV4),
|
5125
5163
|
foreignKeys: recordType(stringType(), fk2)
|
5126
5164
|
}).strict();
|
5165
|
+
tableV6 = objectType({
|
5166
|
+
name: stringType(),
|
5167
|
+
schema: stringType(),
|
5168
|
+
columns: recordType(stringType(), column2),
|
5169
|
+
indexes: recordType(stringType(), indexV6),
|
5170
|
+
foreignKeys: recordType(stringType(), fk2),
|
5171
|
+
compositePrimaryKeys: recordType(stringType(), compositePK2),
|
5172
|
+
uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
|
5173
|
+
}).strict();
|
5174
|
+
tableV5 = objectType({
|
5175
|
+
name: stringType(),
|
5176
|
+
schema: stringType(),
|
5177
|
+
columns: recordType(stringType(), column2),
|
5178
|
+
indexes: recordType(stringType(), indexV5),
|
5179
|
+
foreignKeys: recordType(stringType(), fk2),
|
5180
|
+
compositePrimaryKeys: recordType(stringType(), compositePK2),
|
5181
|
+
uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
|
5182
|
+
}).strict();
|
5127
5183
|
table2 = objectType({
|
5128
5184
|
name: stringType(),
|
5129
5185
|
schema: stringType(),
|
@@ -5168,7 +5224,7 @@ var init_pgSchema = __esm({
|
|
5168
5224
|
pgSchemaInternalV5 = objectType({
|
5169
5225
|
version: literalType("5"),
|
5170
5226
|
dialect: literalType("pg"),
|
5171
|
-
tables: recordType(stringType(),
|
5227
|
+
tables: recordType(stringType(), tableV5),
|
5172
5228
|
enums: recordType(stringType(), enumSchemaV1),
|
5173
5229
|
schemas: recordType(stringType(), stringType()),
|
5174
5230
|
_meta: objectType({
|
@@ -5178,6 +5234,19 @@ var init_pgSchema = __esm({
|
|
5178
5234
|
}),
|
5179
5235
|
internal: kitInternals2
|
5180
5236
|
}).strict();
|
5237
|
+
pgSchemaInternalV6 = objectType({
|
5238
|
+
version: literalType("6"),
|
5239
|
+
dialect: literalType("postgresql"),
|
5240
|
+
tables: recordType(stringType(), tableV6),
|
5241
|
+
enums: recordType(stringType(), enumSchema),
|
5242
|
+
schemas: recordType(stringType(), stringType()),
|
5243
|
+
_meta: objectType({
|
5244
|
+
schemas: recordType(stringType(), stringType()),
|
5245
|
+
tables: recordType(stringType(), stringType()),
|
5246
|
+
columns: recordType(stringType(), stringType())
|
5247
|
+
}),
|
5248
|
+
internal: kitInternals2
|
5249
|
+
}).strict();
|
5181
5250
|
pgSchemaExternal = objectType({
|
5182
5251
|
version: literalType("5"),
|
5183
5252
|
dialect: literalType("pg"),
|
@@ -5191,7 +5260,7 @@ var init_pgSchema = __esm({
|
|
5191
5260
|
})
|
5192
5261
|
}).strict();
|
5193
5262
|
pgSchemaInternal = objectType({
|
5194
|
-
version: literalType("
|
5263
|
+
version: literalType("7"),
|
5195
5264
|
dialect: literalType("postgresql"),
|
5196
5265
|
tables: recordType(stringType(), table2),
|
5197
5266
|
enums: recordType(stringType(), enumSchema),
|
@@ -5226,18 +5295,30 @@ var init_pgSchema = __esm({
|
|
5226
5295
|
enums: recordType(stringType(), enumSchemaV1),
|
5227
5296
|
schemas: recordType(stringType(), stringType())
|
5228
5297
|
}).strict();
|
5229
|
-
|
5298
|
+
pgSchemaSquashedV6 = objectType({
|
5230
5299
|
version: literalType("6"),
|
5231
5300
|
dialect: literalType("postgresql"),
|
5232
5301
|
tables: recordType(stringType(), tableSquashed2),
|
5233
5302
|
enums: recordType(stringType(), enumSchema),
|
5234
5303
|
schemas: recordType(stringType(), stringType())
|
5235
5304
|
}).strict();
|
5305
|
+
pgSchemaSquashed = objectType({
|
5306
|
+
version: literalType("7"),
|
5307
|
+
dialect: literalType("postgresql"),
|
5308
|
+
tables: recordType(stringType(), tableSquashed2),
|
5309
|
+
enums: recordType(stringType(), enumSchema),
|
5310
|
+
schemas: recordType(stringType(), stringType())
|
5311
|
+
}).strict();
|
5236
5312
|
pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash2);
|
5237
5313
|
pgSchemaV4 = pgSchemaInternalV4.merge(schemaHash2);
|
5238
5314
|
pgSchemaV5 = pgSchemaInternalV5.merge(schemaHash2);
|
5315
|
+
pgSchemaV6 = pgSchemaInternalV6.merge(schemaHash2);
|
5239
5316
|
pgSchema2 = pgSchemaInternal.merge(schemaHash2);
|
5240
|
-
backwardCompatiblePgSchema = unionType([
|
5317
|
+
backwardCompatiblePgSchema = unionType([
|
5318
|
+
pgSchemaV5,
|
5319
|
+
pgSchemaV6,
|
5320
|
+
pgSchema2
|
5321
|
+
]);
|
5241
5322
|
dryPg = pgSchema2.parse({
|
5242
5323
|
version: snapshotVersion,
|
5243
5324
|
dialect: "postgresql",
|
@@ -5930,6 +6011,13 @@ var require_brace_expansion = __commonJS({
|
|
5930
6011
|
}
|
5931
6012
|
});
|
5932
6013
|
|
6014
|
+
// src/extensions/vector.ts
|
6015
|
+
var init_vector = __esm({
|
6016
|
+
"src/extensions/vector.ts"() {
|
6017
|
+
"use strict";
|
6018
|
+
}
|
6019
|
+
});
|
6020
|
+
|
5933
6021
|
// src/serializer/pgSerializer.ts
|
5934
6022
|
var import_pg_core2, import_pg_core3, import_drizzle_orm2, dialect4, trimChar, fromDatabase2, columnToDefault, defaultForColumn;
|
5935
6023
|
var init_pgSerializer = __esm({
|
@@ -5940,6 +6028,7 @@ var init_pgSerializer = __esm({
|
|
5940
6028
|
import_drizzle_orm2 = require("drizzle-orm");
|
5941
6029
|
init_serializer();
|
5942
6030
|
init_outputs();
|
6031
|
+
init_vector();
|
5943
6032
|
dialect4 = new import_pg_core2.PgDialect();
|
5944
6033
|
trimChar = (str, char) => {
|
5945
6034
|
let start = 0;
|
@@ -6201,7 +6290,10 @@ var init_pgSerializer = __esm({
|
|
6201
6290
|
columnTypeMapped = trimChar(columnTypeMapped, '"');
|
6202
6291
|
columnToReturn[columnName] = {
|
6203
6292
|
name: columnName,
|
6204
|
-
type:
|
6293
|
+
type: (
|
6294
|
+
// filter vectors, but in future we should filter any extension that was installed by user
|
6295
|
+
columnAdditionalDT === "USER-DEFINED" && enumType3 !== "vector" ? enumType3 : columnTypeMapped
|
6296
|
+
),
|
6205
6297
|
typeSchema: enumsToReturn[`${tableSchema}.${enumType3}`] !== void 0 ? enumsToReturn[`${tableSchema}.${enumType3}`].schema : void 0,
|
6206
6298
|
primaryKey: primaryKey.length === 1 && cprimaryKey.length < 2,
|
6207
6299
|
// default: isSerial ? undefined : defaultValue,
|
@@ -6212,15 +6304,42 @@ var init_pgSerializer = __esm({
|
|
6212
6304
|
}
|
6213
6305
|
}
|
6214
6306
|
const dbIndexes = await db.query(
|
6215
|
-
`SELECT t.relname
|
6216
|
-
|
6217
|
-
|
6218
|
-
|
6219
|
-
|
6220
|
-
|
6221
|
-
|
6222
|
-
|
6223
|
-
|
6307
|
+
`SELECT DISTINCT ON (t.relname, ic.relname, k.i) t.relname as table_name, ic.relname AS indexname,
|
6308
|
+
k.i AS index_order,
|
6309
|
+
i.indisunique as is_unique,
|
6310
|
+
am.amname as method,
|
6311
|
+
ic.reloptions as with,
|
6312
|
+
coalesce(a.attname,
|
6313
|
+
(('{' || pg_get_expr(
|
6314
|
+
i.indexprs,
|
6315
|
+
i.indrelid
|
6316
|
+
)
|
6317
|
+
|| '}')::text[]
|
6318
|
+
)[k.i]
|
6319
|
+
) AS column_name,
|
6320
|
+
CASE
|
6321
|
+
WHEN pg_get_expr(i.indexprs, i.indrelid) IS NOT NULL THEN 1
|
6322
|
+
ELSE 0
|
6323
|
+
END AS is_expression,
|
6324
|
+
i.indoption[k.i-1] & 1 = 1 AS descending,
|
6325
|
+
i.indoption[k.i-1] & 2 = 2 AS nulls_first,
|
6326
|
+
pg_get_expr(
|
6327
|
+
i.indpred,
|
6328
|
+
i.indrelid
|
6329
|
+
) as where,
|
6330
|
+
opc.opcname
|
6331
|
+
FROM pg_class t
|
6332
|
+
LEFT JOIN pg_index i ON t.oid = i.indrelid
|
6333
|
+
LEFT JOIN pg_class ic ON ic.oid = i.indexrelid
|
6334
|
+
CROSS JOIN LATERAL (SELECT unnest(i.indkey), generate_subscripts(i.indkey, 1) + 1) AS k(attnum, i)
|
6335
|
+
LEFT JOIN pg_attribute AS a
|
6336
|
+
ON i.indrelid = a.attrelid AND k.attnum = a.attnum
|
6337
|
+
JOIN pg_namespace c on c.oid = t.relnamespace
|
6338
|
+
LEFT JOIN pg_am AS am ON ic.relam = am.oid
|
6339
|
+
JOIN pg_opclass opc ON opc.oid = ANY(i.indclass)
|
6340
|
+
WHERE
|
6341
|
+
c.nspname = '${tableSchema}' AND
|
6342
|
+
t.relname = '${tableName}';`
|
6224
6343
|
);
|
6225
6344
|
const dbIndexFromConstraint = await db.query(
|
6226
6345
|
`SELECT
|
@@ -6237,18 +6356,51 @@ var init_pgSerializer = __esm({
|
|
6237
6356
|
);
|
6238
6357
|
const idxsInConsteraint = dbIndexFromConstraint.filter((it) => it.generated_by_constraint === 1).map((it) => it.index_name);
|
6239
6358
|
for (const dbIndex of dbIndexes) {
|
6240
|
-
const indexName = dbIndex.
|
6359
|
+
const indexName = dbIndex.indexname;
|
6241
6360
|
const indexColumnName = dbIndex.column_name;
|
6242
6361
|
const indexIsUnique = dbIndex.is_unique;
|
6362
|
+
const indexMethod = dbIndex.method;
|
6363
|
+
const indexWith = dbIndex.with;
|
6364
|
+
const indexWhere = dbIndex.where;
|
6365
|
+
const opclass = dbIndex.opcname;
|
6366
|
+
const isExpression = dbIndex.is_expression === 1;
|
6367
|
+
const desc = dbIndex.descending;
|
6368
|
+
const nullsFirst = dbIndex.nulls_first;
|
6369
|
+
const mappedWith = {};
|
6370
|
+
if (indexWith !== null) {
|
6371
|
+
indexWith.forEach((it) => {
|
6372
|
+
const splitted = it.split("=");
|
6373
|
+
mappedWith[splitted[0]] = splitted[1];
|
6374
|
+
});
|
6375
|
+
}
|
6243
6376
|
if (idxsInConsteraint.includes(indexName))
|
6244
6377
|
continue;
|
6245
6378
|
if (typeof indexToReturn[indexName] !== "undefined") {
|
6246
|
-
indexToReturn[indexName].columns.push(
|
6379
|
+
indexToReturn[indexName].columns.push({
|
6380
|
+
expression: indexColumnName,
|
6381
|
+
asc: !desc,
|
6382
|
+
nulls: nullsFirst ? "first" : "last",
|
6383
|
+
opclass,
|
6384
|
+
isExpression
|
6385
|
+
});
|
6247
6386
|
} else {
|
6248
6387
|
indexToReturn[indexName] = {
|
6249
6388
|
name: indexName,
|
6250
|
-
columns: [
|
6251
|
-
|
6389
|
+
columns: [
|
6390
|
+
{
|
6391
|
+
expression: indexColumnName,
|
6392
|
+
asc: !desc,
|
6393
|
+
nulls: nullsFirst ? "first" : "last",
|
6394
|
+
opclass,
|
6395
|
+
isExpression
|
6396
|
+
}
|
6397
|
+
],
|
6398
|
+
isUnique: indexIsUnique,
|
6399
|
+
// should not be a part of diff detecs
|
6400
|
+
concurrently: false,
|
6401
|
+
method: indexMethod,
|
6402
|
+
where: indexWhere === null ? void 0 : indexWhere,
|
6403
|
+
with: mappedWith
|
6252
6404
|
};
|
6253
6405
|
}
|
6254
6406
|
}
|
@@ -6284,7 +6436,7 @@ var init_pgSerializer = __esm({
|
|
6284
6436
|
}
|
6285
6437
|
const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
|
6286
6438
|
return {
|
6287
|
-
version: "
|
6439
|
+
version: "7",
|
6288
6440
|
dialect: "postgresql",
|
6289
6441
|
tables: result,
|
6290
6442
|
enums: enumsToReturn,
|
package/utils-studio.mjs
CHANGED
@@ -1080,7 +1080,7 @@ var init_global = __esm({
|
|
1080
1080
|
"src/global.ts"() {
|
1081
1081
|
"use strict";
|
1082
1082
|
originUUID = "00000000-0000-0000-0000-000000000000";
|
1083
|
-
snapshotVersion = "
|
1083
|
+
snapshotVersion = "7";
|
1084
1084
|
}
|
1085
1085
|
});
|
1086
1086
|
|
@@ -5009,7 +5009,7 @@ var init_mysqlSchema = __esm({
|
|
5009
5009
|
});
|
5010
5010
|
|
5011
5011
|
// src/serializer/pgSchema.ts
|
5012
|
-
var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, index2, fk2, column2, tableV32, compositePK2, uniqueConstraint2, tableV42, table2, schemaHash2, kitInternals2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternalV5, pgSchemaExternal, pgSchemaInternal, tableSquashed2, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchemaV5, pgSchema2, backwardCompatiblePgSchema, dryPg;
|
5012
|
+
var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1, indexColumn, index2, indexV4, indexV5, indexV6, fk2, column2, tableV32, compositePK2, uniqueConstraint2, tableV42, tableV6, tableV5, table2, schemaHash2, kitInternals2, pgSchemaInternalV3, pgSchemaInternalV4, pgSchemaInternalV5, pgSchemaInternalV6, pgSchemaExternal, pgSchemaInternal, tableSquashed2, tableSquashedV42, pgSchemaSquashedV4, pgSchemaSquashedV6, pgSchemaSquashed, pgSchemaV3, pgSchemaV4, pgSchemaV5, pgSchemaV6, pgSchema2, backwardCompatiblePgSchema, dryPg;
|
5013
5013
|
var init_pgSchema = __esm({
|
5014
5014
|
"src/serializer/pgSchema.ts"() {
|
5015
5015
|
"use strict";
|
@@ -5077,10 +5077,48 @@ var init_pgSchema = __esm({
|
|
5077
5077
|
tables: recordType(stringType(), tableV1),
|
5078
5078
|
enums: recordType(stringType(), enumSchemaV1)
|
5079
5079
|
}).strict();
|
5080
|
+
indexColumn = objectType({
|
5081
|
+
expression: stringType(),
|
5082
|
+
isExpression: booleanType(),
|
5083
|
+
asc: booleanType(),
|
5084
|
+
nulls: stringType().optional(),
|
5085
|
+
opclass: stringType().optional()
|
5086
|
+
});
|
5080
5087
|
index2 = objectType({
|
5088
|
+
name: stringType(),
|
5089
|
+
columns: indexColumn.array(),
|
5090
|
+
isUnique: booleanType(),
|
5091
|
+
with: recordType(stringType(), anyType()).optional(),
|
5092
|
+
method: stringType().default("btree"),
|
5093
|
+
where: stringType().optional(),
|
5094
|
+
concurrently: booleanType().default(false)
|
5095
|
+
}).strict();
|
5096
|
+
indexV4 = objectType({
|
5081
5097
|
name: stringType(),
|
5082
5098
|
columns: stringType().array(),
|
5083
|
-
isUnique: booleanType()
|
5099
|
+
isUnique: booleanType(),
|
5100
|
+
with: recordType(stringType(), stringType()).optional(),
|
5101
|
+
method: stringType().default("btree"),
|
5102
|
+
where: stringType().optional(),
|
5103
|
+
concurrently: booleanType().default(false)
|
5104
|
+
}).strict();
|
5105
|
+
indexV5 = objectType({
|
5106
|
+
name: stringType(),
|
5107
|
+
columns: stringType().array(),
|
5108
|
+
isUnique: booleanType(),
|
5109
|
+
with: recordType(stringType(), stringType()).optional(),
|
5110
|
+
method: stringType().default("btree"),
|
5111
|
+
where: stringType().optional(),
|
5112
|
+
concurrently: booleanType().default(false)
|
5113
|
+
}).strict();
|
5114
|
+
indexV6 = objectType({
|
5115
|
+
name: stringType(),
|
5116
|
+
columns: stringType().array(),
|
5117
|
+
isUnique: booleanType(),
|
5118
|
+
with: recordType(stringType(), stringType()).optional(),
|
5119
|
+
method: stringType().default("btree"),
|
5120
|
+
where: stringType().optional(),
|
5121
|
+
concurrently: booleanType().default(false)
|
5084
5122
|
}).strict();
|
5085
5123
|
fk2 = objectType({
|
5086
5124
|
name: stringType(),
|
@@ -5122,9 +5160,27 @@ var init_pgSchema = __esm({
|
|
5122
5160
|
name: stringType(),
|
5123
5161
|
schema: stringType(),
|
5124
5162
|
columns: recordType(stringType(), column2),
|
5125
|
-
indexes: recordType(stringType(),
|
5163
|
+
indexes: recordType(stringType(), indexV4),
|
5126
5164
|
foreignKeys: recordType(stringType(), fk2)
|
5127
5165
|
}).strict();
|
5166
|
+
tableV6 = objectType({
|
5167
|
+
name: stringType(),
|
5168
|
+
schema: stringType(),
|
5169
|
+
columns: recordType(stringType(), column2),
|
5170
|
+
indexes: recordType(stringType(), indexV6),
|
5171
|
+
foreignKeys: recordType(stringType(), fk2),
|
5172
|
+
compositePrimaryKeys: recordType(stringType(), compositePK2),
|
5173
|
+
uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
|
5174
|
+
}).strict();
|
5175
|
+
tableV5 = objectType({
|
5176
|
+
name: stringType(),
|
5177
|
+
schema: stringType(),
|
5178
|
+
columns: recordType(stringType(), column2),
|
5179
|
+
indexes: recordType(stringType(), indexV5),
|
5180
|
+
foreignKeys: recordType(stringType(), fk2),
|
5181
|
+
compositePrimaryKeys: recordType(stringType(), compositePK2),
|
5182
|
+
uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
|
5183
|
+
}).strict();
|
5128
5184
|
table2 = objectType({
|
5129
5185
|
name: stringType(),
|
5130
5186
|
schema: stringType(),
|
@@ -5169,7 +5225,7 @@ var init_pgSchema = __esm({
|
|
5169
5225
|
pgSchemaInternalV5 = objectType({
|
5170
5226
|
version: literalType("5"),
|
5171
5227
|
dialect: literalType("pg"),
|
5172
|
-
tables: recordType(stringType(),
|
5228
|
+
tables: recordType(stringType(), tableV5),
|
5173
5229
|
enums: recordType(stringType(), enumSchemaV1),
|
5174
5230
|
schemas: recordType(stringType(), stringType()),
|
5175
5231
|
_meta: objectType({
|
@@ -5179,6 +5235,19 @@ var init_pgSchema = __esm({
|
|
5179
5235
|
}),
|
5180
5236
|
internal: kitInternals2
|
5181
5237
|
}).strict();
|
5238
|
+
pgSchemaInternalV6 = objectType({
|
5239
|
+
version: literalType("6"),
|
5240
|
+
dialect: literalType("postgresql"),
|
5241
|
+
tables: recordType(stringType(), tableV6),
|
5242
|
+
enums: recordType(stringType(), enumSchema),
|
5243
|
+
schemas: recordType(stringType(), stringType()),
|
5244
|
+
_meta: objectType({
|
5245
|
+
schemas: recordType(stringType(), stringType()),
|
5246
|
+
tables: recordType(stringType(), stringType()),
|
5247
|
+
columns: recordType(stringType(), stringType())
|
5248
|
+
}),
|
5249
|
+
internal: kitInternals2
|
5250
|
+
}).strict();
|
5182
5251
|
pgSchemaExternal = objectType({
|
5183
5252
|
version: literalType("5"),
|
5184
5253
|
dialect: literalType("pg"),
|
@@ -5192,7 +5261,7 @@ var init_pgSchema = __esm({
|
|
5192
5261
|
})
|
5193
5262
|
}).strict();
|
5194
5263
|
pgSchemaInternal = objectType({
|
5195
|
-
version: literalType("
|
5264
|
+
version: literalType("7"),
|
5196
5265
|
dialect: literalType("postgresql"),
|
5197
5266
|
tables: recordType(stringType(), table2),
|
5198
5267
|
enums: recordType(stringType(), enumSchema),
|
@@ -5227,18 +5296,30 @@ var init_pgSchema = __esm({
|
|
5227
5296
|
enums: recordType(stringType(), enumSchemaV1),
|
5228
5297
|
schemas: recordType(stringType(), stringType())
|
5229
5298
|
}).strict();
|
5230
|
-
|
5299
|
+
pgSchemaSquashedV6 = objectType({
|
5231
5300
|
version: literalType("6"),
|
5232
5301
|
dialect: literalType("postgresql"),
|
5233
5302
|
tables: recordType(stringType(), tableSquashed2),
|
5234
5303
|
enums: recordType(stringType(), enumSchema),
|
5235
5304
|
schemas: recordType(stringType(), stringType())
|
5236
5305
|
}).strict();
|
5306
|
+
pgSchemaSquashed = objectType({
|
5307
|
+
version: literalType("7"),
|
5308
|
+
dialect: literalType("postgresql"),
|
5309
|
+
tables: recordType(stringType(), tableSquashed2),
|
5310
|
+
enums: recordType(stringType(), enumSchema),
|
5311
|
+
schemas: recordType(stringType(), stringType())
|
5312
|
+
}).strict();
|
5237
5313
|
pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash2);
|
5238
5314
|
pgSchemaV4 = pgSchemaInternalV4.merge(schemaHash2);
|
5239
5315
|
pgSchemaV5 = pgSchemaInternalV5.merge(schemaHash2);
|
5316
|
+
pgSchemaV6 = pgSchemaInternalV6.merge(schemaHash2);
|
5240
5317
|
pgSchema2 = pgSchemaInternal.merge(schemaHash2);
|
5241
|
-
backwardCompatiblePgSchema = unionType([
|
5318
|
+
backwardCompatiblePgSchema = unionType([
|
5319
|
+
pgSchemaV5,
|
5320
|
+
pgSchemaV6,
|
5321
|
+
pgSchema2
|
5322
|
+
]);
|
5242
5323
|
dryPg = pgSchema2.parse({
|
5243
5324
|
version: snapshotVersion,
|
5244
5325
|
dialect: "postgresql",
|
@@ -5935,6 +6016,13 @@ var require_brace_expansion = __commonJS({
|
|
5935
6016
|
}
|
5936
6017
|
});
|
5937
6018
|
|
6019
|
+
// src/extensions/vector.ts
|
6020
|
+
var init_vector = __esm({
|
6021
|
+
"src/extensions/vector.ts"() {
|
6022
|
+
"use strict";
|
6023
|
+
}
|
6024
|
+
});
|
6025
|
+
|
5938
6026
|
// src/serializer/pgSerializer.ts
|
5939
6027
|
import {
|
5940
6028
|
PgDialect,
|
@@ -5949,6 +6037,7 @@ var init_pgSerializer = __esm({
|
|
5949
6037
|
"use strict";
|
5950
6038
|
init_serializer();
|
5951
6039
|
init_outputs();
|
6040
|
+
init_vector();
|
5952
6041
|
dialect4 = new PgDialect();
|
5953
6042
|
trimChar = (str, char) => {
|
5954
6043
|
let start = 0;
|
@@ -6210,7 +6299,10 @@ var init_pgSerializer = __esm({
|
|
6210
6299
|
columnTypeMapped = trimChar(columnTypeMapped, '"');
|
6211
6300
|
columnToReturn[columnName] = {
|
6212
6301
|
name: columnName,
|
6213
|
-
type:
|
6302
|
+
type: (
|
6303
|
+
// filter vectors, but in future we should filter any extension that was installed by user
|
6304
|
+
columnAdditionalDT === "USER-DEFINED" && enumType3 !== "vector" ? enumType3 : columnTypeMapped
|
6305
|
+
),
|
6214
6306
|
typeSchema: enumsToReturn[`${tableSchema}.${enumType3}`] !== void 0 ? enumsToReturn[`${tableSchema}.${enumType3}`].schema : void 0,
|
6215
6307
|
primaryKey: primaryKey.length === 1 && cprimaryKey.length < 2,
|
6216
6308
|
// default: isSerial ? undefined : defaultValue,
|
@@ -6221,15 +6313,42 @@ var init_pgSerializer = __esm({
|
|
6221
6313
|
}
|
6222
6314
|
}
|
6223
6315
|
const dbIndexes = await db.query(
|
6224
|
-
`SELECT t.relname
|
6225
|
-
|
6226
|
-
|
6227
|
-
|
6228
|
-
|
6229
|
-
|
6230
|
-
|
6231
|
-
|
6232
|
-
|
6316
|
+
`SELECT DISTINCT ON (t.relname, ic.relname, k.i) t.relname as table_name, ic.relname AS indexname,
|
6317
|
+
k.i AS index_order,
|
6318
|
+
i.indisunique as is_unique,
|
6319
|
+
am.amname as method,
|
6320
|
+
ic.reloptions as with,
|
6321
|
+
coalesce(a.attname,
|
6322
|
+
(('{' || pg_get_expr(
|
6323
|
+
i.indexprs,
|
6324
|
+
i.indrelid
|
6325
|
+
)
|
6326
|
+
|| '}')::text[]
|
6327
|
+
)[k.i]
|
6328
|
+
) AS column_name,
|
6329
|
+
CASE
|
6330
|
+
WHEN pg_get_expr(i.indexprs, i.indrelid) IS NOT NULL THEN 1
|
6331
|
+
ELSE 0
|
6332
|
+
END AS is_expression,
|
6333
|
+
i.indoption[k.i-1] & 1 = 1 AS descending,
|
6334
|
+
i.indoption[k.i-1] & 2 = 2 AS nulls_first,
|
6335
|
+
pg_get_expr(
|
6336
|
+
i.indpred,
|
6337
|
+
i.indrelid
|
6338
|
+
) as where,
|
6339
|
+
opc.opcname
|
6340
|
+
FROM pg_class t
|
6341
|
+
LEFT JOIN pg_index i ON t.oid = i.indrelid
|
6342
|
+
LEFT JOIN pg_class ic ON ic.oid = i.indexrelid
|
6343
|
+
CROSS JOIN LATERAL (SELECT unnest(i.indkey), generate_subscripts(i.indkey, 1) + 1) AS k(attnum, i)
|
6344
|
+
LEFT JOIN pg_attribute AS a
|
6345
|
+
ON i.indrelid = a.attrelid AND k.attnum = a.attnum
|
6346
|
+
JOIN pg_namespace c on c.oid = t.relnamespace
|
6347
|
+
LEFT JOIN pg_am AS am ON ic.relam = am.oid
|
6348
|
+
JOIN pg_opclass opc ON opc.oid = ANY(i.indclass)
|
6349
|
+
WHERE
|
6350
|
+
c.nspname = '${tableSchema}' AND
|
6351
|
+
t.relname = '${tableName}';`
|
6233
6352
|
);
|
6234
6353
|
const dbIndexFromConstraint = await db.query(
|
6235
6354
|
`SELECT
|
@@ -6246,18 +6365,51 @@ var init_pgSerializer = __esm({
|
|
6246
6365
|
);
|
6247
6366
|
const idxsInConsteraint = dbIndexFromConstraint.filter((it) => it.generated_by_constraint === 1).map((it) => it.index_name);
|
6248
6367
|
for (const dbIndex of dbIndexes) {
|
6249
|
-
const indexName = dbIndex.
|
6368
|
+
const indexName = dbIndex.indexname;
|
6250
6369
|
const indexColumnName = dbIndex.column_name;
|
6251
6370
|
const indexIsUnique = dbIndex.is_unique;
|
6371
|
+
const indexMethod = dbIndex.method;
|
6372
|
+
const indexWith = dbIndex.with;
|
6373
|
+
const indexWhere = dbIndex.where;
|
6374
|
+
const opclass = dbIndex.opcname;
|
6375
|
+
const isExpression = dbIndex.is_expression === 1;
|
6376
|
+
const desc = dbIndex.descending;
|
6377
|
+
const nullsFirst = dbIndex.nulls_first;
|
6378
|
+
const mappedWith = {};
|
6379
|
+
if (indexWith !== null) {
|
6380
|
+
indexWith.forEach((it) => {
|
6381
|
+
const splitted = it.split("=");
|
6382
|
+
mappedWith[splitted[0]] = splitted[1];
|
6383
|
+
});
|
6384
|
+
}
|
6252
6385
|
if (idxsInConsteraint.includes(indexName))
|
6253
6386
|
continue;
|
6254
6387
|
if (typeof indexToReturn[indexName] !== "undefined") {
|
6255
|
-
indexToReturn[indexName].columns.push(
|
6388
|
+
indexToReturn[indexName].columns.push({
|
6389
|
+
expression: indexColumnName,
|
6390
|
+
asc: !desc,
|
6391
|
+
nulls: nullsFirst ? "first" : "last",
|
6392
|
+
opclass,
|
6393
|
+
isExpression
|
6394
|
+
});
|
6256
6395
|
} else {
|
6257
6396
|
indexToReturn[indexName] = {
|
6258
6397
|
name: indexName,
|
6259
|
-
columns: [
|
6260
|
-
|
6398
|
+
columns: [
|
6399
|
+
{
|
6400
|
+
expression: indexColumnName,
|
6401
|
+
asc: !desc,
|
6402
|
+
nulls: nullsFirst ? "first" : "last",
|
6403
|
+
opclass,
|
6404
|
+
isExpression
|
6405
|
+
}
|
6406
|
+
],
|
6407
|
+
isUnique: indexIsUnique,
|
6408
|
+
// should not be a part of diff detecs
|
6409
|
+
concurrently: false,
|
6410
|
+
method: indexMethod,
|
6411
|
+
where: indexWhere === null ? void 0 : indexWhere,
|
6412
|
+
with: mappedWith
|
6261
6413
|
};
|
6262
6414
|
}
|
6263
6415
|
}
|
@@ -6293,7 +6445,7 @@ var init_pgSerializer = __esm({
|
|
6293
6445
|
}
|
6294
6446
|
const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
|
6295
6447
|
return {
|
6296
|
-
version: "
|
6448
|
+
version: "7",
|
6297
6449
|
dialect: "postgresql",
|
6298
6450
|
tables: result,
|
6299
6451
|
enums: enumsToReturn,
|