mirror of
https://github.com/standardebooks/web.git
synced 2025-07-07 15:20:32 -04:00
Add script to delete users who have no other connections in the database
This commit is contained in:
parent
343d92f7c9
commit
aad37981ab
1 changed files with 20 additions and 0 deletions
20
scripts/delete-orphan-users
Normal file
20
scripts/delete-orphan-users
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#!/usr/bin/php
|
||||||
|
<?
|
||||||
|
require_once('/standardebooks.org/web/lib/Core.php');
|
||||||
|
|
||||||
|
Db::Query('DELETE u.* from Users u
|
||||||
|
left outer join Payments on u.UserId = Payments.UserId
|
||||||
|
left outer join NewsletterSubscriptions on u.UserId = NewsletterSubscriptions.UserId
|
||||||
|
left outer join Benefits on u.UserId = Benefits.UserId
|
||||||
|
left outer join Patrons on u.UserId = Patrons.UserId
|
||||||
|
left outer join PollVotes on u.UserId = PollVotes.UserId
|
||||||
|
left outer join Sessions on u.UserId = Sessions.UserId
|
||||||
|
left outer join Artworks on u.UserId = Artworks.SubmitterUserId
|
||||||
|
where
|
||||||
|
Payments.userid is null
|
||||||
|
and NewsletterSubscriptions.userid is null
|
||||||
|
and Benefits.userid is null
|
||||||
|
and Patrons.userid is null
|
||||||
|
and PollVotes.userid is null
|
||||||
|
and Sessions.userid is null
|
||||||
|
and Artworks.SubmitterUserId is null');
|
Loading…
Add table
Add a link
Reference in a new issue