Fix various user/project deletion queries (#5511)

This commit is contained in:
aecsocket
2026-03-12 12:46:39 +00:00
committed by GitHub
parent 407e6217f5
commit 1c1683adb6
30 changed files with 298 additions and 237 deletions

View File

@@ -1,15 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "\n UPDATE oauth_clients\n SET created_by = $1\n WHERE created_by = $2\n ",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int8",
"Int8"
]
},
"nullable": []
},
"hash": "015d9b9191d9fd0a4de36ea8f44a13be89f18c2099ccb80c2fa1d394f681cebc"
}

View File

@@ -1,14 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "\n DELETE FROM users_notifications_preferences\n WHERE user_id = $1\n ",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int8"
]
},
"nullable": []
},
"hash": "05b65c44a55654af963329d2fcd68178411e8cfa3f3796d7741637f2c2be4850"
}

View File

@@ -0,0 +1,14 @@
{
"db_name": "PostgreSQL",
"query": "\n\t\t\t\tDELETE FROM notifications_actions\n\t\t\t\t WHERE notification_id = ANY($1)\n\t\t\t\t",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int8Array"
]
},
"nullable": []
},
"hash": "06baf2712b15a932c1fa9f4b5fc8fa774579b98479f33d39d9ef260487326343"
}

View File

@@ -0,0 +1,14 @@
{
"db_name": "PostgreSQL",
"query": "\n\t\t\t\tDELETE FROM users\n\t\t\t\tWHERE id = $1\n\t\t\t\t",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int8"
]
},
"nullable": []
},
"hash": "14f62cf25c77a07fc158f166977b368c308aa713fb16d6def5491449a1fc7df6"
}

View File

@@ -0,0 +1,14 @@
{
"db_name": "PostgreSQL",
"query": "\n\t\t\t\tDELETE FROM user_limits\n\t\t\t\tWHERE user_id = $1\n\t\t\t\t",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int8"
]
},
"nullable": []
},
"hash": "16bdf13909d14e773a2db7fb46574e86154fbda1965d0302a14f718d36231ff6"
}

View File

@@ -1,14 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "\n DELETE FROM moderation_locks\n WHERE moderator_id = $1\n ",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int8"
]
},
"nullable": []
},
"hash": "2829629354f77ea579d11be8671c3cec00f07f11f3d7972efd9441b263aa6c76"
}

View File

@@ -0,0 +1,15 @@
{
"db_name": "PostgreSQL",
"query": "\n\t\t\t\tUPDATE payouts\n\t\t\t\tSET user_id = $1\n\t\t\t\tWHERE user_id = $2",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int8",
"Int8"
]
},
"nullable": []
},
"hash": "2e65657a0d7fcf9e0204212ed7b923295dd9c2dd064634b2ebe4cd774bdc9e61"
}

View File

@@ -1,15 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "\n UPDATE users_compliance\n SET user_id = $1\n WHERE user_id = $2\n ",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int8",
"Int8"
]
},
"nullable": []
},
"hash": "32e68c09c9dd29dd9e18e139c49ac9cb039d2883ee139b6065fc49abb0c6176e"
}

View File

@@ -0,0 +1,14 @@
{
"db_name": "PostgreSQL",
"query": "\n\t\t\t\tDELETE FROM shared_instance_invited_users\n\t\t\t\tWHERE invited_user_id = $1\n\t\t\t\t",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int8"
]
},
"nullable": []
},
"hash": "3a2a1962875e5164d3d20802886db93631d57be2fe82bc2986dffd878ef1174d"
}

View File

@@ -0,0 +1,14 @@
{
"db_name": "PostgreSQL",
"query": "\n\t\t\t\tDELETE FROM notifications_deliveries\n\t\t\t\tWHERE user_id = $1\n\t\t\t\t",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int8"
]
},
"nullable": []
},
"hash": "3dd10a63bf390e48bc0c515b0f829baea647d2ac349cfe0fbc67d72b317c27f9"
}

View File

@@ -0,0 +1,14 @@
{
"db_name": "PostgreSQL",
"query": "\n\t\t\t\tDELETE FROM moderation_locks\n\t\t\t\tWHERE moderator_id = $1\n\t\t\t\t",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int8"
]
},
"nullable": []
},
"hash": "46101c0ee885ee24a5dab914a574217fd19392b5ae6219f674b3fe1a1e5b7af9"
}

View File

@@ -1,15 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "\n UPDATE users_redeemals\n SET user_id = $1\n WHERE user_id = $2\n ",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int8",
"Int8"
]
},
"nullable": []
},
"hash": "4e5ae05e21fa85032304a1cac45ab928d15ebda1cf342eb7d25b7fb9e2cd27ca"
}

View File

@@ -1,14 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "\n DELETE FROM oauth_client_authorizations\n WHERE user_id = $1\n ",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int8"
]
},
"nullable": []
},
"hash": "530b030fe1248d594718dce3a453baa08664677da4da57192795a9c1d86a6c88"
}

View File

@@ -0,0 +1,14 @@
{
"db_name": "PostgreSQL",
"query": "\n\t\t\t\tDELETE FROM notifications_deliveries\n\t\t\t\tWHERE notification_id = ANY($1)\n\t\t\t\t",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int8Array"
]
},
"nullable": []
},
"hash": "5387c684f4bc4ffaac71b1dfe83a68c9fda3f1185892de5750a077422db8136e"
}

View File

@@ -0,0 +1,14 @@
{
"db_name": "PostgreSQL",
"query": "\n\t\t\t\tDELETE FROM oauth_client_authorizations\n\t\t\t\tWHERE user_id = $1\n\t\t\t\t",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int8"
]
},
"nullable": []
},
"hash": "55feebc1bea8cee146860d5e2740d5291fa5507758f7f53a6e3db02c641048b1"
}

View File

@@ -0,0 +1,15 @@
{
"db_name": "PostgreSQL",
"query": "\n\t\t\t\tUPDATE users_compliance\n\t\t\t\tSET user_id = $1\n\t\t\t\tWHERE user_id = $2\n\t\t\t\t",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int8",
"Int8"
]
},
"nullable": []
},
"hash": "63d1e194be8e8f26acb088ee04abf5ccc2695c8982b8207a1dd527ad297b9668"
}

View File

@@ -1,14 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "\n DELETE FROM users\n WHERE id = $1\n ",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int8"
]
},
"nullable": []
},
"hash": "6db607d629be3047d53ff92bb82c07700595e8f4fcb7b602918540af4ae50d8b"
}

View File

@@ -0,0 +1,15 @@
{
"db_name": "PostgreSQL",
"query": "\n\t\t\t\tUPDATE payouts_values\n\t\t\t\tSET user_id = $1\n\t\t\t\tWHERE user_id = $2",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int8",
"Int8"
]
},
"nullable": []
},
"hash": "6f82c4f31d6b9344d48d997dafeff28a7365ac2483fea2ba34be4e348b73c723"
}

View File

@@ -1,14 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "\n DELETE FROM shared_instance_invited_users\n WHERE invited_user_id = $1\n ",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int8"
]
},
"nullable": []
},
"hash": "7234964dd4ea30d2ccd9742b5a454eee3a284573de7efb48e3982f1fb9f6702d"
}

View File

@@ -0,0 +1,14 @@
{
"db_name": "PostgreSQL",
"query": "\n\t\t\t\tDELETE FROM users_notifications_preferences\n\t\t\t\tWHERE user_id = $1\n\t\t\t\t",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int8"
]
},
"nullable": []
},
"hash": "7c49c8faa3dff955064e7ce04c15417d2ec1b9c56284b5160ead573ab5e1e597"
}

View File

@@ -0,0 +1,15 @@
{
"db_name": "PostgreSQL",
"query": "\n\t\t\t\tUPDATE oauth_clients\n\t\t\t\tSET created_by = $1\n\t\t\t\tWHERE created_by = $2\n\t\t\t\t",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int8",
"Int8"
]
},
"nullable": []
},
"hash": "91a93e039827c4f5a9331e431b5f4563d1d38ced13890397d1ab55a97d186ea6"
}

