You've already forked pages
forked from didirus/AstralRinth
Fix error when trying to delete user with uploaded images (#4295)
* Fix error when trying to delete user with uploaded images
`{"error":"database_error","description":"Database Error: Error while interacting with the database: error returned from database: update or delete on table \"users\" violates foreign key constraint \"uploaded_images_owner_id_fkey\" on table \"uploaded_images\""}`
* Update certain things to use Ghost instead of deleting entirely
* Fix mistake
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n DELETE FROM reports\n WHERE user_id = $1 OR reporter = $1\n ",
|
||||
"query": "\n DELETE FROM reports\n WHERE reporter = $1\n ",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
@@ -10,5 +10,5 @@
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "0461463e3e14f6c8ede5571a2905b8171e8caf4ebbd3ec844ef2cebd83980247"
|
||||
"hash": "4a28872d188834822be5df7be5d023ba6425bda15bf568eebbd8175912eb5700"
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n DELETE FROM payouts\n WHERE user_id = $1\n ",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int8"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "4de9fdac1831320d744cb6edd0cfe6e1fd670348f0ef881f67d7aec1acd6571f"
|
||||
}
|
||||
15
apps/labrinth/.sqlx/query-54bfa46679475b799f85494e1aafd093dd6023259a1e617eeb2c5491e5e5f704.json
generated
Normal file
15
apps/labrinth/.sqlx/query-54bfa46679475b799f85494e1aafd093dd6023259a1e617eeb2c5491e5e5f704.json
generated
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n UPDATE payouts\n SET user_id = $1\n WHERE user_id = $2\n ",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int8",
|
||||
"Int8"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "54bfa46679475b799f85494e1aafd093dd6023259a1e617eeb2c5491e5e5f704"
|
||||
}
|
||||
15
apps/labrinth/.sqlx/query-b8c62f703e8460a29a406b4b5a46fd30169f7ce6628f31c6749dada507cdc325.json
generated
Normal file
15
apps/labrinth/.sqlx/query-b8c62f703e8460a29a406b4b5a46fd30169f7ce6628f31c6749dada507cdc325.json
generated
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n UPDATE reports\n SET user_id = $1\n WHERE user_id = $2\n ",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int8",
|
||||
"Int8"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "b8c62f703e8460a29a406b4b5a46fd30169f7ce6628f31c6749dada507cdc325"
|
||||
}
|
||||
15
apps/labrinth/.sqlx/query-fbc0c5d96263c6bc65787bbecdd264e8130a353058ac028d4fce4a38568019ee.json
generated
Normal file
15
apps/labrinth/.sqlx/query-fbc0c5d96263c6bc65787bbecdd264e8130a353058ac028d4fce4a38568019ee.json
generated
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n UPDATE uploaded_images\n SET owner_id = $1\n WHERE owner_id = $2\n ",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int8",
|
||||
"Int8"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "fbc0c5d96263c6bc65787bbecdd264e8130a353058ac028d4fce4a38568019ee"
|
||||
}
|
||||
@@ -599,13 +599,25 @@ impl DBUser {
|
||||
sqlx::query!(
|
||||
"
|
||||
DELETE FROM reports
|
||||
WHERE user_id = $1 OR reporter = $1
|
||||
WHERE reporter = $1
|
||||
",
|
||||
id as DBUserId,
|
||||
)
|
||||
.execute(&mut **transaction)
|
||||
.await?;
|
||||
|
||||
sqlx::query!(
|
||||
"
|
||||
UPDATE reports
|
||||
SET user_id = $1
|
||||
WHERE user_id = $2
|
||||
",
|
||||
deleted_user as DBUserId,
|
||||
id as DBUserId,
|
||||
)
|
||||
.execute(&mut **transaction)
|
||||
.await?;
|
||||
|
||||
sqlx::query!(
|
||||
"
|
||||
DELETE FROM mod_follows
|
||||
@@ -638,9 +650,11 @@ impl DBUser {
|
||||
|
||||
sqlx::query!(
|
||||
"
|
||||
DELETE FROM payouts
|
||||
WHERE user_id = $1
|
||||
UPDATE payouts
|
||||
SET user_id = $1
|
||||
WHERE user_id = $2
|
||||
",
|
||||
deleted_user as DBUserId,
|
||||
id as DBUserId,
|
||||
)
|
||||
.execute(&mut **transaction)
|
||||
@@ -668,6 +682,18 @@ impl DBUser {
|
||||
.execute(&mut **transaction)
|
||||
.await?;
|
||||
|
||||
sqlx::query!(
|
||||
"
|
||||
UPDATE uploaded_images
|
||||
SET owner_id = $1
|
||||
WHERE owner_id = $2
|
||||
",
|
||||
deleted_user as DBUserId,
|
||||
id as DBUserId,
|
||||
)
|
||||
.execute(&mut **transaction)
|
||||
.await?;
|
||||
|
||||
sqlx::query!(
|
||||
"
|
||||
DELETE FROM sessions
|
||||
|
||||
Reference in New Issue
Block a user