Skip to content

Instantly share code, notes, and snippets.

@afquinterog
Last active April 13, 2020 21:50
Show Gist options
  • Save afquinterog/3c33ca1dd258c42cc441f4ffd2f13a89 to your computer and use it in GitHub Desktop.
Save afquinterog/3c33ca1dd258c42cc441f4ffd2f13a89 to your computer and use it in GitHub Desktop.
delete syndication users
DO $$
declare
userToDelete UUID;
BEGIN
SET SCHEMA 'independentco';
select INTO userToDelete user_id
from users_roles where role_id IN (
select id
from roles
where name = 'syndication_service'
);
raise notice 'Syndication user = %', userToDelete;
delete from oauth_tokens where oauth_client_id IN
(select id from oauth_clients where user_id=userToDelete);
delete from oauth_client_users where oauth_client_id IN
(select id from oauth_clients where user_id=userToDelete);
delete from oauth_clients where user_id = userToDelete;
delete from accreditations where user_id=userToDelete;
delete from users_roles where user_id=userToDelete;
delete from street_addresses where user_id=userToDelete;
delete from assets where user_id = userToDelete;
delete from users where id = userToDelete ;
END$$;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment