Parent issue: #23
Context
The database currently uses default journal mode and lacks cascading deletes, which can leave orphan records.
Scope
1. Enable WAL mode
Add these PRAGMAs on connection init:
PRAGMA journal_mode=WAL;
PRAGMA busy_timeout=5000;
This allows concurrent reads during writes and prevents "database is locked" errors.
2. Add cascading deletes
Ensure that when a conversation is deleted, all related messages and tool calls are cleaned up. Either:
- Add
ON DELETE CASCADE to foreign keys in migration
- Or add application-level cleanup in
delete_conversation()
3. Wrap reindex in a transaction
Currently reindex_vault deletes all chunks then inserts new ones. If the process crashes mid-way, data is lost. Wrap in a single transaction:
let tx = conn.transaction()?;
tx.execute("DELETE FROM chunks WHERE vault_path = ?", [&vault_path])?;
// ... insert new chunks ...
tx.commit()?;
Files to look at
src-tauri/src/adapters/db/ — database module
- Migration files in
src-tauri/migrations/
Parent issue: #23
Context
The database currently uses default journal mode and lacks cascading deletes, which can leave orphan records.
Scope
1. Enable WAL mode
Add these PRAGMAs on connection init:
This allows concurrent reads during writes and prevents "database is locked" errors.
2. Add cascading deletes
Ensure that when a conversation is deleted, all related messages and tool calls are cleaned up. Either:
ON DELETE CASCADEto foreign keys in migrationdelete_conversation()3. Wrap reindex in a transaction
Currently
reindex_vaultdeletes all chunks then inserts new ones. If the process crashes mid-way, data is lost. Wrap in a single transaction:Files to look at
src-tauri/src/adapters/db/— database modulesrc-tauri/migrations/