added versioning to files table

KCaverly created

Change summary

crates/vector_store/src/db.rs           | 9 ++++++---
crates/vector_store/src/vector_store.rs | 7 ++++---
2 files changed, 10 insertions(+), 6 deletions(-)

Detailed changes

crates/vector_store/src/db.rs 🔗

@@ -9,6 +9,7 @@ use std::{
 use anyhow::{anyhow, Result};
 
 use crate::parsing::ParsedFile;
+use crate::VECTOR_STORE_VERSION;
 use rpc::proto::Timestamp;
 use rusqlite::{
     params,
@@ -72,6 +73,7 @@ impl VectorDatabase {
                 relative_path VARCHAR NOT NULL,
                 mtime_seconds INTEGER NOT NULL,
                 mtime_nanos INTEGER NOT NULL,
+                vector_store_version INTEGER NOT NULL,
                 FOREIGN KEY(worktree_id) REFERENCES worktrees(id) ON DELETE CASCADE
             )",
             [],
@@ -112,15 +114,16 @@ impl VectorDatabase {
         self.db.execute(
             "
             INSERT INTO files
-            (worktree_id, relative_path, mtime_seconds, mtime_nanos)
+            (worktree_id, relative_path, mtime_seconds, mtime_nanos, vector_store_version)
             VALUES
-            (?1, ?2, $3, $4);
+            (?1, ?2, $3, $4, $5);
             ",
             params![
                 worktree_id,
                 indexed_file.path.to_str(),
                 mtime.seconds,
-                mtime.nanos
+                mtime.nanos,
+                VECTOR_STORE_VERSION
             ],
         )?;
 

crates/vector_store/src/vector_store.rs 🔗

@@ -13,14 +13,13 @@ use db::VectorDatabase;
 use embedding::{EmbeddingProvider, OpenAIEmbeddings};
 use futures::{channel::oneshot, Future};
 use gpui::{
-    AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle, Subscription, Task,
-    ViewContext, WeakModelHandle,
+    AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle, Task, ViewContext,
+    WeakModelHandle,
 };
 use language::{Language, LanguageRegistry};
 use modal::{SemanticSearch, SemanticSearchDelegate, Toggle};
 use parsing::{CodeContextRetriever, ParsedFile};
 use project::{Fs, PathChange, Project, ProjectEntryId, WorktreeId};
-use settings::SettingsStore;
 use smol::channel;
 use std::{
     collections::HashMap,
@@ -37,6 +36,8 @@ use util::{
 };
 use workspace::{Workspace, WorkspaceCreated};
 
+const VECTOR_STORE_VERSION: usize = 0;
+
 pub fn init(
     fs: Arc<dyn Fs>,
     http_client: Arc<dyn HttpClient>,