-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
collab: Make
users.github_user_id
required and unique (#16704)
This PR makes the `github_user_id` column on the `users` table required and replaces the index with a unique index. I have gone through and ensured that all users have a unique `github_user_id` in the staging and production databases. Release Notes: - N/A
- Loading branch information
1 parent
69e76a3
commit 4ddf2cb
Showing
12 changed files
with
73 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
crates/collab/migrations/20240822215737_add_unique_constraint_on_github_user_id_on_users.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
alter table users alter column github_user_id set not null; | ||
|
||
drop index index_users_on_github_user_id; | ||
create unique index uix_users_on_github_user_id on users (github_user_id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,25 +45,25 @@ async fn test_get_users(db: &Arc<Database>) { | |
( | ||
user_ids[0], | ||
"user1".to_string(), | ||
Some(1), | ||
1, | ||
Some("[email protected]".to_string()), | ||
), | ||
( | ||
user_ids[1], | ||
"user2".to_string(), | ||
Some(2), | ||
2, | ||
Some("[email protected]".to_string()), | ||
), | ||
( | ||
user_ids[2], | ||
"user3".to_string(), | ||
Some(3), | ||
3, | ||
Some("[email protected]".to_string()), | ||
), | ||
( | ||
user_ids[3], | ||
"user4".to_string(), | ||
Some(4), | ||
4, | ||
Some("[email protected]".to_string()), | ||
) | ||
] | ||
|
@@ -101,31 +101,25 @@ async fn test_get_or_create_user_by_github_account(db: &Arc<Database>) { | |
.user_id; | ||
|
||
let user = db | ||
.get_or_create_user_by_github_account( | ||
"the-new-login2", | ||
Some(102), | ||
None, | ||
Some(Utc::now()), | ||
None, | ||
) | ||
.get_or_create_user_by_github_account("the-new-login2", 102, None, Some(Utc::now()), None) | ||
.await | ||
.unwrap(); | ||
assert_eq!(user.id, user_id2); | ||
assert_eq!(&user.github_login, "the-new-login2"); | ||
assert_eq!(user.github_user_id, Some(102)); | ||
assert_eq!(user.github_user_id, 102); | ||
|
||
let user = db | ||
.get_or_create_user_by_github_account( | ||
"login3", | ||
Some(103), | ||
103, | ||
Some("[email protected]"), | ||
Some(Utc::now()), | ||
None, | ||
) | ||
.await | ||
.unwrap(); | ||
assert_eq!(&user.github_login, "login3"); | ||
assert_eq!(user.github_user_id, Some(103)); | ||
assert_eq!(user.github_user_id, 103); | ||
assert_eq!(user.email_address, Some("[email protected]".into())); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters