1
0

Update appropriate rows when removing a user (#4597)

* Update appropriate rows when removing a user

* Update sqlx cache

* Delete rows from payouts_values_notifications instead of make ghost user
This commit is contained in:
aecsocket
2025-10-24 07:19:53 -07:00
committed by GitHub
parent 8d80433c2c
commit 707ff2146b
6 changed files with 100 additions and 0 deletions

View File

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

View File

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

View File

@@ -0,0 +1,15 @@
{
"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

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

View File

@@ -1104,5 +1104,7 @@ COPY public.users (id, github_id, username, email, avatar_url, bio, created, rol
103587649610509 \N Default admin user admin@modrinth.invalid https://avatars.githubusercontent.com/u/106493074 $ chmod 777 labrinth 2020-07-18 16:03:00.000000+00 admin 0 0.00000000000000000000 \N \N \N \N \N $argon2i$v=19$m=4096,t=3,p=1$c2FsdEl0V2l0aFNhbHQ$xTGvQNICqetaNA0Wu1GwFmYhQjAreRcjBz6ornhaFXA t \N \N \N \N \N \N https://avatars.githubusercontent.com/u/106493074 t
\.
INSERT INTO sessions (id, session, user_id, created, last_login, expires, refresh_expires, city, country, ip, os, platform, user_agent)
VALUES (93083445641246, 'mra_admin', 103587649610509, '2025-10-20 14:58:53.128901+00', '2025-10-20 14:58:53.128901+00', '2025-11-03 14:58:53.128901+00', '2025-12-19 14:58:53.128901+00', '', '', '127.0.0.1', 'Linux', 'Chrome', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36');
COMMIT;

View File

@@ -753,6 +753,46 @@ impl DBUser {
.execute(&mut **transaction)
.await?;
sqlx::query!(
"
UPDATE affiliate_codes
SET created_by = $1
WHERE created_by = $2",
deleted_user as DBUserId,
id as DBUserId,
)
.execute(&mut **transaction)
.await?;
sqlx::query!(
"
DELETE FROM affiliate_codes
WHERE affiliate = $1",
id as DBUserId,
)
.execute(&mut **transaction)
.await?;
sqlx::query!(
"
UPDATE payouts_values
SET user_id = $1
WHERE user_id = $2",
deleted_user as DBUserId,
id as DBUserId,
)
.execute(&mut **transaction)
.await?;
sqlx::query!(
"
DELETE FROM payouts_values_notifications
WHERE user_id = $1",
id as DBUserId,
)
.execute(&mut **transaction)
.await?;
let open_subscriptions =
DBUserSubscription::get_all_user(id, &mut **transaction)
.await?;