mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-03 17:44:30 +00:00
Fix duplicate key error that occurs when a user joins that is already in the db
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
This commit is contained in:
parent
3b67602b13
commit
383334633f
1 changed files with 5 additions and 0 deletions
|
@ -567,6 +567,10 @@ impl Db for PostgresDb {
|
||||||
(email_address, github_login, github_user_id, admin, invite_count, invite_code)
|
(email_address, github_login, github_user_id, admin, invite_count, invite_code)
|
||||||
VALUES
|
VALUES
|
||||||
($1, $2, $3, 'f', $4, $5)
|
($1, $2, $3, 'f', $4, $5)
|
||||||
|
ON CONFLICT (github_login) DO UPDATE SET
|
||||||
|
email_address = excluded.email_address,
|
||||||
|
github_user_id = excluded.github_user_id,
|
||||||
|
admin = excluded.admin
|
||||||
RETURNING id, metrics_id::text
|
RETURNING id, metrics_id::text
|
||||||
",
|
",
|
||||||
)
|
)
|
||||||
|
@ -616,6 +620,7 @@ impl Db for PostgresDb {
|
||||||
(user_id_a, user_id_b, a_to_b, should_notify, accepted)
|
(user_id_a, user_id_b, a_to_b, should_notify, accepted)
|
||||||
VALUES
|
VALUES
|
||||||
($1, $2, 't', 't', 't')
|
($1, $2, 't', 't', 't')
|
||||||
|
ON CONFLICT DO NOTHING
|
||||||
",
|
",
|
||||||
)
|
)
|
||||||
.bind(inviting_user_id)
|
.bind(inviting_user_id)
|
||||||
|
|
Loading…
Reference in a new issue