Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
collab: Remove unused fields from database user model (#56898)
Marshall Bowersb138243438ef
diff --git a/crates/collab/src/db/queries/users.rs b/crates/collab/src/db/queries/users.rsindex b25b8b1fda0..6f84ae8ab5e 100644--- a/crates/collab/src/db/queries/users.rs+++ b/crates/collab/src/db/queries/users.rs@@ -3,18 +3,10 @@ use super::*;impl Database {/// Creates a new user.#[cfg(feature = "test-support")]- pub async fn create_user(- &self,- email_address: &str,- name: Option<&str>,- admin: bool,- params: NewUserParams,- ) -> Result<NewUserResult> {+ pub async fn create_user(&self, admin: bool, params: NewUserParams) -> Result<NewUserResult> {self.transaction(|tx| async {let tx = tx;let user = user::Entity::insert(user::ActiveModel {- email_address: ActiveValue::set(Some(email_address.into())),- name: ActiveValue::set(name.map(|s| s.into())),github_login: ActiveValue::set(params.github_login.clone()),github_user_id: ActiveValue::set(params.github_user_id),admin: ActiveValue::set(admin),@@ -22,11 +14,7 @@ impl Database {}).on_conflict(OnConflict::column(user::Column::GithubUserId)- .update_columns([- user::Column::Admin,- user::Column::EmailAddress,- user::Column::GithubLogin,- ])+ .update_columns([user::Column::Admin, user::Column::GithubLogin]).to_owned(),).exec_with_returning(&*tx)diff --git a/crates/collab/src/db/tables/user.rs b/crates/collab/src/db/tables/user.rsindex 97b96661d7b..75dd72f1c12 100644--- a/crates/collab/src/db/tables/user.rs+++ b/crates/collab/src/db/tables/user.rs@@ -1,5 +1,4 @@use crate::db::UserId;-use chrono::NaiveDateTime;use sea_orm::entity::prelude::*;use serde::Serialize;@@ -11,12 +10,8 @@ pub struct Model {pub id: UserId,pub github_login: String,pub github_user_id: i32,- pub github_user_created_at: Option<NaiveDateTime>,- pub email_address: Option<String>,- pub name: Option<String>,pub admin: bool,pub connected_once: bool,- pub created_at: NaiveDateTime,}#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]diff --git a/crates/collab/tests/integration/db_tests.rs b/crates/collab/tests/integration/db_tests.rsindex b956c5874b4..4142a4575b2 100644--- a/crates/collab/tests/integration/db_tests.rs+++ b/crates/collab/tests/integration/db_tests.rs@@ -209,8 +209,6 @@ static GITHUB_USER_ID: AtomicI32 = AtomicI32::new(5);async fn new_test_user(db: &Arc<Database>, email: &str) -> UserId {db.create_user(- email,- None,false,NewUserParams {github_login: email[0..email.find('@').unwrap()].to_string(),diff --git a/crates/collab/tests/integration/db_tests/buffer_tests.rs b/crates/collab/tests/integration/db_tests/buffer_tests.rsindex 6fca75a9e8a..35ce57cbf4d 100644--- a/crates/collab/tests/integration/db_tests/buffer_tests.rs+++ b/crates/collab/tests/integration/db_tests/buffer_tests.rs@@ -13,8 +13,6 @@ test_both_dbs!(async fn test_channel_buffers(db: &Arc<Database>) {let a_id = db.create_user(- "[email protected]",- None,false,NewUserParams {github_login: "user_a".into(),@@ -26,8 +24,6 @@ async fn test_channel_buffers(db: &Arc<Database>) {.user_id;let b_id = db.create_user(- "[email protected]",- None,false,NewUserParams {github_login: "user_b".into(),@@ -41,8 +37,6 @@ async fn test_channel_buffers(db: &Arc<Database>) {// This user will not be a part of the channellet c_id = db.create_user(- "[email protected]",- None,false,NewUserParams {github_login: "user_c".into(),@@ -188,8 +182,6 @@ test_both_dbs!(async fn test_channel_buffers_last_operations(db: &Database) {let user_id = db.create_user(- "[email protected]",- None,false,NewUserParams {github_login: "user_a".into(),@@ -201,8 +193,6 @@ async fn test_channel_buffers_last_operations(db: &Database) {.user_id;let observer_id = db.create_user(- "[email protected]",- None,false,NewUserParams {github_login: "user_b".into(),diff --git a/crates/collab/tests/integration/db_tests/channel_tests.rs b/crates/collab/tests/integration/db_tests/channel_tests.rsindex 9f3dd5712e3..e7752c27954 100644--- a/crates/collab/tests/integration/db_tests/channel_tests.rs+++ b/crates/collab/tests/integration/db_tests/channel_tests.rs@@ -263,8 +263,6 @@ async fn test_channel_renames(db: &Arc<Database>) {let user_1 = db.create_user(- "[email protected]",- None,false,NewUserParams {github_login: "user1".into(),@@ -277,8 +275,6 @@ async fn test_channel_renames(db: &Arc<Database>) {let user_2 = db.create_user(- "[email protected]",- None,false,NewUserParams {github_login: "user2".into(),@@ -314,8 +310,6 @@ test_both_dbs!(async fn test_db_channel_moving(db: &Arc<Database>) {let a_id = db.create_user(- "[email protected]",- None,false,NewUserParams {github_login: "user1".into(),@@ -404,8 +398,6 @@ test_both_dbs!(async fn test_channel_reordering(db: &Arc<Database>) {let admin_id = db.create_user(- "[email protected]",- None,false,NewUserParams {github_login: "admin".into(),@@ -418,8 +410,6 @@ async fn test_channel_reordering(db: &Arc<Database>) {let user_id = db.create_user(- "[email protected]",- None,false,NewUserParams {github_login: "user".into(),@@ -599,8 +589,6 @@ test_both_dbs!(async fn test_db_channel_moving_bugs(db: &Arc<Database>) {let user_id = db.create_user(- "[email protected]",- None,false,NewUserParams {github_login: "user1".into(),diff --git a/crates/collab/tests/integration/db_tests/db_tests.rs b/crates/collab/tests/integration/db_tests/db_tests.rsindex 0834e5c90af..17123db1b41 100644--- a/crates/collab/tests/integration/db_tests/db_tests.rs+++ b/crates/collab/tests/integration/db_tests/db_tests.rs@@ -18,8 +18,6 @@ async fn test_add_contacts(db: &Arc<Database>) {for i in 0..3 {user_ids.push(db.create_user(- &format!("user{i}@example.com"),- None,false,NewUserParams {github_login: format!("user{i}"),@@ -178,8 +176,6 @@ async fn test_project_count(db: &Arc<Database>) {let user1 = db.create_user(- "[email protected]",- None,true,NewUserParams {github_login: "admin".into(),@@ -190,8 +186,6 @@ async fn test_project_count(db: &Arc<Database>) {.unwrap();let user2 = db.create_user(- "[email protected]",- None,false,NewUserParams {github_login: "user".into(),diff --git a/crates/collab/tests/integration/randomized_test_helpers.rs b/crates/collab/tests/integration/randomized_test_helpers.rsindex 0a2555929a9..98e64ced414 100644--- a/crates/collab/tests/integration/randomized_test_helpers.rs+++ b/crates/collab/tests/integration/randomized_test_helpers.rs@@ -225,8 +225,6 @@ impl<T: RandomizedTest> TestPlan<T> {.app_state.db.create_user(- &format!("{username}@example.com"),- None,false,NewUserParams {github_login: username.clone(),