with usr as (
select 1111111 as id -- <<< EDIT USER ID HERE!
), collections_d as (
delete from collection
where user_id in (select id from usr) returning id
), posts_d as (
delete from post
where user_id in (select id from usr) returning id
), comments_d as (
delete from post_comment
where user_id in (select id from usr) returning id
), ban as (
update person set status = 'banned'
where status <> 'banned' and id in (select id from usr) returning id
)
select
(select count(*) from collections_d) as collections_deleted,
(select count(*) from posts_d) as posts_deleted,
(select count(*) from comments_d) as comments_deleted,
(select count(*) from ban) as users_banned
;
Last active
May 1, 2017 19:02
-
-
Save NikolayS/8bb91faeeda8fc885ab98b1a427ecf1b to your computer and use it in GitHub Desktop.
ban+delete CTE
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment