fix(store): migrate sqlite-vec table to partition keys#416
Open
arabold wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR migrates the sqlite-vec documents_vec index to use partition keys so vector search can efficiently filter by library and version.
Changes:
- Adds migration 014 to rebuild
documents_vecwith partition keys and backfill vectors. - Updates
DocumentStorevector-table reconciliation and hybrid search to use the partition-key schema. - Adds tests for partition-key migration, runtime rebuild, and partition-filtered search.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
db/migrations/014-rebuild-vector-partition-keys.sql |
Adds the vector-table rebuild migration. |
src/store/DocumentStore.ts |
Reworks vector table creation/rebuild logic and restores direct partition-filtered KNN search. |
src/store/DocumentStore.test.ts |
Adds/updates runtime vector schema and search tests. |
src/store/applyMigrations.test.ts |
Adds migration assertions and vector backfill coverage. |
Comments suppressed due to low confidence (1)
src/store/applyMigrations.test.ts:220
- This test removes every existing vector before re-running migration 014, so it only verifies the backfill path from
documents.embeddingand does not exercise the migration's preservation path for rows that exist only in the olddocuments_vectable. Add a case that keeps an old vector row (ideally with nodocuments.embedding) so regressions in the preservation logic are caught.
DELETE FROM documents_vec;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Owner
Author
|
Addressed Copilot review comments in
Verification under Node 22:
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
documents_vecwith sqlite-vec partition keys forlibrary_idandversion_iddocuments.embeddingDocumentStore.findByContent()Fixes #411.
Migration note
This rebuilds the sqlite-vec virtual table. Operators should stop the server and keep a database backup before applying the migration on real data.
Verification
zsh -lc 'source ~/.nvm/nvm.sh && nvm use 22 >/dev/null && npx vitest run src/store/applyMigrations.test.ts && npx vitest run src/store/DocumentStore.test.ts -t "partition-filtered vector search|rebuild old metadata-column vec table"'\n-zsh -lc 'source ~/.nvm/nvm.sh && nvm use 22 >/dev/null && npm run typecheck'\n-zsh -lc 'source ~/.nvm/nvm.sh && nvm use 22 >/dev/null && npm run lint'reports existing unrelated optional-chain warnings in scraper/web files\n