-
Notifications
You must be signed in to change notification settings - Fork 5
fix(indexer): reactivate deactivated documents when file is restored #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
aa4b02d
fix(indexer): reactivate deactivated documents when file is restored
itsmostafa 964166d
test(indexer): add regression test for re-indexing a restored file
itsmostafa 07a05e8
fix(db): add ON DELETE CASCADE to chunk_vectors and embeddings
itsmostafa 3b6a63d
test(indexer): regression test for reindex with embeddings present
itsmostafa 3c63343
fix(db): make migration 003 idempotent with DROP IF EXISTS guards
itsmostafa 6021475
fix(db): handle missing dimension column in legacy embeddings table
itsmostafa 36a17ca
feat(indexer): skip all dot-directories during walk
itsmostafa 974548d
docs(skills): add command selection guidance to qi-cli skill
itsmostafa 16976bb
chore(plugin): bump plugin version to 0.4.0
itsmostafa 2206075
update readme
itsmostafa 70f0d9f
docs(readme): rewrite tagline for clarity and brevity
itsmostafa 83217e3
docs(readme): add AI agent token-saving use case blurb
itsmostafa 655480d
docs(readme): fix typo delegating
itsmostafa 1cc2607
fix(db): preserve embedding dimension during migration 003 table rebuild
itsmostafa d58e3d6
fix(indexer): return error on non-ErrNoRows scan failure in indexFile
itsmostafa 40c2376
fix(indexer): preserve embeddings when reactivating unchanged documents
itsmostafa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| -- Add ON DELETE CASCADE to chunk_vectors and embeddings so reindexing a | ||
| -- changed document (which deletes its chunks) does not fail or orphan rows. | ||
| -- SQLite requires a table rebuild to change foreign key actions. | ||
|
|
||
|
itsmostafa marked this conversation as resolved.
|
||
| PRAGMA foreign_keys=OFF; | ||
|
|
||
| DROP TABLE IF EXISTS chunk_vectors_new; | ||
| CREATE TABLE chunk_vectors_new ( | ||
| chunk_id INTEGER PRIMARY KEY REFERENCES chunks(id) ON DELETE CASCADE, | ||
| vector BLOB NOT NULL | ||
| ); | ||
| INSERT INTO chunk_vectors_new(chunk_id, vector) | ||
| SELECT chunk_id, vector FROM chunk_vectors; | ||
| DROP TABLE chunk_vectors; | ||
| ALTER TABLE chunk_vectors_new RENAME TO chunk_vectors; | ||
|
|
||
| DROP TABLE IF EXISTS embeddings_new; | ||
| CREATE TABLE embeddings_new ( | ||
| chunk_id INTEGER PRIMARY KEY REFERENCES chunks(id) ON DELETE CASCADE, | ||
| provider TEXT NOT NULL, | ||
| model TEXT NOT NULL, | ||
| dimension INTEGER NOT NULL DEFAULT 0, | ||
| embedded_at TEXT NOT NULL DEFAULT (datetime('now')) | ||
| ); | ||
| -- Derive dimension from vector length (float32 = 4 bytes each) so that both | ||
| -- old schemas (no dimension column) and new ones are handled correctly. | ||
| INSERT INTO embeddings_new(chunk_id, provider, model, dimension, embedded_at) | ||
| SELECT e.chunk_id, e.provider, e.model, | ||
| COALESCE(length(cv.vector)/4, 0), | ||
| e.embedded_at | ||
| FROM embeddings e | ||
| LEFT JOIN chunk_vectors cv ON cv.chunk_id = e.chunk_id; | ||
| DROP TABLE embeddings; | ||
| ALTER TABLE embeddings_new RENAME TO embeddings; | ||
|
|
||
| PRAGMA foreign_keys=ON; | ||
|
|
||
| INSERT OR IGNORE INTO schema_version(version) VALUES (3); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.