View File

@@ -0,0 +1,15 @@
{
"db_name": "PostgreSQL",
"query": "\n\t\t\t\tUPDATE users_redeemals\n\t\t\t\tSET user_id = $1\n\t\t\t\tWHERE user_id = $2\n\t\t\t\t",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int8",
"Int8"
]
},
"nullable": []
},
"hash": "91e5429c2d543ab748d67df52a49979fddde5e3fd470f1ea29d725e25f047430"
}

View File

@@ -1,14 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "\n DELETE FROM notifications_actions\n WHERE notification_id = ANY($1)\n ",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int8Array"
]
},
"nullable": []
},
"hash": "a0c91184d5a02b986decac3c34e78b61451ff90e103bcf1ec46f8da3bbcc1ff2"
}

View File

@@ -1,14 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "\n DELETE FROM shared_instance_users\n WHERE user_id = $1\n ",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int8"
]
},
"nullable": []
},
"hash": "b090fca733f427156d50feb24a0f360fadc01ee609c3c3a9b85618c64d822e55"
}

View File

@@ -1,15 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "\n UPDATE payouts_values\n SET user_id = $1\n WHERE user_id = $2",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int8",
"Int8"
]
},
"nullable": []
},
"hash": "b97afaa6cab8e042ab0117e64b43a8ba3a2c2be461ff9a6309d7e36c3148aeea"
}

View File

@@ -1,14 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "\n DELETE FROM notifications_deliveries\n WHERE user_id = $1\n ",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int8"
]
},
"nullable": []
},
"hash": "c4b78e945e3ae4976f274e8b8f5fd945e34fcdef00ca80005be7ae235de21df0"
}

View File

@@ -0,0 +1,14 @@
{
"db_name": "PostgreSQL",
"query": "\n\t\t\t\tDELETE FROM shared_instance_users\n\t\t\t\tWHERE user_id = $1\n\t\t\t\t",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int8"
]
},
"nullable": []
},
"hash": "d926d015cece307da567ac44b84d3e7416723ff95fcd83587f113621a9887420"
}

View File

@@ -1,14 +0,0 @@
{
"db_name": "PostgreSQL",
"query": "\n DELETE FROM user_limits\n WHERE user_id = $1\n ",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Int8"
]
},
"nullable": []
},
"hash": "e565b6a2c5e174c261125258b8eaa27613524fde10df6ec956f198367707078e"
}

View File

@@ -0,0 +1,9 @@
ALTER TABLE delphi_issue_detail_verdicts
DROP CONSTRAINT IF EXISTS delphi_issue_detail_verdicts_project_id_fkey;
ALTER TABLE delphi_issue_detail_verdicts
ADD CONSTRAINT delphi_issue_detail_verdicts_project_id_fkey
FOREIGN KEY (project_id)
REFERENCES mods(id)
ON DELETE CASCADE
ON UPDATE CASCADE;

View File

