You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 71de7fb
Browse filesBrowse the repository at this point in the historyBrowse files
fix(migrate-ts): SQLite timestamp "now" defaults use the ISO form generated code writes
A field.timestamp defaulting to now (@autoset, @default "now") emitted
DEFAULT CURRENT_TIMESTAMP, which stores 2026-09-26 14:08:05, while generated code
writes 2026-09-26T14:08:05.053Z. A table mixing database-defaulted and
application-written rows held two spellings that neither sort nor compare as the
same instant. The default is now strftime('%Y-%m-%dT%H:%M:%fZ','now'), which
produces exactly Date.toISOString()'s shape. The generated Drizzle schema carries
the same default (goldens and the showcase regenerated).
No churn for existing databases: columnDefaultsEqual treats CURRENT_TIMESTAMP and
the ISO expression as the same default, so a CURRENT_TIMESTAMP column is not
rebuilt for the spelling. A new integration test proves the re-diff is empty
against such a table.
The SQLite emitter also wraps a function-call default in parentheses, as SQLite
requires; an authored default such as datetime('now') previously produced a
CREATE TABLE that did not parse.
Docs: the SQLite floor section now states 3.35 for tables and views, and the
CHANGELOG covers both SQLite changes plus the #389 agent-context change. Plan
items 6 and 7 of the 1.1 plan are marked done.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01M1mRRB1K2WdYy82kntMQdx
| aggregate `FILTER (WHERE …)`, `NULLS LAST`| 3.30 | a projection view with `origin.*` scoping / ordering |
347
-
| in-aggregate `ORDER BY` (`json_group_array(x ORDER BY …)`) |**3.44**| a projection view using `origin.collect`|
348
-
349
-
**The floor for tables and their constraints is SQLite 3.35** (Ubuntu 22.04 ships 3.37.2;
350
-
D1's baseline is 3.44). A database whose views use `origin.collect` needs **3.44** to open.
347
+
|`json_each`, `json_group_array` (JSON1) | 3.35 in practice (JSON1 built in since 3.38; earlier builds usually enable it) | a projection view using `origin.collect`|
348
+
349
+
**The floor is SQLite 3.35, for tables and views alike** (Ubuntu 22.04 ships 3.37.2; D1's
350
+
baseline is 3.44). Up to 1.0.9 a view using `origin.collect` ordered its elements with an
351
+
in-aggregate `ORDER BY` (`json_group_array(x ORDER BY …)`), which needs SQLite 3.44. A
352
+
collect column is now built in two steps: the grouped query gathers each element together
353
+
with its sort keys, and an outer query sorts them, which every SQLite from 3.35 runs. The
354
+
next `meta migrate` against a database made before that change replaces such views once;
355
+
the re-diff is empty afterwards.
356
+
357
+
A `field.timestamp` whose default is "now" (`@autoSet`, or `@default: "now"`) defaults to
358
+
`strftime('%Y-%m-%dT%H:%M:%fZ','now')`, the same ISO UTC form generated code writes, rather
359
+
than `CURRENT_TIMESTAMP`'s `YYYY-MM-DD HH:MM:SS`. A column that already defaults to
360
+
`CURRENT_TIMESTAMP` is not rebuilt for the spelling: the two are treated as the same default,
361
+
and the ISO one arrives the next time something else rebuilds that table.
351
362
352
363
Null-safe (in)equality in a derived CHECK (`validator.requiredWhen`, `validator.presentIff`)
353
364
is spelled with SQLite's own `IS NOT` / `IS`, which every version parses. Up to 1.0.8 it was
0 commit comments