feat(idb): add IDB content version check system, wire to journals
Adds check_and_clear_idb_tables() helper in core__idb_dexie.ts that clears
Dexie tables when their content version changes. Version numbers live in
IDB_CONTENT_VERSIONS (store_versions.ts); state tracked in localStorage
(ae_idb_ver__{module}__{table}) so each table clears exactly once per bump.
Wired into db_journals.ts (pilot): journal_entry at v3 clears stale
content_md_html/history_md_html data cached before the properties_to_save fix.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -115,6 +115,34 @@ reactivity — only effects that actually read a changed field re-run.
|
||||
|
||||
---
|
||||
|
||||
### [Stores] IDB Content Version System (post June 10)
|
||||
Scaffold added to `store_versions.ts` (`IDB_CONTENT_VERSIONS` constant) — values defined but
|
||||
**not yet wired**. The mechanism mirrors `AE_LOC_VERSION` but targets Dexie table contents
|
||||
rather than localStorage keys.
|
||||
|
||||
**Why:** `db_save_ae_obj_li__ae_obj` uses a `properties_to_save` whitelist. When that whitelist
|
||||
changes (e.g. adding/removing a stored field), existing cached IDB records are stale but never
|
||||
automatically cleared. Users see the old shape until a record is individually refreshed.
|
||||
|
||||
**How it will work:**
|
||||
- Each `db_*.ts` calls a helper (`core__idb_dexie.ts`) on open that checks a `_meta` IDB table
|
||||
- If stored version ≠ `IDB_CONTENT_VERSIONS[module][table]`, clear the table + update `_meta`
|
||||
- SWR repopulates from API on next access (same as any cold-start)
|
||||
- Bump a table's version in `IDB_CONTENT_VERSIONS` when `properties_to_save` changes shape
|
||||
|
||||
**IDAA consideration:**
|
||||
IDAA tables are already cleared by `indexedDB.deleteDatabase()` on sign-out/auth failure in
|
||||
`(idaa)/+layout.svelte`. The content version check is a *complementary* deploy-time reset, not
|
||||
a replacement. When wiring IDAA tables, ensure: (a) the check only runs on IDB open, not
|
||||
mid-session; (b) the `_meta` table is included in the `deleteDatabase()` wipe scope.
|
||||
|
||||
**Tasks:**
|
||||
- [x] Write `check_and_clear_idb_tables()` helper in `core__idb_dexie.ts` (2026-05-14)
|
||||
- [x] Wire helper into `db_journals.ts` (pilot — `journal_entry: 2` clears stale content_md_html on first load) (2026-05-14)
|
||||
- [ ] Roll out to `db_events.ts`, `db_core.ts`
|
||||
- [ ] Roll out to IDAA modules (`db_posts.ts`, `db_archives.ts`) — verify auth-wipe interaction first
|
||||
- [ ] Update `store_versions.ts` comment from "NOT YET ACTIVE" to document the active mechanism
|
||||
|
||||
### [Stores] Refactor — Phase 2c (deferred)
|
||||
Phases 1, 2a, 2b are complete (see ✅ Completed below). One phase remaining:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user