From ad48829337d6612ed3137f77bec146d29b6ba71b Mon Sep 17 00:00:00 2001 From: sravan Date: Wed, 12 Aug 2026 08:20:26 +0530 Subject: [PATCH] =?UTF-8?q?Retire=20the=20SQLite=20backend=20=E2=80=94=20P?= =?UTF-8?q?ostgres=20is=20the=20only=20engine?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The dual backend (SQLite via db.js + Postgres via schema.pg.sql) was a maintenance foot-gun: a schema change could land on the SQLite path only and silently 500 every read on prod (it just did, with #18/#13). Production has run on Postgres for weeks, so SQLite is retired: ONE schema source of truth (db/schema.pg.sql), no drift possible. - dbx.js: default DB_BACKEND=pg; an unknown backend now fails loudly at require time instead of silently selecting a stale engine. - Deleted server/db.js, server/db/sqlite.js, server/db/migrate-sqlite-to-pg.js, server/scripts/migrate-bizgaze-only.js (all SQLite-only, none in the runtime path — the running server loads db/pg.js). - Tests (e2e, db-smoke) target Postgres now and fail-fast (skip) unless DATABASE_URL points at a disposable test DB — never SQLite, never prod. - Removed the dead DB_PATH env + fixed misleading SQLite comments in the Dockerfile / docker-compose (kept the /data volume: it holds uploads/recordings/transcripts/downloads, not just the old data.db). - CLAUDE.md: stack + repo-layout + run-locally updated for Postgres-only. Runtime is unaffected (prod already sets DB_BACKEND=pg and pg is a prod dep); this only removes the unused SQLite path. Co-Authored-By: Claude Opus 4.8 --- CLAUDE.md | 21 +- Dockerfile | 7 +- docker-compose.yml | 9 +- server/db.js | 414 ------------------------- server/db/migrate-sqlite-to-pg.js | 56 ---- server/db/pg.js | 6 +- server/db/sqlite.js | 50 --- server/dbx.js | 14 +- server/scripts/migrate-bizgaze-only.js | 67 ---- server/test/db-smoke.js | 16 +- server/test/e2e.js | 14 +- 11 files changed, 52 insertions(+), 622 deletions(-) delete mode 100644 server/db.js delete mode 100644 server/db/migrate-sqlite-to-pg.js delete mode 100644 server/db/sqlite.js delete mode 100644 server/scripts/migrate-bizgaze-only.js diff --git a/CLAUDE.md b/CLAUDE.md index 304deba..85eabe8 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -12,8 +12,11 @@ Roadmap: grow into a communication platform (meetings + persistent chat) for registered BizGaze users. ## Tech stack (intentionally minimal — keep it this way) -- **Node.js >= 22.5**, single npm dependency: `ws` (WebSocket). -- **Built-in `node:sqlite`** (no native modules). DB file: `server/data.db`. +- **Node.js >= 22.5**. npm deps: `ws`, `pg`, `redis`, `web-push` (+ optional `nodemailer`). +- **PostgreSQL** via the async adapter (`server/dbx.js` → `server/db/pg.js`). SQLite was RETIRED 2026-08-12: + there is now ONE schema source of truth, **`server/db/schema.pg.sql`** — every schema change goes there + (and post-cutover COLUMNS need an explicit `ALTER TABLE … ADD COLUMN IF NOT EXISTS`, since the file is + applied idempotently on every boot and `CREATE TABLE IF NOT EXISTS` won't alter an existing table). - **WebRTC** peer-to-peer for media (screen video + voice + data channels). - **No build step, no framework.** Each page is a single self-contained HTML file with inline `