drizzle-kit 0.23.2-cd71182 → 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 -51
- package/api.mjs +53 -51
- 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,
|
17521
|
-
/** @internal */
|
17522
|
-
__publicField(this, _c, false);
|
17517
|
+
__publicField(this, _c);
|
17523
17518
|
/** @internal */
|
17524
|
-
__publicField(this, _b,
|
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,
|
@@ -24641,30 +24636,6 @@ function minRangeForIdentityBasedOn(columnType) {
|
|
24641
24636
|
function stringFromDatabaseIdentityProperty(field) {
|
24642
24637
|
return typeof field === "string" ? field : typeof field === "undefined" ? void 0 : typeof field === "bigint" ? field.toString() : String(field);
|
24643
24638
|
}
|
24644
|
-
function buildArrayString(array, sqlType) {
|
24645
|
-
sqlType = sqlType.split("[")[0];
|
24646
|
-
const values = array.map((value) => {
|
24647
|
-
if (typeof value === "number" || typeof value === "bigint") {
|
24648
|
-
return value.toString();
|
24649
|
-
} else if (typeof value === "boolean") {
|
24650
|
-
return value ? "true" : "false";
|
24651
|
-
} else if (Array.isArray(value)) {
|
24652
|
-
return buildArrayString(value, sqlType);
|
24653
|
-
} else if (value instanceof Date) {
|
24654
|
-
if (sqlType === "date") {
|
24655
|
-
return `"${value.toISOString().split("T")[0]}"`;
|
24656
|
-
} else if (sqlType === "timestamp") {
|
24657
|
-
return `"${value.toISOString().replace("T", " ").slice(0, 23)}"`;
|
24658
|
-
} else {
|
24659
|
-
return `"${value.toISOString()}"`;
|
24660
|
-
}
|
24661
|
-
} else if (typeof value === "object") {
|
24662
|
-
return `"${JSON.stringify(value).replaceAll('"', '\\"')}"`;
|
24663
|
-
}
|
24664
|
-
return `"${value}"`;
|
24665
|
-
}).join(",");
|
24666
|
-
return `{${values}}`;
|
24667
|
-
}
|
24668
24639
|
var dialect4, indexName, generatePgSnapshot, trimChar, fromDatabase, columnToDefault, defaultForColumn;
|
24669
24640
|
var init_pgSerializer = __esm({
|
24670
24641
|
"src/serializer/pgSerializer.ts"() {
|
@@ -24675,7 +24646,6 @@ var init_pgSerializer = __esm({
|
|
24675
24646
|
init_pg_core();
|
24676
24647
|
init_vector3();
|
24677
24648
|
init_outputs();
|
24678
|
-
init_utils();
|
24679
24649
|
init_serializer();
|
24680
24650
|
dialect4 = new PgDialect();
|
24681
24651
|
indexName = (tableName, columns) => {
|
@@ -24782,11 +24752,6 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
24782
24752
|
} else {
|
24783
24753
|
columnToSet.default = `'${column4.default.toISOString()}'`;
|
24784
24754
|
}
|
24785
|
-
} else if (isPgArrayType(sqlTypeLowered) && Array.isArray(column4.default)) {
|
24786
|
-
columnToSet.default = `'${buildArrayString(
|
24787
|
-
column4.default,
|
24788
|
-
sqlTypeLowered
|
24789
|
-
)}'::${sqlTypeLowered}`;
|
24790
24755
|
} else {
|
24791
24756
|
columnToSet.default = column4.default;
|
24792
24757
|
}
|
@@ -29066,7 +29031,7 @@ The unique constraint ${source_default.underline.blue(
|
|
29066
29031
|
primaryKeys.forEach((it) => {
|
29067
29032
|
if (it.columns.length > 1) {
|
29068
29033
|
primaryKeysObject[it.getName()] = {
|
29069
|
-
columns: it.columns.map((it2) => it2.name)
|
29034
|
+
columns: it.columns.map((it2) => it2.name),
|
29070
29035
|
name: it.getName()
|
29071
29036
|
};
|
29072
29037
|
} else {
|
@@ -33635,7 +33600,7 @@ We have encountered a collision between the index name on columns ${source_defau
|
|
33635
33600
|
onUpdate = true;
|
33636
33601
|
}
|
33637
33602
|
const newColumn = {
|
33638
|
-
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}'`,
|
33639
33604
|
autoincrement: isAutoincrement,
|
33640
33605
|
name: columnName,
|
33641
33606
|
type: changedType,
|
@@ -34852,6 +34817,37 @@ var updateUpToV6 = (json) => {
|
|
34852
34817
|
enums
|
34853
34818
|
};
|
34854
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
|
+
};
|
34855
34851
|
|
34856
34852
|
// src/cli/commands/sqliteIntrospect.ts
|
34857
34853
|
var import_hanji6 = __toESM(require_hanji());
|
@@ -35508,7 +35504,13 @@ var pushMySQLSchema = async (imports, drizzleInstance, databaseName) => {
|
|
35508
35504
|
};
|
35509
35505
|
};
|
35510
35506
|
var upPgSnapshot = (snapshot) => {
|
35511
|
-
|
35507
|
+
if (snapshot.version === "5") {
|
35508
|
+
return updateUpToV7(updateUpToV6(snapshot));
|
35509
|
+
}
|
35510
|
+
if (snapshot.version === "6") {
|
35511
|
+
return updateUpToV7(snapshot);
|
35512
|
+
}
|
35513
|
+
return snapshot;
|
35512
35514
|
};
|
35513
35515
|
// Annotate the CommonJS export names for ESM import in node:
|
35514
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,
|
17526
|
-
/** @internal */
|
17527
|
-
__publicField(this, _c, false);
|
17522
|
+
__publicField(this, _c);
|
17528
17523
|
/** @internal */
|
17529
|
-
__publicField(this, _b,
|
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,
|
@@ -24646,30 +24641,6 @@ function minRangeForIdentityBasedOn(columnType) {
|
|
24646
24641
|
function stringFromDatabaseIdentityProperty(field) {
|
24647
24642
|
return typeof field === "string" ? field : typeof field === "undefined" ? void 0 : typeof field === "bigint" ? field.toString() : String(field);
|
24648
24643
|
}
|
24649
|
-
function buildArrayString(array, sqlType) {
|
24650
|
-
sqlType = sqlType.split("[")[0];
|
24651
|
-
const values = array.map((value) => {
|
24652
|
-
if (typeof value === "number" || typeof value === "bigint") {
|
24653
|
-
return value.toString();
|
24654
|
-
} else if (typeof value === "boolean") {
|
24655
|
-
return value ? "true" : "false";
|
24656
|
-
} else if (Array.isArray(value)) {
|
24657
|
-
return buildArrayString(value, sqlType);
|
24658
|
-
} else if (value instanceof Date) {
|
24659
|
-
if (sqlType === "date") {
|
24660
|
-
return `"${value.toISOString().split("T")[0]}"`;
|
24661
|
-
} else if (sqlType === "timestamp") {
|
24662
|
-
return `"${value.toISOString().replace("T", " ").slice(0, 23)}"`;
|
24663
|
-
} else {
|
24664
|
-
return `"${value.toISOString()}"`;
|
24665
|
-
}
|
24666
|
-
} else if (typeof value === "object") {
|
24667
|
-
return `"${JSON.stringify(value).replaceAll('"', '\\"')}"`;
|
24668
|
-
}
|
24669
|
-
return `"${value}"`;
|
24670
|
-
}).join(",");
|
24671
|
-
return `{${values}}`;
|
24672
|
-
}
|
24673
24644
|
var dialect4, indexName, generatePgSnapshot, trimChar, fromDatabase, columnToDefault, defaultForColumn;
|
24674
24645
|
var init_pgSerializer = __esm({
|
24675
24646
|
"src/serializer/pgSerializer.ts"() {
|
@@ -24680,7 +24651,6 @@ var init_pgSerializer = __esm({
|
|
24680
24651
|
init_pg_core();
|
24681
24652
|
init_vector3();
|
24682
24653
|
init_outputs();
|
24683
|
-
init_utils();
|
24684
24654
|
init_serializer();
|
24685
24655
|
dialect4 = new PgDialect();
|
24686
24656
|
indexName = (tableName, columns) => {
|
@@ -24787,11 +24757,6 @@ ${withStyle.errorWarning(`We've found duplicated unique constraint names in ${so
|
|
24787
24757
|
} else {
|
24788
24758
|
columnToSet.default = `'${column4.default.toISOString()}'`;
|
24789
24759
|
}
|
24790
|
-
} else if (isPgArrayType(sqlTypeLowered) && Array.isArray(column4.default)) {
|
24791
|
-
columnToSet.default = `'${buildArrayString(
|
24792
|
-
column4.default,
|
24793
|
-
sqlTypeLowered
|
24794
|
-
)}'::${sqlTypeLowered}`;
|
24795
24760
|
} else {
|
24796
24761
|
columnToSet.default = column4.default;
|
24797
24762
|
}
|
@@ -29071,7 +29036,7 @@ The unique constraint ${source_default.underline.blue(
|
|
29071
29036
|
primaryKeys.forEach((it) => {
|
29072
29037
|
if (it.columns.length > 1) {
|
29073
29038
|
primaryKeysObject[it.getName()] = {
|
29074
|
-
columns: it.columns.map((it2) => it2.name)
|
29039
|
+
columns: it.columns.map((it2) => it2.name),
|
29075
29040
|
name: it.getName()
|
29076
29041
|
};
|
29077
29042
|
} else {
|
@@ -33640,7 +33605,7 @@ We have encountered a collision between the index name on columns ${source_defau
|
|
33640
33605
|
onUpdate = true;
|
33641
33606
|
}
|
33642
33607
|
const newColumn = {
|
33643
|
-
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}'`,
|
33644
33609
|
autoincrement: isAutoincrement,
|
33645
33610
|
name: columnName,
|
33646
33611
|
type: changedType,
|
@@ -34843,6 +34808,37 @@ var updateUpToV6 = (json) => {
|
|
34843
34808
|
enums
|
34844
34809
|
};
|
34845
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
|
+
};
|
34846
34842
|
|
34847
34843
|
// src/cli/commands/sqliteIntrospect.ts
|
34848
34844
|
var import_hanji6 = __toESM(require_hanji());
|
@@ -35499,7 +35495,13 @@ var pushMySQLSchema = async (imports, drizzleInstance, databaseName) => {
|
|
35499
35495
|
};
|
35500
35496
|
};
|
35501
35497
|
var upPgSnapshot = (snapshot) => {
|
35502
|
-
|
35498
|
+
if (snapshot.version === "5") {
|
35499
|
+
return updateUpToV7(updateUpToV6(snapshot));
|
35500
|
+
}
|
35501
|
+
if (snapshot.version === "6") {
|
35502
|
+
return updateUpToV7(snapshot);
|
35503
|
+
}
|
35504
|
+
return snapshot;
|
35503
35505
|
};
|
35504
35506
|
export {
|
35505
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,
|