diff --git a/frontend/rust-lib/flowy-core/src/integrate/user.rs b/frontend/rust-lib/flowy-core/src/integrate/user.rs index d296964e73ba5..55bee99174347 100644 --- a/frontend/rust-lib/flowy-core/src/integrate/user.rs +++ b/frontend/rust-lib/flowy-core/src/integrate/user.rs @@ -73,7 +73,7 @@ impl UserStatusCallback for UserStatusCallbackImpl { .initialize( user_id, user_workspace.id.clone(), - user_workspace.database_view_tracker_id, + user_workspace.workspace_database_object_id, ) .await?; document_manager @@ -111,7 +111,7 @@ impl UserStatusCallback for UserStatusCallbackImpl { .initialize( user_id, user_workspace.id.clone(), - user_workspace.database_view_tracker_id, + user_workspace.workspace_database_object_id, ) .await?; document_manager @@ -197,7 +197,7 @@ impl UserStatusCallback for UserStatusCallbackImpl { .initialize_with_new_user( user_profile.uid, user_workspace.id.clone(), - user_workspace.database_view_tracker_id, + user_workspace.workspace_database_object_id, ) .await .context("DatabaseManager error")?; @@ -235,7 +235,7 @@ impl UserStatusCallback for UserStatusCallbackImpl { .initialize( user_id, user_workspace.id.clone(), - user_workspace.database_view_tracker_id, + user_workspace.workspace_database_object_id, ) .await?; document_manager diff --git a/frontend/rust-lib/flowy-database2/src/manager.rs b/frontend/rust-lib/flowy-database2/src/manager.rs index 9884342994026..9df2b69402c4b 100644 --- a/frontend/rust-lib/flowy-database2/src/manager.rs +++ b/frontend/rust-lib/flowy-database2/src/manager.rs @@ -80,7 +80,7 @@ impl DatabaseManager { &self, uid: i64, workspace_id: String, - database_views_aggregate_id: String, + workspace_database_object_id: String, ) -> FlowyResult<()> { // Clear all existing tasks self.task_scheduler.write().await.clear_task(); @@ -98,12 +98,12 @@ impl DatabaseManager { let mut collab_raw_data = CollabDocState::default(); // If the workspace database not exist in disk, try to fetch from remote. - if !self.is_collab_exist(uid, &collab_db, &database_views_aggregate_id) { + if !self.is_collab_exist(uid, &collab_db, &workspace_database_object_id) { trace!("workspace database not exist, try to fetch from remote"); match self .cloud_service .get_collab_doc_state_db( - &database_views_aggregate_id, + &workspace_database_object_id, CollabType::WorkspaceDatabase, &workspace_id, ) @@ -115,7 +115,7 @@ impl DatabaseManager { Err(err) => { return Err(FlowyError::record_not_found().with_context(format!( "get workspace database :{} failed: {}", - database_views_aggregate_id, err, + workspace_database_object_id, err, ))); }, } @@ -125,11 +125,11 @@ impl DatabaseManager { event!( tracing::Level::INFO, "open aggregate database views object: {}", - &database_views_aggregate_id + &workspace_database_object_id ); let collab = collab_builder.build_collab_with_config( uid, - &database_views_aggregate_id, + &workspace_database_object_id, CollabType::WorkspaceDatabase, collab_db.clone(), collab_raw_data, @@ -152,10 +152,10 @@ impl DatabaseManager { &self, user_id: i64, workspace_id: String, - database_views_aggregate_id: String, + workspace_database_object_id: String, ) -> FlowyResult<()> { self - .initialize(user_id, workspace_id, database_views_aggregate_id) + .initialize(user_id, workspace_id, workspace_database_object_id) .await?; Ok(()) } diff --git a/frontend/rust-lib/flowy-server/src/af_cloud/impls/user/cloud_service_impl.rs b/frontend/rust-lib/flowy-server/src/af_cloud/impls/user/cloud_service_impl.rs index cf934bed61cb4..97c788cfc9f21 100644 --- a/frontend/rust-lib/flowy-server/src/af_cloud/impls/user/cloud_service_impl.rs +++ b/frontend/rust-lib/flowy-server/src/af_cloud/impls/user/cloud_service_impl.rs @@ -353,7 +353,7 @@ fn to_user_workspace(af_workspace: AFWorkspace) -> UserWorkspace { id: af_workspace.workspace_id.to_string(), name: af_workspace.workspace_name, created_at: af_workspace.created_at, - database_view_tracker_id: af_workspace.database_storage_id.to_string(), + workspace_database_object_id: af_workspace.database_storage_id.to_string(), } } diff --git a/frontend/rust-lib/flowy-server/src/local_server/impls/user.rs b/frontend/rust-lib/flowy-server/src/local_server/impls/user.rs index 8f97d9be68ab0..3fd3fe71319a1 100644 --- a/frontend/rust-lib/flowy-server/src/local_server/impls/user.rs +++ b/frontend/rust-lib/flowy-server/src/local_server/impls/user.rs @@ -181,6 +181,6 @@ fn make_user_workspace() -> UserWorkspace { id: uuid::Uuid::new_v4().to_string(), name: "My Workspace".to_string(), created_at: Default::default(), - database_view_tracker_id: uuid::Uuid::new_v4().to_string(), + workspace_database_object_id: uuid::Uuid::new_v4().to_string(), } } diff --git a/frontend/rust-lib/flowy-server/tests/supabase_test/user_test.rs b/frontend/rust-lib/flowy-server/tests/supabase_test/user_test.rs index 0282685cb8e12..178be52df3cd8 100644 --- a/frontend/rust-lib/flowy-server/tests/supabase_test/user_test.rs +++ b/frontend/rust-lib/flowy-server/tests/supabase_test/user_test.rs @@ -21,7 +21,10 @@ async fn supabase_user_sign_up_test() { let user: AuthResponse = user_service.sign_up(BoxAny::new(params)).await.unwrap(); assert!(!user.latest_workspace.id.is_empty()); assert!(!user.user_workspaces.is_empty()); - assert!(!user.latest_workspace.database_view_tracker_id.is_empty()); + assert!(!user + .latest_workspace + .workspace_database_object_id + .is_empty()); } #[tokio::test] @@ -38,7 +41,10 @@ async fn supabase_user_sign_up_with_existing_uuid_test() { .unwrap(); let user: AuthResponse = user_service.sign_up(BoxAny::new(params)).await.unwrap(); assert!(!user.latest_workspace.id.is_empty()); - assert!(!user.latest_workspace.database_view_tracker_id.is_empty()); + assert!(!user + .latest_workspace + .workspace_database_object_id + .is_empty()); assert!(!user.user_workspaces.is_empty()); } diff --git a/frontend/rust-lib/flowy-user-pub/src/entities.rs b/frontend/rust-lib/flowy-user-pub/src/entities.rs index 81bbb5be176d9..cebab748362f7 100644 --- a/frontend/rust-lib/flowy-user-pub/src/entities.rs +++ b/frontend/rust-lib/flowy-user-pub/src/entities.rs @@ -139,7 +139,7 @@ pub struct UserWorkspace { pub created_at: DateTime, /// The database storage id is used indexing all the database views in current workspace. #[serde(rename = "database_storage_id")] - pub database_view_tracker_id: String, + pub workspace_database_object_id: String, } impl UserWorkspace { @@ -148,7 +148,7 @@ impl UserWorkspace { id: workspace_id.to_string(), name: "".to_string(), created_at: Utc::now(), - database_view_tracker_id: Uuid::new_v4().to_string(), + workspace_database_object_id: Uuid::new_v4().to_string(), } } } diff --git a/frontend/rust-lib/flowy-user-pub/src/session.rs b/frontend/rust-lib/flowy-user-pub/src/session.rs index ef30bc1fc7b43..2b742690b41ac 100644 --- a/frontend/rust-lib/flowy-user-pub/src/session.rs +++ b/frontend/rust-lib/flowy-user-pub/src/session.rs @@ -62,7 +62,7 @@ impl<'de> Visitor<'de> for SessionVisitor { name: "My Workspace".to_string(), created_at: Utc::now(), // For historical reasons, the database_storage_id is constructed by the user_id. - database_view_tracker_id: STANDARD.encode(format!("{}:user:database", user_id)), + workspace_database_object_id: STANDARD.encode(format!("{}:user:database", user_id)), }) } } diff --git a/frontend/rust-lib/flowy-user/src/anon_user/migrate_anon_user_collab.rs b/frontend/rust-lib/flowy-user/src/anon_user/migrate_anon_user_collab.rs index db74881c12080..18a5de7ff075d 100644 --- a/frontend/rust-lib/flowy-user/src/anon_user/migrate_anon_user_collab.rs +++ b/frontend/rust-lib/flowy-user/src/anon_user/migrate_anon_user_collab.rs @@ -57,7 +57,7 @@ pub fn migration_anon_user_on_sign_up( // Migration of all objects except the folder and database_with_views object_ids.retain(|id| { id != &old_user.session.user_workspace.id - && id != &old_user.session.user_workspace.database_view_tracker_id + && id != &old_user.session.user_workspace.workspace_database_object_id }); info!("migrate collab objects: {:?}", object_ids.len()); @@ -148,20 +148,20 @@ where { let database_with_views_collab = Collab::new( old_user.session.user_id, - &old_user.session.user_workspace.database_view_tracker_id, + &old_user.session.user_workspace.workspace_database_object_id, "phantom", vec![], ); database_with_views_collab.with_origin_transact_mut(|txn| { old_collab_r_txn.load_doc_with_txn( old_user.session.user_id, - &old_user.session.user_workspace.database_view_tracker_id, + &old_user.session.user_workspace.workspace_database_object_id, txn, ) })?; let new_uid = new_user_session.user_id; - let new_object_id = &new_user_session.user_workspace.database_view_tracker_id; + let new_object_id = &new_user_session.user_workspace.workspace_database_object_id; let array = DatabaseViewTrackerList::from_collab(&database_with_views_collab); for database_view_tracker in array.get_all_database_tracker() { diff --git a/frontend/rust-lib/flowy-user/src/anon_user/sync_supabase_user_collab.rs b/frontend/rust-lib/flowy-user/src/anon_user/sync_supabase_user_collab.rs index b8486febb005a..6387ec7ba5fc8 100644 --- a/frontend/rust-lib/flowy-user/src/anon_user/sync_supabase_user_collab.rs +++ b/frontend/rust-lib/flowy-user/src/anon_user/sync_supabase_user_collab.rs @@ -43,7 +43,7 @@ pub async fn sync_supabase_user_data_to_cloud( uid, &workspace_id, device_id, - &new_user_session.user_workspace.database_view_tracker_id, + &new_user_session.user_workspace.workspace_database_object_id, collab_db, user_service.clone(), ) diff --git a/frontend/rust-lib/flowy-user/src/services/data_import/appflowy_data_import.rs b/frontend/rust-lib/flowy-user/src/services/data_import/appflowy_data_import.rs index 6ae5ef2a53574..6783a24b04c4e 100644 --- a/frontend/rust-lib/flowy-user/src/services/data_import/appflowy_data_import.rs +++ b/frontend/rust-lib/flowy-user/src/services/data_import/appflowy_data_import.rs @@ -127,7 +127,7 @@ pub(crate) fn import_appflowy_data_folder( // when doing import, we don't want to import the user workspace, database view tracker and the user awareness all_imported_object_ids.retain(|id| id != &imported_session.user_workspace.id); all_imported_object_ids - .retain(|id| id != &imported_session.user_workspace.database_view_tracker_id); + .retain(|id| id != &imported_session.user_workspace.workspace_database_object_id); all_imported_object_ids .retain(|id| id != &awareness_oid_from_user_uuid(&imported_session.user_uuid).to_string()); @@ -268,14 +268,14 @@ where { let database_view_tracker_collab = Collab::new( other_session.user_id, - &other_session.user_workspace.database_view_tracker_id, + &other_session.user_workspace.workspace_database_object_id, "phantom", vec![], ); database_view_tracker_collab.with_origin_transact_mut(|txn| { other_collab_read_txn.load_doc_with_txn( other_session.user_id, - &other_session.user_workspace.database_view_tracker_id, + &other_session.user_workspace.workspace_database_object_id, txn, ) })?; diff --git a/frontend/rust-lib/flowy-user/src/services/sqlite_sql/workspace_sql.rs b/frontend/rust-lib/flowy-user/src/services/sqlite_sql/workspace_sql.rs index 6dca2f849f9f3..9c9eebd5983dd 100644 --- a/frontend/rust-lib/flowy-user/src/services/sqlite_sql/workspace_sql.rs +++ b/frontend/rust-lib/flowy-user/src/services/sqlite_sql/workspace_sql.rs @@ -23,7 +23,7 @@ impl TryFrom<(i64, &UserWorkspace)> for UserWorkspaceTable { if value.1.id.is_empty() { return Err(FlowyError::invalid_data().with_context("The id is empty")); } - if value.1.database_view_tracker_id.is_empty() { + if value.1.workspace_database_object_id.is_empty() { return Err(FlowyError::invalid_data().with_context("The database storage id is empty")); } @@ -32,7 +32,7 @@ impl TryFrom<(i64, &UserWorkspace)> for UserWorkspaceTable { name: value.1.name.clone(), uid: value.0, created_at: value.1.created_at.timestamp(), - database_storage_id: value.1.database_view_tracker_id.clone(), + database_storage_id: value.1.workspace_database_object_id.clone(), }) } } @@ -46,7 +46,7 @@ impl From for UserWorkspace { .timestamp_opt(value.created_at, 0) .single() .unwrap_or_default(), - database_view_tracker_id: value.database_storage_id, + workspace_database_object_id: value.database_storage_id, } } }