diff --git a/Cargo.lock b/Cargo.lock index 1ea230e8..0fcd85b4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2089,7 +2089,7 @@ dependencies = [ [[package]] name = "collab" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=5f3e7163e3a408a08423d079eb41068fb86e562b#5f3e7163e3a408a08423d079eb41068fb86e562b" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=28c439274c222bbc298dc6753200ee492d7e8509#28c439274c222bbc298dc6753200ee492d7e8509" dependencies = [ "anyhow", "arc-swap", @@ -2114,7 +2114,7 @@ dependencies = [ [[package]] name = "collab-database" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=5f3e7163e3a408a08423d079eb41068fb86e562b#5f3e7163e3a408a08423d079eb41068fb86e562b" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=28c439274c222bbc298dc6753200ee492d7e8509#28c439274c222bbc298dc6753200ee492d7e8509" dependencies = [ "anyhow", "async-trait", @@ -2144,7 +2144,7 @@ dependencies = [ [[package]] name = "collab-document" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=5f3e7163e3a408a08423d079eb41068fb86e562b#5f3e7163e3a408a08423d079eb41068fb86e562b" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=28c439274c222bbc298dc6753200ee492d7e8509#28c439274c222bbc298dc6753200ee492d7e8509" dependencies = [ "anyhow", "arc-swap", @@ -2164,7 +2164,7 @@ dependencies = [ [[package]] name = "collab-entity" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=5f3e7163e3a408a08423d079eb41068fb86e562b#5f3e7163e3a408a08423d079eb41068fb86e562b" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=28c439274c222bbc298dc6753200ee492d7e8509#28c439274c222bbc298dc6753200ee492d7e8509" dependencies = [ "anyhow", "bytes", @@ -2183,7 +2183,7 @@ dependencies = [ [[package]] name = "collab-folder" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=5f3e7163e3a408a08423d079eb41068fb86e562b#5f3e7163e3a408a08423d079eb41068fb86e562b" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=28c439274c222bbc298dc6753200ee492d7e8509#28c439274c222bbc298dc6753200ee492d7e8509" dependencies = [ "anyhow", "arc-swap", @@ -2268,7 +2268,7 @@ dependencies = [ [[package]] name = "collab-user" version = "0.2.0" -source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=5f3e7163e3a408a08423d079eb41068fb86e562b#5f3e7163e3a408a08423d079eb41068fb86e562b" +source = "git+https://github.com/AppFlowy-IO/AppFlowy-Collab?rev=28c439274c222bbc298dc6753200ee492d7e8509#28c439274c222bbc298dc6753200ee492d7e8509" dependencies = [ "anyhow", "collab", diff --git a/Cargo.toml b/Cargo.toml index cda39260..34418520 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -287,12 +287,12 @@ debug = true [patch.crates-io] # It's diffcult to resovle different version with the same crate used in AppFlowy Frontend and the Client-API crate. # So using patch to workaround this issue. -collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5f3e7163e3a408a08423d079eb41068fb86e562b" } -collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5f3e7163e3a408a08423d079eb41068fb86e562b" } -collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5f3e7163e3a408a08423d079eb41068fb86e562b" } -collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5f3e7163e3a408a08423d079eb41068fb86e562b" } -collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5f3e7163e3a408a08423d079eb41068fb86e562b" } -collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "5f3e7163e3a408a08423d079eb41068fb86e562b" } +collab = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "28c439274c222bbc298dc6753200ee492d7e8509" } +collab-entity = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "28c439274c222bbc298dc6753200ee492d7e8509" } +collab-folder = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "28c439274c222bbc298dc6753200ee492d7e8509" } +collab-document = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "28c439274c222bbc298dc6753200ee492d7e8509" } +collab-user = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "28c439274c222bbc298dc6753200ee492d7e8509" } +collab-database = { git = "https://github.com/AppFlowy-IO/AppFlowy-Collab", rev = "28c439274c222bbc298dc6753200ee492d7e8509" } [features] history = [] diff --git a/docker/gotrue.Dockerfile b/docker/gotrue.Dockerfile index 7c2fe8bd..d547dce8 100644 --- a/docker/gotrue.Dockerfile +++ b/docker/gotrue.Dockerfile @@ -1,10 +1,10 @@ FROM golang as base WORKDIR /go/src/supabase RUN git clone https://github.com/supabase/auth.git --depth 1 --branch v2.159.1 -WORKDIR /go/src/supabase/gotrue +WORKDIR /go/src/supabase/auth COPY docker/gotrue.patch . RUN git apply gotrue.patch -RUN CGO_ENABLED=0 go build -o /gotrue . +RUN CGO_ENABLED=0 go build -o /auth . FROM scratch COPY --from=base /usr/share/zoneinfo /usr/share/zoneinfo @@ -12,7 +12,7 @@ COPY --from=base /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ COPY --from=base /etc/passwd /etc/passwd COPY --from=base /etc/group /etc/group -COPY --from=base /gotrue . -COPY --from=base /go/src/supabase/gotrue/migrations ./migrations +COPY --from=base /auth . +COPY --from=base /go/src/supabase/auth/migrations ./migrations -CMD ["./gotrue"] +CMD ["./auth"] diff --git a/libs/workspace-template/src/database/database_collab.rs b/libs/workspace-template/src/database/database_collab.rs index 083be635..28d0b144 100644 --- a/libs/workspace-template/src/database/database_collab.rs +++ b/libs/workspace-template/src/database/database_collab.rs @@ -1,49 +1,16 @@ use anyhow::Error; -use async_trait::async_trait; -use collab::preclude::Collab; use collab_database::database::{Database, DatabaseContext}; use collab_database::entity::{CreateDatabaseParams, EncodedDatabase}; -use collab_database::error::DatabaseError; -use collab_database::workspace_database::{ - DatabaseCollabPersistenceService, DatabaseCollabService, -}; -use collab_entity::CollabType; -use collab_folder::CollabOrigin; +use collab_database::workspace_database::NoPersistenceDatabaseCollabService; use std::sync::Arc; -use std::vec; - -struct TemplateDatabaseCollabServiceImpl; - -#[async_trait] -impl DatabaseCollabService for TemplateDatabaseCollabServiceImpl { - async fn build_collab( - &self, - object_id: &str, - _object_type: CollabType, - _is_new: bool, - ) -> Result { - Ok(Collab::new_with_origin( - CollabOrigin::Empty, - object_id, - vec![], - false, - )) - } - - fn persistence(&self) -> Option> { - None - } -} pub async fn create_database_collab( - _object_id: String, params: CreateDatabaseParams, ) -> Result { - let collab_service = Arc::new(TemplateDatabaseCollabServiceImpl); + let collab_service = Arc::new(NoPersistenceDatabaseCollabService); let context = DatabaseContext { collab_service, notifier: Default::default(), - is_new: true, }; Database::create_with_view(params, context) .await? diff --git a/libs/workspace-template/src/document/getting_started.rs b/libs/workspace-template/src/document/getting_started.rs index b31b1ce1..23f0c3b9 100644 --- a/libs/workspace-template/src/document/getting_started.rs +++ b/libs/workspace-template/src/document/getting_started.rs @@ -65,13 +65,10 @@ impl GettingStartedTemplate { object_id: String, create_database_params: CreateDatabaseParams, ) -> anyhow::Result> { - let object_id = object_id.clone(); let database_id = create_database_params.database_id.clone(); - let encoded_database = tokio::task::spawn_blocking({ - let object_id = object_id.clone(); let create_database_params = create_database_params.clone(); - move || create_database_collab(object_id, create_database_params) + move || create_database_collab(create_database_params) }) .await? .await?; @@ -84,7 +81,7 @@ impl GettingStartedTemplate { // 1. create the new database collab let database_template_data = TemplateData { template_id: TemplateObjectId::Database { - object_id: object_id.clone(), + object_id, database_id: database_id.clone(), }, collab_type: CollabType::Database, @@ -95,15 +92,11 @@ impl GettingStartedTemplate { let database_row_template_data = encoded_database .encoded_row_collabs - .iter() - .map(|encoded_row_collab| { - let object_id = encoded_row_collab.object_id.clone(); - let data = encoded_row_collab.encoded_collab.clone(); - TemplateData { - template_id: TemplateObjectId::DatabaseRow(object_id.clone()), - collab_type: CollabType::DatabaseRow, - encoded_collab: data, - } + .into_iter() + .map(|encoded_row_collab| TemplateData { + template_id: TemplateObjectId::DatabaseRow(encoded_row_collab.object_id), + collab_type: CollabType::DatabaseRow, + encoded_collab: encoded_row_collab.encoded_collab, }); let mut template_data = vec![database_template_data]; diff --git a/migrations/20240904000000_af_collab_embeddings_indices.sql b/migrations/20240904000000_af_collab_embeddings_indices.sql deleted file mode 100644 index 338e6c99..00000000 --- a/migrations/20240904000000_af_collab_embeddings_indices.sql +++ /dev/null @@ -1 +0,0 @@ -CREATE INDEX af_collab_embeddings_oid_idx ON public.af_collab_embeddings (oid); diff --git a/migrations/20240910100000_af_collab_embeddings_indices.sql b/migrations/20240910100000_af_collab_embeddings_indices.sql new file mode 100644 index 00000000..a96761d4 --- /dev/null +++ b/migrations/20240910100000_af_collab_embeddings_indices.sql @@ -0,0 +1,6 @@ +DO $$ +BEGIN + CREATE INDEX IF NOT EXISTS af_collab_embeddings_oid_idx ON public.af_collab_embeddings (oid); +EXCEPTION WHEN others THEN + RAISE NOTICE 'could not create index on af_collab_embeddings(oid), ignoring this migration'; +END $$; diff --git a/src/biz/user/user_init.rs b/src/biz/user/user_init.rs index 46de113d..a8f83651 100644 --- a/src/biz/user/user_init.rs +++ b/src/biz/user/user_init.rs @@ -158,7 +158,7 @@ async fn create_workspace_database_collab( let collab_type = CollabType::WorkspaceDatabase; let mut collab = Collab::new_with_origin(CollabOrigin::Empty, object_id, vec![], false); { - let workspace_database_body = WorkspaceDatabaseBody::new(&mut collab); + let workspace_database_body = WorkspaceDatabaseBody::create(&mut collab); let mut txn = collab.context.transact_mut(); for (object_id, database_id) in initial_database_records { workspace_database_body.add_database(&mut txn, &database_id, vec![object_id]); diff --git a/src/biz/workspace/publish_dup.rs b/src/biz/workspace/publish_dup.rs index 4c5cfb08..3620e0c3 100644 --- a/src/biz/workspace/publish_dup.rs +++ b/src/biz/workspace/publish_dup.rs @@ -188,8 +188,7 @@ impl PublishCollabDuplicator { collab_from_doc_state(ws_database_ec.doc_state.to_vec(), &ws_db_oid)? }; - let ws_db_body = WorkspaceDatabaseBody::new(&mut ws_db_collab); - + let ws_db_body = WorkspaceDatabaseBody::open(&mut ws_db_collab); let (ws_db_updates, updated_ws_w_db_collab) = tokio::task::spawn_blocking(move || { let ws_db_updates = { let mut txn_wrapper = ws_db_collab.transact_mut(); diff --git a/tests/workspace/publish.rs b/tests/workspace/publish.rs index 85ded439..0aa4f9cb 100644 --- a/tests/workspace/publish.rs +++ b/tests/workspace/publish.rs @@ -942,7 +942,7 @@ async fn duplicate_to_workspace_doc_inline_database() { let mut ws_db_collab = client_2 .get_workspace_database_collab(&workspace_id_2) .await; - let ws_db_body = WorkspaceDatabaseBody::new(&mut ws_db_collab); + let ws_db_body = WorkspaceDatabaseBody::open(&mut ws_db_collab); let txn = ws_db_collab.transact(); let dup_grid1_db_id = ws_db_body .get_all_database_meta(&txn)