drizzle-kit 0.21.2-7202142 → 0.21.2-9c89270
Sign up to get free protection for your applications and to get access to all the features.
- package/bin.cjs +17923 -11634
- package/index.d.mts +9 -1
- package/index.d.ts +9 -1
- package/package.json +4 -3
- package/payload.d.mts +8 -100
- package/payload.d.ts +8 -100
- package/payload.js +1207 -1532
- package/payload.mjs +1207 -1532
- package/utils-studio.js +40 -98
- package/utils-studio.mjs +40 -98
- package/utils.js +2 -14
- package/utils.mjs +2 -14
package/utils-studio.js
CHANGED
@@ -4498,7 +4498,7 @@ var init_mysqlSchema = __esm({
|
|
4498
4498
|
});
|
4499
4499
|
|
4500
4500
|
// src/serializer/pgSchema.ts
|
4501
|
-
var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1,
|
4501
|
+
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;
|
4502
4502
|
var init_pgSchema = __esm({
|
4503
4503
|
"src/serializer/pgSchema.ts"() {
|
4504
4504
|
"use strict";
|
@@ -4566,21 +4566,10 @@ var init_pgSchema = __esm({
|
|
4566
4566
|
tables: recordType(stringType(), tableV1),
|
4567
4567
|
enums: recordType(stringType(), enumSchemaV1)
|
4568
4568
|
}).strict();
|
4569
|
-
indexColumn = objectType({
|
4570
|
-
expression: stringType(),
|
4571
|
-
isExpression: booleanType(),
|
4572
|
-
asc: booleanType(),
|
4573
|
-
nulls: stringType().optional(),
|
4574
|
-
opclass: stringType().optional()
|
4575
|
-
});
|
4576
4569
|
index2 = objectType({
|
4577
4570
|
name: stringType(),
|
4578
|
-
columns:
|
4579
|
-
isUnique: booleanType()
|
4580
|
-
with: recordType(stringType(), anyType()).optional(),
|
4581
|
-
method: stringType().default("btree"),
|
4582
|
-
where: stringType().optional(),
|
4583
|
-
concurrently: booleanType().default(false)
|
4571
|
+
columns: stringType().array(),
|
4572
|
+
isUnique: booleanType()
|
4584
4573
|
}).strict();
|
4585
4574
|
fk2 = objectType({
|
4586
4575
|
name: stringType(),
|
@@ -4977,12 +4966,24 @@ var init_sqliteSerializer = __esm({
|
|
4977
4966
|
`SELECT
|
4978
4967
|
m.name as "tableName", p.name as "columnName", p.type as "columnType", p."notnull" as "notNull", p.dflt_value as "defaultValue", p.pk as pk
|
4979
4968
|
FROM sqlite_master AS m JOIN pragma_table_info(m.name) AS p
|
4980
|
-
WHERE m.type = 'table'
|
4969
|
+
WHERE m.type = 'table'
|
4970
|
+
and m.tbl_name != 'sqlite_sequence'
|
4971
|
+
and m.tbl_name != 'sqlite_stat1'
|
4972
|
+
and m.tbl_name != '_litestream_seq'
|
4973
|
+
and m.tbl_name != '_litestream_lock'
|
4974
|
+
and m.tbl_name != 'libsql_wasm_func_table'
|
4975
|
+
and m.tbl_name != '__drizzle_migrations'
|
4976
|
+
and m.tbl_name != '_cf_KV';
|
4981
4977
|
`
|
4982
4978
|
);
|
4983
4979
|
const tablesWithSeq = [];
|
4984
4980
|
const seq = await db.query(
|
4985
|
-
`SELECT * FROM sqlite_master WHERE name != 'sqlite_sequence'
|
4981
|
+
`SELECT * FROM sqlite_master WHERE name != 'sqlite_sequence'
|
4982
|
+
and name != 'sqlite_stat1'
|
4983
|
+
and name != '_litestream_seq'
|
4984
|
+
and name != '_litestream_lock'
|
4985
|
+
and tbl_name != '_cf_KV'
|
4986
|
+
and sql GLOB '*[ *' || CHAR(9) || CHAR(10) || CHAR(13) || ']AUTOINCREMENT[^'']*';`
|
4986
4987
|
);
|
4987
4988
|
for (const s of seq) {
|
4988
4989
|
tablesWithSeq.push(s.name);
|
@@ -5067,7 +5068,8 @@ var init_sqliteSerializer = __esm({
|
|
5067
5068
|
try {
|
5068
5069
|
const fks = await db.query(
|
5069
5070
|
`SELECT m.name as "tableFrom", f.id as "id", f."table" as "tableTo", f."from", f."to", f."on_update" as "onUpdate", f."on_delete" as "onDelete", f.seq as "seq"
|
5070
|
-
FROM sqlite_master m, pragma_foreign_key_list(m.name) as f
|
5071
|
+
FROM sqlite_master m, pragma_foreign_key_list(m.name) as f
|
5072
|
+
where m.tbl_name != '_cf_KV';`
|
5071
5073
|
);
|
5072
5074
|
const fkByTableName = {};
|
5073
5075
|
for (const fkRow of fks) {
|
@@ -5126,7 +5128,9 @@ FROM sqlite_master AS m,
|
|
5126
5128
|
pragma_index_list(m.name) AS il,
|
5127
5129
|
pragma_index_info(il.name) AS ii
|
5128
5130
|
WHERE
|
5129
|
-
m.type = 'table'
|
5131
|
+
m.type = 'table'
|
5132
|
+
and il.name NOT LIKE 'sqlite_autoindex_%'
|
5133
|
+
and m.tbl_name != '_cf_KV';`
|
5130
5134
|
);
|
5131
5135
|
for (const idxRow of idxs) {
|
5132
5136
|
const tableName = idxRow.tableName;
|
@@ -5650,10 +5654,7 @@ var init_pgSerializer = __esm({
|
|
5650
5654
|
columnTypeMapped = trimChar(columnTypeMapped, '"');
|
5651
5655
|
columnToReturn[columnName] = {
|
5652
5656
|
name: columnName,
|
5653
|
-
type:
|
5654
|
-
// filter vectors, but in future we should filter any extension that was installed by user
|
5655
|
-
columnAdditionalDT === "USER-DEFINED" && enumType3 !== "vector" ? enumType3 : columnTypeMapped
|
5656
|
-
),
|
5657
|
+
type: columnAdditionalDT === "USER-DEFINED" ? enumType3 : columnTypeMapped,
|
5657
5658
|
typeSchema: enumsToReturn[`${tableSchema}.${enumType3}`] !== void 0 ? enumsToReturn[`${tableSchema}.${enumType3}`].schema : void 0,
|
5658
5659
|
primaryKey: primaryKey.length === 1 && cprimaryKey.length < 2,
|
5659
5660
|
// default: isSerial ? undefined : defaultValue,
|
@@ -5664,42 +5665,15 @@ var init_pgSerializer = __esm({
|
|
5664
5665
|
}
|
5665
5666
|
}
|
5666
5667
|
const dbIndexes = await db.query(
|
5667
|
-
`SELECT
|
5668
|
-
|
5669
|
-
|
5670
|
-
|
5671
|
-
|
5672
|
-
|
5673
|
-
|
5674
|
-
|
5675
|
-
|
5676
|
-
)
|
5677
|
-
|| '}')::text[]
|
5678
|
-
)[k.i]
|
5679
|
-
) AS column_name,
|
5680
|
-
CASE
|
5681
|
-
WHEN pg_get_expr(i.indexprs, i.indrelid) IS NOT NULL THEN 1
|
5682
|
-
ELSE 0
|
5683
|
-
END AS is_expression,
|
5684
|
-
i.indoption[k.i-1] & 1 = 1 AS descending,
|
5685
|
-
i.indoption[k.i-1] & 2 = 2 AS nulls_first,
|
5686
|
-
pg_get_expr(
|
5687
|
-
i.indpred,
|
5688
|
-
i.indrelid
|
5689
|
-
) as where,
|
5690
|
-
opc.opcname
|
5691
|
-
FROM pg_class t
|
5692
|
-
LEFT JOIN pg_index i ON t.oid = i.indrelid
|
5693
|
-
LEFT JOIN pg_class ic ON ic.oid = i.indexrelid
|
5694
|
-
CROSS JOIN LATERAL (SELECT unnest(i.indkey), generate_subscripts(i.indkey, 1) + 1) AS k(attnum, i)
|
5695
|
-
LEFT JOIN pg_attribute AS a
|
5696
|
-
ON i.indrelid = a.attrelid AND k.attnum = a.attnum
|
5697
|
-
JOIN pg_namespace c on c.oid = t.relnamespace
|
5698
|
-
LEFT JOIN pg_am AS am ON ic.relam = am.oid
|
5699
|
-
JOIN pg_opclass opc ON opc.oid = ANY(i.indclass)
|
5700
|
-
WHERE
|
5701
|
-
c.nspname = '${tableSchema}' AND
|
5702
|
-
t.relname = '${tableName}';`
|
5668
|
+
`SELECT t.relname as table_name, i.relname AS index_name, ix.indisunique AS is_unique, a.attname AS column_name
|
5669
|
+
FROM pg_class t
|
5670
|
+
JOIN pg_index ix ON t.oid = ix.indrelid
|
5671
|
+
JOIN pg_class i ON i.oid = ix.indexrelid
|
5672
|
+
JOIN pg_attribute a ON a.attrelid = t.oid AND a.attnum = ANY(ix.indkey)
|
5673
|
+
JOIN pg_namespace ns ON ns.oid = t.relnamespace
|
5674
|
+
WHERE ns.nspname = '${tableSchema}'
|
5675
|
+
AND t.relname = '${tableName}'
|
5676
|
+
and ix.indisprimary = false;`
|
5703
5677
|
);
|
5704
5678
|
const dbIndexFromConstraint = await db.query(
|
5705
5679
|
`SELECT
|
@@ -5716,51 +5690,18 @@ var init_pgSerializer = __esm({
|
|
5716
5690
|
);
|
5717
5691
|
const idxsInConsteraint = dbIndexFromConstraint.filter((it) => it.generated_by_constraint === 1).map((it) => it.index_name);
|
5718
5692
|
for (const dbIndex of dbIndexes) {
|
5719
|
-
const indexName = dbIndex.
|
5693
|
+
const indexName = dbIndex.index_name;
|
5720
5694
|
const indexColumnName = dbIndex.column_name;
|
5721
5695
|
const indexIsUnique = dbIndex.is_unique;
|
5722
|
-
const indexMethod = dbIndex.method;
|
5723
|
-
const indexWith = dbIndex.with;
|
5724
|
-
const indexWhere = dbIndex.where;
|
5725
|
-
const opclass = dbIndex.opcname;
|
5726
|
-
const isExpression = dbIndex.is_expression === 1;
|
5727
|
-
const desc = dbIndex.descending;
|
5728
|
-
const nullsFirst = dbIndex.nulls_first;
|
5729
|
-
const mappedWith = {};
|
5730
|
-
if (indexWith !== null) {
|
5731
|
-
indexWith.forEach((it) => {
|
5732
|
-
const splitted = it.split("=");
|
5733
|
-
mappedWith[splitted[0]] = splitted[1];
|
5734
|
-
});
|
5735
|
-
}
|
5736
5696
|
if (idxsInConsteraint.includes(indexName))
|
5737
5697
|
continue;
|
5738
5698
|
if (typeof indexToReturn[indexName] !== "undefined") {
|
5739
|
-
indexToReturn[indexName].columns.push(
|
5740
|
-
expression: indexColumnName,
|
5741
|
-
asc: !desc,
|
5742
|
-
nulls: nullsFirst ? "first" : "last",
|
5743
|
-
opclass,
|
5744
|
-
isExpression
|
5745
|
-
});
|
5699
|
+
indexToReturn[indexName].columns.push(indexColumnName);
|
5746
5700
|
} else {
|
5747
5701
|
indexToReturn[indexName] = {
|
5748
5702
|
name: indexName,
|
5749
|
-
columns: [
|
5750
|
-
|
5751
|
-
expression: indexColumnName,
|
5752
|
-
asc: !desc,
|
5753
|
-
nulls: nullsFirst ? "first" : "last",
|
5754
|
-
opclass,
|
5755
|
-
isExpression
|
5756
|
-
}
|
5757
|
-
],
|
5758
|
-
isUnique: indexIsUnique,
|
5759
|
-
// should not be a part of diff detecs
|
5760
|
-
concurrently: false,
|
5761
|
-
method: indexMethod,
|
5762
|
-
where: indexWhere === null ? void 0 : indexWhere,
|
5763
|
-
with: mappedWith
|
5703
|
+
columns: [indexColumnName],
|
5704
|
+
isUnique: indexIsUnique
|
5764
5705
|
};
|
5765
5706
|
}
|
5766
5707
|
}
|
@@ -5818,6 +5759,7 @@ var init_pgSerializer = __esm({
|
|
5818
5759
|
"time without time zone": "::time without time zone",
|
5819
5760
|
// "timestamp with time zone": "::timestamp with time zone",
|
5820
5761
|
"timestamp without time zone": "::timestamp without time zone",
|
5762
|
+
"timestamp(": "::timestamp without time zone",
|
5821
5763
|
// date: "::date",
|
5822
5764
|
// interval: "::interval",
|
5823
5765
|
// character: "::bpchar",
|
@@ -5830,15 +5772,15 @@ var init_pgSerializer = __esm({
|
|
5830
5772
|
"character(": "::bpchar"
|
5831
5773
|
};
|
5832
5774
|
defaultForColumn = (column4) => {
|
5775
|
+
if (column4.column_default === null) {
|
5776
|
+
return void 0;
|
5777
|
+
}
|
5833
5778
|
if (column4.data_type === "serial" || column4.data_type === "smallserial" || column4.data_type === "bigserial") {
|
5834
5779
|
return void 0;
|
5835
5780
|
}
|
5836
5781
|
const hasDifferentDefaultCast = Object.keys(columnToDefault).find(
|
5837
5782
|
(it) => column4.data_type.startsWith(it)
|
5838
5783
|
);
|
5839
|
-
if (column4.column_default === null) {
|
5840
|
-
return void 0;
|
5841
|
-
}
|
5842
5784
|
const columnDefaultAsString = column4.column_default.toString();
|
5843
5785
|
if (columnDefaultAsString.endsWith(
|
5844
5786
|
hasDifferentDefaultCast ? columnToDefault[hasDifferentDefaultCast] : column4.data_type
|
package/utils-studio.mjs
CHANGED
@@ -4499,7 +4499,7 @@ var init_mysqlSchema = __esm({
|
|
4499
4499
|
});
|
4500
4500
|
|
4501
4501
|
// src/serializer/pgSchema.ts
|
4502
|
-
var indexV2, columnV2, tableV2, enumSchemaV1, enumSchema, pgSchemaV2, references, columnV1, tableV1, pgSchemaV1,
|
4502
|
+
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;
|
4503
4503
|
var init_pgSchema = __esm({
|
4504
4504
|
"src/serializer/pgSchema.ts"() {
|
4505
4505
|
"use strict";
|
@@ -4567,21 +4567,10 @@ var init_pgSchema = __esm({
|
|
4567
4567
|
tables: recordType(stringType(), tableV1),
|
4568
4568
|
enums: recordType(stringType(), enumSchemaV1)
|
4569
4569
|
}).strict();
|
4570
|
-
indexColumn = objectType({
|
4571
|
-
expression: stringType(),
|
4572
|
-
isExpression: booleanType(),
|
4573
|
-
asc: booleanType(),
|
4574
|
-
nulls: stringType().optional(),
|
4575
|
-
opclass: stringType().optional()
|
4576
|
-
});
|
4577
4570
|
index2 = objectType({
|
4578
4571
|
name: stringType(),
|
4579
|
-
columns:
|
4580
|
-
isUnique: booleanType()
|
4581
|
-
with: recordType(stringType(), anyType()).optional(),
|
4582
|
-
method: stringType().default("btree"),
|
4583
|
-
where: stringType().optional(),
|
4584
|
-
concurrently: booleanType().default(false)
|
4572
|
+
columns: stringType().array(),
|
4573
|
+
isUnique: booleanType()
|
4585
4574
|
}).strict();
|
4586
4575
|
fk2 = objectType({
|
4587
4576
|
name: stringType(),
|
@@ -4982,12 +4971,24 @@ var init_sqliteSerializer = __esm({
|
|
4982
4971
|
`SELECT
|
4983
4972
|
m.name as "tableName", p.name as "columnName", p.type as "columnType", p."notnull" as "notNull", p.dflt_value as "defaultValue", p.pk as pk
|
4984
4973
|
FROM sqlite_master AS m JOIN pragma_table_info(m.name) AS p
|
4985
|
-
WHERE m.type = 'table'
|
4974
|
+
WHERE m.type = 'table'
|
4975
|
+
and m.tbl_name != 'sqlite_sequence'
|
4976
|
+
and m.tbl_name != 'sqlite_stat1'
|
4977
|
+
and m.tbl_name != '_litestream_seq'
|
4978
|
+
and m.tbl_name != '_litestream_lock'
|
4979
|
+
and m.tbl_name != 'libsql_wasm_func_table'
|
4980
|
+
and m.tbl_name != '__drizzle_migrations'
|
4981
|
+
and m.tbl_name != '_cf_KV';
|
4986
4982
|
`
|
4987
4983
|
);
|
4988
4984
|
const tablesWithSeq = [];
|
4989
4985
|
const seq = await db.query(
|
4990
|
-
`SELECT * FROM sqlite_master WHERE name != 'sqlite_sequence'
|
4986
|
+
`SELECT * FROM sqlite_master WHERE name != 'sqlite_sequence'
|
4987
|
+
and name != 'sqlite_stat1'
|
4988
|
+
and name != '_litestream_seq'
|
4989
|
+
and name != '_litestream_lock'
|
4990
|
+
and tbl_name != '_cf_KV'
|
4991
|
+
and sql GLOB '*[ *' || CHAR(9) || CHAR(10) || CHAR(13) || ']AUTOINCREMENT[^'']*';`
|
4991
4992
|
);
|
4992
4993
|
for (const s of seq) {
|
4993
4994
|
tablesWithSeq.push(s.name);
|
@@ -5072,7 +5073,8 @@ var init_sqliteSerializer = __esm({
|
|
5072
5073
|
try {
|
5073
5074
|
const fks = await db.query(
|
5074
5075
|
`SELECT m.name as "tableFrom", f.id as "id", f."table" as "tableTo", f."from", f."to", f."on_update" as "onUpdate", f."on_delete" as "onDelete", f.seq as "seq"
|
5075
|
-
FROM sqlite_master m, pragma_foreign_key_list(m.name) as f
|
5076
|
+
FROM sqlite_master m, pragma_foreign_key_list(m.name) as f
|
5077
|
+
where m.tbl_name != '_cf_KV';`
|
5076
5078
|
);
|
5077
5079
|
const fkByTableName = {};
|
5078
5080
|
for (const fkRow of fks) {
|
@@ -5131,7 +5133,9 @@ FROM sqlite_master AS m,
|
|
5131
5133
|
pragma_index_list(m.name) AS il,
|
5132
5134
|
pragma_index_info(il.name) AS ii
|
5133
5135
|
WHERE
|
5134
|
-
m.type = 'table'
|
5136
|
+
m.type = 'table'
|
5137
|
+
and il.name NOT LIKE 'sqlite_autoindex_%'
|
5138
|
+
and m.tbl_name != '_cf_KV';`
|
5135
5139
|
);
|
5136
5140
|
for (const idxRow of idxs) {
|
5137
5141
|
const tableName = idxRow.tableName;
|
@@ -5659,10 +5663,7 @@ var init_pgSerializer = __esm({
|
|
5659
5663
|
columnTypeMapped = trimChar(columnTypeMapped, '"');
|
5660
5664
|
columnToReturn[columnName] = {
|
5661
5665
|
name: columnName,
|
5662
|
-
type:
|
5663
|
-
// filter vectors, but in future we should filter any extension that was installed by user
|
5664
|
-
columnAdditionalDT === "USER-DEFINED" && enumType3 !== "vector" ? enumType3 : columnTypeMapped
|
5665
|
-
),
|
5666
|
+
type: columnAdditionalDT === "USER-DEFINED" ? enumType3 : columnTypeMapped,
|
5666
5667
|
typeSchema: enumsToReturn[`${tableSchema}.${enumType3}`] !== void 0 ? enumsToReturn[`${tableSchema}.${enumType3}`].schema : void 0,
|
5667
5668
|
primaryKey: primaryKey.length === 1 && cprimaryKey.length < 2,
|
5668
5669
|
// default: isSerial ? undefined : defaultValue,
|
@@ -5673,42 +5674,15 @@ var init_pgSerializer = __esm({
|
|
5673
5674
|
}
|
5674
5675
|
}
|
5675
5676
|
const dbIndexes = await db.query(
|
5676
|
-
`SELECT
|
5677
|
-
|
5678
|
-
|
5679
|
-
|
5680
|
-
|
5681
|
-
|
5682
|
-
|
5683
|
-
|
5684
|
-
|
5685
|
-
)
|
5686
|
-
|| '}')::text[]
|
5687
|
-
)[k.i]
|
5688
|
-
) AS column_name,
|
5689
|
-
CASE
|
5690
|
-
WHEN pg_get_expr(i.indexprs, i.indrelid) IS NOT NULL THEN 1
|
5691
|
-
ELSE 0
|
5692
|
-
END AS is_expression,
|
5693
|
-
i.indoption[k.i-1] & 1 = 1 AS descending,
|
5694
|
-
i.indoption[k.i-1] & 2 = 2 AS nulls_first,
|
5695
|
-
pg_get_expr(
|
5696
|
-
i.indpred,
|
5697
|
-
i.indrelid
|
5698
|
-
) as where,
|
5699
|
-
opc.opcname
|
5700
|
-
FROM pg_class t
|
5701
|
-
LEFT JOIN pg_index i ON t.oid = i.indrelid
|
5702
|
-
LEFT JOIN pg_class ic ON ic.oid = i.indexrelid
|
5703
|
-
CROSS JOIN LATERAL (SELECT unnest(i.indkey), generate_subscripts(i.indkey, 1) + 1) AS k(attnum, i)
|
5704
|
-
LEFT JOIN pg_attribute AS a
|
5705
|
-
ON i.indrelid = a.attrelid AND k.attnum = a.attnum
|
5706
|
-
JOIN pg_namespace c on c.oid = t.relnamespace
|
5707
|
-
LEFT JOIN pg_am AS am ON ic.relam = am.oid
|
5708
|
-
JOIN pg_opclass opc ON opc.oid = ANY(i.indclass)
|
5709
|
-
WHERE
|
5710
|
-
c.nspname = '${tableSchema}' AND
|
5711
|
-
t.relname = '${tableName}';`
|
5677
|
+
`SELECT t.relname as table_name, i.relname AS index_name, ix.indisunique AS is_unique, a.attname AS column_name
|
5678
|
+
FROM pg_class t
|
5679
|
+
JOIN pg_index ix ON t.oid = ix.indrelid
|
5680
|
+
JOIN pg_class i ON i.oid = ix.indexrelid
|
5681
|
+
JOIN pg_attribute a ON a.attrelid = t.oid AND a.attnum = ANY(ix.indkey)
|
5682
|
+
JOIN pg_namespace ns ON ns.oid = t.relnamespace
|
5683
|
+
WHERE ns.nspname = '${tableSchema}'
|
5684
|
+
AND t.relname = '${tableName}'
|
5685
|
+
and ix.indisprimary = false;`
|
5712
5686
|
);
|
5713
5687
|
const dbIndexFromConstraint = await db.query(
|
5714
5688
|
`SELECT
|
@@ -5725,51 +5699,18 @@ var init_pgSerializer = __esm({
|
|
5725
5699
|
);
|
5726
5700
|
const idxsInConsteraint = dbIndexFromConstraint.filter((it) => it.generated_by_constraint === 1).map((it) => it.index_name);
|
5727
5701
|
for (const dbIndex of dbIndexes) {
|
5728
|
-
const indexName = dbIndex.
|
5702
|
+
const indexName = dbIndex.index_name;
|
5729
5703
|
const indexColumnName = dbIndex.column_name;
|
5730
5704
|
const indexIsUnique = dbIndex.is_unique;
|
5731
|
-
const indexMethod = dbIndex.method;
|
5732
|
-
const indexWith = dbIndex.with;
|
5733
|
-
const indexWhere = dbIndex.where;
|
5734
|
-
const opclass = dbIndex.opcname;
|
5735
|
-
const isExpression = dbIndex.is_expression === 1;
|
5736
|
-
const desc = dbIndex.descending;
|
5737
|
-
const nullsFirst = dbIndex.nulls_first;
|
5738
|
-
const mappedWith = {};
|
5739
|
-
if (indexWith !== null) {
|
5740
|
-
indexWith.forEach((it) => {
|
5741
|
-
const splitted = it.split("=");
|
5742
|
-
mappedWith[splitted[0]] = splitted[1];
|
5743
|
-
});
|
5744
|
-
}
|
5745
5705
|
if (idxsInConsteraint.includes(indexName))
|
5746
5706
|
continue;
|
5747
5707
|
if (typeof indexToReturn[indexName] !== "undefined") {
|
5748
|
-
indexToReturn[indexName].columns.push(
|
5749
|
-
expression: indexColumnName,
|
5750
|
-
asc: !desc,
|
5751
|
-
nulls: nullsFirst ? "first" : "last",
|
5752
|
-
opclass,
|
5753
|
-
isExpression
|
5754
|
-
});
|
5708
|
+
indexToReturn[indexName].columns.push(indexColumnName);
|
5755
5709
|
} else {
|
5756
5710
|
indexToReturn[indexName] = {
|
5757
5711
|
name: indexName,
|
5758
|
-
columns: [
|
5759
|
-
|
5760
|
-
expression: indexColumnName,
|
5761
|
-
asc: !desc,
|
5762
|
-
nulls: nullsFirst ? "first" : "last",
|
5763
|
-
opclass,
|
5764
|
-
isExpression
|
5765
|
-
}
|
5766
|
-
],
|
5767
|
-
isUnique: indexIsUnique,
|
5768
|
-
// should not be a part of diff detecs
|
5769
|
-
concurrently: false,
|
5770
|
-
method: indexMethod,
|
5771
|
-
where: indexWhere === null ? void 0 : indexWhere,
|
5772
|
-
with: mappedWith
|
5712
|
+
columns: [indexColumnName],
|
5713
|
+
isUnique: indexIsUnique
|
5773
5714
|
};
|
5774
5715
|
}
|
5775
5716
|
}
|
@@ -5827,6 +5768,7 @@ var init_pgSerializer = __esm({
|
|
5827
5768
|
"time without time zone": "::time without time zone",
|
5828
5769
|
// "timestamp with time zone": "::timestamp with time zone",
|
5829
5770
|
"timestamp without time zone": "::timestamp without time zone",
|
5771
|
+
"timestamp(": "::timestamp without time zone",
|
5830
5772
|
// date: "::date",
|
5831
5773
|
// interval: "::interval",
|
5832
5774
|
// character: "::bpchar",
|
@@ -5839,15 +5781,15 @@ var init_pgSerializer = __esm({
|
|
5839
5781
|
"character(": "::bpchar"
|
5840
5782
|
};
|
5841
5783
|
defaultForColumn = (column4) => {
|
5784
|
+
if (column4.column_default === null) {
|
5785
|
+
return void 0;
|
5786
|
+
}
|
5842
5787
|
if (column4.data_type === "serial" || column4.data_type === "smallserial" || column4.data_type === "bigserial") {
|
5843
5788
|
return void 0;
|
5844
5789
|
}
|
5845
5790
|
const hasDifferentDefaultCast = Object.keys(columnToDefault).find(
|
5846
5791
|
(it) => column4.data_type.startsWith(it)
|
5847
5792
|
);
|
5848
|
-
if (column4.column_default === null) {
|
5849
|
-
return void 0;
|
5850
|
-
}
|
5851
5793
|
const columnDefaultAsString = column4.column_default.toString();
|
5852
5794
|
if (columnDefaultAsString.endsWith(
|
5853
5795
|
hasDifferentDefaultCast ? columnToDefault[hasDifferentDefaultCast] : column4.data_type
|
package/utils.js
CHANGED
@@ -5060,21 +5060,10 @@ var pgSchemaV1 = objectType({
|
|
5060
5060
|
tables: recordType(stringType(), tableV1),
|
5061
5061
|
enums: recordType(stringType(), enumSchemaV1)
|
5062
5062
|
}).strict();
|
5063
|
-
var indexColumn = objectType({
|
5064
|
-
expression: stringType(),
|
5065
|
-
isExpression: booleanType(),
|
5066
|
-
asc: booleanType(),
|
5067
|
-
nulls: stringType().optional(),
|
5068
|
-
opclass: stringType().optional()
|
5069
|
-
});
|
5070
5063
|
var index2 = objectType({
|
5071
5064
|
name: stringType(),
|
5072
|
-
columns:
|
5073
|
-
isUnique: booleanType()
|
5074
|
-
with: recordType(stringType(), anyType()).optional(),
|
5075
|
-
method: stringType().default("btree"),
|
5076
|
-
where: stringType().optional(),
|
5077
|
-
concurrently: booleanType().default(false)
|
5065
|
+
columns: stringType().array(),
|
5066
|
+
isUnique: booleanType()
|
5078
5067
|
}).strict();
|
5079
5068
|
var fk2 = objectType({
|
5080
5069
|
name: stringType(),
|
@@ -5433,7 +5422,6 @@ var validateWithReport = (snapshots, dialect3) => {
|
|
5433
5422
|
}
|
5434
5423
|
const result2 = validator.safeParse(raw);
|
5435
5424
|
if (!result2.success) {
|
5436
|
-
console.error(result2.error);
|
5437
5425
|
accum.malformed.push(it);
|
5438
5426
|
return accum;
|
5439
5427
|
}
|
package/utils.mjs
CHANGED
@@ -5051,21 +5051,10 @@ var pgSchemaV1 = objectType({
|
|
5051
5051
|
tables: recordType(stringType(), tableV1),
|
5052
5052
|
enums: recordType(stringType(), enumSchemaV1)
|
5053
5053
|
}).strict();
|
5054
|
-
var indexColumn = objectType({
|
5055
|
-
expression: stringType(),
|
5056
|
-
isExpression: booleanType(),
|
5057
|
-
asc: booleanType(),
|
5058
|
-
nulls: stringType().optional(),
|
5059
|
-
opclass: stringType().optional()
|
5060
|
-
});
|
5061
5054
|
var index2 = objectType({
|
5062
5055
|
name: stringType(),
|
5063
|
-
columns:
|
5064
|
-
isUnique: booleanType()
|
5065
|
-
with: recordType(stringType(), anyType()).optional(),
|
5066
|
-
method: stringType().default("btree"),
|
5067
|
-
where: stringType().optional(),
|
5068
|
-
concurrently: booleanType().default(false)
|
5056
|
+
columns: stringType().array(),
|
5057
|
+
isUnique: booleanType()
|
5069
5058
|
}).strict();
|
5070
5059
|
var fk2 = objectType({
|
5071
5060
|
name: stringType(),
|
@@ -5424,7 +5413,6 @@ var validateWithReport = (snapshots, dialect3) => {
|
|
5424
5413
|
}
|
5425
5414
|
const result2 = validator.safeParse(raw);
|
5426
5415
|
if (!result2.success) {
|
5427
|
-
console.error(result2.error);
|
5428
5416
|
accum.malformed.push(it);
|
5429
5417
|
return accum;
|
5430
5418
|
}
|