Files
wled-screen-controller-mixed/TODO.md
alexei.dolgolyov 9dfd2365f4
Some checks failed
Lint & Test / test (push) Failing after 28s
feat: migrate storage from JSON files to SQLite
Replace 22 individual JSON store files with a single SQLite database
(data/ledgrab.db). All entity stores now use BaseSqliteStore backed by
SQLite with WAL mode, write-through caching, and thread-safe access.

- Add Database class with SQLite backup/restore API
- Add BaseSqliteStore as drop-in replacement for BaseJsonStore
- Convert all 16 entity stores to SQLite
- Move global settings (MQTT, external URL, auto-backup) to SQLite
  settings table
- Replace JSON backup/restore with SQLite snapshot backups (.db files)
- Remove partial export/import feature (backend + frontend)
- Update demo seed to write directly to SQLite
- Add "Backup Now" button to settings UI
- Remove StorageConfig file path fields (single database_file remains)
2026-03-25 00:03:19 +03:00

1.7 KiB

SQLite Migration

Phase 1: Infrastructure

  • Create storage/database.py — SQLite connection wrapper (WAL mode, thread-safe)
  • Create storage/base_sqlite_store.py — same public API as BaseJsonStore, backed by SQLite
  • Create storage/migration.py — auto-migrate JSON files to SQLite on first run
  • Add database_file to StorageConfig in config.py
  • Update demo mode path rewriting for database_file

Phase 2: Convert stores (one-by-one)

  • SyncClockStore
  • GradientStore
  • WeatherSourceStore
  • AutomationStore
  • ScenePresetStore
  • TemplateStore
  • PostprocessingTemplateStore
  • PatternTemplateStore
  • AudioTemplateStore
  • ColorStripProcessingTemplateStore
  • PictureSourceStore
  • AudioSourceStore
  • ValueSourceStore
  • DeviceStore
  • OutputTargetStore
  • ColorStripStore

Phase 3: Update backup/restore

  • Refactor backup.py to read from SQLite (export/import/backup/restore)
  • Keep JSON backup format identical for compatibility
  • Update AutoBackupEngine to read from SQLite
  • Add Database to dependency injection

Phase 4: Cleanup

  • Remove individual *_file fields from StorageConfig (keep database_file only)
  • Remove atomic_write_json usage from stores (still used by auto_backup settings)
  • Remove freeze_saves from base_store (only freeze_writes needed)
  • Remove BaseJsonStore (keep EntityNotFoundError — move to shared location)
  • Update _save_all_stores to use _save_all() instead of _save(force=True)
  • Update CLAUDE.md and server/CLAUDE.md documentation
  • Remove _json_key/_legacy_json_keys references from old code
  • Clean up test files to use Database fixture instead of file paths