- Replace hand-written node:sqlite queries with a Prisma client using the better-sqlite3 driver adapter - Version the schema with migrations: baseline table, timestamp normalisation, and WAL journal mode - Store timestamps with an explicit UTC offset so they stop being parsed as local time - Show created/updated times on the edit page, formatted with dayjs - Move the root redirect into next.config to avoid a prerender error - Run migrations from the container entrypoint before starting the server BREAKING CHANGE: DNSMASQ_ADMIN_DB_PATH is replaced by DATABASE_URL, which must be a Prisma connection URL (file:./data/dnsmasq-admin.db). Existing database files are migrated in place and need no conversion.
19 lines
1.0 KiB
SQL
19 lines
1.0 KiB
SQL
-- Rewrite timestamps written by the v0.1.0 schema into the format Prisma expects.
|
|
--
|
|
-- Background: the old column default was `datetime('now')`, producing values like
|
|
-- `2026-10-09 08:55:10`. SQLite stores that UTC, but JavaScript parses the space-separated
|
|
-- form as *local* time — on a UTC+8 machine `new Date('2026-10-09 08:55:10')` yields
|
|
-- 00:55:10Z, silently off by eight hours. Prisma 7's better-sqlite3 adapter writes
|
|
-- `2026-10-09T08:55:10.000+00:00` instead, which is unambiguous.
|
|
--
|
|
-- Leaving old rows in the legacy format would give one column two different parse rules
|
|
-- depending on when the row was created, so every existing row is normalised here.
|
|
--
|
|
-- Idempotent: the WHERE clause skips anything already in ISO shape, so this is a no-op on
|
|
-- freshly migrated databases and safe to re-run.
|
|
UPDATE "records"
|
|
SET
|
|
"created_at" = strftime('%Y-%m-%dT%H:%M:%S.000+00:00', "created_at"),
|
|
"updated_at" = strftime('%Y-%m-%dT%H:%M:%S.000+00:00', "updated_at")
|
|
WHERE "created_at" NOT LIKE '____-__-__T%';
|