fix db schema update process to ensure all tables are dropped
This commit is contained in:
parent
ed1b1a5ccd
commit
80ef92a3e1
2 changed files with 16 additions and 19 deletions
|
@ -66,24 +66,28 @@ impl VectorDatabase {
|
||||||
fn initialize_database(&self) -> Result<()> {
|
fn initialize_database(&self) -> Result<()> {
|
||||||
rusqlite::vtab::array::load_module(&self.db)?;
|
rusqlite::vtab::array::load_module(&self.db)?;
|
||||||
|
|
||||||
|
// Delete existing tables, if SEMANTIC_INDEX_VERSION is bumped
|
||||||
if self
|
if self
|
||||||
.get_existing_version()
|
.get_existing_version()
|
||||||
.map_or(false, |version| version == SEMANTIC_INDEX_VERSION as i64)
|
.map_or(false, |version| version == SEMANTIC_INDEX_VERSION as i64)
|
||||||
{
|
{
|
||||||
|
log::trace!("vector database schema up to date");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log::trace!("vector database schema out of date. updating...");
|
||||||
self.db
|
self.db
|
||||||
.execute(
|
.execute("DROP TABLE IF EXISTS documents", [])
|
||||||
"
|
.context("failed to drop 'documents' table")?;
|
||||||
DROP TABLE IF EXISTS documents;
|
self.db
|
||||||
DROP TABLE IF EXISTS files;
|
.execute("DROP TABLE IF EXISTS files", [])
|
||||||
DROP TABLE IF EXISTS worktrees;
|
.context("failed to drop 'files' table")?;
|
||||||
DROP TABLE IF EXISTS semantic_index_config;
|
self.db
|
||||||
",
|
.execute("DROP TABLE IF EXISTS worktrees", [])
|
||||||
[],
|
.context("failed to drop 'worktrees' table")?;
|
||||||
)
|
self.db
|
||||||
.context("failed to drop tables")?;
|
.execute("DROP TABLE IF EXISTS semantic_index_config", [])
|
||||||
|
.context("failed to drop 'semantic_index_config' table")?;
|
||||||
|
|
||||||
// Initialize Vector Databasing Tables
|
// Initialize Vector Databasing Tables
|
||||||
self.db.execute(
|
self.db.execute(
|
||||||
|
@ -133,6 +137,7 @@ impl VectorDatabase {
|
||||||
[],
|
[],
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
log::trace!("vector database initialized with updated schema.");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ use util::{
|
||||||
ResultExt,
|
ResultExt,
|
||||||
};
|
};
|
||||||
|
|
||||||
const SEMANTIC_INDEX_VERSION: usize = 3;
|
const SEMANTIC_INDEX_VERSION: usize = 4;
|
||||||
const EMBEDDINGS_BATCH_SIZE: usize = 150;
|
const EMBEDDINGS_BATCH_SIZE: usize = 150;
|
||||||
|
|
||||||
pub fn init(
|
pub fn init(
|
||||||
|
@ -344,14 +344,6 @@ impl SemanticIndex {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (worktree_id, documents, path, mtime, job_handle) in embeddings_queue.into_iter() {
|
for (worktree_id, documents, path, mtime, job_handle) in embeddings_queue.into_iter() {
|
||||||
// for document in documents.iter() {
|
|
||||||
// // TODO: Update this so it doesn't panic
|
|
||||||
// assert!(
|
|
||||||
// document.embedding.len() > 0,
|
|
||||||
// "Document Embedding Not Complete"
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
db_update_tx
|
db_update_tx
|
||||||
.send(DbOperation::InsertFile {
|
.send(DbOperation::InsertFile {
|
||||||
worktree_id,
|
worktree_id,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue