From 1649cf81de4bc3cc506b3d118c2454693758088f Mon Sep 17 00:00:00 2001 From: KCaverly Date: Tue, 11 Jul 2023 14:42:03 -0400 Subject: [PATCH] added versioning to files table --- crates/vector_store/src/db.rs | 9 ++++++--- crates/vector_store/src/vector_store.rs | 7 ++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/crates/vector_store/src/db.rs b/crates/vector_store/src/db.rs index 79d90e87bf86012db5d264ce54b421fdf76282d1..a91a1872b59774a1863ae2a9ff867cf1b7ad39b3 100644 --- a/crates/vector_store/src/db.rs +++ b/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 ], )?; diff --git a/crates/vector_store/src/vector_store.rs b/crates/vector_store/src/vector_store.rs index 4b5f6b636f95897cbfebc47a83d3b6a4f19c0556..6f63f07b884d6046e62f9c8a670ea693b062bf5e 100644 --- a/crates/vector_store/src/vector_store.rs +++ b/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, http_client: Arc,