Files
jamo.siu@gmail.com 1e4f028685 refactor(db): switch records layer to Prisma
- 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.
2026-10-12 14:27:03 +08:00

12 lines
746 B
SQL

-- Set journal_mode to WAL, exactly as the pre-Prisma code did on every connection open.
--
-- WAL lets readers proceed while a write is in flight, which matters here: the SQLite file is
-- frequently opened by something else at the same time — the sqlite3 CLI, or a database
-- console in an IDE — and the UI answers from it on every page load.
--
-- Unlike busy_timeout, this cannot be set from the app: the better-sqlite3 adapter takes only
-- a connection URL and driver options, with no hook for PRAGMAs. It is safe to do here
-- because `PRAGMA journal_mode` is a persistent property of the database file, so it only has
-- to be set once rather than on every connection. A no-op on databases already in WAL.
PRAGMA journal_mode = WAL;