Fix two database errors (#3483)
* Fixes error when an admin tries transferring project ownership * Fixes error when trying to delete a user when they previously have a transaction Co-authored-by: Jai Agrawal <18202329+Geometrically@users.noreply.github.com>
This commit is contained in:
parent
edd09b0b16
commit
f2ec89e62b
15
apps/labrinth/.sqlx/query-f1f93419f4394c702f256fe3e5de0368ee972ed20bd4d4b2490c655fde999dda.json
generated
Normal file
15
apps/labrinth/.sqlx/query-f1f93419f4394c702f256fe3e5de0368ee972ed20bd4d4b2490c655fde999dda.json
generated
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"db_name": "PostgreSQL",
|
||||||
|
"query": "\n UPDATE charges\n SET user_id = $1\n WHERE user_id = $2\n ",
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"parameters": {
|
||||||
|
"Left": [
|
||||||
|
"Int8",
|
||||||
|
"Int8"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"nullable": []
|
||||||
|
},
|
||||||
|
"hash": "f1f93419f4394c702f256fe3e5de0368ee972ed20bd4d4b2490c655fde999dda"
|
||||||
|
}
|
||||||
@ -657,6 +657,18 @@ impl User {
|
|||||||
.execute(&mut **transaction)
|
.execute(&mut **transaction)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
sqlx::query!(
|
||||||
|
"
|
||||||
|
UPDATE charges
|
||||||
|
SET user_id = $1
|
||||||
|
WHERE user_id = $2
|
||||||
|
",
|
||||||
|
deleted_user as UserId,
|
||||||
|
id as UserId,
|
||||||
|
)
|
||||||
|
.execute(&mut **transaction)
|
||||||
|
.await?;
|
||||||
|
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
"
|
"
|
||||||
DELETE FROM user_backup_codes
|
DELETE FROM user_backup_codes
|
||||||
|
|||||||
@ -936,9 +936,15 @@ pub async fn transfer_ownership(
|
|||||||
let mut transaction = pool.begin().await?;
|
let mut transaction = pool.begin().await?;
|
||||||
|
|
||||||
// The following are the only places new_is_owner is modified.
|
// The following are the only places new_is_owner is modified.
|
||||||
|
if let Some(former_owner) =
|
||||||
|
TeamMember::get_from_team_full(id.into(), &**pool, &redis)
|
||||||
|
.await?
|
||||||
|
.into_iter()
|
||||||
|
.find(|x| x.is_owner)
|
||||||
|
{
|
||||||
TeamMember::edit_team_member(
|
TeamMember::edit_team_member(
|
||||||
id.into(),
|
id.into(),
|
||||||
current_user.id.into(),
|
former_owner.user_id,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
@ -949,6 +955,7 @@ pub async fn transfer_ownership(
|
|||||||
&mut transaction,
|
&mut transaction,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
}
|
||||||
|
|
||||||
TeamMember::edit_team_member(
|
TeamMember::edit_team_member(
|
||||||
id.into(),
|
id.into(),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user