bun-query-builder 0.2.49 → 0.2.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/cli.js +36 -14
- package/dist/migrations.d.ts +19 -1
- package/dist/src/index.js +36 -13
- package/package.json +1 -1
package/dist/bin/cli.js
CHANGED
|
@@ -18614,8 +18614,10 @@ class MySQLDriver {
|
|
|
18614
18614
|
}
|
|
18615
18615
|
const dv = column.defaultValue;
|
|
18616
18616
|
if (typeof dv === "string") {
|
|
18617
|
-
const rawSqlExpressions = ["CURRENT_TIMESTAMP", "NOW()", "NULL", "CURRENT_DATE", "CURRENT_TIME"];
|
|
18618
18617
|
const upperDv = dv.toUpperCase();
|
|
18618
|
+
if (upperDv === "UTC_TIMESTAMP")
|
|
18619
|
+
return `default (UTC_TIMESTAMP)`;
|
|
18620
|
+
const rawSqlExpressions = ["CURRENT_TIMESTAMP", "NOW()", "NULL", "CURRENT_DATE", "CURRENT_TIME"];
|
|
18619
18621
|
if (rawSqlExpressions.includes(upperDv)) {
|
|
18620
18622
|
return `default ${upperDv}`;
|
|
18621
18623
|
}
|
|
@@ -18875,8 +18877,10 @@ class PostgresDriver {
|
|
|
18875
18877
|
}
|
|
18876
18878
|
const dv = column.defaultValue;
|
|
18877
18879
|
if (typeof dv === "string") {
|
|
18878
|
-
const rawSqlExpressions = ["CURRENT_TIMESTAMP", "NOW()", "NULL", "CURRENT_DATE", "CURRENT_TIME"];
|
|
18879
18880
|
const upperDv = dv.toUpperCase();
|
|
18881
|
+
if (upperDv === "UTC_TIMESTAMP")
|
|
18882
|
+
return `default (now() AT TIME ZONE 'utc')`;
|
|
18883
|
+
const rawSqlExpressions = ["CURRENT_TIMESTAMP", "NOW()", "NULL", "CURRENT_DATE", "CURRENT_TIME"];
|
|
18880
18884
|
if (rawSqlExpressions.includes(upperDv)) {
|
|
18881
18885
|
return `default ${upperDv}`;
|
|
18882
18886
|
}
|
|
@@ -19210,6 +19214,8 @@ class SQLiteDriver {
|
|
|
19210
19214
|
}
|
|
19211
19215
|
const dv = column.defaultValue;
|
|
19212
19216
|
if (typeof dv === "string") {
|
|
19217
|
+
if (dv.toUpperCase() === "UTC_TIMESTAMP")
|
|
19218
|
+
return `default CURRENT_TIMESTAMP`;
|
|
19213
19219
|
const sqlFunctions = ["CURRENT_TIMESTAMP", "CURRENT_DATE", "CURRENT_TIME", "NOW()", "NULL", "TRUE", "FALSE"];
|
|
19214
19220
|
if (sqlFunctions.includes(dv.toUpperCase())) {
|
|
19215
19221
|
return `default ${dv.toUpperCase()}`;
|
|
@@ -29490,7 +29496,7 @@ function buildMigrationPlan2(models, options) {
|
|
|
29490
29496
|
isUnique: false,
|
|
29491
29497
|
isNullable: false,
|
|
29492
29498
|
hasDefault: true,
|
|
29493
|
-
defaultValue:
|
|
29499
|
+
defaultValue: UTC_CLOCK_DEFAULT
|
|
29494
29500
|
});
|
|
29495
29501
|
}
|
|
29496
29502
|
if (!columns.some((c2) => c2.name === "updated_at")) {
|
|
@@ -29569,7 +29575,7 @@ function buildMigrationPlan2(models, options) {
|
|
|
29569
29575
|
{ name: "id", type: "bigint", isPrimaryKey: true, isUnique: false, isNullable: false, hasDefault: false },
|
|
29570
29576
|
{ name: "user_id", type: "bigint", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: false, references: { table: "users", column: "id" } },
|
|
29571
29577
|
{ name: fk, type: "bigint", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: false, references: { table: modelTable, column: "id" } },
|
|
29572
|
-
{ name: "created_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: true, defaultValue:
|
|
29578
|
+
{ name: "created_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: true, defaultValue: UTC_CLOCK_DEFAULT },
|
|
29573
29579
|
{ name: "updated_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: true, hasDefault: false }
|
|
29574
29580
|
],
|
|
29575
29581
|
indexes: [{ name: `${likeTable}_user_target_unique`, columns: ["user_id", fk], type: "unique" }]
|
|
@@ -29587,7 +29593,7 @@ function buildMigrationPlan2(models, options) {
|
|
|
29587
29593
|
{ name: "is_active", type: "boolean", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: true, defaultValue: true },
|
|
29588
29594
|
{ name: "taggable_id", type: "bigint", isPrimaryKey: false, isUnique: false, isNullable: true, hasDefault: false },
|
|
29589
29595
|
{ name: "taggable_type", type: "string", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: false },
|
|
29590
|
-
{ name: "created_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: true, defaultValue:
|
|
29596
|
+
{ name: "created_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: true, defaultValue: UTC_CLOCK_DEFAULT },
|
|
29591
29597
|
{ name: "updated_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: true, hasDefault: false }
|
|
29592
29598
|
],
|
|
29593
29599
|
indexes: [
|
|
@@ -29602,7 +29608,7 @@ function buildMigrationPlan2(models, options) {
|
|
|
29602
29608
|
{ name: "tag_id", type: "bigint", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: false, references: { table: "taggables", column: "id" } },
|
|
29603
29609
|
{ name: "taggable_id", type: "bigint", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: false },
|
|
29604
29610
|
{ name: "taggable_type", type: "string", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: false },
|
|
29605
|
-
{ name: "created_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: true, defaultValue:
|
|
29611
|
+
{ name: "created_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: true, defaultValue: UTC_CLOCK_DEFAULT },
|
|
29606
29612
|
{ name: "updated_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: true, hasDefault: false }
|
|
29607
29613
|
],
|
|
29608
29614
|
indexes: [
|
|
@@ -29621,7 +29627,7 @@ function buildMigrationPlan2(models, options) {
|
|
|
29621
29627
|
{ name: "description", type: "text", isPrimaryKey: false, isUnique: false, isNullable: true, hasDefault: false },
|
|
29622
29628
|
{ name: "is_active", type: "boolean", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: true, defaultValue: true },
|
|
29623
29629
|
{ name: "categorizable_type", type: "string", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: false },
|
|
29624
|
-
{ name: "created_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: true, defaultValue:
|
|
29630
|
+
{ name: "created_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: true, defaultValue: UTC_CLOCK_DEFAULT },
|
|
29625
29631
|
{ name: "updated_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: true, hasDefault: false }
|
|
29626
29632
|
],
|
|
29627
29633
|
indexes: [{ name: "categorizables_type_slug_unique", columns: ["categorizable_type", "slug"], type: "unique" }]
|
|
@@ -29633,7 +29639,7 @@ function buildMigrationPlan2(models, options) {
|
|
|
29633
29639
|
{ name: "category_id", type: "bigint", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: false, references: { table: "categorizables", column: "id" } },
|
|
29634
29640
|
{ name: "categorizable_id", type: "bigint", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: false },
|
|
29635
29641
|
{ name: "categorizable_type", type: "string", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: false },
|
|
29636
|
-
{ name: "created_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: true, defaultValue:
|
|
29642
|
+
{ name: "created_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: true, defaultValue: UTC_CLOCK_DEFAULT },
|
|
29637
29643
|
{ name: "updated_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: true, hasDefault: false }
|
|
29638
29644
|
],
|
|
29639
29645
|
indexes: [
|
|
@@ -29697,7 +29703,7 @@ function buildMigrationPlan2(models, options) {
|
|
|
29697
29703
|
}
|
|
29698
29704
|
}
|
|
29699
29705
|
if (pivotCfg.timestamps) {
|
|
29700
|
-
cols.push({ name: "created_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: true, defaultValue:
|
|
29706
|
+
cols.push({ name: "created_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: true, defaultValue: UTC_CLOCK_DEFAULT });
|
|
29701
29707
|
cols.push({ name: "updated_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: true, hasDefault: false });
|
|
29702
29708
|
}
|
|
29703
29709
|
const idx = [];
|
|
@@ -29920,7 +29926,7 @@ function canonicalStorageType(col, dialect) {
|
|
|
29920
29926
|
}
|
|
29921
29927
|
return col.type;
|
|
29922
29928
|
}
|
|
29923
|
-
function canonicalizeDefault(col) {
|
|
29929
|
+
function canonicalizeDefault(col, dialect) {
|
|
29924
29930
|
if (!col.hasDefault || col.defaultValue === undefined)
|
|
29925
29931
|
return;
|
|
29926
29932
|
const dv = col.defaultValue;
|
|
@@ -29935,6 +29941,20 @@ function canonicalizeDefault(col) {
|
|
|
29935
29941
|
if (s2.startsWith("'") && s2.endsWith("'") || s2.startsWith('"') && s2.endsWith('"'))
|
|
29936
29942
|
s2 = s2.slice(1, -1);
|
|
29937
29943
|
const upper = s2.toUpperCase();
|
|
29944
|
+
const utcSpellings = [
|
|
29945
|
+
"UTC_TIMESTAMP",
|
|
29946
|
+
"UTC_TIMESTAMP()",
|
|
29947
|
+
"(UTC_TIMESTAMP)",
|
|
29948
|
+
"(UTC_TIMESTAMP())",
|
|
29949
|
+
"TIMEZONE('UTC', NOW())",
|
|
29950
|
+
"TIMEZONE('UTC'::TEXT, NOW())",
|
|
29951
|
+
"(NOW() AT TIME ZONE 'UTC')",
|
|
29952
|
+
"NOW() AT TIME ZONE 'UTC'"
|
|
29953
|
+
];
|
|
29954
|
+
if (utcSpellings.includes(upper.replace(/\s+/g, " ")))
|
|
29955
|
+
return UTC_CLOCK_DEFAULT;
|
|
29956
|
+
if (dialect === "sqlite" && upper === "CURRENT_TIMESTAMP")
|
|
29957
|
+
return UTC_CLOCK_DEFAULT;
|
|
29938
29958
|
const sqlFns = ["CURRENT_TIMESTAMP", "NOW()", "CURRENT_DATE", "CURRENT_TIME", "NULL", "TRUE", "FALSE"];
|
|
29939
29959
|
if (sqlFns.includes(upper))
|
|
29940
29960
|
return upper === "NOW()" ? "CURRENT_TIMESTAMP" : upper;
|
|
@@ -29955,7 +29975,7 @@ function columnsAreDifferent(col1, col2, dialect) {
|
|
|
29955
29975
|
return true;
|
|
29956
29976
|
if (col1.hasDefault !== col2.hasDefault)
|
|
29957
29977
|
return true;
|
|
29958
|
-
if (canonicalizeDefault(col1) !== canonicalizeDefault(col2))
|
|
29978
|
+
if (canonicalizeDefault(col1, dialect) !== canonicalizeDefault(col2, dialect))
|
|
29959
29979
|
return true;
|
|
29960
29980
|
if (col1.isUnique !== col2.isUnique)
|
|
29961
29981
|
return true;
|
|
@@ -29974,7 +29994,7 @@ function columnSignature(col, dialect) {
|
|
|
29974
29994
|
col.isUnique,
|
|
29975
29995
|
col.isNullable,
|
|
29976
29996
|
col.hasDefault,
|
|
29977
|
-
canonicalizeDefault(col) ?? null,
|
|
29997
|
+
canonicalizeDefault(col, dialect) ?? null,
|
|
29978
29998
|
(col.enumValues ?? []).slice().sort(),
|
|
29979
29999
|
col.references ? [col.references.table, col.references.column, col.references.onDelete ?? null, col.references.onUpdate ?? null] : null
|
|
29980
30000
|
]);
|
|
@@ -30334,7 +30354,7 @@ function generateDiffOperations(previous, next, opts = {}) {
|
|
|
30334
30354
|
function generateDiffSql(previous, next, opts = {}) {
|
|
30335
30355
|
return generateDiffOperations(previous, next, opts).statements;
|
|
30336
30356
|
}
|
|
30337
|
-
var migrationCounter = 0, migrationsCreatedCount = 0, migrationsUpdatedCount = 0, useDeterministicNames = true, createdMigrationFiles, existingCorpusBodies = null, GENERATED_MARKER = "-- qb:generated", MAX_BOUNDED_VARCHAR_LENGTH = 767;
|
|
30357
|
+
var migrationCounter = 0, migrationsCreatedCount = 0, migrationsUpdatedCount = 0, useDeterministicNames = true, createdMigrationFiles, existingCorpusBodies = null, GENERATED_MARKER = "-- qb:generated", MAX_BOUNDED_VARCHAR_LENGTH = 767, UTC_CLOCK_DEFAULT = "UTC_TIMESTAMP";
|
|
30338
30358
|
var init_migrations = __esm(() => {
|
|
30339
30359
|
init_config();
|
|
30340
30360
|
init_drivers();
|
|
@@ -30417,6 +30437,8 @@ function satisfies(declared, actual, dialect) {
|
|
|
30417
30437
|
if ((declared === "date" || declared === "json") && actual === "text")
|
|
30418
30438
|
return true;
|
|
30419
30439
|
}
|
|
30440
|
+
if (isMysqlLike(dialect) && declared === "boolean" && actual === "integer")
|
|
30441
|
+
return true;
|
|
30420
30442
|
if (declared === "varchar" && actual === "text")
|
|
30421
30443
|
return true;
|
|
30422
30444
|
if (declared === "integer" && actual === "fractional")
|
|
@@ -32593,7 +32615,7 @@ function getPrefix() {
|
|
|
32593
32615
|
}
|
|
32594
32616
|
var prefix = getPrefix();
|
|
32595
32617
|
// package.json
|
|
32596
|
-
var version2 = "0.2.
|
|
32618
|
+
var version2 = "0.2.51";
|
|
32597
32619
|
|
|
32598
32620
|
// bin/cli.ts
|
|
32599
32621
|
init_actions();
|
package/dist/migrations.d.ts
CHANGED
|
@@ -49,7 +49,7 @@ export declare function canonicalStorageType(col: ColumnPlan, dialect: Supported
|
|
|
49
49
|
* differently by a live DB vs a model (quoting, casts, `now()` vs
|
|
50
50
|
* `CURRENT_TIMESTAMP`, `0` vs `'0'`) compare equal.
|
|
51
51
|
*/
|
|
52
|
-
export declare function canonicalizeDefault(col: ColumnPlan): string | undefined;
|
|
52
|
+
export declare function canonicalizeDefault(col: ColumnPlan, dialect?: SupportedDialect): string | undefined;
|
|
53
53
|
/**
|
|
54
54
|
* Generate comprehensive SQL to migrate from a previous plan to a new plan,
|
|
55
55
|
* plus a structured list of the operations involved (so callers can gate
|
|
@@ -83,6 +83,24 @@ export declare function generateDiffSql(previous: MigrationPlan | undefined, nex
|
|
|
83
83
|
* are recorded, run once, and never removed.
|
|
84
84
|
*/
|
|
85
85
|
export declare const GENERATED_MARKER: '-- qb:generated';
|
|
86
|
+
/**
|
|
87
|
+
* The database's own clock, in UTC, as a default.
|
|
88
|
+
*
|
|
89
|
+
* A managed `created_at` used to default to `CURRENT_TIMESTAMP`, which is the
|
|
90
|
+
* *session's local* wall clock on both Postgres and MySQL. On a host set to
|
|
91
|
+
* anything but UTC that writes digits that never happened in UTC, and every
|
|
92
|
+
* reader is out by the offset - it surfaced in ReviewOS as "7 hours ago" on a
|
|
93
|
+
* row written seconds earlier. The column type is not the bug and is unchanged:
|
|
94
|
+
* naive UTC is the convention, because MySQL has nothing equivalent to
|
|
95
|
+
* `timestamptz`.
|
|
96
|
+
*
|
|
97
|
+
* This is the marker, not the SQL. Each driver renders it in its own spelling,
|
|
98
|
+
* because there is no portable one: Postgres wants `(now() AT TIME ZONE 'utc')`,
|
|
99
|
+
* MySQL takes `UTC_TIMESTAMP` only inside brackets, and SQLite's
|
|
100
|
+
* `CURRENT_TIMESTAMP` is already UTC and is the only dialect that was right by
|
|
101
|
+
* accident.
|
|
102
|
+
*/
|
|
103
|
+
export declare const UTC_CLOCK_DEFAULT: 'UTC_TIMESTAMP';
|
|
86
104
|
export declare interface ColumnPlan {
|
|
87
105
|
name: string
|
|
88
106
|
type: NormalizedColumnType
|
package/dist/src/index.js
CHANGED
|
@@ -18613,8 +18613,10 @@ class MySQLDriver {
|
|
|
18613
18613
|
}
|
|
18614
18614
|
const dv = column.defaultValue;
|
|
18615
18615
|
if (typeof dv === "string") {
|
|
18616
|
-
const rawSqlExpressions = ["CURRENT_TIMESTAMP", "NOW()", "NULL", "CURRENT_DATE", "CURRENT_TIME"];
|
|
18617
18616
|
const upperDv = dv.toUpperCase();
|
|
18617
|
+
if (upperDv === "UTC_TIMESTAMP")
|
|
18618
|
+
return `default (UTC_TIMESTAMP)`;
|
|
18619
|
+
const rawSqlExpressions = ["CURRENT_TIMESTAMP", "NOW()", "NULL", "CURRENT_DATE", "CURRENT_TIME"];
|
|
18618
18620
|
if (rawSqlExpressions.includes(upperDv)) {
|
|
18619
18621
|
return `default ${upperDv}`;
|
|
18620
18622
|
}
|
|
@@ -18874,8 +18876,10 @@ class PostgresDriver {
|
|
|
18874
18876
|
}
|
|
18875
18877
|
const dv = column.defaultValue;
|
|
18876
18878
|
if (typeof dv === "string") {
|
|
18877
|
-
const rawSqlExpressions = ["CURRENT_TIMESTAMP", "NOW()", "NULL", "CURRENT_DATE", "CURRENT_TIME"];
|
|
18878
18879
|
const upperDv = dv.toUpperCase();
|
|
18880
|
+
if (upperDv === "UTC_TIMESTAMP")
|
|
18881
|
+
return `default (now() AT TIME ZONE 'utc')`;
|
|
18882
|
+
const rawSqlExpressions = ["CURRENT_TIMESTAMP", "NOW()", "NULL", "CURRENT_DATE", "CURRENT_TIME"];
|
|
18879
18883
|
if (rawSqlExpressions.includes(upperDv)) {
|
|
18880
18884
|
return `default ${upperDv}`;
|
|
18881
18885
|
}
|
|
@@ -19209,6 +19213,8 @@ class SQLiteDriver {
|
|
|
19209
19213
|
}
|
|
19210
19214
|
const dv = column.defaultValue;
|
|
19211
19215
|
if (typeof dv === "string") {
|
|
19216
|
+
if (dv.toUpperCase() === "UTC_TIMESTAMP")
|
|
19217
|
+
return `default CURRENT_TIMESTAMP`;
|
|
19212
19218
|
const sqlFunctions = ["CURRENT_TIMESTAMP", "CURRENT_DATE", "CURRENT_TIME", "NOW()", "NULL", "TRUE", "FALSE"];
|
|
19213
19219
|
if (sqlFunctions.includes(dv.toUpperCase())) {
|
|
19214
19220
|
return `default ${dv.toUpperCase()}`;
|
|
@@ -29489,7 +29495,7 @@ function buildMigrationPlan2(models, options) {
|
|
|
29489
29495
|
isUnique: false,
|
|
29490
29496
|
isNullable: false,
|
|
29491
29497
|
hasDefault: true,
|
|
29492
|
-
defaultValue:
|
|
29498
|
+
defaultValue: UTC_CLOCK_DEFAULT
|
|
29493
29499
|
});
|
|
29494
29500
|
}
|
|
29495
29501
|
if (!columns.some((c2) => c2.name === "updated_at")) {
|
|
@@ -29568,7 +29574,7 @@ function buildMigrationPlan2(models, options) {
|
|
|
29568
29574
|
{ name: "id", type: "bigint", isPrimaryKey: true, isUnique: false, isNullable: false, hasDefault: false },
|
|
29569
29575
|
{ name: "user_id", type: "bigint", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: false, references: { table: "users", column: "id" } },
|
|
29570
29576
|
{ name: fk, type: "bigint", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: false, references: { table: modelTable, column: "id" } },
|
|
29571
|
-
{ name: "created_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: true, defaultValue:
|
|
29577
|
+
{ name: "created_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: true, defaultValue: UTC_CLOCK_DEFAULT },
|
|
29572
29578
|
{ name: "updated_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: true, hasDefault: false }
|
|
29573
29579
|
],
|
|
29574
29580
|
indexes: [{ name: `${likeTable}_user_target_unique`, columns: ["user_id", fk], type: "unique" }]
|
|
@@ -29586,7 +29592,7 @@ function buildMigrationPlan2(models, options) {
|
|
|
29586
29592
|
{ name: "is_active", type: "boolean", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: true, defaultValue: true },
|
|
29587
29593
|
{ name: "taggable_id", type: "bigint", isPrimaryKey: false, isUnique: false, isNullable: true, hasDefault: false },
|
|
29588
29594
|
{ name: "taggable_type", type: "string", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: false },
|
|
29589
|
-
{ name: "created_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: true, defaultValue:
|
|
29595
|
+
{ name: "created_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: true, defaultValue: UTC_CLOCK_DEFAULT },
|
|
29590
29596
|
{ name: "updated_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: true, hasDefault: false }
|
|
29591
29597
|
],
|
|
29592
29598
|
indexes: [
|
|
@@ -29601,7 +29607,7 @@ function buildMigrationPlan2(models, options) {
|
|
|
29601
29607
|
{ name: "tag_id", type: "bigint", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: false, references: { table: "taggables", column: "id" } },
|
|
29602
29608
|
{ name: "taggable_id", type: "bigint", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: false },
|
|
29603
29609
|
{ name: "taggable_type", type: "string", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: false },
|
|
29604
|
-
{ name: "created_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: true, defaultValue:
|
|
29610
|
+
{ name: "created_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: true, defaultValue: UTC_CLOCK_DEFAULT },
|
|
29605
29611
|
{ name: "updated_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: true, hasDefault: false }
|
|
29606
29612
|
],
|
|
29607
29613
|
indexes: [
|
|
@@ -29620,7 +29626,7 @@ function buildMigrationPlan2(models, options) {
|
|
|
29620
29626
|
{ name: "description", type: "text", isPrimaryKey: false, isUnique: false, isNullable: true, hasDefault: false },
|
|
29621
29627
|
{ name: "is_active", type: "boolean", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: true, defaultValue: true },
|
|
29622
29628
|
{ name: "categorizable_type", type: "string", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: false },
|
|
29623
|
-
{ name: "created_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: true, defaultValue:
|
|
29629
|
+
{ name: "created_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: true, defaultValue: UTC_CLOCK_DEFAULT },
|
|
29624
29630
|
{ name: "updated_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: true, hasDefault: false }
|
|
29625
29631
|
],
|
|
29626
29632
|
indexes: [{ name: "categorizables_type_slug_unique", columns: ["categorizable_type", "slug"], type: "unique" }]
|
|
@@ -29632,7 +29638,7 @@ function buildMigrationPlan2(models, options) {
|
|
|
29632
29638
|
{ name: "category_id", type: "bigint", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: false, references: { table: "categorizables", column: "id" } },
|
|
29633
29639
|
{ name: "categorizable_id", type: "bigint", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: false },
|
|
29634
29640
|
{ name: "categorizable_type", type: "string", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: false },
|
|
29635
|
-
{ name: "created_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: true, defaultValue:
|
|
29641
|
+
{ name: "created_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: true, defaultValue: UTC_CLOCK_DEFAULT },
|
|
29636
29642
|
{ name: "updated_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: true, hasDefault: false }
|
|
29637
29643
|
],
|
|
29638
29644
|
indexes: [
|
|
@@ -29696,7 +29702,7 @@ function buildMigrationPlan2(models, options) {
|
|
|
29696
29702
|
}
|
|
29697
29703
|
}
|
|
29698
29704
|
if (pivotCfg.timestamps) {
|
|
29699
|
-
cols.push({ name: "created_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: true, defaultValue:
|
|
29705
|
+
cols.push({ name: "created_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: false, hasDefault: true, defaultValue: UTC_CLOCK_DEFAULT });
|
|
29700
29706
|
cols.push({ name: "updated_at", type: "datetime", isPrimaryKey: false, isUnique: false, isNullable: true, hasDefault: false });
|
|
29701
29707
|
}
|
|
29702
29708
|
const idx = [];
|
|
@@ -29919,7 +29925,7 @@ function canonicalStorageType(col, dialect) {
|
|
|
29919
29925
|
}
|
|
29920
29926
|
return col.type;
|
|
29921
29927
|
}
|
|
29922
|
-
function canonicalizeDefault(col) {
|
|
29928
|
+
function canonicalizeDefault(col, dialect) {
|
|
29923
29929
|
if (!col.hasDefault || col.defaultValue === undefined)
|
|
29924
29930
|
return;
|
|
29925
29931
|
const dv = col.defaultValue;
|
|
@@ -29934,6 +29940,20 @@ function canonicalizeDefault(col) {
|
|
|
29934
29940
|
if (s2.startsWith("'") && s2.endsWith("'") || s2.startsWith('"') && s2.endsWith('"'))
|
|
29935
29941
|
s2 = s2.slice(1, -1);
|
|
29936
29942
|
const upper = s2.toUpperCase();
|
|
29943
|
+
const utcSpellings = [
|
|
29944
|
+
"UTC_TIMESTAMP",
|
|
29945
|
+
"UTC_TIMESTAMP()",
|
|
29946
|
+
"(UTC_TIMESTAMP)",
|
|
29947
|
+
"(UTC_TIMESTAMP())",
|
|
29948
|
+
"TIMEZONE('UTC', NOW())",
|
|
29949
|
+
"TIMEZONE('UTC'::TEXT, NOW())",
|
|
29950
|
+
"(NOW() AT TIME ZONE 'UTC')",
|
|
29951
|
+
"NOW() AT TIME ZONE 'UTC'"
|
|
29952
|
+
];
|
|
29953
|
+
if (utcSpellings.includes(upper.replace(/\s+/g, " ")))
|
|
29954
|
+
return UTC_CLOCK_DEFAULT;
|
|
29955
|
+
if (dialect === "sqlite" && upper === "CURRENT_TIMESTAMP")
|
|
29956
|
+
return UTC_CLOCK_DEFAULT;
|
|
29937
29957
|
const sqlFns = ["CURRENT_TIMESTAMP", "NOW()", "CURRENT_DATE", "CURRENT_TIME", "NULL", "TRUE", "FALSE"];
|
|
29938
29958
|
if (sqlFns.includes(upper))
|
|
29939
29959
|
return upper === "NOW()" ? "CURRENT_TIMESTAMP" : upper;
|
|
@@ -29954,7 +29974,7 @@ function columnsAreDifferent(col1, col2, dialect) {
|
|
|
29954
29974
|
return true;
|
|
29955
29975
|
if (col1.hasDefault !== col2.hasDefault)
|
|
29956
29976
|
return true;
|
|
29957
|
-
if (canonicalizeDefault(col1) !== canonicalizeDefault(col2))
|
|
29977
|
+
if (canonicalizeDefault(col1, dialect) !== canonicalizeDefault(col2, dialect))
|
|
29958
29978
|
return true;
|
|
29959
29979
|
if (col1.isUnique !== col2.isUnique)
|
|
29960
29980
|
return true;
|
|
@@ -29973,7 +29993,7 @@ function columnSignature(col, dialect) {
|
|
|
29973
29993
|
col.isUnique,
|
|
29974
29994
|
col.isNullable,
|
|
29975
29995
|
col.hasDefault,
|
|
29976
|
-
canonicalizeDefault(col) ?? null,
|
|
29996
|
+
canonicalizeDefault(col, dialect) ?? null,
|
|
29977
29997
|
(col.enumValues ?? []).slice().sort(),
|
|
29978
29998
|
col.references ? [col.references.table, col.references.column, col.references.onDelete ?? null, col.references.onUpdate ?? null] : null
|
|
29979
29999
|
]);
|
|
@@ -30333,7 +30353,7 @@ function generateDiffOperations(previous, next, opts = {}) {
|
|
|
30333
30353
|
function generateDiffSql(previous, next, opts = {}) {
|
|
30334
30354
|
return generateDiffOperations(previous, next, opts).statements;
|
|
30335
30355
|
}
|
|
30336
|
-
var migrationCounter = 0, migrationsCreatedCount = 0, migrationsUpdatedCount = 0, useDeterministicNames = true, createdMigrationFiles, existingCorpusBodies = null, GENERATED_MARKER = "-- qb:generated", MAX_BOUNDED_VARCHAR_LENGTH = 767;
|
|
30356
|
+
var migrationCounter = 0, migrationsCreatedCount = 0, migrationsUpdatedCount = 0, useDeterministicNames = true, createdMigrationFiles, existingCorpusBodies = null, GENERATED_MARKER = "-- qb:generated", MAX_BOUNDED_VARCHAR_LENGTH = 767, UTC_CLOCK_DEFAULT = "UTC_TIMESTAMP";
|
|
30337
30357
|
var init_migrations = __esm(() => {
|
|
30338
30358
|
init_config();
|
|
30339
30359
|
init_drivers();
|
|
@@ -30416,6 +30436,8 @@ function satisfies(declared, actual, dialect) {
|
|
|
30416
30436
|
if ((declared === "date" || declared === "json") && actual === "text")
|
|
30417
30437
|
return true;
|
|
30418
30438
|
}
|
|
30439
|
+
if (isMysqlLike(dialect) && declared === "boolean" && actual === "integer")
|
|
30440
|
+
return true;
|
|
30419
30441
|
if (declared === "varchar" && actual === "text")
|
|
30420
30442
|
return true;
|
|
30421
30443
|
if (declared === "integer" && actual === "fractional")
|
|
@@ -30670,6 +30692,7 @@ export {
|
|
|
30670
30692
|
auditSchemaDrift,
|
|
30671
30693
|
applySqliteBootstrapPragmas,
|
|
30672
30694
|
VitessDriver,
|
|
30695
|
+
UTC_CLOCK_DEFAULT,
|
|
30673
30696
|
SingleTableRepository,
|
|
30674
30697
|
SingleTableQueryBuilder,
|
|
30675
30698
|
SingleTablePatterns,
|
package/package.json
CHANGED