Skip to content

Commit 707ff21

Browse files
authored
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
1 parent 8d80433 commit 707ff21

6 files changed

+100
-0
lines changed

apps/labrinth/.sqlx/query-6443da83032ef5d6cb907f97fb37ae62351eeeb2ae3b8148cf8a8fd0deb2795a.json

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/labrinth/.sqlx/query-713034d4968b290a0096e41b9da044f6760683cb89ff39255a177bb025e7638e.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/labrinth/.sqlx/query-b97afaa6cab8e042ab0117e64b43a8ba3a2c2be461ff9a6309d7e36c3148aeea.json

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/labrinth/.sqlx/query-ca9b41de4618bcf8ff4f6086f658add5d93855f599a48eeb5f1811f14e7fe610.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/labrinth/fixtures/labrinth-seed-data-202508052143.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,5 +1104,7 @@ COPY public.users (id, github_id, username, email, avatar_url, bio, created, rol
11041104
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
11051105
\.
11061106

1107+
INSERT INTO sessions (id, session, user_id, created, last_login, expires, refresh_expires, city, country, ip, os, platform, user_agent)
1108+
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');
11071109

11081110
COMMIT;

apps/labrinth/src/database/models/user_item.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,46 @@ impl DBUser {
753753
.execute(&mut **transaction)
754754
.await?;
755755

756+
sqlx::query!(
757+
"
758+
UPDATE affiliate_codes
759+
SET created_by = $1
760+
WHERE created_by = $2",
761+
deleted_user as DBUserId,
762+
id as DBUserId,
763+
)
764+
.execute(&mut **transaction)
765+
.await?;
766+
767+
sqlx::query!(
768+
"
769+
DELETE FROM affiliate_codes
770+
WHERE affiliate = $1",
771+
id as DBUserId,
772+
)
773+
.execute(&mut **transaction)
774+
.await?;
775+
776+
sqlx::query!(
777+
"
778+
UPDATE payouts_values
779+
SET user_id = $1
780+
WHERE user_id = $2",
781+
deleted_user as DBUserId,
782+
id as DBUserId,
783+
)
784+
.execute(&mut **transaction)
785+
.await?;
786+
787+
sqlx::query!(
788+
"
789+
DELETE FROM payouts_values_notifications
790+
WHERE user_id = $1",
791+
id as DBUserId,
792+
)
793+
.execute(&mut **transaction)
794+
.await?;
795+
756796
let open_subscriptions =
757797
DBUserSubscription::get_all_user(id, &mut **transaction)
758798
.await?;

0 commit comments

Comments
 (0)