drizzle-kit 0.24.0 → 0.24.1-3d751e8
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 +169 -109
- package/api.mjs +169 -109
- package/bin.cjs +1114 -487
- package/index.d.mts +10 -4
- package/index.d.ts +10 -4
- package/package.json +4 -4
- package/utils.js +10 -1
- package/utils.mjs +9 -1
package/api.d.mts
CHANGED
@@ -801,23 +801,28 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
|
|
801
801
|
isArray: zod.ZodOptional<zod.ZodBoolean>;
|
802
802
|
dimensions: zod.ZodOptional<zod.ZodNumber>;
|
803
803
|
rawType: zod.ZodOptional<zod.ZodString>;
|
804
|
+
isDefaultAnExpression: zod.ZodOptional<zod.ZodBoolean>;
|
804
805
|
}, "strip", zod.ZodTypeAny, {
|
806
|
+
isDefaultAnExpression?: boolean | undefined;
|
805
807
|
isArray?: boolean | undefined;
|
806
808
|
dimensions?: number | undefined;
|
807
809
|
rawType?: string | undefined;
|
808
810
|
}, {
|
811
|
+
isDefaultAnExpression?: boolean | undefined;
|
809
812
|
isArray?: boolean | undefined;
|
810
813
|
dimensions?: number | undefined;
|
811
814
|
rawType?: string | undefined;
|
812
815
|
}>>>;
|
813
816
|
}, "strip", zod.ZodTypeAny, {
|
814
817
|
columns: Record<string, {
|
818
|
+
isDefaultAnExpression?: boolean | undefined;
|
815
819
|
isArray?: boolean | undefined;
|
816
820
|
dimensions?: number | undefined;
|
817
821
|
rawType?: string | undefined;
|
818
822
|
} | undefined>;
|
819
823
|
}, {
|
820
824
|
columns: Record<string, {
|
825
|
+
isDefaultAnExpression?: boolean | undefined;
|
821
826
|
isArray?: boolean | undefined;
|
822
827
|
dimensions?: number | undefined;
|
823
828
|
rawType?: string | undefined;
|
@@ -826,6 +831,7 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
|
|
826
831
|
}, "strip", zod.ZodTypeAny, {
|
827
832
|
tables: Record<string, {
|
828
833
|
columns: Record<string, {
|
834
|
+
isDefaultAnExpression?: boolean | undefined;
|
829
835
|
isArray?: boolean | undefined;
|
830
836
|
dimensions?: number | undefined;
|
831
837
|
rawType?: string | undefined;
|
@@ -834,6 +840,7 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
|
|
834
840
|
}, {
|
835
841
|
tables: Record<string, {
|
836
842
|
columns: Record<string, {
|
843
|
+
isDefaultAnExpression?: boolean | undefined;
|
837
844
|
isArray?: boolean | undefined;
|
838
845
|
dimensions?: number | undefined;
|
839
846
|
rawType?: string | undefined;
|
@@ -936,6 +943,7 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
|
|
936
943
|
internal?: {
|
937
944
|
tables: Record<string, {
|
938
945
|
columns: Record<string, {
|
946
|
+
isDefaultAnExpression?: boolean | undefined;
|
939
947
|
isArray?: boolean | undefined;
|
940
948
|
dimensions?: number | undefined;
|
941
949
|
rawType?: string | undefined;
|
@@ -1025,6 +1033,7 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
|
|
1025
1033
|
internal?: {
|
1026
1034
|
tables: Record<string, {
|
1027
1035
|
columns: Record<string, {
|
1036
|
+
isDefaultAnExpression?: boolean | undefined;
|
1028
1037
|
isArray?: boolean | undefined;
|
1029
1038
|
dimensions?: number | undefined;
|
1030
1039
|
rawType?: string | undefined;
|
@@ -1506,6 +1515,7 @@ declare const upPgSnapshot: (snapshot: Record<string, unknown>) => {
|
|
1506
1515
|
isArray?: boolean | undefined;
|
1507
1516
|
dimensions?: number | undefined;
|
1508
1517
|
rawType?: string | undefined;
|
1518
|
+
isDefaultAnExpression?: boolean | undefined;
|
1509
1519
|
} | undefined>;
|
1510
1520
|
} | undefined>;
|
1511
1521
|
} | undefined;
|
package/api.d.ts
CHANGED
@@ -801,23 +801,28 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
|
|
801
801
|
isArray: zod.ZodOptional<zod.ZodBoolean>;
|
802
802
|
dimensions: zod.ZodOptional<zod.ZodNumber>;
|
803
803
|
rawType: zod.ZodOptional<zod.ZodString>;
|
804
|
+
isDefaultAnExpression: zod.ZodOptional<zod.ZodBoolean>;
|
804
805
|
}, "strip", zod.ZodTypeAny, {
|
806
|
+
isDefaultAnExpression?: boolean | undefined;
|
805
807
|
isArray?: boolean | undefined;
|
806
808
|
dimensions?: number | undefined;
|
807
809
|
rawType?: string | undefined;
|
808
810
|
}, {
|
811
|
+
isDefaultAnExpression?: boolean | undefined;
|
809
812
|
isArray?: boolean | undefined;
|
810
813
|
dimensions?: number | undefined;
|
811
814
|
rawType?: string | undefined;
|
812
815
|
}>>>;
|
813
816
|
}, "strip", zod.ZodTypeAny, {
|
814
817
|
columns: Record<string, {
|
818
|
+
isDefaultAnExpression?: boolean | undefined;
|
815
819
|
isArray?: boolean | undefined;
|
816
820
|
dimensions?: number | undefined;
|
817
821
|
rawType?: string | undefined;
|
818
822
|
} | undefined>;
|
819
823
|
}, {
|
820
824
|
columns: Record<string, {
|
825
|
+
isDefaultAnExpression?: boolean | undefined;
|
821
826
|
isArray?: boolean | undefined;
|
822
827
|
dimensions?: number | undefined;
|
823
828
|
rawType?: string | undefined;
|
@@ -826,6 +831,7 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
|
|
826
831
|
}, "strip", zod.ZodTypeAny, {
|
827
832
|
tables: Record<string, {
|
828
833
|
columns: Record<string, {
|
834
|
+
isDefaultAnExpression?: boolean | undefined;
|
829
835
|
isArray?: boolean | undefined;
|
830
836
|
dimensions?: number | undefined;
|
831
837
|
rawType?: string | undefined;
|
@@ -834,6 +840,7 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
|
|
834
840
|
}, {
|
835
841
|
tables: Record<string, {
|
836
842
|
columns: Record<string, {
|
843
|
+
isDefaultAnExpression?: boolean | undefined;
|
837
844
|
isArray?: boolean | undefined;
|
838
845
|
dimensions?: number | undefined;
|
839
846
|
rawType?: string | undefined;
|
@@ -936,6 +943,7 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
|
|
936
943
|
internal?: {
|
937
944
|
tables: Record<string, {
|
938
945
|
columns: Record<string, {
|
946
|
+
isDefaultAnExpression?: boolean | undefined;
|
939
947
|
isArray?: boolean | undefined;
|
940
948
|
dimensions?: number | undefined;
|
941
949
|
rawType?: string | undefined;
|
@@ -1025,6 +1033,7 @@ declare const pgSchema: zod.ZodObject<zod.objectUtil.extendShape<{
|
|
1025
1033
|
internal?: {
|
1026
1034
|
tables: Record<string, {
|
1027
1035
|
columns: Record<string, {
|
1036
|
+
isDefaultAnExpression?: boolean | undefined;
|
1028
1037
|
isArray?: boolean | undefined;
|
1029
1038
|
dimensions?: number | undefined;
|
1030
1039
|
rawType?: string | undefined;
|
@@ -1506,6 +1515,7 @@ declare const upPgSnapshot: (snapshot: Record<string, unknown>) => {
|
|
1506
1515
|
isArray?: boolean | undefined;
|
1507
1516
|
dimensions?: number | undefined;
|
1508
1517
|
rawType?: string | undefined;
|
1518
|
+
isDefaultAnExpression?: boolean | undefined;
|
1509
1519
|
} | undefined>;
|
1510
1520
|
} | undefined>;
|
1511
1521
|
} | undefined;
|
package/api.js
CHANGED
@@ -7464,11 +7464,30 @@ var init_mysqlSchema = __esm({
|
|
7464
7464
|
}
|
7465
7465
|
});
|
7466
7466
|
|
7467
|
+
// src/extensions/vector.ts
|
7468
|
+
var vectorOps;
|
7469
|
+
var init_vector = __esm({
|
7470
|
+
"src/extensions/vector.ts"() {
|
7471
|
+
"use strict";
|
7472
|
+
vectorOps = [
|
7473
|
+
"vector_l2_ops",
|
7474
|
+
"vector_ip_ops",
|
7475
|
+
"vector_cosine_ops",
|
7476
|
+
"vector_l1_ops",
|
7477
|
+
"bit_hamming_ops",
|
7478
|
+
"bit_jaccard_ops",
|
7479
|
+
"halfvec_l2_ops",
|
7480
|
+
"sparsevec_l2_ops"
|
7481
|
+
];
|
7482
|
+
}
|
7483
|
+
});
|
7484
|
+
|
7467
7485
|
// src/serializer/pgSchema.ts
|
7468
7486
|
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;
|
7469
7487
|
var init_pgSchema = __esm({
|
7470
7488
|
"src/serializer/pgSchema.ts"() {
|
7471
7489
|
"use strict";
|
7490
|
+
init_vector();
|
7472
7491
|
init_global();
|
7473
7492
|
init_lib();
|
7474
7493
|
indexV2 = objectType({
|
@@ -7715,7 +7734,8 @@ var init_pgSchema = __esm({
|
|
7715
7734
|
objectType({
|
7716
7735
|
isArray: booleanType().optional(),
|
7717
7736
|
dimensions: numberType().optional(),
|
7718
|
-
rawType: stringType().optional()
|
7737
|
+
rawType: stringType().optional(),
|
7738
|
+
isDefaultAnExpression: booleanType().optional()
|
7719
7739
|
}).optional()
|
7720
7740
|
)
|
7721
7741
|
}).optional()
|
@@ -7853,7 +7873,7 @@ var init_pgSchema = __esm({
|
|
7853
7873
|
squashIdx: (idx) => {
|
7854
7874
|
index2.parse(idx);
|
7855
7875
|
return `${idx.name};${idx.columns.map(
|
7856
|
-
(c) => `${c.expression}--${c.isExpression}--${c.asc}--${c.nulls}--${c.opclass}`
|
7876
|
+
(c) => `${c.expression}--${c.isExpression}--${c.asc}--${c.nulls}--${c.opclass && vectorOps.includes(c.opclass) ? c.opclass : ""}`
|
7857
7877
|
).join(",,")};${idx.isUnique};${idx.concurrently};${idx.method};${idx.where};${JSON.stringify(idx.with)}`;
|
7858
7878
|
},
|
7859
7879
|
unsquashIdx: (input) => {
|
@@ -11502,7 +11522,7 @@ var init_sqlgenerator = __esm({
|
|
11502
11522
|
isPgNativeType = (it) => {
|
11503
11523
|
if (pgNativeTypes.has(it)) return true;
|
11504
11524
|
const toCheck = it.replace(/ /g, "");
|
11505
|
-
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);
|
11525
|
+
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);
|
11506
11526
|
};
|
11507
11527
|
Convertor = class {
|
11508
11528
|
};
|
@@ -15845,7 +15865,7 @@ var init_schemaValidator = __esm({
|
|
15845
15865
|
});
|
15846
15866
|
|
15847
15867
|
// src/cli/validations/common.ts
|
15848
|
-
var sqliteDriversLiterals, prefixes, prefix, sqliteDriver, postgresDriver, driver, configMigrations, configCommonSchema, casing, introspectParams, configIntrospectCliSchema, configGenerateSchema, configPushSchema;
|
15868
|
+
var sqliteDriversLiterals, postgresqlDriversLiterals, prefixes, prefix, sqliteDriver, postgresDriver, driver, configMigrations, configCommonSchema, casing, introspectParams, configIntrospectCliSchema, configGenerateSchema, configPushSchema;
|
15849
15869
|
var init_common = __esm({
|
15850
15870
|
"src/cli/validations/common.ts"() {
|
15851
15871
|
"use strict";
|
@@ -15857,6 +15877,10 @@ var init_common = __esm({
|
|
15857
15877
|
literalType("d1-http"),
|
15858
15878
|
literalType("expo")
|
15859
15879
|
];
|
15880
|
+
postgresqlDriversLiterals = [
|
15881
|
+
literalType("aws-data-api"),
|
15882
|
+
literalType("pglite")
|
15883
|
+
];
|
15860
15884
|
prefixes = [
|
15861
15885
|
"index",
|
15862
15886
|
"timestamp",
|
@@ -15869,7 +15893,7 @@ var init_common = __esm({
|
|
15869
15893
|
const _2 = "";
|
15870
15894
|
}
|
15871
15895
|
sqliteDriver = unionType(sqliteDriversLiterals);
|
15872
|
-
postgresDriver =
|
15896
|
+
postgresDriver = unionType(postgresqlDriversLiterals);
|
15873
15897
|
driver = unionType([sqliteDriver, postgresDriver]);
|
15874
15898
|
configMigrations = objectType({
|
15875
15899
|
table: stringType().optional(),
|
@@ -19373,7 +19397,7 @@ function jaccardDistance(column4, value) {
|
|
19373
19397
|
}
|
19374
19398
|
return sql`${column4} <%> ${value}`;
|
19375
19399
|
}
|
19376
|
-
var
|
19400
|
+
var init_vector2 = __esm({
|
19377
19401
|
"../drizzle-orm/dist/sql/functions/vector.js"() {
|
19378
19402
|
"use strict";
|
19379
19403
|
init_sql();
|
@@ -19385,7 +19409,7 @@ var init_functions = __esm({
|
|
19385
19409
|
"../drizzle-orm/dist/sql/functions/index.js"() {
|
19386
19410
|
"use strict";
|
19387
19411
|
init_aggregate();
|
19388
|
-
|
19412
|
+
init_vector2();
|
19389
19413
|
}
|
19390
19414
|
});
|
19391
19415
|
|
@@ -21049,7 +21073,7 @@ var init_sparsevec = __esm({
|
|
21049
21073
|
|
21050
21074
|
// ../drizzle-orm/dist/pg-core/columns/vector_extension/vector.js
|
21051
21075
|
var _a122, _b95, PgVectorBuilder, _a123, _b96, PgVector;
|
21052
|
-
var
|
21076
|
+
var init_vector3 = __esm({
|
21053
21077
|
"../drizzle-orm/dist/pg-core/columns/vector_extension/vector.js"() {
|
21054
21078
|
"use strict";
|
21055
21079
|
init_entity();
|
@@ -21121,7 +21145,7 @@ var init_columns = __esm({
|
|
21121
21145
|
init_bit();
|
21122
21146
|
init_halfvec();
|
21123
21147
|
init_sparsevec();
|
21124
|
-
|
21148
|
+
init_vector3();
|
21125
21149
|
}
|
21126
21150
|
});
|
21127
21151
|
|
@@ -24619,24 +24643,6 @@ var init_pg_core = __esm({
|
|
24619
24643
|
}
|
24620
24644
|
});
|
24621
24645
|
|
24622
|
-
// src/extensions/vector.ts
|
24623
|
-
var vectorOps;
|
24624
|
-
var init_vector3 = __esm({
|
24625
|
-
"src/extensions/vector.ts"() {
|
24626
|
-
"use strict";
|
24627
|
-
vectorOps = [
|
24628
|
-
"vector_l2_ops",
|
24629
|
-
"vector_ip_ops",
|
24630
|
-
"vector_cosine_ops",
|
24631
|
-
"vector_l1_ops",
|
24632
|
-
"bit_hamming_ops",
|
24633
|
-
"bit_jaccard_ops",
|
24634
|
-
"halfvec_l2_ops",
|
24635
|
-
"sparsevec_l2_ops"
|
24636
|
-
];
|
24637
|
-
}
|
24638
|
-
});
|
24639
|
-
|
24640
24646
|
// src/serializer/pgSerializer.ts
|
24641
24647
|
function stringFromIdentityProperty(field) {
|
24642
24648
|
return typeof field === "string" ? field : typeof field === "undefined" ? void 0 : String(field);
|
@@ -24674,7 +24680,7 @@ function buildArrayString(array, sqlType) {
|
|
24674
24680
|
}).join(",");
|
24675
24681
|
return `{${values}}`;
|
24676
24682
|
}
|
24677
|
-
var dialect4, indexName, generatePgSnapshot, trimChar, fromDatabase,
|
24683
|
+
var dialect4, indexName, generatePgSnapshot, trimChar, fromDatabase, defaultForColumn;
|
24678
24684
|
var init_pgSerializer = __esm({
|
24679
24685
|
"src/serializer/pgSerializer.ts"() {
|
24680
24686
|
"use strict";
|
@@ -24682,7 +24688,7 @@ var init_pgSerializer = __esm({
|
|
24682
24688
|
init_dist();
|
24683
24689
|
init_pg_core();
|
24684
24690
|
init_pg_core();
|
24685
|
-
|
24691
|
+
init_vector();
|
24686
24692
|
init_outputs();
|
24687
24693
|
init_utils();
|
24688
24694
|
init_serializer();
|
@@ -24795,7 +24801,7 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
24795
24801
|
columnToSet.default = `'${buildArrayString(
|
24796
24802
|
column4.default,
|
24797
24803
|
sqlTypeLowered
|
24798
|
-
)}'
|
24804
|
+
)}'`;
|
24799
24805
|
} else {
|
24800
24806
|
columnToSet.default = column4.default;
|
24801
24807
|
}
|
@@ -25142,7 +25148,7 @@ ${withStyle.errorWarning(
|
|
25142
25148
|
WHEN 'int2'::regtype THEN 'smallserial'
|
25143
25149
|
END
|
25144
25150
|
ELSE format_type(a.atttypid, a.atttypmod)
|
25145
|
-
END AS data_type, INFORMATION_SCHEMA.COLUMNS.table_name,
|
25151
|
+
END AS data_type, INFORMATION_SCHEMA.COLUMNS.table_name, ns.nspname as type_schema,
|
25146
25152
|
pg_get_serial_sequence('"${tableSchema}"."${tableName}"', a.attname)::regclass as seq_name, INFORMATION_SCHEMA.COLUMNS.column_name,
|
25147
25153
|
INFORMATION_SCHEMA.COLUMNS.column_default, INFORMATION_SCHEMA.COLUMNS.data_type as additional_dt,
|
25148
25154
|
INFORMATION_SCHEMA.COLUMNS.udt_name as enum_name,
|
@@ -25153,6 +25159,7 @@ ${withStyle.errorWarning(
|
|
25153
25159
|
INFORMATION_SCHEMA.COLUMNS.identity_cycle
|
25154
25160
|
FROM pg_attribute a
|
25155
25161
|
JOIN INFORMATION_SCHEMA.COLUMNS ON INFORMATION_SCHEMA.COLUMNS.column_name = a.attname
|
25162
|
+
JOIN pg_type t ON t.oid = a.atttypid LEFT JOIN pg_namespace ns ON ns.oid = t.typnamespace
|
25156
25163
|
WHERE a.attrelid = '"${tableSchema}"."${tableName}"'::regclass and INFORMATION_SCHEMA.COLUMNS.table_name = '${tableName}' and INFORMATION_SCHEMA.COLUMNS.table_schema = '${tableSchema}'
|
25157
25164
|
AND a.attnum > 0
|
25158
25165
|
AND NOT a.attisdropped
|
@@ -25172,30 +25179,42 @@ ${withStyle.errorWarning(
|
|
25172
25179
|
}
|
25173
25180
|
const tableForeignKeys = await db.query(
|
25174
25181
|
`SELECT
|
25175
|
-
|
25176
|
-
|
25177
|
-
|
25178
|
-
|
25179
|
-
|
25180
|
-
|
25181
|
-
|
25182
|
-
|
25183
|
-
|
25184
|
-
|
25185
|
-
|
25186
|
-
|
25187
|
-
|
25188
|
-
|
25189
|
-
|
25190
|
-
|
25191
|
-
|
25192
|
-
|
25193
|
-
|
25194
|
-
|
25195
|
-
|
25196
|
-
|
25197
|
-
|
25198
|
-
|
25182
|
+
con.contype AS constraint_type,
|
25183
|
+
nsp.nspname AS constraint_schema,
|
25184
|
+
con.conname AS constraint_name,
|
25185
|
+
rel.relname AS table_name,
|
25186
|
+
att.attname AS column_name,
|
25187
|
+
fnsp.nspname AS foreign_table_schema,
|
25188
|
+
frel.relname AS foreign_table_name,
|
25189
|
+
fatt.attname AS foreign_column_name,
|
25190
|
+
CASE con.confupdtype
|
25191
|
+
WHEN 'a' THEN 'NO ACTION'
|
25192
|
+
WHEN 'r' THEN 'RESTRICT'
|
25193
|
+
WHEN 'n' THEN 'SET NULL'
|
25194
|
+
WHEN 'c' THEN 'CASCADE'
|
25195
|
+
WHEN 'd' THEN 'SET DEFAULT'
|
25196
|
+
END AS update_rule,
|
25197
|
+
CASE con.confdeltype
|
25198
|
+
WHEN 'a' THEN 'NO ACTION'
|
25199
|
+
WHEN 'r' THEN 'RESTRICT'
|
25200
|
+
WHEN 'n' THEN 'SET NULL'
|
25201
|
+
WHEN 'c' THEN 'CASCADE'
|
25202
|
+
WHEN 'd' THEN 'SET DEFAULT'
|
25203
|
+
END AS delete_rule
|
25204
|
+
FROM
|
25205
|
+
pg_catalog.pg_constraint con
|
25206
|
+
JOIN pg_catalog.pg_class rel ON rel.oid = con.conrelid
|
25207
|
+
JOIN pg_catalog.pg_namespace nsp ON nsp.oid = con.connamespace
|
25208
|
+
LEFT JOIN pg_catalog.pg_attribute att ON att.attnum = ANY (con.conkey)
|
25209
|
+
AND att.attrelid = con.conrelid
|
25210
|
+
LEFT JOIN pg_catalog.pg_class frel ON frel.oid = con.confrelid
|
25211
|
+
LEFT JOIN pg_catalog.pg_namespace fnsp ON fnsp.oid = frel.relnamespace
|
25212
|
+
LEFT JOIN pg_catalog.pg_attribute fatt ON fatt.attnum = ANY (con.confkey)
|
25213
|
+
AND fatt.attrelid = con.confrelid
|
25214
|
+
WHERE
|
25215
|
+
nsp.nspname = '${tableSchema}'
|
25216
|
+
AND rel.relname = '${tableName}'
|
25217
|
+
AND con.contype IN ('f');`
|
25199
25218
|
);
|
25200
25219
|
foreignKeysCount += tableForeignKeys.length;
|
25201
25220
|
if (progressCallback) {
|
@@ -25207,8 +25226,8 @@ ${withStyle.errorWarning(
|
|
25207
25226
|
const columnTo = fk4.foreign_column_name;
|
25208
25227
|
const schemaTo = fk4.foreign_table_schema;
|
25209
25228
|
const foreignKeyName = fk4.constraint_name;
|
25210
|
-
const onUpdate = fk4.update_rule
|
25211
|
-
const onDelete = fk4.delete_rule
|
25229
|
+
const onUpdate = fk4.update_rule?.toLowerCase();
|
25230
|
+
const onDelete = fk4.delete_rule?.toLowerCase();
|
25212
25231
|
if (typeof foreignKeysToReturn[foreignKeyName] !== "undefined") {
|
25213
25232
|
foreignKeysToReturn[foreignKeyName].columnsFrom.push(columnFrom);
|
25214
25233
|
foreignKeysToReturn[foreignKeyName].columnsTo.push(columnTo);
|
@@ -25253,6 +25272,8 @@ ${withStyle.errorWarning(
|
|
25253
25272
|
const columnDimensions = columnResponse.array_dimensions;
|
25254
25273
|
const enumType2 = columnResponse.enum_name;
|
25255
25274
|
let columnType = columnResponse.data_type;
|
25275
|
+
const typeSchema = columnResponse.type_schema;
|
25276
|
+
const defaultValueRes = columnResponse.column_default;
|
25256
25277
|
const isGenerated = columnResponse.is_generated === "ALWAYS";
|
25257
25278
|
const generationExpression = columnResponse.generation_expression;
|
25258
25279
|
const isIdentity = columnResponse.is_identity === "YES";
|
@@ -25283,12 +25304,7 @@ ${withStyle.errorWarning(
|
|
25283
25304
|
columns: cprimaryKey.map((c) => c.column_name)
|
25284
25305
|
};
|
25285
25306
|
}
|
25286
|
-
const defaultValue = defaultForColumn(columnResponse);
|
25287
|
-
const isSerial = columnType === "serial";
|
25288
25307
|
let columnTypeMapped = columnType;
|
25289
|
-
if (columnTypeMapped.startsWith("numeric(")) {
|
25290
|
-
columnTypeMapped = columnTypeMapped.replace(",", ", ");
|
25291
|
-
}
|
25292
25308
|
if (columnAdditionalDT === "ARRAY") {
|
25293
25309
|
if (typeof internals.tables[tableName] === "undefined") {
|
25294
25310
|
internals.tables[tableName] = {
|
@@ -25316,6 +25332,34 @@ ${withStyle.errorWarning(
|
|
25316
25332
|
}
|
25317
25333
|
}
|
25318
25334
|
}
|
25335
|
+
const defaultValue = defaultForColumn(
|
25336
|
+
columnResponse,
|
25337
|
+
internals,
|
25338
|
+
tableName
|
25339
|
+
);
|
25340
|
+
if (defaultValue === "NULL" || defaultValueRes && defaultValueRes.startsWith("(") && defaultValueRes.endsWith(")")) {
|
25341
|
+
if (typeof internals.tables[tableName] === "undefined") {
|
25342
|
+
internals.tables[tableName] = {
|
25343
|
+
columns: {
|
25344
|
+
[columnName]: {
|
25345
|
+
isDefaultAnExpression: true
|
25346
|
+
}
|
25347
|
+
}
|
25348
|
+
};
|
25349
|
+
} else {
|
25350
|
+
if (typeof internals.tables[tableName].columns[columnName] === "undefined") {
|
25351
|
+
internals.tables[tableName].columns[columnName] = {
|
25352
|
+
isDefaultAnExpression: true
|
25353
|
+
};
|
25354
|
+
} else {
|
25355
|
+
internals.tables[tableName].columns[columnName].isDefaultAnExpression = true;
|
25356
|
+
}
|
25357
|
+
}
|
25358
|
+
}
|
25359
|
+
const isSerial = columnType === "serial";
|
25360
|
+
if (columnTypeMapped.startsWith("numeric(")) {
|
25361
|
+
columnTypeMapped = columnTypeMapped.replace(",", ", ");
|
25362
|
+
}
|
25319
25363
|
if (columnAdditionalDT === "ARRAY") {
|
25320
25364
|
for (let i = 1; i < Number(columnDimensions); i++) {
|
25321
25365
|
columnTypeMapped += "[]";
|
@@ -25329,7 +25373,7 @@ ${withStyle.errorWarning(
|
|
25329
25373
|
// filter vectors, but in future we should filter any extension that was installed by user
|
25330
25374
|
columnAdditionalDT === "USER-DEFINED" && !["vector", "geometry"].includes(enumType2) ? enumType2 : columnTypeMapped
|
25331
25375
|
),
|
25332
|
-
typeSchema: enumsToReturn[`${
|
25376
|
+
typeSchema: enumsToReturn[`${typeSchema}.${enumType2}`] !== void 0 ? enumsToReturn[`${typeSchema}.${enumType2}`].schema : void 0,
|
25333
25377
|
primaryKey: primaryKey.length === 1 && cprimaryKey.length < 2,
|
25334
25378
|
// default: isSerial ? undefined : defaultValue,
|
25335
25379
|
notNull: columnResponse.is_nullable === "NO",
|
@@ -25347,7 +25391,7 @@ ${withStyle.errorWarning(
|
|
25347
25391
|
} : void 0
|
25348
25392
|
};
|
25349
25393
|
if (identityName) {
|
25350
|
-
delete sequencesToReturn[`${tableSchema}.${identityName}`];
|
25394
|
+
delete sequencesToReturn[`${tableSchema}.${identityName.startsWith('"') && identityName.endsWith('"') ? identityName.slice(1, -1) : identityName}`];
|
25351
25395
|
delete sequencesToReturn[identityName];
|
25352
25396
|
}
|
25353
25397
|
if (!isSerial && typeof defaultValue !== "undefined") {
|
@@ -25500,59 +25544,71 @@ ${withStyle.errorWarning(
|
|
25500
25544
|
internal: internals
|
25501
25545
|
};
|
25502
25546
|
};
|
25503
|
-
|
25504
|
-
|
25505
|
-
|
25506
|
-
// "character varying": "::character varying",
|
25507
|
-
// "double precision": "::double precision",
|
25508
|
-
// "time with time zone": "::time with time zone",
|
25509
|
-
"time without time zone": "::time without time zone",
|
25510
|
-
// "timestamp with time zone": "::timestamp with time zone",
|
25511
|
-
"timestamp without time zone": "::timestamp without time zone",
|
25512
|
-
"timestamp(": "::timestamp without time zone",
|
25513
|
-
// date: "::date",
|
25514
|
-
// interval: "::interval",
|
25515
|
-
// character: "::bpchar",
|
25516
|
-
// macaddr8: "::macaddr8",
|
25517
|
-
// macaddr: "::macaddr",
|
25518
|
-
// inet: "::inet",
|
25519
|
-
// cidr: "::cidr",
|
25520
|
-
// jsonb: "::jsonb",
|
25521
|
-
// json: "::json",
|
25522
|
-
"character(": "::bpchar"
|
25523
|
-
};
|
25524
|
-
defaultForColumn = (column4) => {
|
25547
|
+
defaultForColumn = (column4, internals, tableName) => {
|
25548
|
+
const columnName = column4.attname;
|
25549
|
+
const isArray = internals?.tables[tableName]?.columns[columnName]?.isArray ?? false;
|
25525
25550
|
if (column4.column_default === null) {
|
25526
25551
|
return void 0;
|
25527
25552
|
}
|
25528
25553
|
if (column4.data_type === "serial" || column4.data_type === "smallserial" || column4.data_type === "bigserial") {
|
25529
25554
|
return void 0;
|
25530
25555
|
}
|
25531
|
-
|
25556
|
+
if (column4.column_default.endsWith("[]")) {
|
25557
|
+
column4.column_default = column4.column_default.slice(0, -2);
|
25558
|
+
}
|
25559
|
+
column4.column_default = column4.column_default.replace(/::(.*?)(?<![^\w"])(?=$)/, "");
|
25532
25560
|
const columnDefaultAsString = column4.column_default.toString();
|
25533
|
-
if (
|
25534
|
-
|
25535
|
-
|
25536
|
-
|
25537
|
-
|
25538
|
-
|
25539
|
-
|
25540
|
-
|
25541
|
-
|
25542
|
-
|
25543
|
-
|
25544
|
-
|
25545
|
-
|
25546
|
-
|
25547
|
-
|
25548
|
-
|
25549
|
-
|
25561
|
+
if (isArray) {
|
25562
|
+
return `'{${columnDefaultAsString.slice(2, -2).split(/\s*,\s*/g).map((value) => {
|
25563
|
+
if (["integer", "smallint", "bigint", "double precision", "real"].includes(column4.data_type.slice(0, -2))) {
|
25564
|
+
return value;
|
25565
|
+
} else if (column4.data_type.startsWith("timestamp")) {
|
25566
|
+
return `${value}`;
|
25567
|
+
} else if (column4.data_type.slice(0, -2) === "interval") {
|
25568
|
+
return value.replaceAll('"', `"`);
|
25569
|
+
} else if (column4.data_type.slice(0, -2) === "boolean") {
|
25570
|
+
return value === "t" ? "true" : "false";
|
25571
|
+
} else if (["json", "jsonb"].includes(column4.data_type.slice(0, -2))) {
|
25572
|
+
return JSON.stringify(JSON.stringify(JSON.parse(JSON.parse(value)), null, 0));
|
25573
|
+
} else {
|
25574
|
+
return `"${value}"`;
|
25575
|
+
}
|
25576
|
+
}).join(",")}}'`;
|
25577
|
+
}
|
25578
|
+
if (["integer", "smallint", "bigint", "double precision", "real"].includes(column4.data_type)) {
|
25579
|
+
if (/^-?[\d.]+(?:e-?\d+)?$/.test(columnDefaultAsString)) {
|
25550
25580
|
return Number(columnDefaultAsString);
|
25551
|
-
} else if (column4.data_type === "boolean") {
|
25552
|
-
return column4.column_default === "true";
|
25553
25581
|
} else {
|
25554
|
-
|
25582
|
+
if (typeof internals.tables[tableName] === "undefined") {
|
25583
|
+
internals.tables[tableName] = {
|
25584
|
+
columns: {
|
25585
|
+
[columnName]: {
|
25586
|
+
isDefaultAnExpression: true
|
25587
|
+
}
|
25588
|
+
}
|
25589
|
+
};
|
25590
|
+
} else {
|
25591
|
+
if (typeof internals.tables[tableName].columns[columnName] === "undefined") {
|
25592
|
+
internals.tables[tableName].columns[columnName] = {
|
25593
|
+
isDefaultAnExpression: true
|
25594
|
+
};
|
25595
|
+
} else {
|
25596
|
+
internals.tables[tableName].columns[columnName].isDefaultAnExpression = true;
|
25597
|
+
}
|
25598
|
+
}
|
25599
|
+
return columnDefaultAsString;
|
25555
25600
|
}
|
25601
|
+
} else if (column4.data_type === "json" || column4.data_type === "jsonb") {
|
25602
|
+
const jsonWithoutSpaces = JSON.stringify(JSON.parse(columnDefaultAsString.slice(1, -1)));
|
25603
|
+
return `'${jsonWithoutSpaces}'::${column4.data_type}`;
|
25604
|
+
} else if (column4.data_type === "boolean") {
|
25605
|
+
return column4.column_default === "true";
|
25606
|
+
} else if (columnDefaultAsString === "NULL") {
|
25607
|
+
return `NULL`;
|
25608
|
+
} else if (columnDefaultAsString.startsWith("'") && columnDefaultAsString.endsWith("'")) {
|
25609
|
+
return columnDefaultAsString;
|
25610
|
+
} else {
|
25611
|
+
return `${columnDefaultAsString.replace(/\\/g, "`\\")}`;
|
25556
25612
|
}
|
25557
25613
|
};
|
25558
25614
|
}
|
@@ -33880,9 +33936,9 @@ var init_cli = __esm({
|
|
33880
33936
|
tablesFilter: unionType([stringType(), stringType().array()]).optional(),
|
33881
33937
|
schemaFilter: unionType([stringType(), stringType().array()]).optional().default(["public"]),
|
33882
33938
|
extensionsFilters: literalType("postgis").array().optional(),
|
33883
|
-
|
33939
|
+
casing,
|
33884
33940
|
breakpoints: booleanType().optional().default(true),
|
33885
|
-
|
33941
|
+
migrations: objectType({
|
33886
33942
|
prefix: prefix.optional().default("index")
|
33887
33943
|
}).optional()
|
33888
33944
|
}).passthrough();
|
@@ -33976,6 +34032,10 @@ var init_postgres = __esm({
|
|
33976
34032
|
database: stringType().min(1),
|
33977
34033
|
secretArn: stringType().min(1),
|
33978
34034
|
resourceArn: stringType().min(1)
|
34035
|
+
}),
|
34036
|
+
objectType({
|
34037
|
+
driver: literalType("pglite"),
|
34038
|
+
url: stringType().min(1)
|
33979
34039
|
})
|
33980
34040
|
]);
|
33981
34041
|
}
|