refactor(backend): single SQLite store — config.json eliminated

backend.db (renamed from sessions.db) now holds everything: the sessions
and samples tables plus a settings table with the app-state sections
(users, allowlist, relays, chargers, learn_mode, session_secret) as JSON
blobs. All mutations go through the API/panel and take effect immediately;
there is no config file and no hand-edit-then-restart ambiguity.

- legacy config.json auto-imports into the db on first start (renamed to
  config.json.migrated as a backup)
- new admin endpoints: PUT/DELETE /api/relays/{name} (how tinytuya wizard
  results are registered now) and PUT /api/chargers/{cp_id} (panel labels)
- BACKEND_DB env override so tests run on an isolated temp database
- smoke test: 45 checks, real db verified untouched
This commit is contained in:
2026-07-11 20:15:38 +02:00
parent 70c2fe1210
commit 56c9020d9f
10 changed files with 132 additions and 96 deletions
+3 -1
View File
@@ -1,5 +1,7 @@
# Runtime state + secrets (Tuya local keys live in config.json)
# Runtime state + secrets (users, Tuya local keys, session secret live in backend.db)
backend.db
config.json
config.json.migrated
events.jsonl
seen_tags.json
sessions.db