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.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
|
|
@@ -4848,7 +4848,7 @@ var init_lib = __esm({
|
|
4848
4848
|
});
|
4849
4849
|
|
4850
4850
|
// src/serializer/mysqlSchema.ts
|
4851
|
-
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;
|
4851
|
+
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;
|
4852
4852
|
var init_mysqlSchema = __esm({
|
4853
4853
|
"src/serializer/mysqlSchema.ts"() {
|
4854
4854
|
"use strict";
|
@@ -4918,7 +4918,16 @@ var init_mysqlSchema = __esm({
|
|
4918
4918
|
objectType({ isDefaultAnExpression: booleanType().optional() }).optional()
|
4919
4919
|
)
|
4920
4920
|
}).optional()
|
4921
|
-
)
|
4921
|
+
).optional(),
|
4922
|
+
indexes: recordType(
|
4923
|
+
stringType(),
|
4924
|
+
objectType({
|
4925
|
+
columns: recordType(
|
4926
|
+
stringType(),
|
4927
|
+
objectType({ isExpression: booleanType().optional() }).optional()
|
4928
|
+
)
|
4929
|
+
}).optional()
|
4930
|
+
).optional()
|
4922
4931
|
}).optional();
|
4923
4932
|
dialect = literalType("mysql");
|
4924
4933
|
schemaHash = objectType({
|
@@ -4990,6 +4999,7 @@ var init_mysqlSchema = __esm({
|
|
4990
4999
|
}).strict();
|
4991
5000
|
mysqlSchema = schema;
|
4992
5001
|
mysqlSchemaV5 = schemaV5;
|
5002
|
+
mysqlSchemaSquashed = schemaSquashed;
|
4993
5003
|
backwardCompatibleMysqlSchema = unionType([mysqlSchemaV5, schema]);
|
4994
5004
|
dryMySql = mysqlSchema.parse({
|
4995
5005
|
version: "5",
|
@@ -5008,7 +5018,7 @@ var init_mysqlSchema = __esm({
|
|
5008
5018
|
});
|
5009
5019
|
|
5010
5020
|
// 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;
|
5021
|
+
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
5022
|
var init_pgSchema = __esm({
|
5013
5023
|
"src/serializer/pgSchema.ts"() {
|
5014
5024
|
"use strict";
|
@@ -5076,10 +5086,48 @@ var init_pgSchema = __esm({
|
|
5076
5086
|
tables: recordType(stringType(), tableV1),
|
5077
5087
|
enums: recordType(stringType(), enumSchemaV1)
|
5078
5088
|
}).strict();
|
5089
|
+
indexColumn = objectType({
|
5090
|
+
expression: stringType(),
|
5091
|
+
isExpression: booleanType(),
|
5092
|
+
asc: booleanType(),
|
5093
|
+
nulls: stringType().optional(),
|
5094
|
+
opclass: stringType().optional()
|
5095
|
+
});
|
5079
5096
|
index2 = objectType({
|
5097
|
+
name: stringType(),
|
5098
|
+
columns: indexColumn.array(),
|
5099
|
+
isUnique: booleanType(),
|
5100
|
+
with: recordType(stringType(), anyType()).optional(),
|
5101
|
+
method: stringType().default("btree"),
|
5102
|
+
where: stringType().optional(),
|
5103
|
+
concurrently: booleanType().default(false)
|
5104
|
+
}).strict();
|
5105
|
+
indexV4 = objectType({
|
5080
5106
|
name: stringType(),
|
5081
5107
|
columns: stringType().array(),
|
5082
|
-
isUnique: booleanType()
|
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
|
+
indexV5 = 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)
|
5122
|
+
}).strict();
|
5123
|
+
indexV6 = objectType({
|
5124
|
+
name: stringType(),
|
5125
|
+
columns: stringType().array(),
|
5126
|
+
isUnique: booleanType(),
|
5127
|
+
with: recordType(stringType(), stringType()).optional(),
|
5128
|
+
method: stringType().default("btree"),
|
5129
|
+
where: stringType().optional(),
|
5130
|
+
concurrently: booleanType().default(false)
|
5083
5131
|
}).strict();
|
5084
5132
|
fk2 = objectType({
|
5085
5133
|
name: stringType(),
|
@@ -5121,9 +5169,27 @@ var init_pgSchema = __esm({
|
|
5121
5169
|
name: stringType(),
|
5122
5170
|
schema: stringType(),
|
5123
5171
|
columns: recordType(stringType(), column2),
|
5124
|
-
indexes: recordType(stringType(),
|
5172
|
+
indexes: recordType(stringType(), indexV4),
|
5125
5173
|
foreignKeys: recordType(stringType(), fk2)
|
5126
5174
|
}).strict();
|
5175
|
+
tableV6 = objectType({
|
5176
|
+
name: stringType(),
|
5177
|
+
schema: stringType(),
|
5178
|
+
columns: recordType(stringType(), column2),
|
5179
|
+
indexes: recordType(stringType(), indexV6),
|
5180
|
+
foreignKeys: recordType(stringType(), fk2),
|
5181
|
+
compositePrimaryKeys: recordType(stringType(), compositePK2),
|
5182
|
+
uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
|
5183
|
+
}).strict();
|
5184
|
+
tableV5 = objectType({
|
5185
|
+
name: stringType(),
|
5186
|
+
schema: stringType(),
|
5187
|
+
columns: recordType(stringType(), column2),
|
5188
|
+
indexes: recordType(stringType(), indexV5),
|
5189
|
+
foreignKeys: recordType(stringType(), fk2),
|
5190
|
+
compositePrimaryKeys: recordType(stringType(), compositePK2),
|
5191
|
+
uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
|
5192
|
+
}).strict();
|
5127
5193
|
table2 = objectType({
|
5128
5194
|
name: stringType(),
|
5129
5195
|
schema: stringType(),
|
@@ -5168,7 +5234,7 @@ var init_pgSchema = __esm({
|
|
5168
5234
|
pgSchemaInternalV5 = objectType({
|
5169
5235
|
version: literalType("5"),
|
5170
5236
|
dialect: literalType("pg"),
|
5171
|
-
tables: recordType(stringType(),
|
5237
|
+
tables: recordType(stringType(), tableV5),
|
5172
5238
|
enums: recordType(stringType(), enumSchemaV1),
|
5173
5239
|
schemas: recordType(stringType(), stringType()),
|
5174
5240
|
_meta: objectType({
|
@@ -5178,6 +5244,19 @@ var init_pgSchema = __esm({
|
|
5178
5244
|
}),
|
5179
5245
|
internal: kitInternals2
|
5180
5246
|
}).strict();
|
5247
|
+
pgSchemaInternalV6 = objectType({
|
5248
|
+
version: literalType("6"),
|
5249
|
+
dialect: literalType("postgresql"),
|
5250
|
+
tables: recordType(stringType(), tableV6),
|
5251
|
+
enums: recordType(stringType(), enumSchema),
|
5252
|
+
schemas: recordType(stringType(), stringType()),
|
5253
|
+
_meta: objectType({
|
5254
|
+
schemas: recordType(stringType(), stringType()),
|
5255
|
+
tables: recordType(stringType(), stringType()),
|
5256
|
+
columns: recordType(stringType(), stringType())
|
5257
|
+
}),
|
5258
|
+
internal: kitInternals2
|
5259
|
+
}).strict();
|
5181
5260
|
pgSchemaExternal = objectType({
|
5182
5261
|
version: literalType("5"),
|
5183
5262
|
dialect: literalType("pg"),
|
@@ -5191,7 +5270,7 @@ var init_pgSchema = __esm({
|
|
5191
5270
|
})
|
5192
5271
|
}).strict();
|
5193
5272
|
pgSchemaInternal = objectType({
|
5194
|
-
version: literalType("
|
5273
|
+
version: literalType("7"),
|
5195
5274
|
dialect: literalType("postgresql"),
|
5196
5275
|
tables: recordType(stringType(), table2),
|
5197
5276
|
enums: recordType(stringType(), enumSchema),
|
@@ -5226,18 +5305,30 @@ var init_pgSchema = __esm({
|
|
5226
5305
|
enums: recordType(stringType(), enumSchemaV1),
|
5227
5306
|
schemas: recordType(stringType(), stringType())
|
5228
5307
|
}).strict();
|
5229
|
-
|
5308
|
+
pgSchemaSquashedV6 = objectType({
|
5230
5309
|
version: literalType("6"),
|
5231
5310
|
dialect: literalType("postgresql"),
|
5232
5311
|
tables: recordType(stringType(), tableSquashed2),
|
5233
5312
|
enums: recordType(stringType(), enumSchema),
|
5234
5313
|
schemas: recordType(stringType(), stringType())
|
5235
5314
|
}).strict();
|
5315
|
+
pgSchemaSquashed = objectType({
|
5316
|
+
version: literalType("7"),
|
5317
|
+
dialect: literalType("postgresql"),
|
5318
|
+
tables: recordType(stringType(), tableSquashed2),
|
5319
|
+
enums: recordType(stringType(), enumSchema),
|
5320
|
+
schemas: recordType(stringType(), stringType())
|
5321
|
+
}).strict();
|
5236
5322
|
pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash2);
|
5237
5323
|
pgSchemaV4 = pgSchemaInternalV4.merge(schemaHash2);
|
5238
5324
|
pgSchemaV5 = pgSchemaInternalV5.merge(schemaHash2);
|
5325
|
+
pgSchemaV6 = pgSchemaInternalV6.merge(schemaHash2);
|
5239
5326
|
pgSchema2 = pgSchemaInternal.merge(schemaHash2);
|
5240
|
-
backwardCompatiblePgSchema = unionType([
|
5327
|
+
backwardCompatiblePgSchema = unionType([
|
5328
|
+
pgSchemaV5,
|
5329
|
+
pgSchemaV6,
|
5330
|
+
pgSchema2
|
5331
|
+
]);
|
5241
5332
|
dryPg = pgSchema2.parse({
|
5242
5333
|
version: snapshotVersion,
|
5243
5334
|
dialect: "postgresql",
|
@@ -5256,7 +5347,7 @@ var init_pgSchema = __esm({
|
|
5256
5347
|
});
|
5257
5348
|
|
5258
5349
|
// src/serializer/sqliteSchema.ts
|
5259
|
-
var index3, fk3, compositePK3, column3, tableV33, uniqueConstraint3, table3, dialect2, schemaHash3, schemaInternalV32, schemaInternalV42, schemaInternalV52, latestVersion, schemaInternal2, schemaV32, schemaV42, schemaV52, schema2, tableSquashed3, schemaSquashed2, drySQLite, sqliteSchemaV5, backwardCompatibleSqliteSchema;
|
5350
|
+
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;
|
5260
5351
|
var init_sqliteSchema = __esm({
|
5261
5352
|
"src/serializer/sqliteSchema.ts"() {
|
5262
5353
|
"use strict";
|
@@ -5334,6 +5425,17 @@ var init_sqliteSchema = __esm({
|
|
5334
5425
|
columns: recordType(stringType(), stringType())
|
5335
5426
|
})
|
5336
5427
|
}).strict();
|
5428
|
+
kitInternals3 = objectType({
|
5429
|
+
indexes: recordType(
|
5430
|
+
stringType(),
|
5431
|
+
objectType({
|
5432
|
+
columns: recordType(
|
5433
|
+
stringType(),
|
5434
|
+
objectType({ isExpression: booleanType().optional() }).optional()
|
5435
|
+
)
|
5436
|
+
}).optional()
|
5437
|
+
).optional()
|
5438
|
+
}).optional();
|
5337
5439
|
latestVersion = literalType("6");
|
5338
5440
|
schemaInternal2 = objectType({
|
5339
5441
|
version: latestVersion,
|
@@ -5343,7 +5445,8 @@ var init_sqliteSchema = __esm({
|
|
5343
5445
|
_meta: objectType({
|
5344
5446
|
tables: recordType(stringType(), stringType()),
|
5345
5447
|
columns: recordType(stringType(), stringType())
|
5346
|
-
})
|
5448
|
+
}),
|
5449
|
+
internal: kitInternals3
|
5347
5450
|
}).strict();
|
5348
5451
|
schemaV32 = schemaInternalV32.merge(schemaHash3).strict();
|
5349
5452
|
schemaV42 = schemaInternalV42.merge(schemaHash3).strict();
|
@@ -5376,6 +5479,8 @@ var init_sqliteSchema = __esm({
|
|
5376
5479
|
}
|
5377
5480
|
});
|
5378
5481
|
sqliteSchemaV5 = schemaV52;
|
5482
|
+
sqliteSchema = schema2;
|
5483
|
+
SQLiteSchemaSquashed = schemaSquashed2;
|
5379
5484
|
backwardCompatibleSqliteSchema = unionType([sqliteSchemaV5, schema2]);
|
5380
5485
|
}
|
5381
5486
|
});
|
@@ -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
|
|
@@ -5498,7 +5693,7 @@ function mapSqlToSqliteType(sqlType) {
|
|
5498
5693
|
return "numeric";
|
5499
5694
|
}
|
5500
5695
|
}
|
5501
|
-
var import_drizzle_orm, import_sqlite_core2,
|
5696
|
+
var import_drizzle_orm, import_sqlite_core2, dialect4, fromDatabase;
|
5502
5697
|
var init_sqliteSerializer = __esm({
|
5503
5698
|
"src/serializer/sqliteSerializer.ts"() {
|
5504
5699
|
"use strict";
|
@@ -5506,7 +5701,7 @@ var init_sqliteSerializer = __esm({
|
|
5506
5701
|
import_sqlite_core2 = require("drizzle-orm/sqlite-core");
|
5507
5702
|
init_serializer();
|
5508
5703
|
init_outputs();
|
5509
|
-
|
5704
|
+
dialect4 = new import_sqlite_core2.SQLiteSyncDialect();
|
5510
5705
|
fromDatabase = async (db, tablesFilter = (table4) => true, progressCallback) => {
|
5511
5706
|
const result = {};
|
5512
5707
|
const columns = await db.query(
|
@@ -5930,8 +6125,15 @@ var require_brace_expansion = __commonJS({
|
|
5930
6125
|
}
|
5931
6126
|
});
|
5932
6127
|
|
6128
|
+
// src/extensions/vector.ts
|
6129
|
+
var init_vector = __esm({
|
6130
|
+
"src/extensions/vector.ts"() {
|
6131
|
+
"use strict";
|
6132
|
+
}
|
6133
|
+
});
|
6134
|
+
|
5933
6135
|
// src/serializer/pgSerializer.ts
|
5934
|
-
var import_pg_core2, import_pg_core3, import_drizzle_orm2,
|
6136
|
+
var import_pg_core2, import_pg_core3, import_drizzle_orm2, dialect5, trimChar, fromDatabase2, columnToDefault, defaultForColumn;
|
5935
6137
|
var init_pgSerializer = __esm({
|
5936
6138
|
"src/serializer/pgSerializer.ts"() {
|
5937
6139
|
"use strict";
|
@@ -5940,7 +6142,8 @@ var init_pgSerializer = __esm({
|
|
5940
6142
|
import_drizzle_orm2 = require("drizzle-orm");
|
5941
6143
|
init_serializer();
|
5942
6144
|
init_outputs();
|
5943
|
-
|
6145
|
+
init_vector();
|
6146
|
+
dialect5 = new import_pg_core2.PgDialect();
|
5944
6147
|
trimChar = (str, char) => {
|
5945
6148
|
let start = 0;
|
5946
6149
|
let end = str.length;
|
@@ -6201,7 +6404,10 @@ var init_pgSerializer = __esm({
|
|
6201
6404
|
columnTypeMapped = trimChar(columnTypeMapped, '"');
|
6202
6405
|
columnToReturn[columnName] = {
|
6203
6406
|
name: columnName,
|
6204
|
-
type:
|
6407
|
+
type: (
|
6408
|
+
// filter vectors, but in future we should filter any extension that was installed by user
|
6409
|
+
columnAdditionalDT === "USER-DEFINED" && !["vector", "geometry"].includes(enumType3) ? enumType3 : columnTypeMapped
|
6410
|
+
),
|
6205
6411
|
typeSchema: enumsToReturn[`${tableSchema}.${enumType3}`] !== void 0 ? enumsToReturn[`${tableSchema}.${enumType3}`].schema : void 0,
|
6206
6412
|
primaryKey: primaryKey.length === 1 && cprimaryKey.length < 2,
|
6207
6413
|
// default: isSerial ? undefined : defaultValue,
|
@@ -6212,15 +6418,42 @@ var init_pgSerializer = __esm({
|
|
6212
6418
|
}
|
6213
6419
|
}
|
6214
6420
|
const dbIndexes = await db.query(
|
6215
|
-
`SELECT t.relname
|
6216
|
-
|
6217
|
-
|
6218
|
-
|
6219
|
-
|
6220
|
-
|
6221
|
-
|
6222
|
-
|
6223
|
-
|
6421
|
+
`SELECT DISTINCT ON (t.relname, ic.relname, k.i) t.relname as table_name, ic.relname AS indexname,
|
6422
|
+
k.i AS index_order,
|
6423
|
+
i.indisunique as is_unique,
|
6424
|
+
am.amname as method,
|
6425
|
+
ic.reloptions as with,
|
6426
|
+
coalesce(a.attname,
|
6427
|
+
(('{' || pg_get_expr(
|
6428
|
+
i.indexprs,
|
6429
|
+
i.indrelid
|
6430
|
+
)
|
6431
|
+
|| '}')::text[]
|
6432
|
+
)[k.i]
|
6433
|
+
) AS column_name,
|
6434
|
+
CASE
|
6435
|
+
WHEN pg_get_expr(i.indexprs, i.indrelid) IS NOT NULL THEN 1
|
6436
|
+
ELSE 0
|
6437
|
+
END AS is_expression,
|
6438
|
+
i.indoption[k.i-1] & 1 = 1 AS descending,
|
6439
|
+
i.indoption[k.i-1] & 2 = 2 AS nulls_first,
|
6440
|
+
pg_get_expr(
|
6441
|
+
i.indpred,
|
6442
|
+
i.indrelid
|
6443
|
+
) as where,
|
6444
|
+
opc.opcname
|
6445
|
+
FROM pg_class t
|
6446
|
+
LEFT JOIN pg_index i ON t.oid = i.indrelid
|
6447
|
+
LEFT JOIN pg_class ic ON ic.oid = i.indexrelid
|
6448
|
+
CROSS JOIN LATERAL (SELECT unnest(i.indkey), generate_subscripts(i.indkey, 1) + 1) AS k(attnum, i)
|
6449
|
+
LEFT JOIN pg_attribute AS a
|
6450
|
+
ON i.indrelid = a.attrelid AND k.attnum = a.attnum
|
6451
|
+
JOIN pg_namespace c on c.oid = t.relnamespace
|
6452
|
+
LEFT JOIN pg_am AS am ON ic.relam = am.oid
|
6453
|
+
JOIN pg_opclass opc ON opc.oid = ANY(i.indclass)
|
6454
|
+
WHERE
|
6455
|
+
c.nspname = '${tableSchema}' AND
|
6456
|
+
t.relname = '${tableName}';`
|
6224
6457
|
);
|
6225
6458
|
const dbIndexFromConstraint = await db.query(
|
6226
6459
|
`SELECT
|
@@ -6237,18 +6470,51 @@ var init_pgSerializer = __esm({
|
|
6237
6470
|
);
|
6238
6471
|
const idxsInConsteraint = dbIndexFromConstraint.filter((it) => it.generated_by_constraint === 1).map((it) => it.index_name);
|
6239
6472
|
for (const dbIndex of dbIndexes) {
|
6240
|
-
const indexName = dbIndex.
|
6473
|
+
const indexName = dbIndex.indexname;
|
6241
6474
|
const indexColumnName = dbIndex.column_name;
|
6242
6475
|
const indexIsUnique = dbIndex.is_unique;
|
6476
|
+
const indexMethod = dbIndex.method;
|
6477
|
+
const indexWith = dbIndex.with;
|
6478
|
+
const indexWhere = dbIndex.where;
|
6479
|
+
const opclass = dbIndex.opcname;
|
6480
|
+
const isExpression = dbIndex.is_expression === 1;
|
6481
|
+
const desc = dbIndex.descending;
|
6482
|
+
const nullsFirst = dbIndex.nulls_first;
|
6483
|
+
const mappedWith = {};
|
6484
|
+
if (indexWith !== null) {
|
6485
|
+
indexWith.forEach((it) => {
|
6486
|
+
const splitted = it.split("=");
|
6487
|
+
mappedWith[splitted[0]] = splitted[1];
|
6488
|
+
});
|
6489
|
+
}
|
6243
6490
|
if (idxsInConsteraint.includes(indexName))
|
6244
6491
|
continue;
|
6245
6492
|
if (typeof indexToReturn[indexName] !== "undefined") {
|
6246
|
-
indexToReturn[indexName].columns.push(
|
6493
|
+
indexToReturn[indexName].columns.push({
|
6494
|
+
expression: indexColumnName,
|
6495
|
+
asc: !desc,
|
6496
|
+
nulls: nullsFirst ? "first" : "last",
|
6497
|
+
opclass,
|
6498
|
+
isExpression
|
6499
|
+
});
|
6247
6500
|
} else {
|
6248
6501
|
indexToReturn[indexName] = {
|
6249
6502
|
name: indexName,
|
6250
|
-
columns: [
|
6251
|
-
|
6503
|
+
columns: [
|
6504
|
+
{
|
6505
|
+
expression: indexColumnName,
|
6506
|
+
asc: !desc,
|
6507
|
+
nulls: nullsFirst ? "first" : "last",
|
6508
|
+
opclass,
|
6509
|
+
isExpression
|
6510
|
+
}
|
6511
|
+
],
|
6512
|
+
isUnique: indexIsUnique,
|
6513
|
+
// should not be a part of diff detecs
|
6514
|
+
concurrently: false,
|
6515
|
+
method: indexMethod,
|
6516
|
+
where: indexWhere === null ? void 0 : indexWhere,
|
6517
|
+
with: mappedWith
|
6252
6518
|
};
|
6253
6519
|
}
|
6254
6520
|
}
|
@@ -6284,7 +6550,7 @@ var init_pgSerializer = __esm({
|
|
6284
6550
|
}
|
6285
6551
|
const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
|
6286
6552
|
return {
|
6287
|
-
version: "
|
6553
|
+
version: "7",
|
6288
6554
|
dialect: "postgresql",
|
6289
6555
|
tables: result,
|
6290
6556
|
enums: enumsToReturn,
|