From 78120cc568072396ec375ce8d96a0a0d7c4637dd Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Thu, 22 Aug 2024 19:15:32 -0400 Subject: [PATCH] collab: Upsert users by `github_user_id` instead of `github_login` (#16706) This PR makes it so users are upserted by their `github_user_id` instead of by their `github_login`. The `github_user_id` is a stable identifier that does not change, while the `github_login` can change. In practice we were already using `get_or_create_user_by_github_account`, which already checks for an existing user with a `github_user_id` first, so this change doesn't result in a change in behavior. This change is primarily for correctness in the event that `create_user` is called directly, as we want to be upserting by the stable identifier. Release Notes: - N/A --- crates/collab/src/db/queries/users.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/collab/src/db/queries/users.rs b/crates/collab/src/db/queries/users.rs index 54c0dc17d171b34f0b8c559038e66effa4368726..b7646e3d4e2f83bbca99ca37cc680d5a97ea8288 100644 --- a/crates/collab/src/db/queries/users.rs +++ b/crates/collab/src/db/queries/users.rs @@ -21,11 +21,11 @@ impl Database { ..Default::default() }) .on_conflict( - OnConflict::column(user::Column::GithubLogin) + OnConflict::column(user::Column::GithubUserId) .update_columns([ user::Column::Admin, user::Column::EmailAddress, - user::Column::GithubUserId, + user::Column::GithubLogin, ]) .to_owned(), )