drizzle-kit 0.21.2-4691a9f → 0.21.2-9c89270
Sign up to get free protection for your applications and to get access to all the features.
- package/bin.cjs +24463 -18324
- package/index.d.mts +9 -1
- package/index.d.ts +9 -1
- package/package.json +4 -3
- package/payload.d.mts +10 -96
- package/payload.d.ts +10 -96
- package/payload.js +1218 -1660
- package/payload.mjs +1218 -1660
- package/utils-studio.js +46 -182
- package/utils-studio.mjs +46 -182
- package/utils.js +8 -90
- package/utils.mjs +8 -90
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 = "6";
|
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,
|
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,48 +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
|
-
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({
|
4586
|
-
name: stringType(),
|
4587
|
-
columns: stringType().array(),
|
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
4570
|
name: stringType(),
|
4596
4571
|
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)
|
4572
|
+
isUnique: booleanType()
|
4611
4573
|
}).strict();
|
4612
4574
|
fk2 = objectType({
|
4613
4575
|
name: stringType(),
|
@@ -4649,27 +4611,9 @@ var init_pgSchema = __esm({
|
|
4649
4611
|
name: stringType(),
|
4650
4612
|
schema: stringType(),
|
4651
4613
|
columns: recordType(stringType(), column2),
|
4652
|
-
indexes: recordType(stringType(),
|
4614
|
+
indexes: recordType(stringType(), index2),
|
4653
4615
|
foreignKeys: recordType(stringType(), fk2)
|
4654
4616
|
}).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();
|
4673
4617
|
table2 = objectType({
|
4674
4618
|
name: stringType(),
|
4675
4619
|
schema: stringType(),
|
@@ -4714,7 +4658,7 @@ var init_pgSchema = __esm({
|
|
4714
4658
|
pgSchemaInternalV5 = objectType({
|
4715
4659
|
version: literalType("5"),
|
4716
4660
|
dialect: literalType("pg"),
|
4717
|
-
tables: recordType(stringType(),
|
4661
|
+
tables: recordType(stringType(), table2),
|
4718
4662
|
enums: recordType(stringType(), enumSchemaV1),
|
4719
4663
|
schemas: recordType(stringType(), stringType()),
|
4720
4664
|
_meta: objectType({
|
@@ -4724,19 +4668,6 @@ var init_pgSchema = __esm({
|
|
4724
4668
|
}),
|
4725
4669
|
internal: kitInternals2
|
4726
4670
|
}).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();
|
4740
4671
|
pgSchemaExternal = objectType({
|
4741
4672
|
version: literalType("5"),
|
4742
4673
|
dialect: literalType("pg"),
|
@@ -4750,7 +4681,7 @@ var init_pgSchema = __esm({
|
|
4750
4681
|
})
|
4751
4682
|
}).strict();
|
4752
4683
|
pgSchemaInternal = objectType({
|
4753
|
-
version: literalType("
|
4684
|
+
version: literalType("6"),
|
4754
4685
|
dialect: literalType("postgresql"),
|
4755
4686
|
tables: recordType(stringType(), table2),
|
4756
4687
|
enums: recordType(stringType(), enumSchema),
|
@@ -4785,15 +4716,8 @@ var init_pgSchema = __esm({
|
|
4785
4716
|
enums: recordType(stringType(), enumSchemaV1),
|
4786
4717
|
schemas: recordType(stringType(), stringType())
|
4787
4718
|
}).strict();
|
4788
|
-
pgSchemaSquashedV6 = objectType({
|
4789
|
-
version: literalType("6"),
|
4790
|
-
dialect: literalType("postgresql"),
|
4791
|
-
tables: recordType(stringType(), tableSquashed2),
|
4792
|
-
enums: recordType(stringType(), enumSchema),
|
4793
|
-
schemas: recordType(stringType(), stringType())
|
4794
|
-
}).strict();
|
4795
4719
|
pgSchemaSquashed = objectType({
|
4796
|
-
version: literalType("
|
4720
|
+
version: literalType("6"),
|
4797
4721
|
dialect: literalType("postgresql"),
|
4798
4722
|
tables: recordType(stringType(), tableSquashed2),
|
4799
4723
|
enums: recordType(stringType(), enumSchema),
|
@@ -4802,13 +4726,8 @@ var init_pgSchema = __esm({
|
|
4802
4726
|
pgSchemaV3 = pgSchemaInternalV3.merge(schemaHash2);
|
4803
4727
|
pgSchemaV4 = pgSchemaInternalV4.merge(schemaHash2);
|
4804
4728
|
pgSchemaV5 = pgSchemaInternalV5.merge(schemaHash2);
|
4805
|
-
pgSchemaV6 = pgSchemaInternalV6.merge(schemaHash2);
|
4806
4729
|
pgSchema2 = pgSchemaInternal.merge(schemaHash2);
|
4807
|
-
backwardCompatiblePgSchema = unionType([
|
4808
|
-
pgSchemaV5,
|
4809
|
-
pgSchemaV6,
|
4810
|
-
pgSchema2
|
4811
|
-
]);
|
4730
|
+
backwardCompatiblePgSchema = unionType([pgSchemaV5, pgSchema2]);
|
4812
4731
|
dryPg = pgSchema2.parse({
|
4813
4732
|
version: snapshotVersion,
|
4814
4733
|
dialect: "postgresql",
|
@@ -5047,12 +4966,24 @@ var init_sqliteSerializer = __esm({
|
|
5047
4966
|
`SELECT
|
5048
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
|
5049
4968
|
FROM sqlite_master AS m JOIN pragma_table_info(m.name) AS p
|
5050
|
-
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';
|
5051
4977
|
`
|
5052
4978
|
);
|
5053
4979
|
const tablesWithSeq = [];
|
5054
4980
|
const seq = await db.query(
|
5055
|
-
`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[^'']*';`
|
5056
4987
|
);
|
5057
4988
|
for (const s of seq) {
|
5058
4989
|
tablesWithSeq.push(s.name);
|
@@ -5137,7 +5068,8 @@ var init_sqliteSerializer = __esm({
|
|
5137
5068
|
try {
|
5138
5069
|
const fks = await db.query(
|
5139
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"
|
5140
|
-
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';`
|
5141
5073
|
);
|
5142
5074
|
const fkByTableName = {};
|
5143
5075
|
for (const fkRow of fks) {
|
@@ -5196,7 +5128,9 @@ FROM sqlite_master AS m,
|
|
5196
5128
|
pragma_index_list(m.name) AS il,
|
5197
5129
|
pragma_index_info(il.name) AS ii
|
5198
5130
|
WHERE
|
5199
|
-
m.type = 'table'
|
5131
|
+
m.type = 'table'
|
5132
|
+
and il.name NOT LIKE 'sqlite_autoindex_%'
|
5133
|
+
and m.tbl_name != '_cf_KV';`
|
5200
5134
|
);
|
5201
5135
|
for (const idxRow of idxs) {
|
5202
5136
|
const tableName = idxRow.tableName;
|
@@ -5449,13 +5383,6 @@ var require_brace_expansion = __commonJS({
|
|
5449
5383
|
}
|
5450
5384
|
});
|
5451
5385
|
|
5452
|
-
// src/extensions/vector.ts
|
5453
|
-
var init_vector = __esm({
|
5454
|
-
"src/extensions/vector.ts"() {
|
5455
|
-
"use strict";
|
5456
|
-
}
|
5457
|
-
});
|
5458
|
-
|
5459
5386
|
// src/serializer/pgSerializer.ts
|
5460
5387
|
var import_pg_core2, import_pg_core3, import_drizzle_orm2, dialect4, trimChar, fromDatabase2, columnToDefault, defaultForColumn;
|
5461
5388
|
var init_pgSerializer = __esm({
|
@@ -5466,7 +5393,6 @@ var init_pgSerializer = __esm({
|
|
5466
5393
|
import_drizzle_orm2 = require("drizzle-orm");
|
5467
5394
|
init_serializer();
|
5468
5395
|
init_outputs();
|
5469
|
-
init_vector();
|
5470
5396
|
dialect4 = new import_pg_core2.PgDialect();
|
5471
5397
|
trimChar = (str, char) => {
|
5472
5398
|
let start = 0;
|
@@ -5728,10 +5654,7 @@ var init_pgSerializer = __esm({
|
|
5728
5654
|
columnTypeMapped = trimChar(columnTypeMapped, '"');
|
5729
5655
|
columnToReturn[columnName] = {
|
5730
5656
|
name: columnName,
|
5731
|
-
type:
|
5732
|
-
// filter vectors, but in future we should filter any extension that was installed by user
|
5733
|
-
columnAdditionalDT === "USER-DEFINED" && enumType3 !== "vector" ? enumType3 : columnTypeMapped
|
5734
|
-
),
|
5657
|
+
type: columnAdditionalDT === "USER-DEFINED" ? enumType3 : columnTypeMapped,
|
5735
5658
|
typeSchema: enumsToReturn[`${tableSchema}.${enumType3}`] !== void 0 ? enumsToReturn[`${tableSchema}.${enumType3}`].schema : void 0,
|
5736
5659
|
primaryKey: primaryKey.length === 1 && cprimaryKey.length < 2,
|
5737
5660
|
// default: isSerial ? undefined : defaultValue,
|
@@ -5742,42 +5665,15 @@ var init_pgSerializer = __esm({
|
|
5742
5665
|
}
|
5743
5666
|
}
|
5744
5667
|
const dbIndexes = await db.query(
|
5745
|
-
`SELECT
|
5746
|
-
|
5747
|
-
|
5748
|
-
|
5749
|
-
|
5750
|
-
|
5751
|
-
|
5752
|
-
|
5753
|
-
|
5754
|
-
)
|
5755
|
-
|| '}')::text[]
|
5756
|
-
)[k.i]
|
5757
|
-
) AS column_name,
|
5758
|
-
CASE
|
5759
|
-
WHEN pg_get_expr(i.indexprs, i.indrelid) IS NOT NULL THEN 1
|
5760
|
-
ELSE 0
|
5761
|
-
END AS is_expression,
|
5762
|
-
i.indoption[k.i-1] & 1 = 1 AS descending,
|
5763
|
-
i.indoption[k.i-1] & 2 = 2 AS nulls_first,
|
5764
|
-
pg_get_expr(
|
5765
|
-
i.indpred,
|
5766
|
-
i.indrelid
|
5767
|
-
) as where,
|
5768
|
-
opc.opcname
|
5769
|
-
FROM pg_class t
|
5770
|
-
LEFT JOIN pg_index i ON t.oid = i.indrelid
|
5771
|
-
LEFT JOIN pg_class ic ON ic.oid = i.indexrelid
|
5772
|
-
CROSS JOIN LATERAL (SELECT unnest(i.indkey), generate_subscripts(i.indkey, 1) + 1) AS k(attnum, i)
|
5773
|
-
LEFT JOIN pg_attribute AS a
|
5774
|
-
ON i.indrelid = a.attrelid AND k.attnum = a.attnum
|
5775
|
-
JOIN pg_namespace c on c.oid = t.relnamespace
|
5776
|
-
LEFT JOIN pg_am AS am ON ic.relam = am.oid
|
5777
|
-
JOIN pg_opclass opc ON opc.oid = ANY(i.indclass)
|
5778
|
-
WHERE
|
5779
|
-
c.nspname = '${tableSchema}' AND
|
5780
|
-
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;`
|
5781
5677
|
);
|
5782
5678
|
const dbIndexFromConstraint = await db.query(
|
5783
5679
|
`SELECT
|
@@ -5794,51 +5690,18 @@ var init_pgSerializer = __esm({
|
|
5794
5690
|
);
|
5795
5691
|
const idxsInConsteraint = dbIndexFromConstraint.filter((it) => it.generated_by_constraint === 1).map((it) => it.index_name);
|
5796
5692
|
for (const dbIndex of dbIndexes) {
|
5797
|
-
const indexName = dbIndex.
|
5693
|
+
const indexName = dbIndex.index_name;
|
5798
5694
|
const indexColumnName = dbIndex.column_name;
|
5799
5695
|
const indexIsUnique = dbIndex.is_unique;
|
5800
|
-
const indexMethod = dbIndex.method;
|
5801
|
-
const indexWith = dbIndex.with;
|
5802
|
-
const indexWhere = dbIndex.where;
|
5803
|
-
const opclass = dbIndex.opcname;
|
5804
|
-
const isExpression = dbIndex.is_expression === 1;
|
5805
|
-
const desc = dbIndex.descending;
|
5806
|
-
const nullsFirst = dbIndex.nulls_first;
|
5807
|
-
const mappedWith = {};
|
5808
|
-
if (indexWith !== null) {
|
5809
|
-
indexWith.forEach((it) => {
|
5810
|
-
const splitted = it.split("=");
|
5811
|
-
mappedWith[splitted[0]] = splitted[1];
|
5812
|
-
});
|
5813
|
-
}
|
5814
5696
|
if (idxsInConsteraint.includes(indexName))
|
5815
5697
|
continue;
|
5816
5698
|
if (typeof indexToReturn[indexName] !== "undefined") {
|
5817
|
-
indexToReturn[indexName].columns.push(
|
5818
|
-
expression: indexColumnName,
|
5819
|
-
asc: !desc,
|
5820
|
-
nulls: nullsFirst ? "first" : "last",
|
5821
|
-
opclass,
|
5822
|
-
isExpression
|
5823
|
-
});
|
5699
|
+
indexToReturn[indexName].columns.push(indexColumnName);
|
5824
5700
|
} else {
|
5825
5701
|
indexToReturn[indexName] = {
|
5826
5702
|
name: indexName,
|
5827
|
-
columns: [
|
5828
|
-
|
5829
|
-
expression: indexColumnName,
|
5830
|
-
asc: !desc,
|
5831
|
-
nulls: nullsFirst ? "first" : "last",
|
5832
|
-
opclass,
|
5833
|
-
isExpression
|
5834
|
-
}
|
5835
|
-
],
|
5836
|
-
isUnique: indexIsUnique,
|
5837
|
-
// should not be a part of diff detecs
|
5838
|
-
concurrently: false,
|
5839
|
-
method: indexMethod,
|
5840
|
-
where: indexWhere === null ? void 0 : indexWhere,
|
5841
|
-
with: mappedWith
|
5703
|
+
columns: [indexColumnName],
|
5704
|
+
isUnique: indexIsUnique
|
5842
5705
|
};
|
5843
5706
|
}
|
5844
5707
|
}
|
@@ -5874,7 +5737,7 @@ var init_pgSerializer = __esm({
|
|
5874
5737
|
}
|
5875
5738
|
const schemasObject = Object.fromEntries([...schemas].map((it) => [it, it]));
|
5876
5739
|
return {
|
5877
|
-
version: "
|
5740
|
+
version: "6",
|
5878
5741
|
dialect: "postgresql",
|
5879
5742
|
tables: result,
|
5880
5743
|
enums: enumsToReturn,
|
@@ -5896,6 +5759,7 @@ var init_pgSerializer = __esm({
|
|
5896
5759
|
"time without time zone": "::time without time zone",
|
5897
5760
|
// "timestamp with time zone": "::timestamp with time zone",
|
5898
5761
|
"timestamp without time zone": "::timestamp without time zone",
|
5762
|
+
"timestamp(": "::timestamp without time zone",
|
5899
5763
|
// date: "::date",
|
5900
5764
|
// interval: "::interval",
|
5901
5765
|
// character: "::bpchar",
|
@@ -5908,15 +5772,15 @@ var init_pgSerializer = __esm({
|
|
5908
5772
|
"character(": "::bpchar"
|
5909
5773
|
};
|
5910
5774
|
defaultForColumn = (column4) => {
|
5775
|
+
if (column4.column_default === null) {
|
5776
|
+
return void 0;
|
5777
|
+
}
|
5911
5778
|
if (column4.data_type === "serial" || column4.data_type === "smallserial" || column4.data_type === "bigserial") {
|
5912
5779
|
return void 0;
|
5913
5780
|
}
|
5914
5781
|
const hasDifferentDefaultCast = Object.keys(columnToDefault).find(
|
5915
5782
|
(it) => column4.data_type.startsWith(it)
|
5916
5783
|
);
|
5917
|
-
if (column4.column_default === null) {
|
5918
|
-
return void 0;
|
5919
|
-
}
|
5920
5784
|
const columnDefaultAsString = column4.column_default.toString();
|
5921
5785
|
if (columnDefaultAsString.endsWith(
|
5922
5786
|
hasDifferentDefaultCast ? columnToDefault[hasDifferentDefaultCast] : column4.data_type
|