@@ -573,9 +573,9 @@ impl DBUser {
sqlx::query!(
"
DELETE FROM notifications_actions
WHERE notification_id = ANY($1)
",
DELETE FROM notifications_actions
WHERE notification_id = ANY($1)
",
&notifications
)
.execute(&mut *transaction)
@@ -584,9 +584,20 @@ impl DBUser {
sqlx::query!(
"
DELETE FROM notifications_deliveries
WHERE user_id = $1
",
DELETE FROM notifications_deliveries
WHERE notification_id = ANY($1)
",
&notifications
)
.execute(&mut *transaction)
.await
.wrap_err("failed to delete notifications_deliveries")?;
sqlx::query!(
"
DELETE FROM notifications_deliveries
WHERE user_id = $1
",
id as DBUserId
)
.execute(&mut *transaction)
@@ -785,9 +796,9 @@ impl DBUser {
sqlx::query!(
"
UPDATE payouts_values
SET user_id = $1
WHERE user_id = $2",
UPDATE payouts_values
SET user_id = $1
WHERE user_id = $2",
deleted_user as DBUserId,
id as DBUserId,
)
@@ -795,6 +806,18 @@ impl DBUser {
.await
.wrap_err("failed to update payouts_values user_id")?;
sqlx::query!(
"
UPDATE payouts
SET user_id = $1
WHERE user_id = $2",
deleted_user as DBUserId,
id as DBUserId,
)
.execute(&mut *transaction)
.await
.wrap_err("failed to update payouts user_id")?;
sqlx::query!(
"
DELETE FROM payouts_values_notifications
@@ -866,9 +889,22 @@ impl DBUser {
sqlx::query!(
"
DELETE FROM users
WHERE id = $1
",
UPDATE oauth_clients
SET created_by = $1
WHERE created_by = $2
",
deleted_user as DBUserId,
id as DBUserId,
)
.execute(&mut *transaction)
.await
.wrap_err("failed to update oauth_clients created_by")?;
sqlx::query!(
"
DELETE FROM users
WHERE id = $1
",
id as DBUserId,
)
.execute(&mut *transaction)
@@ -877,9 +913,9 @@ impl DBUser {
sqlx::query!(
"
DELETE FROM oauth_client_authorizations
WHERE user_id = $1
",
DELETE FROM oauth_client_authorizations
WHERE user_id = $1
",
id as DBUserId,
)
.execute(&mut *transaction)
@@ -888,9 +924,9 @@ impl DBUser {
sqlx::query!(
"
DELETE FROM shared_instance_users
WHERE user_id = $1
",
DELETE FROM shared_instance_users
WHERE user_id = $1
",
id as DBUserId,
)
.execute(&mut *transaction)
@@ -899,9 +935,9 @@ impl DBUser {
sqlx::query!(
"
DELETE FROM shared_instance_invited_users
WHERE invited_user_id = $1
",
DELETE FROM shared_instance_invited_users
WHERE invited_user_id = $1
",
id as DBUserId,
)
.execute(&mut *transaction)
@@ -910,10 +946,10 @@ impl DBUser {
sqlx::query!(
"
UPDATE users_redeemals
SET user_id = $1
WHERE user_id = $2
",
UPDATE users_redeemals
SET user_id = $1
WHERE user_id = $2
",
deleted_user as DBUserId,
id as DBUserId,
)
@@ -923,10 +959,10 @@ impl DBUser {
sqlx::query!(
"
UPDATE users_compliance
SET user_id = $1
WHERE user_id = $2
",
UPDATE users_compliance
SET user_id = $1
WHERE user_id = $2
",
deleted_user as DBUserId,
id as DBUserId,
)
@@ -936,9 +972,9 @@ impl DBUser {
sqlx::query!(
"
DELETE FROM user_limits
WHERE user_id = $1
",
DELETE FROM user_limits
WHERE user_id = $1
",
id as DBUserId,
)
.execute(&mut *transaction)
@@ -947,9 +983,9 @@ impl DBUser {
sqlx::query!(
"
DELETE FROM users_notifications_preferences
WHERE user_id = $1
",
DELETE FROM users_notifications_preferences
WHERE user_id = $1
",
id as DBUserId,
)
.execute(&mut *transaction)
@@ -958,28 +994,15 @@ impl DBUser {
sqlx::query!(
"
DELETE FROM moderation_locks
WHERE moderator_id = $1
",
DELETE FROM moderation_locks
WHERE moderator_id = $1
",
id as DBUserId,
)
.execute(&mut *transaction)
.await
.wrap_err("failed to delete moderation_locks")?;
sqlx::query!(
"
UPDATE oauth_clients
SET created_by = $1
WHERE created_by = $2
",
deleted_user as DBUserId,
id as DBUserId,
)
.execute(&mut *transaction)
.await
.wrap_err("failed to update oauth_clients created_by")?;
Ok(Some(()))
} else {
Ok(None)