drizzle-kit 0.21.4 → 0.22.0-18d9643
Sign up to get free protection for your applications and to get access to all the features.
- package/bin.cjs +1256 -526
- package/index.d.mts +6 -11
- package/index.d.ts +6 -11
- package/package.json +4 -4
- package/payload.d.mts +188 -20
- package/payload.d.ts +188 -20
- package/payload.js +2477 -1404
- package/payload.mjs +2507 -1425
- package/utils-studio.js +297 -31
- package/utils-studio.mjs +297 -31
- package/utils.js +141 -10
- package/utils.mjs +140 -10
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
|
|
@@ -4849,7 +4849,7 @@ var init_lib = __esm({
|
|
4849
4849
|
});
|
4850
4850
|
|
4851
4851
|
// src/serializer/mysqlSchema.ts
|
4852
|
-
var index, fk, column, tableV3, compositePK, uniqueConstraint, tableV4, table, kitInternals, dialect, schemaHash, schemaInternalV3, schemaInternalV4, schemaInternalV5, schemaInternal, schemaV3, schemaV4, schemaV5, schema, tableSquashedV4, tableSquashed, schemaSquashed, schemaSquashedV4, mysqlSchema, mysqlSchemaV5, backwardCompatibleMysqlSchema, dryMySql;
|
4852
|
+
var index, fk, column, tableV3, compositePK, uniqueConstraint, tableV4, table, kitInternals, dialect, schemaHash, schemaInternalV3, schemaInternalV4, schemaInternalV5, schemaInternal, schemaV3, schemaV4, schemaV5, schema, tableSquashedV4, tableSquashed, schemaSquashed, schemaSquashedV4, mysqlSchema, mysqlSchemaV5, mysqlSchemaSquashed, backwardCompatibleMysqlSchema, dryMySql;
|
4853
4853
|
var init_mysqlSchema = __esm({
|
4854
4854
|
"src/serializer/mysqlSchema.ts"() {
|
4855
4855
|
"use strict";
|
@@ -4919,7 +4919,16 @@ var init_mysqlSchema = __esm({
|
|
4919
4919
|
objectType({ isDefaultAnExpression: booleanType().optional() }).optional()
|
4920
4920
|
)
|
4921
4921
|
}).optional()
|
4922
|
-
)
|
4922
|
+
).optional(),
|
4923
|
+
indexes: recordType(
|
4924
|
+
stringType(),
|
4925
|
+
objectType({
|
4926
|
+
columns: recordType(
|
4927
|
+
stringType(),
|
4928
|
+
objectType({ isExpression: booleanType().optional() }).optional()
|
4929
|
+
)
|
4930
|
+
}).optional()
|
4931
|
+
).optional()
|
4923
4932
|
}).optional();
|
4924
4933
|
dialect = literalType("mysql");
|
4925
4934
|
schemaHash = objectType({
|
@@ -4991,6 +5000,7 @@ var init_mysqlSchema = __esm({
|
|
4991
5000
|
}).strict();
|
4992
5001
|
mysqlSchema = schema;
|
4993
5002
|
mysqlSchemaV5 = schemaV5;
|
5003
|
+
mysqlSchemaSquashed = schemaSquashed;
|
4994
5004
|
backwardCompatibleMysqlSchema = unionType([mysqlSchemaV5, schema]);
|
4995
5005
|
dryMySql = mysqlSchema.parse({
|
4996
5006
|
version: "5",
|
@@ -5009,7 +5019,7 @@ var init_mysqlSchema = __esm({
|
|
5009
5019
|
});
|
5010
5020
|
|
5011
5021
|
// 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;
|
5022
|
+
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
5023
|
var init_pgSchema = __esm({
|
5014
5024
|
"src/serializer/pgSchema.ts"() {
|
5015
5025
|
"use strict";
|
@@ -5077,10 +5087,48 @@ var init_pgSchema = __esm({
|
|
5077
5087
|
tables: recordType(stringType(), tableV1),
|
5078
5088
|
enums: recordType(stringType(), enumSchemaV1)
|
5079
5089
|
}).strict();
|
5090
|
+
indexColumn = objectType({
|
5091
|
+
expression: stringType(),
|
5092
|
+
isExpression: booleanType(),
|
5093
|
+
asc: booleanType(),
|
5094
|
+
nulls: stringType().optional(),
|
5095
|
+
opclass: stringType().optional()
|
5096
|
+
});
|
5080
5097
|
index2 = objectType({
|
5098
|
+
name: stringType(),
|
5099
|
+
columns: indexColumn.array(),
|
5100
|
+
isUnique: booleanType(),
|
5101
|
+
with: recordType(stringType(), anyType()).optional(),
|
5102
|
+
method: stringType().default("btree"),
|
5103
|
+
where: stringType().optional(),
|
5104
|
+
concurrently: booleanType().default(false)
|
5105
|
+
}).strict();
|
5106
|
+
indexV4 = objectType({
|
5081
5107
|
name: stringType(),
|
5082
5108
|
columns: stringType().array(),
|
5083
|
-
isUnique: booleanType()
|
5109
|
+
isUnique: booleanType(),
|
5110
|
+
with: recordType(stringType(), stringType()).optional(),
|
5111
|
+
method: stringType().default("btree"),
|
5112
|
+
where: stringType().optional(),
|
5113
|
+
concurrently: booleanType().default(false)
|
5114
|
+
}).strict();
|
5115
|
+
indexV5 = objectType({
|
5116
|
+
name: stringType(),
|
5117
|
+
columns: stringType().array(),
|
5118
|
+
isUnique: booleanType(),
|
5119
|
+
with: recordType(stringType(), stringType()).optional(),
|
5120
|
+
method: stringType().default("btree"),
|
5121
|
+
where: stringType().optional(),
|
5122
|
+
concurrently: booleanType().default(false)
|
5123
|
+
}).strict();
|
5124
|
+
indexV6 = objectType({
|
5125
|
+
name: stringType(),
|
5126
|
+
columns: stringType().array(),
|
5127
|
+
isUnique: booleanType(),
|
5128
|
+
with: recordType(stringType(), stringType()).optional(),
|
5129
|
+
method: stringType().default("btree"),
|
5130
|
+
where: stringType().optional(),
|
5131
|
+
concurrently: booleanType().default(false)
|
5084
5132
|
}).strict();
|
5085
5133
|
fk2 = objectType({
|
5086
5134
|
name: stringType(),
|
@@ -5122,9 +5170,27 @@ var init_pgSchema = __esm({
|
|
5122
5170
|
name: stringType(),
|
5123
5171
|
schema: stringType(),
|
5124
5172
|
columns: recordType(stringType(), column2),
|
5125
|
-
indexes: recordType(stringType(),
|
5173
|
+
indexes: recordType(stringType(), indexV4),
|
5126
5174
|
foreignKeys: recordType(stringType(), fk2)
|
5127
5175
|
}).strict();
|
5176
|
+
tableV6 = objectType({
|
5177
|
+
name: stringType(),
|
5178
|
+
schema: stringType(),
|
5179
|
+
columns: recordType(stringType(), column2),
|
5180
|
+
indexes: recordType(stringType(), indexV6),
|
5181
|
+
foreignKeys: recordType(stringType(), fk2),
|
5182
|
+
compositePrimaryKeys: recordType(stringType(), compositePK2),
|
5183
|
+
uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
|
5184
|
+
}).strict();
|
5185
|
+
tableV5 = objectType({
|
5186
|
+
name: stringType(),
|
5187
|
+
schema: stringType(),
|
5188
|
+
columns: recordType(stringType(), column2),
|
5189
|
+
indexes: recordType(stringType(), indexV5),
|
5190
|
+
foreignKeys: recordType(stringType(), fk2),
|
5191
|
+
compositePrimaryKeys: recordType(stringType(), compositePK2),
|
5192
|
+
uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
|
5193
|
+
}).strict();
|
5128
5194
|
table2 = objectType({
|
5129
5195
|
name: stringType(),
|
5130
5196
|
schema: stringType(),
|
@@ -5169,7 +5235,7 @@ var init_pgSchema = __esm({
|
|
5169
5235
|
pgSchemaInternalV5 = objectType({
|
5170
5236
|
version: literalType("5"),
|
5171
5237
|
dialect: literalType("pg"),
|
5172
|
-
tables: recordType(stringType(),
|
5238
|
+
tables: recordType(stringType(), tableV5),
|
5173
5239
|
enums: recordType(stringType(), enumSchemaV1),
|
5174
5240
|
schemas: recordType(stringType(), stringType()),
|
5175
5241
|
_meta: objectType({
|
@@ -5179,6 +5245,19 @@ var init_pgSchema = __esm({
|
|
5179
5245
|
}),
|
5180
5246
|
internal: kitInternals2
|
5181
5247
|
}).strict();
|
5248
|
+
pgSchemaInternalV6 = objectType({
|
5249
|
+
version: literalType("6"),
|
5250
|
+
dialect: literalType("postgresql"),
|
5251
|
+
tables: recordType(stringType(), tableV6),
|
5252
|
+
enums: recordType(stringType(), enumSchema),
|
5253
|
+
schemas: recordType(stringType(), stringType()),
|
5254
|
+
_meta: objectType({
|
5255
|
+
schemas: recordType(stringType(), stringType()),
|
5256
|
+
tables: recordType(stringType(), stringType()),
|
5257
|
+
columns: recordType(stringType(), stringType())
|
5258
|
+
}),
|
5259
|
+
internal: kitInternals2
|
5260
|
+
}).strict();
|
5182
5261
|
pgSchemaExternal = objectType({
|
5183
5262
|
version: literalType("5"),
|
5184
5263
|
dialect: literalType("pg"),
|
@@ -5192,7 +5271,7 @@ var init_pgSchema = __esm({
|
|
5192
5271
|
})
|
5193
5272
|
}).strict();
|
5194
5273
|
pgSchemaInternal = objectType({
|
5195
|
-
version: literalType("
|
5274
|
+
version: literalType("7"),
|
5196
5275
|
dialect: literalType("postgresql"),
|
5197
5276
|
tables: recordType(stringType(), table2),
|
5198
5277
|
enums: recordType(stringType(), enumSchema),
|
@@ -5227,18 +5306,30 @@ var init_pgSchema = __esm({
|
|
5227
5306
|
enums: recordType(stringType(), enumSchemaV1),
|
5228
5307
|
schemas: recordType(stringType(), stringType())
|
5229
5308
|
}).strict();
|
5230
|
-
|
5309
|
+
pgSchemaSquashedV6 = objectType({
|
5231
5310
|
version: literalType("6"),
|
5232
5311
|
dialect: literalType("postgresql"),
|
5233
5312
|
tables: recordType(stringType(), tableSquashed2),
|
5234
5313
|
enums: recordType(stringType(), enumSchema),
|
5235
5314
|
schemas: recordType(stringType(), stringType())
|
5236
5315
|
}).strict();
|
5316
|
+
pgSchemaSquashed = objectType({
|
5317
|
+
version: literalType("7"),
|
5318
|
+
dialect: literalType("postgresql"),
|
5319
|
+
tables: recordType(stringType(), tableSquashed2),
|
5320
|
+
enums: recordType(stringType(), enumSchema),
|
5321
|
+
schemas: recordType(stringType(), stringType())
|
5322
|
+
}).strict();
|
5237
5323
|
pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash2);
|
5238
5324
|
pgSchemaV4 = pgSchemaInternalV4.merge(schemaHash2);
|
5239
5325
|
pgSchemaV5 = pgSchemaInternalV5.merge(schemaHash2);
|
5326
|
+
pgSchemaV6 = pgSchemaInternalV6.merge(schemaHash2);
|
5240
5327
|
pgSchema2 = pgSchemaInternal.merge(schemaHash2);
|
5241
|
-
backwardCompatiblePgSchema = unionType([
|
5328
|
+
backwardCompatiblePgSchema = unionType([
|
5329
|
+
pgSchemaV5,
|
5330
|
+
pgSchemaV6,
|
5331
|
+
pgSchema2
|
5332
|
+
]);
|
5242
5333
|
dryPg = pgSchema2.parse({
|
5243
5334
|
version: snapshotVersion,
|
5244
5335
|
dialect: "postgresql",
|
@@ -5257,7 +5348,7 @@ var init_pgSchema = __esm({
|
|
5257
5348
|
});
|
5258
5349
|
|
5259
5350
|
// src/serializer/sqliteSchema.ts
|
5260
|
-
var index3, fk3, compositePK3, column3, tableV33, uniqueConstraint3, table3, dialect2, schemaHash3, schemaInternalV32, schemaInternalV42, schemaInternalV52, latestVersion, schemaInternal2, schemaV32, schemaV42, schemaV52, schema2, tableSquashed3, schemaSquashed2, drySQLite, sqliteSchemaV5, backwardCompatibleSqliteSchema;
|
5351
|
+
var index3, fk3, compositePK3, column3, tableV33, uniqueConstraint3, table3, dialect2, schemaHash3, schemaInternalV32, schemaInternalV42, schemaInternalV52, kitInternals3, latestVersion, schemaInternal2, schemaV32, schemaV42, schemaV52, schema2, tableSquashed3, schemaSquashed2, drySQLite, sqliteSchemaV5, sqliteSchema, SQLiteSchemaSquashed, backwardCompatibleSqliteSchema;
|
5261
5352
|
var init_sqliteSchema = __esm({
|
5262
5353
|
"src/serializer/sqliteSchema.ts"() {
|
5263
5354
|
"use strict";
|
@@ -5335,6 +5426,17 @@ var init_sqliteSchema = __esm({
|
|
5335
5426
|
columns: recordType(stringType(), stringType())
|
5336
5427
|
})
|
5337
5428
|
}).strict();
|
5429
|
+
kitInternals3 = objectType({
|
5430
|
+
indexes: recordType(
|
5431
|
+
stringType(),
|
5432
|
+
objectType({
|
5433
|
+
columns: recordType(
|
5434
|
+
stringType(),
|
5435
|
+
objectType({ isExpression: booleanType().optional() }).optional()
|
5436
|
+
)
|
5437
|
+
}).optional()
|
5438
|
+
).optional()
|
5439
|
+
}).optional();
|
5338
5440
|
latestVersion = literalType("6");
|
5339
5441
|
schemaInternal2 = objectType({
|
5340
5442
|
version: latestVersion,
|
@@ -5344,7 +5446,8 @@ var init_sqliteSchema = __esm({
|
|
5344
5446
|
_meta: objectType({
|
5345
5447
|
tables: recordType(stringType(), stringType()),
|
5346
5448
|
columns: recordType(stringType(), stringType())
|
5347
|
-
})
|
5449
|
+
}),
|
5450
|
+
internal: kitInternals3
|
5348
5451
|
}).strict();
|
5349
5452
|
schemaV32 = schemaInternalV32.merge(schemaHash3).strict();
|
5350
5453
|
schemaV42 = schemaInternalV42.merge(schemaHash3).strict();
|
@@ -5377,6 +5480,8 @@ var init_sqliteSchema = __esm({
|
|
5377
5480
|
}
|
5378
5481
|
});
|
5379
5482
|
sqliteSchemaV5 = schemaV52;
|
5483
|
+
sqliteSchema = schema2;
|
5484
|
+
SQLiteSchemaSquashed = schemaSquashed2;
|
5380
5485
|
backwardCompatibleSqliteSchema = unionType([sqliteSchemaV5, schema2]);
|
5381
5486
|
}
|
5382
5487
|
});
|
@@ -5449,10 +5554,100 @@ var init_serializer = __esm({
|
|
5449
5554
|
}
|
5450
5555
|
});
|
5451
5556
|
|
5557
|
+
// src/schemaValidator.ts
|
5558
|
+
var dialect3, commonSquashedSchema, commonSchema;
|
5559
|
+
var init_schemaValidator = __esm({
|
5560
|
+
"src/schemaValidator.ts"() {
|
5561
|
+
"use strict";
|
5562
|
+
init_lib();
|
5563
|
+
init_mysqlSchema();
|
5564
|
+
init_pgSchema();
|
5565
|
+
init_sqliteSchema();
|
5566
|
+
dialect3 = enumType(["postgresql", "mysql", "sqlite"]);
|
5567
|
+
commonSquashedSchema = unionType([
|
5568
|
+
pgSchemaSquashed,
|
5569
|
+
mysqlSchemaSquashed,
|
5570
|
+
SQLiteSchemaSquashed
|
5571
|
+
]);
|
5572
|
+
commonSchema = unionType([
|
5573
|
+
pgSchema2,
|
5574
|
+
mysqlSchema,
|
5575
|
+
sqliteSchema
|
5576
|
+
]);
|
5577
|
+
}
|
5578
|
+
});
|
5579
|
+
|
5580
|
+
// src/cli/validations/common.ts
|
5581
|
+
var sqliteDriversLiterals, sqliteDriver, postgresDriver, mysqlDriver, driver, configCommonSchema, casing, introspectParams, configIntrospectCliSchema, configGenerateSchema, configPushSchema;
|
5582
|
+
var init_common = __esm({
|
5583
|
+
"src/cli/validations/common.ts"() {
|
5584
|
+
"use strict";
|
5585
|
+
init_outputs();
|
5586
|
+
init_lib();
|
5587
|
+
init_schemaValidator();
|
5588
|
+
sqliteDriversLiterals = [
|
5589
|
+
literalType("turso"),
|
5590
|
+
literalType("d1-http"),
|
5591
|
+
literalType("expo")
|
5592
|
+
];
|
5593
|
+
sqliteDriver = unionType(sqliteDriversLiterals);
|
5594
|
+
postgresDriver = literalType("aws-data-api");
|
5595
|
+
mysqlDriver = literalType("mysql2");
|
5596
|
+
driver = unionType([sqliteDriver, postgresDriver, mysqlDriver]);
|
5597
|
+
configCommonSchema = objectType({
|
5598
|
+
dialect: dialect3,
|
5599
|
+
schema: unionType([stringType(), stringType().array()]).optional(),
|
5600
|
+
out: stringType().optional(),
|
5601
|
+
breakpoints: booleanType().optional().default(true),
|
5602
|
+
driver: driver.optional(),
|
5603
|
+
tablesFilter: unionType([stringType(), stringType().array()]).optional(),
|
5604
|
+
schemaFilter: unionType([stringType(), stringType().array()]).default(["public"])
|
5605
|
+
});
|
5606
|
+
casing = unionType([literalType("camel"), literalType("preserve")]).default(
|
5607
|
+
"preserve"
|
5608
|
+
);
|
5609
|
+
introspectParams = objectType({
|
5610
|
+
schema: unionType([stringType(), stringType().array()]).optional(),
|
5611
|
+
out: stringType().optional().default("./drizzle"),
|
5612
|
+
breakpoints: booleanType().default(true),
|
5613
|
+
tablesFilter: unionType([stringType(), stringType().array()]).optional(),
|
5614
|
+
schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
|
5615
|
+
introspect: objectType({
|
5616
|
+
casing
|
5617
|
+
}).default({ casing: "camel" })
|
5618
|
+
});
|
5619
|
+
configIntrospectCliSchema = objectType({
|
5620
|
+
schema: unionType([stringType(), stringType().array()]).optional(),
|
5621
|
+
out: stringType().optional().default("./drizzle"),
|
5622
|
+
breakpoints: booleanType().default(true),
|
5623
|
+
tablesFilter: unionType([stringType(), stringType().array()]).optional(),
|
5624
|
+
schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
|
5625
|
+
introspectCasing: unionType([literalType("camel"), literalType("preserve")]).default(
|
5626
|
+
"camel"
|
5627
|
+
)
|
5628
|
+
});
|
5629
|
+
configGenerateSchema = objectType({
|
5630
|
+
schema: unionType([stringType(), stringType().array()]),
|
5631
|
+
out: stringType().optional().default("./drizzle"),
|
5632
|
+
breakpoints: booleanType().default(true)
|
5633
|
+
});
|
5634
|
+
configPushSchema = objectType({
|
5635
|
+
dialect: dialect3,
|
5636
|
+
schema: unionType([stringType(), stringType().array()]),
|
5637
|
+
tablesFilter: unionType([stringType(), stringType().array()]).optional(),
|
5638
|
+
schemaFilter: unionType([stringType(), stringType().array()]).default(["public"]),
|
5639
|
+
verbose: booleanType().default(false),
|
5640
|
+
strict: booleanType().default(false),
|
5641
|
+
out: stringType().optional()
|
5642
|
+
});
|
5643
|
+
}
|
5644
|
+
});
|
5645
|
+
|
5452
5646
|
// src/cli/validations/outputs.ts
|
5453
5647
|
var init_outputs = __esm({
|
5454
5648
|
"src/cli/validations/outputs.ts"() {
|
5455
5649
|
"use strict";
|
5650
|
+
init_common();
|
5456
5651
|
}
|
5457
5652
|
});
|
5458
5653
|
|
@@ -5505,13 +5700,13 @@ function mapSqlToSqliteType(sqlType) {
|
|
5505
5700
|
return "numeric";
|
5506
5701
|
}
|
5507
5702
|
}
|
5508
|
-
var
|
5703
|
+
var dialect4, fromDatabase;
|
5509
5704
|
var init_sqliteSerializer = __esm({
|
5510
5705
|
"src/serializer/sqliteSerializer.ts"() {
|
5511
5706
|
"use strict";
|
5512
5707
|
init_serializer();
|
5513
5708
|
init_outputs();
|
5514
|
-
|
5709
|
+
dialect4 = new SQLiteSyncDialect();
|
5515
5710
|
fromDatabase = async (db, tablesFilter = (table4) => true, progressCallback) => {
|
5516
5711
|
const result = {};
|
5517
5712
|
const columns = await db.query(
|
@@ -5935,6 +6130,13 @@ var require_brace_expansion = __commonJS({
|
|
5935
6130
|
}
|
5936
6131
|
});
|
5937
6132
|
|
6133
|
+
// src/extensions/vector.ts
|
6134
|
+
var init_vector = __esm({
|
6135
|
+
"src/extensions/vector.ts"() {
|
6136
|
+
"use strict";
|
6137
|
+
}
|
6138
|
+
});
|
6139
|
+
|
5938
6140
|
// src/serializer/pgSerializer.ts
|
5939
6141
|
import {
|
5940
6142
|
PgDialect,
|
@@ -5943,13 +6145,14 @@ import {
|
|
5943
6145
|
} from "drizzle-orm/pg-core";
|
5944
6146
|
import { getTableConfig as getTableConfig2 } from "drizzle-orm/pg-core";
|
5945
6147
|
import { is as is2, SQL as SQL2, getTableName as getTableName2 } from "drizzle-orm";
|
5946
|
-
var
|
6148
|
+
var dialect5, trimChar, fromDatabase2, columnToDefault, defaultForColumn;
|
5947
6149
|
var init_pgSerializer = __esm({
|
5948
6150
|
"src/serializer/pgSerializer.ts"() {
|
5949
6151
|
"use strict";
|
5950
6152
|
init_serializer();
|
5951
6153
|
init_outputs();
|
5952
|
-
|
6154
|
+
init_vector();
|
6155
|
+
dialect5 = new PgDialect();
|
5953
6156
|
trimChar = (str, char) => {
|
5954
6157
|
let start = 0;
|
5955
6158
|
let end = str.length;
|
@@ -6210,7 +6413,10 @@ var init_pgSerializer = __esm({
|
|
6210
6413
|
columnTypeMapped = trimChar(columnTypeMapped, '"');
|
6211
6414
|
columnToReturn[columnName] = {
|
6212
6415
|
name: columnName,
|
6213
|
-
type:
|
6416
|
+
type: (
|
6417
|
+
// filter vectors, but in future we should filter any extension that was installed by user
|
6418
|
+
columnAdditionalDT === "USER-DEFINED" && !["vector", "geometry"].includes(enumType3) ? enumType3 : columnTypeMapped
|
6419
|
+
),
|
6214
6420
|
typeSchema: enumsToReturn[`${tableSchema}.${enumType3}`] !== void 0 ? enumsToReturn[`${tableSchema}.${enumType3}`].schema : void 0,
|
6215
6421
|
primaryKey: primaryKey.length === 1 && cprimaryKey.length < 2,
|
6216
6422
|
// default: isSerial ? undefined : defaultValue,
|
@@ -6221,15 +6427,42 @@ var init_pgSerializer = __esm({
|
|
6221
6427
|
}
|
6222
6428
|
}
|
6223
6429
|
const dbIndexes = await db.query(
|
6224
|
-
`SELECT t.relname
|
6225
|
-
|
6226
|
-
|
6227
|
-
|
6228
|
-
|
6229
|
-
|
6230
|
-
|
6231
|
-
|
6232
|
-
|
6430
|
+
`SELECT DISTINCT ON (t.relname, ic.relname, k.i) t.relname as table_name, ic.relname AS indexname,
|
6431
|
+
k.i AS index_order,
|
6432
|
+
i.indisunique as is_unique,
|
6433
|
+
am.amname as method,
|
6434
|
+
ic.reloptions as with,
|
6435
|
+
coalesce(a.attname,
|
6436
|
+
(('{' || pg_get_expr(
|
6437
|
+
i.indexprs,
|
6438
|
+
i.indrelid
|
6439
|
+
)
|
6440
|
+
|| '}')::text[]
|
6441
|
+
)[k.i]
|
6442
|
+
) AS column_name,
|
6443
|
+
CASE
|
6444
|
+
WHEN pg_get_expr(i.indexprs, i.indrelid) IS NOT NULL THEN 1
|
6445
|
+
ELSE 0
|
6446
|
+
END AS is_expression,
|
6447
|
+
i.indoption[k.i-1] & 1 = 1 AS descending,
|
6448
|
+
i.indoption[k.i-1] & 2 = 2 AS nulls_first,
|
6449
|
+
pg_get_expr(
|
6450
|
+
i.indpred,
|
6451
|
+
i.indrelid
|
6452
|
+
) as where,
|
6453
|
+
opc.opcname
|
6454
|
+
FROM pg_class t
|
6455
|
+
LEFT JOIN pg_index i ON t.oid = i.indrelid
|
6456
|
+
LEFT JOIN pg_class ic ON ic.oid = i.indexrelid
|
6457
|
+
CROSS JOIN LATERAL (SELECT unnest(i.indkey), generate_subscripts(i.indkey, 1) + 1) AS k(attnum, i)
|
6458
|
+
LEFT JOIN pg_attribute AS a
|
6459
|
+
ON i.indrelid = a.attrelid AND k.attnum = a.attnum
|
6460
|
+
JOIN pg_namespace c on c.oid = t.relnamespace
|
6461
|
+
LEFT JOIN pg_am AS am ON ic.relam = am.oid
|
6462
|
+
JOIN pg_opclass opc ON opc.oid = ANY(i.indclass)
|
6463
|
+
WHERE
|
6464
|
+
c.nspname = '${tableSchema}' AND
|
6465
|
+
t.relname = '${tableName}';`
|
6233
6466
|
);
|
6234
6467
|
const dbIndexFromConstraint = await db.query(
|
6235
6468
|
`SELECT
|
@@ -6246,18 +6479,51 @@ var init_pgSerializer = __esm({
|
|
6246
6479
|
);
|
6247
6480
|
const idxsInConsteraint = dbIndexFromConstraint.filter((it) => it.generated_by_constraint === 1).map((it) => it.index_name);
|
6248
6481
|
for (const dbIndex of dbIndexes) {
|
6249
|
-
const indexName = dbIndex.
|
6482
|
+
const indexName = dbIndex.indexname;
|
6250
6483
|
const indexColumnName = dbIndex.column_name;
|
6251
6484
|
const indexIsUnique = dbIndex.is_unique;
|
6485
|
+
const indexMethod = dbIndex.method;
|
6486
|
+
const indexWith = dbIndex.with;
|
6487
|
+
const indexWhere = dbIndex.where;
|
6488
|
+
const opclass = dbIndex.opcname;
|
6489
|
+
const isExpression = dbIndex.is_expression === 1;
|
6490
|
+
const desc = dbIndex.descending;
|
6491
|
+
const nullsFirst = dbIndex.nulls_first;
|
6492
|
+
const mappedWith = {};
|
6493
|
+
if (indexWith !== null) {
|
6494
|
+
indexWith.forEach((it) => {
|
6495
|
+
const splitted = it.split("=");
|
6496
|
+
mappedWith[splitted[0]] = splitted[1];
|
6497
|
+
});
|
6498
|
+
}
|
6252
6499
|
if (idxsInConsteraint.includes(indexName))
|
6253
6500
|
continue;
|
6254
6501
|
if (typeof indexToReturn[indexName] !== "undefined") {
|
6255
|
-
indexToReturn[indexName].columns.push(
|
6502
|
+
indexToReturn[indexName].columns.push({
|
6503
|
+
expression: indexColumnName,
|
6504
|
+
asc: !desc,
|
6505
|
+
nulls: nullsFirst ? "first" : "last",
|
6506
|
+
opclass,
|
6507
|
+
isExpression
|
6508
|
+
});
|
6256
6509
|
} else {
|
6257
6510
|
indexToReturn[indexName] = {
|
6258
6511
|
name: indexName,
|
6259
|
-
columns: [
|
6260
|
-
|
6512
|
+
columns: [
|
6513
|
+
{
|
6514
|
+
expression: indexColumnName,
|
6515
|
+
asc: !desc,
|
6516
|
+
nulls: nullsFirst ? "first" : "last",
|
6517
|
+
opclass,
|
6518
|
+
isExpression
|
6519
|
+
}
|
6520
|
+
],
|
6521
|
+
isUnique: indexIsUnique,
|
6522
|
+
// should not be a part of diff detecs
|
6523
|
+
concurrently: false,
|
6524
|
+
method: indexMethod,
|
6525
|
+
where: indexWhere === null ? void 0 : indexWhere,
|
6526
|
+
with: mappedWith
|
6261
6527
|
};
|
6262
6528
|
}
|
6263
6529
|
}
|
@@ -6293,7 +6559,7 @@ var init_pgSerializer = __esm({
|
|
6293
6559
|
}
|
6294
6560
|
const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
|
6295
6561
|
return {
|
6296
|
-
version: "
|
6562
|
+
version: "7",
|
6297
6563
|
dialect: "postgresql",
|
6298
6564
|
tables: result,
|
6299
6565
|
enums: enumsToReturn,
|