5f695ebe2a
Eine readonly-Verbindung (web-Container) kann eine WAL-Datenbank ohne aktiven Writer/-shm nicht öffnen -> "attempt to write a readonly database", die Seite blieb leer. Da collector (Writer) und web (Reader) getrennte Prozesse sind und der collector keine Dauerverbindung hält, existiert im Ruhezustand kein -shm. - collector/db.py + schema.sql: WAL entfernt (Rollback-Journal als Default); readonly-Reads sind damit jederzeit möglich. - web/lib/db.ts: busy_timeout=5s, falls gerade geschrieben wird. Bestehende DB einmalig umstellen: PRAGMA journal_mode=DELETE; Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
16 lines
473 B
SQL
16 lines
473 B
SQL
CREATE TABLE IF NOT EXISTS charges (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
start_time TEXT NOT NULL, -- ISO 8601, lokale Zeit (Europe/Berlin)
|
|
end_time TEXT NOT NULL,
|
|
duration_s INTEGER NOT NULL, -- aus cdi.value (ms/1000)
|
|
energy_wh REAL NOT NULL, -- aus wh
|
|
created_at TEXT NOT NULL
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_charges_start ON charges(start_time);
|
|
|
|
CREATE TABLE IF NOT EXISTS meta (
|
|
key TEXT PRIMARY KEY,
|
|
value TEXT
|
|
);
|