# Storage Schema — IndexedDB (idb) ## DB Name - glowtrack ## Versioning - Start at version 1; bump on schema changes - Provide forward-only migrations for v1 → v2 → ... ## Object Stores - settings (key: 'singleton') - value: GridSettings - habits (keyPath: 'id') - indexes: by_type (type) - days (keyPath: 'date') - value: DayTile without entries - entries (keyPath: 'id') - indexes: - by_date (date) - by_habit (habitId) ## Transactions - Log habit: readwrite on entries, days (update netScore) - Edit/delete: readwrite on entries, days - Import JSON: version check, bulk put within a single transaction per store ## Migrations - v1: create stores and indexes above - Future: add derived caches (e.g., monthly aggregates) — must be rebuildable ## Data Integrity - Enforce unique DayTile.date - Recompute DayTile.netScore after entry mutations - Maintain referential link of HabitEntry.habitId to habits store