drizzle-kit 0.21.2-9c89270 → 0.21.2-cf9fe8d
Sign up to get free protection for your applications and to get access to all the features.
- package/bin.cjs +18812 -24996
- package/index.d.mts +1 -9
- package/index.d.ts +1 -9
- package/package.json +3 -4
- package/payload.d.mts +96 -10
- package/payload.d.ts +96 -10
- package/payload.js +1614 -1218
- package/payload.mjs +1614 -1218
- package/utils-studio.js +174 -46
- package/utils-studio.mjs +174 -46
- package/utils.js +90 -8
- package/utils.mjs +90 -8
package/utils-studio.js
CHANGED
@@ -569,7 +569,7 @@ var init_global = __esm({
|
|
569
569
|
"src/global.ts"() {
|
570
570
|
"use strict";
|
571
571
|
originUUID = "00000000-0000-0000-0000-000000000000";
|
572
|
-
snapshotVersion = "
|
572
|
+
snapshotVersion = "7";
|
573
573
|
}
|
574
574
|
});
|
575
575
|
|
@@ -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, 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;
|
4501
|
+
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;
|
4502
4502
|
var init_pgSchema = __esm({
|
4503
4503
|
"src/serializer/pgSchema.ts"() {
|
4504
4504
|
"use strict";
|
@@ -4566,10 +4566,48 @@ 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
|
+
});
|
4569
4576
|
index2 = objectType({
|
4577
|
+
name: stringType(),
|
4578
|
+
columns: indexColumn.array(),
|
4579
|
+
isUnique: booleanType(),
|
4580
|
+
with: recordType(stringType(), anyType()).optional(),
|
4581
|
+
method: stringType().default("btree"),
|
4582
|
+
where: stringType().optional(),
|
4583
|
+
concurrently: booleanType().default(false)
|
4584
|
+
}).strict();
|
4585
|
+
indexV4 = objectType({
|
4570
4586
|
name: stringType(),
|
4571
4587
|
columns: stringType().array(),
|
4572
|
-
isUnique: booleanType()
|
4588
|
+
isUnique: booleanType(),
|
4589
|
+
with: recordType(stringType(), stringType()).optional(),
|
4590
|
+
method: stringType().default("btree"),
|
4591
|
+
where: stringType().optional(),
|
4592
|
+
concurrently: booleanType().default(false)
|
4593
|
+
}).strict();
|
4594
|
+
indexV5 = objectType({
|
4595
|
+
name: stringType(),
|
4596
|
+
columns: stringType().array(),
|
4597
|
+
isUnique: booleanType(),
|
4598
|
+
with: recordType(stringType(), stringType()).optional(),
|
4599
|
+
method: stringType().default("btree"),
|
4600
|
+
where: stringType().optional(),
|
4601
|
+
concurrently: booleanType().default(false)
|
4602
|
+
}).strict();
|
4603
|
+
indexV6 = objectType({
|
4604
|
+
name: stringType(),
|
4605
|
+
columns: stringType().array(),
|
4606
|
+
isUnique: booleanType(),
|
4607
|
+
with: recordType(stringType(), stringType()).optional(),
|
4608
|
+
method: stringType().default("btree"),
|
4609
|
+
where: stringType().optional(),
|
4610
|
+
concurrently: booleanType().default(false)
|
4573
4611
|
}).strict();
|
4574
4612
|
fk2 = objectType({
|
4575
4613
|
name: stringType(),
|
@@ -4611,9 +4649,27 @@ var init_pgSchema = __esm({
|
|
4611
4649
|
name: stringType(),
|
4612
4650
|
schema: stringType(),
|
4613
4651
|
columns: recordType(stringType(), column2),
|
4614
|
-
indexes: recordType(stringType(),
|
4652
|
+
indexes: recordType(stringType(), indexV4),
|
4615
4653
|
foreignKeys: recordType(stringType(), fk2)
|
4616
4654
|
}).strict();
|
4655
|
+
tableV6 = objectType({
|
4656
|
+
name: stringType(),
|
4657
|
+
schema: stringType(),
|
4658
|
+
columns: recordType(stringType(), column2),
|
4659
|
+
indexes: recordType(stringType(), indexV6),
|
4660
|
+
foreignKeys: recordType(stringType(), fk2),
|
4661
|
+
compositePrimaryKeys: recordType(stringType(), compositePK2),
|
4662
|
+
uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
|
4663
|
+
}).strict();
|
4664
|
+
tableV5 = objectType({
|
4665
|
+
name: stringType(),
|
4666
|
+
schema: stringType(),
|
4667
|
+
columns: recordType(stringType(), column2),
|
4668
|
+
indexes: recordType(stringType(), indexV5),
|
4669
|
+
foreignKeys: recordType(stringType(), fk2),
|
4670
|
+
compositePrimaryKeys: recordType(stringType(), compositePK2),
|
4671
|
+
uniqueConstraints: recordType(stringType(), uniqueConstraint2).default({})
|
4672
|
+
}).strict();
|
4617
4673
|
table2 = objectType({
|
4618
4674
|
name: stringType(),
|
4619
4675
|
schema: stringType(),
|
@@ -4658,7 +4714,7 @@ var init_pgSchema = __esm({
|
|
4658
4714
|
pgSchemaInternalV5 = objectType({
|
4659
4715
|
version: literalType("5"),
|
4660
4716
|
dialect: literalType("pg"),
|
4661
|
-
tables: recordType(stringType(),
|
4717
|
+
tables: recordType(stringType(), tableV5),
|
4662
4718
|
enums: recordType(stringType(), enumSchemaV1),
|
4663
4719
|
schemas: recordType(stringType(), stringType()),
|
4664
4720
|
_meta: objectType({
|
@@ -4668,6 +4724,19 @@ var init_pgSchema = __esm({
|
|
4668
4724
|
}),
|
4669
4725
|
internal: kitInternals2
|
4670
4726
|
}).strict();
|
4727
|
+
pgSchemaInternalV6 = objectType({
|
4728
|
+
version: literalType("6"),
|
4729
|
+
dialect: literalType("postgresql"),
|
4730
|
+
tables: recordType(stringType(), tableV6),
|
4731
|
+
enums: recordType(stringType(), enumSchema),
|
4732
|
+
schemas: recordType(stringType(), stringType()),
|
4733
|
+
_meta: objectType({
|
4734
|
+
schemas: recordType(stringType(), stringType()),
|
4735
|
+
tables: recordType(stringType(), stringType()),
|
4736
|
+
columns: recordType(stringType(), stringType())
|
4737
|
+
}),
|
4738
|
+
internal: kitInternals2
|
4739
|
+
}).strict();
|
4671
4740
|
pgSchemaExternal = objectType({
|
4672
4741
|
version: literalType("5"),
|
4673
4742
|
dialect: literalType("pg"),
|
@@ -4681,7 +4750,7 @@ var init_pgSchema = __esm({
|
|
4681
4750
|
})
|
4682
4751
|
}).strict();
|
4683
4752
|
pgSchemaInternal = objectType({
|
4684
|
-
version: literalType("
|
4753
|
+
version: literalType("7"),
|
4685
4754
|
dialect: literalType("postgresql"),
|
4686
4755
|
tables: recordType(stringType(), table2),
|
4687
4756
|
enums: recordType(stringType(), enumSchema),
|
@@ -4716,18 +4785,30 @@ var init_pgSchema = __esm({
|
|
4716
4785
|
enums: recordType(stringType(), enumSchemaV1),
|
4717
4786
|
schemas: recordType(stringType(), stringType())
|
4718
4787
|
}).strict();
|
4719
|
-
|
4788
|
+
pgSchemaSquashedV6 = objectType({
|
4720
4789
|
version: literalType("6"),
|
4721
4790
|
dialect: literalType("postgresql"),
|
4722
4791
|
tables: recordType(stringType(), tableSquashed2),
|
4723
4792
|
enums: recordType(stringType(), enumSchema),
|
4724
4793
|
schemas: recordType(stringType(), stringType())
|
4725
4794
|
}).strict();
|
4795
|
+
pgSchemaSquashed = objectType({
|
4796
|
+
version: literalType("7"),
|
4797
|
+
dialect: literalType("postgresql"),
|
4798
|
+
tables: recordType(stringType(), tableSquashed2),
|
4799
|
+
enums: recordType(stringType(), enumSchema),
|
4800
|
+
schemas: recordType(stringType(), stringType())
|
4801
|
+
}).strict();
|
4726
4802
|
pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash2);
|
4727
4803
|
pgSchemaV4 = pgSchemaInternalV4.merge(schemaHash2);
|
4728
4804
|
pgSchemaV5 = pgSchemaInternalV5.merge(schemaHash2);
|
4805
|
+
pgSchemaV6 = pgSchemaInternalV6.merge(schemaHash2);
|
4729
4806
|
pgSchema2 = pgSchemaInternal.merge(schemaHash2);
|
4730
|
-
backwardCompatiblePgSchema = unionType([
|
4807
|
+
backwardCompatiblePgSchema = unionType([
|
4808
|
+
pgSchemaV5,
|
4809
|
+
pgSchemaV6,
|
4810
|
+
pgSchema2
|
4811
|
+
]);
|
4731
4812
|
dryPg = pgSchema2.parse({
|
4732
4813
|
version: snapshotVersion,
|
4733
4814
|
dialect: "postgresql",
|
@@ -4966,24 +5047,12 @@ var init_sqliteSerializer = __esm({
|
|
4966
5047
|
`SELECT
|
4967
5048
|
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
|
4968
5049
|
FROM sqlite_master AS m JOIN pragma_table_info(m.name) AS p
|
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';
|
5050
|
+
WHERE m.type = 'table' and m.tbl_name != 'sqlite_sequence' and m.tbl_name != 'sqlite_stat1' and m.tbl_name != '_litestream_seq' and m.tbl_name != '_litestream_lock' and m.tbl_name != 'libsql_wasm_func_table' and m.tbl_name != '__drizzle_migrations';
|
4977
5051
|
`
|
4978
5052
|
);
|
4979
5053
|
const tablesWithSeq = [];
|
4980
5054
|
const seq = await db.query(
|
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[^'']*';`
|
5055
|
+
`SELECT * FROM sqlite_master WHERE name != 'sqlite_sequence' and name != 'sqlite_stat1' and name != '_litestream_seq' and name != '_litestream_lock' and sql GLOB '*[ *' || CHAR(9) || CHAR(10) || CHAR(13) || ']AUTOINCREMENT[^'']*';`
|
4987
5056
|
);
|
4988
5057
|
for (const s of seq) {
|
4989
5058
|
tablesWithSeq.push(s.name);
|
@@ -5068,8 +5137,7 @@ var init_sqliteSerializer = __esm({
|
|
5068
5137
|
try {
|
5069
5138
|
const fks = await db.query(
|
5070
5139
|
`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"
|
5071
|
-
FROM sqlite_master m, pragma_foreign_key_list(m.name) as f
|
5072
|
-
where m.tbl_name != '_cf_KV';`
|
5140
|
+
FROM sqlite_master m, pragma_foreign_key_list(m.name) as f;`
|
5073
5141
|
);
|
5074
5142
|
const fkByTableName = {};
|
5075
5143
|
for (const fkRow of fks) {
|
@@ -5128,9 +5196,7 @@ FROM sqlite_master AS m,
|
|
5128
5196
|
pragma_index_list(m.name) AS il,
|
5129
5197
|
pragma_index_info(il.name) AS ii
|
5130
5198
|
WHERE
|
5131
|
-
m.type = 'table'
|
5132
|
-
and il.name NOT LIKE 'sqlite_autoindex_%'
|
5133
|
-
and m.tbl_name != '_cf_KV';`
|
5199
|
+
m.type = 'table' and il.name NOT LIKE 'sqlite_autoindex_%';`
|
5134
5200
|
);
|
5135
5201
|
for (const idxRow of idxs) {
|
5136
5202
|
const tableName = idxRow.tableName;
|
@@ -5654,7 +5720,10 @@ var init_pgSerializer = __esm({
|
|
5654
5720
|
columnTypeMapped = trimChar(columnTypeMapped, '"');
|
5655
5721
|
columnToReturn[columnName] = {
|
5656
5722
|
name: columnName,
|
5657
|
-
type:
|
5723
|
+
type: (
|
5724
|
+
// filter vectors, but in future we should filter any extension that was installed by user
|
5725
|
+
columnAdditionalDT === "USER-DEFINED" && enumType3 !== "vector" ? enumType3 : columnTypeMapped
|
5726
|
+
),
|
5658
5727
|
typeSchema: enumsToReturn[`${tableSchema}.${enumType3}`] !== void 0 ? enumsToReturn[`${tableSchema}.${enumType3}`].schema : void 0,
|
5659
5728
|
primaryKey: primaryKey.length === 1 && cprimaryKey.length < 2,
|
5660
5729
|
// default: isSerial ? undefined : defaultValue,
|
@@ -5665,15 +5734,42 @@ var init_pgSerializer = __esm({
|
|
5665
5734
|
}
|
5666
5735
|
}
|
5667
5736
|
const dbIndexes = await db.query(
|
5668
|
-
`SELECT
|
5669
|
-
|
5670
|
-
|
5671
|
-
|
5672
|
-
|
5673
|
-
|
5674
|
-
|
5675
|
-
|
5676
|
-
|
5737
|
+
`SELECT t.relname as table_name, ic.relname AS indexname,
|
5738
|
+
k.i AS index_order,
|
5739
|
+
i.indisunique as is_unique,
|
5740
|
+
am.amname as method,
|
5741
|
+
ic.reloptions as with,
|
5742
|
+
coalesce(a.attname,
|
5743
|
+
(('{' || pg_get_expr(
|
5744
|
+
i.indexprs,
|
5745
|
+
i.indrelid
|
5746
|
+
)
|
5747
|
+
|| '}')::text[]
|
5748
|
+
)[k.i]
|
5749
|
+
) AS column_name,
|
5750
|
+
CASE
|
5751
|
+
WHEN pg_get_expr(i.indexprs, i.indrelid) IS NOT NULL THEN 1
|
5752
|
+
ELSE 0
|
5753
|
+
END AS is_expression,
|
5754
|
+
i.indoption[k.i-1] & 1 = 1 AS descending,
|
5755
|
+
i.indoption[k.i-1] & 2 = 2 AS nulls_first,
|
5756
|
+
pg_get_expr(
|
5757
|
+
i.indpred,
|
5758
|
+
i.indrelid
|
5759
|
+
) as where,
|
5760
|
+
opc.opcname
|
5761
|
+
FROM pg_class t
|
5762
|
+
LEFT JOIN pg_index i ON t.oid = i.indrelid
|
5763
|
+
LEFT JOIN pg_class ic ON ic.oid = i.indexrelid
|
5764
|
+
CROSS JOIN LATERAL (SELECT unnest(i.indkey), generate_subscripts(i.indkey, 1) + 1) AS k(attnum, i)
|
5765
|
+
LEFT JOIN pg_attribute AS a
|
5766
|
+
ON i.indrelid = a.attrelid AND k.attnum = a.attnum
|
5767
|
+
JOIN pg_namespace c on c.oid = t.relnamespace
|
5768
|
+
LEFT JOIN pg_am AS am ON ic.relam = am.oid
|
5769
|
+
JOIN pg_opclass opc ON opc.oid = ANY(i.indclass)
|
5770
|
+
WHERE
|
5771
|
+
c.nspname = '${tableSchema}' AND
|
5772
|
+
t.relname = '${tableName}';`
|
5677
5773
|
);
|
5678
5774
|
const dbIndexFromConstraint = await db.query(
|
5679
5775
|
`SELECT
|
@@ -5690,18 +5786,51 @@ var init_pgSerializer = __esm({
|
|
5690
5786
|
);
|
5691
5787
|
const idxsInConsteraint = dbIndexFromConstraint.filter((it) => it.generated_by_constraint === 1).map((it) => it.index_name);
|
5692
5788
|
for (const dbIndex of dbIndexes) {
|
5693
|
-
const indexName = dbIndex.
|
5789
|
+
const indexName = dbIndex.indexname;
|
5694
5790
|
const indexColumnName = dbIndex.column_name;
|
5695
5791
|
const indexIsUnique = dbIndex.is_unique;
|
5792
|
+
const indexMethod = dbIndex.method;
|
5793
|
+
const indexWith = dbIndex.with;
|
5794
|
+
const indexWhere = dbIndex.where;
|
5795
|
+
const opclass = dbIndex.opcname;
|
5796
|
+
const isExpression = dbIndex.is_expression === 1;
|
5797
|
+
const desc = dbIndex.descending;
|
5798
|
+
const nullsFirst = dbIndex.nulls_first;
|
5799
|
+
const mappedWith = {};
|
5800
|
+
if (indexWith !== null) {
|
5801
|
+
indexWith.forEach((it) => {
|
5802
|
+
const splitted = it.split("=");
|
5803
|
+
mappedWith[splitted[0]] = splitted[1];
|
5804
|
+
});
|
5805
|
+
}
|
5696
5806
|
if (idxsInConsteraint.includes(indexName))
|
5697
5807
|
continue;
|
5698
5808
|
if (typeof indexToReturn[indexName] !== "undefined") {
|
5699
|
-
indexToReturn[indexName].columns.push(
|
5809
|
+
indexToReturn[indexName].columns.push({
|
5810
|
+
expression: indexColumnName,
|
5811
|
+
asc: !desc,
|
5812
|
+
nulls: nullsFirst ? "first" : "last",
|
5813
|
+
opclass,
|
5814
|
+
isExpression
|
5815
|
+
});
|
5700
5816
|
} else {
|
5701
5817
|
indexToReturn[indexName] = {
|
5702
5818
|
name: indexName,
|
5703
|
-
columns: [
|
5704
|
-
|
5819
|
+
columns: [
|
5820
|
+
{
|
5821
|
+
expression: indexColumnName,
|
5822
|
+
asc: !desc,
|
5823
|
+
nulls: nullsFirst ? "first" : "last",
|
5824
|
+
opclass,
|
5825
|
+
isExpression
|
5826
|
+
}
|
5827
|
+
],
|
5828
|
+
isUnique: indexIsUnique,
|
5829
|
+
// should not be a part of diff detecs
|
5830
|
+
concurrently: false,
|
5831
|
+
method: indexMethod,
|
5832
|
+
where: indexWhere === null ? void 0 : indexWhere,
|
5833
|
+
with: mappedWith
|
5705
5834
|
};
|
5706
5835
|
}
|
5707
5836
|
}
|
@@ -5737,7 +5866,7 @@ var init_pgSerializer = __esm({
|
|
5737
5866
|
}
|
5738
5867
|
const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
|
5739
5868
|
return {
|
5740
|
-
version: "
|
5869
|
+
version: "7",
|
5741
5870
|
dialect: "postgresql",
|
5742
5871
|
tables: result,
|
5743
5872
|
enums: enumsToReturn,
|
@@ -5759,7 +5888,6 @@ var init_pgSerializer = __esm({
|
|
5759
5888
|
"time without time zone": "::time without time zone",
|
5760
5889
|
// "timestamp with time zone": "::timestamp with time zone",
|
5761
5890
|
"timestamp without time zone": "::timestamp without time zone",
|
5762
|
-
"timestamp(": "::timestamp without time zone",
|
5763
5891
|
// date: "::date",
|
5764
5892
|
// interval: "::interval",
|
5765
5893
|
// character: "::bpchar",
|
@@ -5772,15 +5900,15 @@ var init_pgSerializer = __esm({
|
|
5772
5900
|
"character(": "::bpchar"
|
5773
5901
|
};
|
5774
5902
|
defaultForColumn = (column4) => {
|
5775
|
-
if (column4.column_default === null) {
|
5776
|
-
return void 0;
|
5777
|
-
}
|
5778
5903
|
if (column4.data_type === "serial" || column4.data_type === "smallserial" || column4.data_type === "bigserial") {
|
5779
5904
|
return void 0;
|
5780
5905
|
}
|
5781
5906
|
const hasDifferentDefaultCast = Object.keys(columnToDefault).find(
|
5782
5907
|
(it) => column4.data_type.startsWith(it)
|
5783
5908
|
);
|
5909
|
+
if (column4.column_default === null) {
|
5910
|
+
return void 0;
|
5911
|
+
}
|
5784
5912
|
const columnDefaultAsString = column4.column_default.toString();
|
5785
5913
|
if (columnDefaultAsString.endsWith(
|
5786
5914
|
hasDifferentDefaultCast ? columnToDefault[hasDifferentDefaultCast] : column4.data_type
|