Home

giogio / openez-graph

public
Overview Code History Branches Pull requestsIssuesInsights
main
HomeOverview Code PRsIssues

fix(db): backfill missing FTS rows on existing databases after interrupted indexing

3 months ago

5524dcb
Authored
asta-nguyen8/8/2026, 6:57:49 AM
Indexing drops FTS triggers to avoid double-writes, then restores
them after chunk inserts. If indexing is interrupted (crash, kill),
triggers are never restored — chunks exist in the chunks table but
are absent from chunks_fts. On restart, the schema init saw the FTS
table already existed and skipped backfill entirely, leaving those
chunks permanently unsearchable.

Fix: when chunks_fts already exists, run a LEFT JOIN backfill to
insert any chunks missing from FTS, and delete orphaned FTS rows
whose chunks were deleted. This runs before restoreFtsTriggerDefinitions
so triggers don't double-insert during backfill.

Typecheck 8/8, tests 144 pass.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

Parent0cda296

1 file changed
  • packages/db/src/sqlite/workspace-db.ts+20−0