drizzle-kit 0.23.2-d486e9b → 0.23.2-df9e596
Sign up to get free protection for your applications and to get access to all the features.
- package/api.d.mts +20 -4
- package/api.d.ts +20 -4
- package/api.js +53 -60
- package/api.mjs +53 -60
- package/bin.cjs +3 -37
- package/package.json +1 -1
- package/utils.js +0 -5
- package/utils.mjs +0 -4
package/api.d.mts
CHANGED
@@ -1411,7 +1411,7 @@ declare const pushMySQLSchema: (imports: Record<string, unknown>, drizzleInstanc
|
|
1411
1411
|
apply: () => Promise<void>;
|
1412
1412
|
}>;
|
1413
1413
|
declare const upPgSnapshot: (snapshot: Record<string, unknown>) => {
|
1414
|
-
version: "
|
1414
|
+
version: "7";
|
1415
1415
|
dialect: "postgresql";
|
1416
1416
|
tables: Record<string, {
|
1417
1417
|
name: string;
|
@@ -1444,11 +1444,17 @@ declare const upPgSnapshot: (snapshot: Record<string, unknown>) => {
|
|
1444
1444
|
}>;
|
1445
1445
|
indexes: Record<string, {
|
1446
1446
|
name: string;
|
1447
|
-
columns:
|
1447
|
+
columns: {
|
1448
|
+
expression: string;
|
1449
|
+
isExpression: boolean;
|
1450
|
+
asc: boolean;
|
1451
|
+
nulls?: string | undefined;
|
1452
|
+
opclass?: string | undefined;
|
1453
|
+
}[];
|
1448
1454
|
isUnique: boolean;
|
1449
1455
|
method: string;
|
1450
1456
|
concurrently: boolean;
|
1451
|
-
with?: Record<string,
|
1457
|
+
with?: Record<string, any> | undefined;
|
1452
1458
|
where?: string | undefined;
|
1453
1459
|
}>;
|
1454
1460
|
foreignKeys: Record<string, {
|
@@ -1477,6 +1483,16 @@ declare const upPgSnapshot: (snapshot: Record<string, unknown>) => {
|
|
1477
1483
|
schema: string;
|
1478
1484
|
}>;
|
1479
1485
|
schemas: Record<string, string>;
|
1486
|
+
sequences: Record<string, {
|
1487
|
+
name: string;
|
1488
|
+
schema: string;
|
1489
|
+
increment?: string | undefined;
|
1490
|
+
minValue?: string | undefined;
|
1491
|
+
maxValue?: string | undefined;
|
1492
|
+
startWith?: string | undefined;
|
1493
|
+
cache?: string | undefined;
|
1494
|
+
cycle?: boolean | undefined;
|
1495
|
+
}>;
|
1480
1496
|
_meta: {
|
1481
1497
|
tables: Record<string, string>;
|
1482
1498
|
columns: Record<string, string>;
|
@@ -1493,6 +1509,6 @@ declare const upPgSnapshot: (snapshot: Record<string, unknown>) => {
|
|
1493
1509
|
} | undefined>;
|
1494
1510
|
} | undefined>;
|
1495
1511
|
} | undefined;
|
1496
|
-
}
|
1512
|
+
} | Record<string, unknown>;
|
1497
1513
|
|
1498
1514
|
export { type DrizzleMySQLSnapshotJSON, type DrizzleSQLiteSnapshotJSON, type DrizzleSnapshotJSON, generateDrizzleJson, generateMigration, generateMySQLDrizzleJson, generateMySQLMigration, generateSQLiteDrizzleJson, generateSQLiteMigration, pushMySQLSchema, pushSQLiteSchema, pushSchema, upPgSnapshot };
|
package/api.d.ts
CHANGED
@@ -1411,7 +1411,7 @@ declare const pushMySQLSchema: (imports: Record<string, unknown>, drizzleInstanc
|
|
1411
1411
|
apply: () => Promise<void>;
|
1412
1412
|
}>;
|
1413
1413
|
declare const upPgSnapshot: (snapshot: Record<string, unknown>) => {
|
1414
|
-
version: "
|
1414
|
+
version: "7";
|
1415
1415
|
dialect: "postgresql";
|
1416
1416
|
tables: Record<string, {
|
1417
1417
|
name: string;
|
@@ -1444,11 +1444,17 @@ declare const upPgSnapshot: (snapshot: Record<string, unknown>) => {
|
|
1444
1444
|
}>;
|
1445
1445
|
indexes: Record<string, {
|
1446
1446
|
name: string;
|
1447
|
-
columns:
|
1447
|
+
columns: {
|
1448
|
+
expression: string;
|
1449
|
+
isExpression: boolean;
|
1450
|
+
asc: boolean;
|
1451
|
+
nulls?: string | undefined;
|
1452
|
+
opclass?: string | undefined;
|
1453
|
+
}[];
|
1448
1454
|
isUnique: boolean;
|
1449
1455
|
method: string;
|
1450
1456
|
concurrently: boolean;
|
1451
|
-
with?: Record<string,
|
1457
|
+
with?: Record<string, any> | undefined;
|
1452
1458
|
where?: string | undefined;
|
1453
1459
|
}>;
|
1454
1460
|
foreignKeys: Record<string, {
|
@@ -1477,6 +1483,16 @@ declare const upPgSnapshot: (snapshot: Record<string, unknown>) => {
|
|
1477
1483
|
schema: string;
|
1478
1484
|
}>;
|
1479
1485
|
schemas: Record<string, string>;
|
1486
|
+
sequences: Record<string, {
|
1487
|
+
name: string;
|
1488
|
+
schema: string;
|
1489
|
+
increment?: string | undefined;
|
1490
|
+
minValue?: string | undefined;
|
1491
|
+
maxValue?: string | undefined;
|
1492
|
+
startWith?: string | undefined;
|
1493
|
+
cache?: string | undefined;
|
1494
|
+
cycle?: boolean | undefined;
|
1495
|
+
}>;
|
1480
1496
|
_meta: {
|
1481
1497
|
tables: Record<string, string>;
|
1482
1498
|
columns: Record<string, string>;
|
@@ -1493,6 +1509,6 @@ declare const upPgSnapshot: (snapshot: Record<string, unknown>) => {
|
|
1493
1509
|
} | undefined>;
|
1494
1510
|
} | undefined>;
|
1495
1511
|
} | undefined;
|
1496
|
-
}
|
1512
|
+
} | Record<string, unknown>;
|
1497
1513
|
|
1498
1514
|
export { type DrizzleMySQLSnapshotJSON, type DrizzleSQLiteSnapshotJSON, type DrizzleSnapshotJSON, generateDrizzleJson, generateMigration, generateMySQLDrizzleJson, generateMySQLMigration, generateSQLiteDrizzleJson, generateSQLiteMigration, pushMySQLSchema, pushSQLiteSchema, pushSchema, upPgSnapshot };
|
package/api.js
CHANGED
@@ -8338,9 +8338,6 @@ var init_sqliteSchema = __esm({
|
|
8338
8338
|
});
|
8339
8339
|
|
8340
8340
|
// src/utils.ts
|
8341
|
-
function isPgArrayType(sqlType) {
|
8342
|
-
return sqlType.match(/.*\[\d*\].*|.*\[\].*/g) !== null;
|
8343
|
-
}
|
8344
8341
|
var copy, prepareMigrationMeta, schemaRenameKey, tableRenameKey, columnRenameKey;
|
8345
8342
|
var init_utils = __esm({
|
8346
8343
|
"src/utils.ts"() {
|
@@ -8714,14 +8711,14 @@ var require_heap = __commonJS({
|
|
8714
8711
|
return item;
|
8715
8712
|
};
|
8716
8713
|
heapify = function(array, cmp) {
|
8717
|
-
var i, _i2,
|
8714
|
+
var i, _i2, _j, _len, _ref, _ref1, _results, _results1;
|
8718
8715
|
if (cmp == null) {
|
8719
8716
|
cmp = defaultCmp;
|
8720
8717
|
}
|
8721
8718
|
_ref1 = function() {
|
8722
8719
|
_results1 = [];
|
8723
|
-
for (var
|
8724
|
-
_results1.push(
|
8720
|
+
for (var _j2 = 0, _ref2 = floor(array.length / 2); 0 <= _ref2 ? _j2 < _ref2 : _j2 > _ref2; 0 <= _ref2 ? _j2++ : _j2--) {
|
8721
|
+
_results1.push(_j2);
|
8725
8722
|
}
|
8726
8723
|
return _results1;
|
8727
8724
|
}.apply(this).reverse();
|
@@ -8762,7 +8759,7 @@ var require_heap = __commonJS({
|
|
8762
8759
|
return result.sort(cmp).reverse();
|
8763
8760
|
};
|
8764
8761
|
nsmallest = function(array, n, cmp) {
|
8765
|
-
var elem, i, los, result, _i2,
|
8762
|
+
var elem, i, los, result, _i2, _j, _len, _ref, _ref1, _results;
|
8766
8763
|
if (cmp == null) {
|
8767
8764
|
cmp = defaultCmp;
|
8768
8765
|
}
|
@@ -8785,7 +8782,7 @@ var require_heap = __commonJS({
|
|
8785
8782
|
}
|
8786
8783
|
heapify(array, cmp);
|
8787
8784
|
_results = [];
|
8788
|
-
for (i =
|
8785
|
+
for (i = _j = 0, _ref1 = min2(n, array.length); 0 <= _ref1 ? _j < _ref1 : _j > _ref1; i = 0 <= _ref1 ? ++_j : --_j) {
|
8789
8786
|
_results.push(heappop(array, cmp));
|
8790
8787
|
}
|
8791
8788
|
return _results;
|
@@ -17480,7 +17477,7 @@ function getTableName(table4) {
|
|
17480
17477
|
function getTableUniqueName(table4) {
|
17481
17478
|
return `${table4[Schema] ?? "public"}.${table4[TableName]}`;
|
17482
17479
|
}
|
17483
|
-
var TableName, Schema, Columns, ExtraConfigColumns, OriginalName, BaseName, IsAlias, ExtraConfigBuilder, IsDrizzleTable, _a3, _b, _c, _d, _e, _f, _g, _h, _i,
|
17480
|
+
var TableName, Schema, Columns, ExtraConfigColumns, OriginalName, BaseName, IsAlias, ExtraConfigBuilder, IsDrizzleTable, _a3, _b, _c, _d, _e, _f, _g, _h, _i, Table2;
|
17484
17481
|
var init_table = __esm({
|
17485
17482
|
"../drizzle-orm/dist/table.js"() {
|
17486
17483
|
"use strict";
|
@@ -17494,34 +17491,32 @@ var init_table = __esm({
|
|
17494
17491
|
IsAlias = Symbol.for("drizzle:IsAlias");
|
17495
17492
|
ExtraConfigBuilder = Symbol.for("drizzle:ExtraConfigBuilder");
|
17496
17493
|
IsDrizzleTable = Symbol.for("drizzle:IsDrizzleTable");
|
17497
|
-
|
17494
|
+
_i = entityKind, _h = TableName, _g = OriginalName, _f = Schema, _e = Columns, _d = ExtraConfigColumns, _c = BaseName, _b = IsAlias, _a3 = ExtraConfigBuilder;
|
17498
17495
|
Table2 = class {
|
17499
17496
|
constructor(name2, schema4, baseName) {
|
17500
17497
|
/**
|
17501
17498
|
* @internal
|
17502
17499
|
* Can be changed if the table is aliased.
|
17503
17500
|
*/
|
17504
|
-
__publicField(this,
|
17501
|
+
__publicField(this, _h);
|
17505
17502
|
/**
|
17506
17503
|
* @internal
|
17507
17504
|
* Used to store the original name of the table, before any aliasing.
|
17508
17505
|
*/
|
17509
|
-
__publicField(this, _h);
|
17510
|
-
/** @internal */
|
17511
17506
|
__publicField(this, _g);
|
17512
17507
|
/** @internal */
|
17513
17508
|
__publicField(this, _f);
|
17514
17509
|
/** @internal */
|
17515
17510
|
__publicField(this, _e);
|
17511
|
+
/** @internal */
|
17512
|
+
__publicField(this, _d);
|
17516
17513
|
/**
|
17517
17514
|
* @internal
|
17518
17515
|
* Used to store the table name before the transformation via the `tableCreator` functions.
|
17519
17516
|
*/
|
17520
|
-
__publicField(this,
|
17517
|
+
__publicField(this, _c);
|
17521
17518
|
/** @internal */
|
17522
|
-
__publicField(this,
|
17523
|
-
/** @internal */
|
17524
|
-
__publicField(this, _b, true);
|
17519
|
+
__publicField(this, _b, false);
|
17525
17520
|
/** @internal */
|
17526
17521
|
__publicField(this, _a3);
|
17527
17522
|
this[TableName] = this[OriginalName] = name2;
|
@@ -17529,7 +17524,7 @@ var init_table = __esm({
|
|
17529
17524
|
this[BaseName] = baseName;
|
17530
17525
|
}
|
17531
17526
|
};
|
17532
|
-
__publicField(Table2,
|
17527
|
+
__publicField(Table2, _i, "Table");
|
17533
17528
|
/** @internal */
|
17534
17529
|
__publicField(Table2, "Symbol", {
|
17535
17530
|
Name: TableName,
|
@@ -18207,12 +18202,6 @@ function fillPlaceholders(params, values) {
|
|
18207
18202
|
}
|
18208
18203
|
return values[p.name];
|
18209
18204
|
}
|
18210
|
-
if (is(p, Param) && is(p.value, Placeholder)) {
|
18211
|
-
if (!(p.value.name in values)) {
|
18212
|
-
throw new Error(`No value for placeholder "${p.value.name}" was provided`);
|
18213
|
-
}
|
18214
|
-
return p.encoder.mapToDriverValue(values[p.value.name]);
|
18215
|
-
}
|
18216
18205
|
return p;
|
18217
18206
|
});
|
18218
18207
|
}
|
@@ -18326,9 +18315,6 @@ var init_sql = __esm({
|
|
18326
18315
|
};
|
18327
18316
|
}
|
18328
18317
|
if (is(chunk, Param)) {
|
18329
|
-
if (is(chunk.value, Placeholder)) {
|
18330
|
-
return { sql: escapeParam(paramStartIndex.value++, chunk), params: [chunk], typings: ["none"] };
|
18331
|
-
}
|
18332
18318
|
const mappedValue = chunk.value === null ? null : chunk.encoder.mapToDriverValue(chunk.value);
|
18333
18319
|
if (is(mappedValue, _SQL)) {
|
18334
18320
|
return this.buildQueryFromSourceParams([mappedValue], config);
|
@@ -24650,30 +24636,6 @@ function minRangeForIdentityBasedOn(columnType) {
|
|
24650
24636
|
function stringFromDatabaseIdentityProperty(field) {
|
24651
24637
|
return typeof field === "string" ? field : typeof field === "undefined" ? void 0 : typeof field === "bigint" ? field.toString() : String(field);
|
24652
24638
|
}
|
24653
|
-
function buildArrayString(array, sqlType) {
|
24654
|
-
sqlType = sqlType.split("[")[0];
|
24655
|
-
const values = array.map((value) => {
|
24656
|
-
if (typeof value === "number" || typeof value === "bigint") {
|
24657
|
-
return value.toString();
|
24658
|
-
} else if (typeof value === "boolean") {
|
24659
|
-
return value ? "true" : "false";
|
24660
|
-
} else if (Array.isArray(value)) {
|
24661
|
-
return buildArrayString(value, sqlType);
|
24662
|
-
} else if (value instanceof Date) {
|
24663
|
-
if (sqlType === "date") {
|
24664
|
-
return `"${value.toISOString().split("T")[0]}"`;
|
24665
|
-
} else if (sqlType === "timestamp") {
|
24666
|
-
return `"${value.toISOString().replace("T", " ").slice(0, 23)}"`;
|
24667
|
-
} else {
|
24668
|
-
return `"${value.toISOString()}"`;
|
24669
|
-
}
|
24670
|
-
} else if (typeof value === "object") {
|
24671
|
-
return `"${JSON.stringify(value).replaceAll('"', '\\"')}"`;
|
24672
|
-
}
|
24673
|
-
return `"${value}"`;
|
24674
|
-
}).join(",");
|
24675
|
-
return `{${values}}`;
|
24676
|
-
}
|
24677
24639
|
var dialect4, indexName, generatePgSnapshot, trimChar, fromDatabase, columnToDefault, defaultForColumn;
|
24678
24640
|
var init_pgSerializer = __esm({
|
24679
24641
|
"src/serializer/pgSerializer.ts"() {
|
@@ -24684,7 +24646,6 @@ var init_pgSerializer = __esm({
|
|
24684
24646
|
init_pg_core();
|
24685
24647
|
init_vector3();
|
24686
24648
|
init_outputs();
|
24687
|
-
init_utils();
|
24688
24649
|
init_serializer();
|
24689
24650
|
dialect4 = new PgDialect();
|
24690
24651
|
indexName = (tableName, columns) => {
|
@@ -24791,11 +24752,6 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
24791
24752
|
} else {
|
24792
24753
|
columnToSet.default = `'${column4.default.toISOString()}'`;
|
24793
24754
|
}
|
24794
|
-
} else if (isPgArrayType(sqlTypeLowered) && Array.isArray(column4.default)) {
|
24795
|
-
columnToSet.default = `'${buildArrayString(
|
24796
|
-
column4.default,
|
24797
|
-
sqlTypeLowered
|
24798
|
-
)}'::${sqlTypeLowered}`;
|
24799
24755
|
} else {
|
24800
24756
|
columnToSet.default = column4.default;
|
24801
24757
|
}
|
@@ -29075,7 +29031,7 @@ The unique constraint ${source_default.underline.blue(
|
|
29075
29031
|
primaryKeys.forEach((it) => {
|
29076
29032
|
if (it.columns.length > 1) {
|
29077
29033
|
primaryKeysObject[it.getName()] = {
|
29078
|
-
columns: it.columns.map((it2) => it2.name)
|
29034
|
+
columns: it.columns.map((it2) => it2.name),
|
29079
29035
|
name: it.getName()
|
29080
29036
|
};
|
29081
29037
|
} else {
|
@@ -33644,7 +33600,7 @@ We have encountered a collision between the index name on columns ${source_defau
|
|
33644
33600
|
onUpdate = true;
|
33645
33601
|
}
|
33646
33602
|
const newColumn = {
|
33647
|
-
default: columnDefault === null ? void 0 : /^-?[\d.]+(?:e-?\d+)?$/.test(columnDefault) && !
|
33603
|
+
default: columnDefault === null ? void 0 : /^-?[\d.]+(?:e-?\d+)?$/.test(columnDefault) && !columnType.startsWith("decimal") ? Number(columnDefault) : isDefaultAnExpression ? clearDefaults(columnDefault, collation) : `'${columnDefault}'`,
|
33648
33604
|
autoincrement: isAutoincrement,
|
33649
33605
|
name: columnName,
|
33650
33606
|
type: changedType,
|
@@ -34861,6 +34817,37 @@ var updateUpToV6 = (json) => {
|
|
34861
34817
|
enums
|
34862
34818
|
};
|
34863
34819
|
};
|
34820
|
+
var updateUpToV7 = (json) => {
|
34821
|
+
const schema4 = pgSchemaV6.parse(json);
|
34822
|
+
const tables = Object.fromEntries(
|
34823
|
+
Object.entries(schema4.tables).map((it) => {
|
34824
|
+
const table4 = it[1];
|
34825
|
+
const mappedIndexes = Object.fromEntries(
|
34826
|
+
Object.entries(table4.indexes).map((idx) => {
|
34827
|
+
const { columns, ...rest } = idx[1];
|
34828
|
+
const mappedColumns = columns.map((it2) => {
|
34829
|
+
return {
|
34830
|
+
expression: it2,
|
34831
|
+
isExpression: false,
|
34832
|
+
asc: true,
|
34833
|
+
nulls: "last",
|
34834
|
+
opClass: void 0
|
34835
|
+
};
|
34836
|
+
});
|
34837
|
+
return [idx[0], { columns: mappedColumns, with: {}, ...rest }];
|
34838
|
+
})
|
34839
|
+
);
|
34840
|
+
return [it[0], { ...table4, indexes: mappedIndexes }];
|
34841
|
+
})
|
34842
|
+
);
|
34843
|
+
return {
|
34844
|
+
...schema4,
|
34845
|
+
version: "7",
|
34846
|
+
dialect: "postgresql",
|
34847
|
+
sequences: {},
|
34848
|
+
tables
|
34849
|
+
};
|
34850
|
+
};
|
34864
34851
|
|
34865
34852
|
// src/cli/commands/sqliteIntrospect.ts
|
34866
34853
|
var import_hanji6 = __toESM(require_hanji());
|
@@ -35517,7 +35504,13 @@ var pushMySQLSchema = async (imports, drizzleInstance, databaseName) => {
|
|
35517
35504
|
};
|
35518
35505
|
};
|
35519
35506
|
var upPgSnapshot = (snapshot) => {
|
35520
|
-
|
35507
|
+
if (snapshot.version === "5") {
|
35508
|
+
return updateUpToV7(updateUpToV6(snapshot));
|
35509
|
+
}
|
35510
|
+
if (snapshot.version === "6") {
|
35511
|
+
return updateUpToV7(snapshot);
|
35512
|
+
}
|
35513
|
+
return snapshot;
|
35521
35514
|
};
|
35522
35515
|
// Annotate the CommonJS export names for ESM import in node:
|
35523
35516
|
0 && (module.exports = {
|
package/api.mjs
CHANGED
@@ -8343,9 +8343,6 @@ var init_sqliteSchema = __esm({
|
|
8343
8343
|
});
|
8344
8344
|
|
8345
8345
|
// src/utils.ts
|
8346
|
-
function isPgArrayType(sqlType) {
|
8347
|
-
return sqlType.match(/.*\[\d*\].*|.*\[\].*/g) !== null;
|
8348
|
-
}
|
8349
8346
|
var copy, prepareMigrationMeta, schemaRenameKey, tableRenameKey, columnRenameKey;
|
8350
8347
|
var init_utils = __esm({
|
8351
8348
|
"src/utils.ts"() {
|
@@ -8719,14 +8716,14 @@ var require_heap = __commonJS({
|
|
8719
8716
|
return item;
|
8720
8717
|
};
|
8721
8718
|
heapify = function(array, cmp) {
|
8722
|
-
var i, _i2,
|
8719
|
+
var i, _i2, _j, _len, _ref, _ref1, _results, _results1;
|
8723
8720
|
if (cmp == null) {
|
8724
8721
|
cmp = defaultCmp;
|
8725
8722
|
}
|
8726
8723
|
_ref1 = function() {
|
8727
8724
|
_results1 = [];
|
8728
|
-
for (var
|
8729
|
-
_results1.push(
|
8725
|
+
for (var _j2 = 0, _ref2 = floor(array.length / 2); 0 <= _ref2 ? _j2 < _ref2 : _j2 > _ref2; 0 <= _ref2 ? _j2++ : _j2--) {
|
8726
|
+
_results1.push(_j2);
|
8730
8727
|
}
|
8731
8728
|
return _results1;
|
8732
8729
|
}.apply(this).reverse();
|
@@ -8767,7 +8764,7 @@ var require_heap = __commonJS({
|
|
8767
8764
|
return result.sort(cmp).reverse();
|
8768
8765
|
};
|
8769
8766
|
nsmallest = function(array, n, cmp) {
|
8770
|
-
var elem, i, los, result, _i2,
|
8767
|
+
var elem, i, los, result, _i2, _j, _len, _ref, _ref1, _results;
|
8771
8768
|
if (cmp == null) {
|
8772
8769
|
cmp = defaultCmp;
|
8773
8770
|
}
|
@@ -8790,7 +8787,7 @@ var require_heap = __commonJS({
|
|
8790
8787
|
}
|
8791
8788
|
heapify(array, cmp);
|
8792
8789
|
_results = [];
|
8793
|
-
for (i =
|
8790
|
+
for (i = _j = 0, _ref1 = min2(n, array.length); 0 <= _ref1 ? _j < _ref1 : _j > _ref1; i = 0 <= _ref1 ? ++_j : --_j) {
|
8794
8791
|
_results.push(heappop(array, cmp));
|
8795
8792
|
}
|
8796
8793
|
return _results;
|
@@ -17485,7 +17482,7 @@ function getTableName(table4) {
|
|
17485
17482
|
function getTableUniqueName(table4) {
|
17486
17483
|
return `${table4[Schema] ?? "public"}.${table4[TableName]}`;
|
17487
17484
|
}
|
17488
|
-
var TableName, Schema, Columns, ExtraConfigColumns, OriginalName, BaseName, IsAlias, ExtraConfigBuilder, IsDrizzleTable, _a3, _b, _c, _d, _e, _f, _g, _h, _i,
|
17485
|
+
var TableName, Schema, Columns, ExtraConfigColumns, OriginalName, BaseName, IsAlias, ExtraConfigBuilder, IsDrizzleTable, _a3, _b, _c, _d, _e, _f, _g, _h, _i, Table2;
|
17489
17486
|
var init_table = __esm({
|
17490
17487
|
"../drizzle-orm/dist/table.js"() {
|
17491
17488
|
"use strict";
|
@@ -17499,34 +17496,32 @@ var init_table = __esm({
|
|
17499
17496
|
IsAlias = Symbol.for("drizzle:IsAlias");
|
17500
17497
|
ExtraConfigBuilder = Symbol.for("drizzle:ExtraConfigBuilder");
|
17501
17498
|
IsDrizzleTable = Symbol.for("drizzle:IsDrizzleTable");
|
17502
|
-
|
17499
|
+
_i = entityKind, _h = TableName, _g = OriginalName, _f = Schema, _e = Columns, _d = ExtraConfigColumns, _c = BaseName, _b = IsAlias, _a3 = ExtraConfigBuilder;
|
17503
17500
|
Table2 = class {
|
17504
17501
|
constructor(name2, schema4, baseName) {
|
17505
17502
|
/**
|
17506
17503
|
* @internal
|
17507
17504
|
* Can be changed if the table is aliased.
|
17508
17505
|
*/
|
17509
|
-
__publicField(this,
|
17506
|
+
__publicField(this, _h);
|
17510
17507
|
/**
|
17511
17508
|
* @internal
|
17512
17509
|
* Used to store the original name of the table, before any aliasing.
|
17513
17510
|
*/
|
17514
|
-
__publicField(this, _h);
|
17515
|
-
/** @internal */
|
17516
17511
|
__publicField(this, _g);
|
17517
17512
|
/** @internal */
|
17518
17513
|
__publicField(this, _f);
|
17519
17514
|
/** @internal */
|
17520
17515
|
__publicField(this, _e);
|
17516
|
+
/** @internal */
|
17517
|
+
__publicField(this, _d);
|
17521
17518
|
/**
|
17522
17519
|
* @internal
|
17523
17520
|
* Used to store the table name before the transformation via the `tableCreator` functions.
|
17524
17521
|
*/
|
17525
|
-
__publicField(this,
|
17522
|
+
__publicField(this, _c);
|
17526
17523
|
/** @internal */
|
17527
|
-
__publicField(this,
|
17528
|
-
/** @internal */
|
17529
|
-
__publicField(this, _b, true);
|
17524
|
+
__publicField(this, _b, false);
|
17530
17525
|
/** @internal */
|
17531
17526
|
__publicField(this, _a3);
|
17532
17527
|
this[TableName] = this[OriginalName] = name2;
|
@@ -17534,7 +17529,7 @@ var init_table = __esm({
|
|
17534
17529
|
this[BaseName] = baseName;
|
17535
17530
|
}
|
17536
17531
|
};
|
17537
|
-
__publicField(Table2,
|
17532
|
+
__publicField(Table2, _i, "Table");
|
17538
17533
|
/** @internal */
|
17539
17534
|
__publicField(Table2, "Symbol", {
|
17540
17535
|
Name: TableName,
|
@@ -18212,12 +18207,6 @@ function fillPlaceholders(params, values) {
|
|
18212
18207
|
}
|
18213
18208
|
return values[p.name];
|
18214
18209
|
}
|
18215
|
-
if (is(p, Param) && is(p.value, Placeholder)) {
|
18216
|
-
if (!(p.value.name in values)) {
|
18217
|
-
throw new Error(`No value for placeholder "${p.value.name}" was provided`);
|
18218
|
-
}
|
18219
|
-
return p.encoder.mapToDriverValue(values[p.value.name]);
|
18220
|
-
}
|
18221
18210
|
return p;
|
18222
18211
|
});
|
18223
18212
|
}
|
@@ -18331,9 +18320,6 @@ var init_sql = __esm({
|
|
18331
18320
|
};
|
18332
18321
|
}
|
18333
18322
|
if (is(chunk, Param)) {
|
18334
|
-
if (is(chunk.value, Placeholder)) {
|
18335
|
-
return { sql: escapeParam(paramStartIndex.value++, chunk), params: [chunk], typings: ["none"] };
|
18336
|
-
}
|
18337
18323
|
const mappedValue = chunk.value === null ? null : chunk.encoder.mapToDriverValue(chunk.value);
|
18338
18324
|
if (is(mappedValue, _SQL)) {
|
18339
18325
|
return this.buildQueryFromSourceParams([mappedValue], config);
|
@@ -24655,30 +24641,6 @@ function minRangeForIdentityBasedOn(columnType) {
|
|
24655
24641
|
function stringFromDatabaseIdentityProperty(field) {
|
24656
24642
|
return typeof field === "string" ? field : typeof field === "undefined" ? void 0 : typeof field === "bigint" ? field.toString() : String(field);
|
24657
24643
|
}
|
24658
|
-
function buildArrayString(array, sqlType) {
|
24659
|
-
sqlType = sqlType.split("[")[0];
|
24660
|
-
const values = array.map((value) => {
|
24661
|
-
if (typeof value === "number" || typeof value === "bigint") {
|
24662
|
-
return value.toString();
|
24663
|
-
} else if (typeof value === "boolean") {
|
24664
|
-
return value ? "true" : "false";
|
24665
|
-
} else if (Array.isArray(value)) {
|
24666
|
-
return buildArrayString(value, sqlType);
|
24667
|
-
} else if (value instanceof Date) {
|
24668
|
-
if (sqlType === "date") {
|
24669
|
-
return `"${value.toISOString().split("T")[0]}"`;
|
24670
|
-
} else if (sqlType === "timestamp") {
|
24671
|
-
return `"${value.toISOString().replace("T", " ").slice(0, 23)}"`;
|
24672
|
-
} else {
|
24673
|
-
return `"${value.toISOString()}"`;
|
24674
|
-
}
|
24675
|
-
} else if (typeof value === "object") {
|
24676
|
-
return `"${JSON.stringify(value).replaceAll('"', '\\"')}"`;
|
24677
|
-
}
|
24678
|
-
return `"${value}"`;
|
24679
|
-
}).join(",");
|
24680
|
-
return `{${values}}`;
|
24681
|
-
}
|
24682
24644
|
var dialect4, indexName, generatePgSnapshot, trimChar, fromDatabase, columnToDefault, defaultForColumn;
|
24683
24645
|
var init_pgSerializer = __esm({
|
24684
24646
|
"src/serializer/pgSerializer.ts"() {
|
@@ -24689,7 +24651,6 @@ var init_pgSerializer = __esm({
|
|
24689
24651
|
init_pg_core();
|
24690
24652
|
init_vector3();
|
24691
24653
|
init_outputs();
|
24692
|
-
init_utils();
|
24693
24654
|
init_serializer();
|
24694
24655
|
dialect4 = new PgDialect();
|
24695
24656
|
indexName = (tableName, columns) => {
|
@@ -24796,11 +24757,6 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
24796
24757
|
} else {
|
24797
24758
|
columnToSet.default = `'${column4.default.toISOString()}'`;
|
24798
24759
|
}
|
24799
|
-
} else if (isPgArrayType(sqlTypeLowered) && Array.isArray(column4.default)) {
|
24800
|
-
columnToSet.default = `'${buildArrayString(
|
24801
|
-
column4.default,
|
24802
|
-
sqlTypeLowered
|
24803
|
-
)}'::${sqlTypeLowered}`;
|
24804
24760
|
} else {
|
24805
24761
|
columnToSet.default = column4.default;
|
24806
24762
|
}
|
@@ -29080,7 +29036,7 @@ The unique constraint ${source_default.underline.blue(
|
|
29080
29036
|
primaryKeys.forEach((it) => {
|
29081
29037
|
if (it.columns.length > 1) {
|
29082
29038
|
primaryKeysObject[it.getName()] = {
|
29083
|
-
columns: it.columns.map((it2) => it2.name)
|
29039
|
+
columns: it.columns.map((it2) => it2.name),
|
29084
29040
|
name: it.getName()
|
29085
29041
|
};
|
29086
29042
|
} else {
|
@@ -33649,7 +33605,7 @@ We have encountered a collision between the index name on columns ${source_defau
|
|
33649
33605
|
onUpdate = true;
|
33650
33606
|
}
|
33651
33607
|
const newColumn = {
|
33652
|
-
default: columnDefault === null ? void 0 : /^-?[\d.]+(?:e-?\d+)?$/.test(columnDefault) && !
|
33608
|
+
default: columnDefault === null ? void 0 : /^-?[\d.]+(?:e-?\d+)?$/.test(columnDefault) && !columnType.startsWith("decimal") ? Number(columnDefault) : isDefaultAnExpression ? clearDefaults(columnDefault, collation) : `'${columnDefault}'`,
|
33653
33609
|
autoincrement: isAutoincrement,
|
33654
33610
|
name: columnName,
|
33655
33611
|
type: changedType,
|
@@ -34852,6 +34808,37 @@ var updateUpToV6 = (json) => {
|
|
34852
34808
|
enums
|
34853
34809
|
};
|
34854
34810
|
};
|
34811
|
+
var updateUpToV7 = (json) => {
|
34812
|
+
const schema4 = pgSchemaV6.parse(json);
|
34813
|
+
const tables = Object.fromEntries(
|
34814
|
+
Object.entries(schema4.tables).map((it) => {
|
34815
|
+
const table4 = it[1];
|
34816
|
+
const mappedIndexes = Object.fromEntries(
|
34817
|
+
Object.entries(table4.indexes).map((idx) => {
|
34818
|
+
const { columns, ...rest } = idx[1];
|
34819
|
+
const mappedColumns = columns.map((it2) => {
|
34820
|
+
return {
|
34821
|
+
expression: it2,
|
34822
|
+
isExpression: false,
|
34823
|
+
asc: true,
|
34824
|
+
nulls: "last",
|
34825
|
+
opClass: void 0
|
34826
|
+
};
|
34827
|
+
});
|
34828
|
+
return [idx[0], { columns: mappedColumns, with: {}, ...rest }];
|
34829
|
+
})
|
34830
|
+
);
|
34831
|
+
return [it[0], { ...table4, indexes: mappedIndexes }];
|
34832
|
+
})
|
34833
|
+
);
|
34834
|
+
return {
|
34835
|
+
...schema4,
|
34836
|
+
version: "7",
|
34837
|
+
dialect: "postgresql",
|
34838
|
+
sequences: {},
|
34839
|
+
tables
|
34840
|
+
};
|
34841
|
+
};
|
34855
34842
|
|
34856
34843
|
// src/cli/commands/sqliteIntrospect.ts
|
34857
34844
|
var import_hanji6 = __toESM(require_hanji());
|
@@ -35508,7 +35495,13 @@ var pushMySQLSchema = async (imports, drizzleInstance, databaseName) => {
|
|
35508
35495
|
};
|
35509
35496
|
};
|
35510
35497
|
var upPgSnapshot = (snapshot) => {
|
35511
|
-
|
35498
|
+
if (snapshot.version === "5") {
|
35499
|
+
return updateUpToV7(updateUpToV6(snapshot));
|
35500
|
+
}
|
35501
|
+
if (snapshot.version === "6") {
|
35502
|
+
return updateUpToV7(snapshot);
|
35503
|
+
}
|
35504
|
+
return snapshot;
|
35512
35505
|
};
|
35513
35506
|
export {
|
35514
35507
|
generateDrizzleJson,
|
package/bin.cjs
CHANGED
@@ -6561,9 +6561,6 @@ var init_sqliteSchema = __esm({
|
|
6561
6561
|
});
|
6562
6562
|
|
6563
6563
|
// src/utils.ts
|
6564
|
-
function isPgArrayType(sqlType) {
|
6565
|
-
return sqlType.match(/.*\[\d*\].*|.*\[\].*/g) !== null;
|
6566
|
-
}
|
6567
6564
|
var import_fs, import_path, import_url, copy, objectValues, assertV1OutFolder, dryJournal, prepareOutFolder, validatorForDialect, validateWithReport, prepareMigrationFolder, prepareMigrationMeta, schemaRenameKey, tableRenameKey, columnRenameKey, normaliseSQLiteUrl;
|
6568
6565
|
var init_utils = __esm({
|
6569
6566
|
"src/utils.ts"() {
|
@@ -18110,7 +18107,7 @@ We have encountered a collision between the index name on columns ${source_defau
|
|
18110
18107
|
onUpdate = true;
|
18111
18108
|
}
|
18112
18109
|
const newColumn = {
|
18113
|
-
default: columnDefault === null ? void 0 : /^-?[\d.]+(?:e-?\d+)?$/.test(columnDefault) && !
|
18110
|
+
default: columnDefault === null ? void 0 : /^-?[\d.]+(?:e-?\d+)?$/.test(columnDefault) && !columnType.startsWith("decimal") ? Number(columnDefault) : isDefaultAnExpression ? clearDefaults(columnDefault, collation) : `'${columnDefault}'`,
|
18114
18111
|
autoincrement: isAutoincrement,
|
18115
18112
|
name: columnName,
|
18116
18113
|
type: changedType,
|
@@ -18409,30 +18406,6 @@ function minRangeForIdentityBasedOn(columnType) {
|
|
18409
18406
|
function stringFromDatabaseIdentityProperty(field) {
|
18410
18407
|
return typeof field === "string" ? field : typeof field === "undefined" ? void 0 : typeof field === "bigint" ? field.toString() : String(field);
|
18411
18408
|
}
|
18412
|
-
function buildArrayString(array, sqlType) {
|
18413
|
-
sqlType = sqlType.split("[")[0];
|
18414
|
-
const values = array.map((value) => {
|
18415
|
-
if (typeof value === "number" || typeof value === "bigint") {
|
18416
|
-
return value.toString();
|
18417
|
-
} else if (typeof value === "boolean") {
|
18418
|
-
return value ? "true" : "false";
|
18419
|
-
} else if (Array.isArray(value)) {
|
18420
|
-
return buildArrayString(value, sqlType);
|
18421
|
-
} else if (value instanceof Date) {
|
18422
|
-
if (sqlType === "date") {
|
18423
|
-
return `"${value.toISOString().split("T")[0]}"`;
|
18424
|
-
} else if (sqlType === "timestamp") {
|
18425
|
-
return `"${value.toISOString().replace("T", " ").slice(0, 23)}"`;
|
18426
|
-
} else {
|
18427
|
-
return `"${value.toISOString()}"`;
|
18428
|
-
}
|
18429
|
-
} else if (typeof value === "object") {
|
18430
|
-
return `"${JSON.stringify(value).replaceAll('"', '\\"')}"`;
|
18431
|
-
}
|
18432
|
-
return `"${value}"`;
|
18433
|
-
}).join(",");
|
18434
|
-
return `{${values}}`;
|
18435
|
-
}
|
18436
18409
|
var import_drizzle_orm5, import_pg_core2, import_pg_core3, dialect5, indexName2, generatePgSnapshot, trimChar, fromDatabase2, columnToDefault, defaultForColumn;
|
18437
18410
|
var init_pgSerializer = __esm({
|
18438
18411
|
"src/serializer/pgSerializer.ts"() {
|
@@ -18443,7 +18416,6 @@ var init_pgSerializer = __esm({
|
|
18443
18416
|
import_pg_core3 = require("drizzle-orm/pg-core");
|
18444
18417
|
init_vector();
|
18445
18418
|
init_outputs();
|
18446
|
-
init_utils();
|
18447
18419
|
init_serializer();
|
18448
18420
|
dialect5 = new import_pg_core2.PgDialect();
|
18449
18421
|
indexName2 = (tableName, columns) => {
|
@@ -18552,11 +18524,6 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
18552
18524
|
} else {
|
18553
18525
|
columnToSet.default = `'${column7.default.toISOString()}'`;
|
18554
18526
|
}
|
18555
|
-
} else if (isPgArrayType(sqlTypeLowered) && Array.isArray(column7.default)) {
|
18556
|
-
columnToSet.default = `'${buildArrayString(
|
18557
|
-
column7.default,
|
18558
|
-
sqlTypeLowered
|
18559
|
-
)}'::${sqlTypeLowered}`;
|
18560
18527
|
} else {
|
18561
18528
|
columnToSet.default = column7.default;
|
18562
18529
|
}
|
@@ -19603,7 +19570,7 @@ The unique constraint ${source_default.underline.blue(
|
|
19603
19570
|
primaryKeys.forEach((it) => {
|
19604
19571
|
if (it.columns.length > 1) {
|
19605
19572
|
primaryKeysObject[it.getName()] = {
|
19606
|
-
columns: it.columns.map((it2) => it2.name)
|
19573
|
+
columns: it.columns.map((it2) => it2.name),
|
19607
19574
|
name: it.getName()
|
19608
19575
|
};
|
19609
19576
|
} else {
|
@@ -75298,7 +75265,6 @@ var init_introspect_mysql = __esm({
|
|
75298
75265
|
patched = patched.startsWith("datetime(") ? "datetime" : patched;
|
75299
75266
|
patched = patched.startsWith("varbinary(") ? "varbinary" : patched;
|
75300
75267
|
patched = patched.startsWith("int(") ? "int" : patched;
|
75301
|
-
patched = patched.startsWith("double(") ? "double" : patched;
|
75302
75268
|
return patched;
|
75303
75269
|
}).filter((type) => {
|
75304
75270
|
return mysqlImportsList.has(type);
|
@@ -83403,7 +83369,7 @@ init_utils2();
|
|
83403
83369
|
var version2 = async () => {
|
83404
83370
|
const { npmVersion } = await ormCoreVersions();
|
83405
83371
|
const ormVersion = npmVersion ? `drizzle-orm: v${npmVersion}` : "";
|
83406
|
-
const envVersion = "0.23.2-
|
83372
|
+
const envVersion = "0.23.2-df9e596";
|
83407
83373
|
const kitVersion = envVersion ? `v${envVersion}` : "--";
|
83408
83374
|
const versions = `drizzle-kit: ${kitVersion}
|
83409
83375
|
${ormVersion}`;
|
package/package.json
CHANGED
package/utils.js
CHANGED
@@ -568,7 +568,6 @@ __export(utils_exports, {
|
|
568
568
|
columnRenameKey: () => columnRenameKey,
|
569
569
|
copy: () => copy,
|
570
570
|
dryJournal: () => dryJournal,
|
571
|
-
isPgArrayType: () => isPgArrayType,
|
572
571
|
kloudMeta: () => kloudMeta,
|
573
572
|
normaliseSQLiteUrl: () => normaliseSQLiteUrl,
|
574
573
|
objectValues: () => objectValues,
|
@@ -5739,16 +5738,12 @@ var normaliseSQLiteUrl = (it, type) => {
|
|
5739
5738
|
}
|
5740
5739
|
assertUnreachable(type);
|
5741
5740
|
};
|
5742
|
-
function isPgArrayType(sqlType) {
|
5743
|
-
return sqlType.match(/.*\[\d*\].*|.*\[\].*/g) !== null;
|
5744
|
-
}
|
5745
5741
|
// Annotate the CommonJS export names for ESM import in node:
|
5746
5742
|
0 && (module.exports = {
|
5747
5743
|
assertV1OutFolder,
|
5748
5744
|
columnRenameKey,
|
5749
5745
|
copy,
|
5750
5746
|
dryJournal,
|
5751
|
-
isPgArrayType,
|
5752
5747
|
kloudMeta,
|
5753
5748
|
normaliseSQLiteUrl,
|
5754
5749
|
objectValues,
|
package/utils.mjs
CHANGED
@@ -5720,15 +5720,11 @@ var normaliseSQLiteUrl = (it, type) => {
|
|
5720
5720
|
}
|
5721
5721
|
assertUnreachable(type);
|
5722
5722
|
};
|
5723
|
-
function isPgArrayType(sqlType) {
|
5724
|
-
return sqlType.match(/.*\[\d*\].*|.*\[\].*/g) !== null;
|
5725
|
-
}
|
5726
5723
|
export {
|
5727
5724
|
assertV1OutFolder,
|
5728
5725
|
columnRenameKey,
|
5729
5726
|
copy,
|
5730
5727
|
dryJournal,
|
5731
|
-
isPgArrayType,
|
5732
5728
|
kloudMeta,
|
5733
5729
|
normaliseSQLiteUrl,
|
5734
5730
|
objectValues,
|