Skip to content

Enable SQLite WAL mode + cascading deletes #53

Description

@ryuhmanov-m

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/

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendRust / Tauri backendbugSomething isn't workingdatabaseSQLite, schema, migrationsgood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions