mirror of
https://github.com/zed-industries/zed.git
synced 2026-06-01 03:14:56 +07:00
collab: Remove unused fields from database user model (#56898)
This PR removes some more unused fields from the database user model: - `github_user_created_at` - `email_address` - `name` - `created_at` These fields were not being used anywhere, and are nullable/defaulted in the database in tests. Release Notes: - N/A
This commit is contained in:
parent
1fb920775b
commit
b138243438
7 changed files with 2 additions and 51 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -13,8 +13,6 @@ test_both_dbs!(
|
|||
async fn test_channel_buffers(db: &Arc<Database>) {
|
||||
let a_id = db
|
||||
.create_user(
|
||||
"user_a@example.com",
|
||||
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(
|
||||
"user_b@example.com",
|
||||
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 channel
|
||||
let c_id = db
|
||||
.create_user(
|
||||
"user_c@example.com",
|
||||
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(
|
||||
"user_a@example.com",
|
||||
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(
|
||||
"user_b@example.com",
|
||||
None,
|
||||
false,
|
||||
NewUserParams {
|
||||
github_login: "user_b".into(),
|
||||
|
|
|
|||
|
|
@ -263,8 +263,6 @@ async fn test_channel_renames(db: &Arc<Database>) {
|
|||
|
||||
let user_1 = db
|
||||
.create_user(
|
||||
"user1@example.com",
|
||||
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(
|
||||
"user2@example.com",
|
||||
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(
|
||||
"user1@example.com",
|
||||
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(
|
||||
"admin@example.com",
|
||||
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(
|
||||
"user@example.com",
|
||||
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(
|
||||
"user1@example.com",
|
||||
None,
|
||||
false,
|
||||
NewUserParams {
|
||||
github_login: "user1".into(),
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
"admin@example.com",
|
||||
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(
|
||||
"user@example.com",
|
||||
None,
|
||||
false,
|
||||
NewUserParams {
|
||||
github_login: "user".into(),
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue