Skip to content

Enhancement: deleteDocument does not clean up chunk_embeddings or chunks_fts #10

@RobertLD

Description

@RobertLD

The deleteDocument() function in src/core/documents.ts only deletes from the documents table and relies on ON DELETE CASCADE for chunks and ratings. However:

  1. chunk_embeddings (vec0 virtual table) has no foreign key — orphaned embedding rows remain after document deletion
  2. chunks_fts has a trigger chunks_ad that fires on chunk deletion, which should cascade from the document delete. But this depends on the trigger being present (migration v2) and the cascade working correctly through the virtual table.

Should explicitly delete from chunk_embeddings before deleting the document, or at least verify the cascade path works end-to-end.

Metadata

Metadata

Assignees

No one assigned

    Labels

    correctnessLogic or correctness bugtech-debtCode quality and technical debt

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions