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:
@@ -1,7 +1,10 @@
|
||||
import Dexie, { type Table } from 'dexie';
|
||||
import { browser } from '$app/environment';
|
||||
|
||||
import type { key_val } from '$lib/stores/ae_stores';
|
||||
import type { ae_Journal, ae_JournalEntry } from '$lib/types/ae_types';
|
||||
import { IDB_CONTENT_VERSIONS } from '$lib/stores/store_versions';
|
||||
import { check_and_clear_idb_tables } from '$lib/ae_core/core__idb_dexie';
|
||||
|
||||
// li = list
|
||||
// kv = key value list
|
||||
@@ -141,3 +144,14 @@ export class MySubClassedDexie extends Dexie {
|
||||
}
|
||||
|
||||
export const db_journals = new MySubClassedDexie();
|
||||
|
||||
// On each page load, clear any tables whose content version has changed.
|
||||
// Versions are defined in store_versions.ts IDB_CONTENT_VERSIONS.journals.
|
||||
// Each table is only cleared once per version bump (tracked in localStorage).
|
||||
if (browser) {
|
||||
check_and_clear_idb_tables({
|
||||
db_instance: db_journals,
|
||||
module_name: 'journals',
|
||||
table_versions: IDB_CONTENT_VERSIONS.journals
|
||||
}).catch((e) => console.warn('[db_journals] IDB version check failed:', e));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user