From 71899ec792183bb180ee24016f40516dc3a8841c Mon Sep 17 00:00:00 2001 From: Bartosz Sypytkowski Date: Fri, 28 Jun 2024 08:59:53 +0200 Subject: [PATCH] chore: disabling indexing on workspace prunes collab embeddings --- libs/database/src/workspace.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libs/database/src/workspace.rs b/libs/database/src/workspace.rs index 1fecebcd..926e3c02 100644 --- a/libs/database/src/workspace.rs +++ b/libs/database/src/workspace.rs @@ -814,6 +814,20 @@ pub async fn upsert_workspace_settings( .execute(tx.deref_mut()) .await?; + if settings.disable_search_indexing { + sqlx::query!( + r#"DELETE FROM af_collab_embeddings e WHERE e.oid in ( + SELECT c.oid + FROM af_collab c + WHERE c.partition_key = e.partition_key + AND c.oid = e.oid + AND c.workspace_id = $1)"#, + workspace_id + ) + .execute(tx.deref_mut()) + .await?; + } + Ok(()) }