docs: schema.sql reference and DBeaver snapshot instructions

A test fails if docs/schema.sql drifts from the table server.js creates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfmHGGiYUjNcvJoyzdf
This commit is contained in:
ngqileandClaude Opus 5.5 committed 2026-12-01 11:41:56 +08:00
1 parent b20ef0a592
commit 5bb2a7343d
3 files changed
+52 -3

No files matched your search

+20 -3
View File
@@ -62,8 +62,25 @@ for(const r of rows)console.log(Object.values(r).map(q).join(','));
" > leads.csv
```
Prefer the CSV export above. The database runs in WAL mode, so copying only `leads.db` can miss the newest leads; if you copy the file, copy `leads.db-wal` with it.
### Opening the database in DBeaver
Columns: `id, created_at (UTC), name, email, phone, company, service, referrer, utm_source, utm_medium, utm_campaign`.
SQLite is a file, not a network server, so DBeaver cannot connect to the pod. Take a consistent snapshot and open that copy:
```bash
NS=ins-landing-page
POD=$(microk8s kubectl -n $NS get pod -l app=ins-landing-page -o name | head -1 | cut -d/ -f2)
# VACUUM INTO writes one complete file, including leads still in the WAL
microk8s kubectl -n $NS exec $POD -- node --disable-warning=ExperimentalWarning -e \
"new (require('node:sqlite').DatabaseSync)(process.env.DB_PATH).exec(\"VACUUM INTO '/data/snapshot.db'\")"
microk8s kubectl -n $NS cp $POD:/data/snapshot.db ./leads-snapshot.db
microk8s kubectl -n $NS exec $POD -- rm /data/snapshot.db
```
In DBeaver: **New Database Connection → SQLite →** point **Path** at `leads-snapshot.db`. Query and export freely; it's your own copy.
Edits made in DBeaver stay in the copy. **Never copy a file back into the pod while the app is running**: it would overwrite leads submitted in the meantime. To fix or delete live rows, run the SQL in the pod (`exec ... node -e "..."`) and keep a snapshot first.
Leads are personal data (PDPA): delete snapshots and CSVs when you're done.
Schema: `docs/schema.sql`. Columns: `id, created_at (UTC), name, email, phone, company, service, referrer, utm_source, utm_medium, utm_campaign`.
Leads contain personal data (PDPA). Keep exported files out of shared drives and delete them when done.