Skip to content

Commit

Permalink
Merge pull request #214 from zalando/wrapper-tp-drop-role
Browse files Browse the repository at this point in the history
Add a wrapper to drop_user() to make devs' life easier
  • Loading branch information
avaczi committed Mar 12, 2018
2 parents 08d9a56 + cce5fc2 commit 3618a81
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions postgres-appliance/create_user_functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,21 @@ COMMENT ON FUNCTION drop_user(text) IS 'Drop a human or application user. Inten
Roles (= users) that own database objects cannot be dropped.';


CREATE OR REPLACE FUNCTION drop_role(username text)
RETURNS void
LANGUAGE sql
AS $function$
SELECT user_management.drop_user(username);
$function$
SECURITY DEFINER;

REVOKE ALL ON FUNCTION drop_role(text) FROM public;
GRANT EXECUTE ON FUNCTION drop_role(text) TO admin;

COMMENT ON FUNCTION drop_role(text) IS 'Drop a human or application user. Intended for cleanup (either after team changes or mistakes in role setup).
Roles (= users) that own database objects cannot be dropped.';


CREATE OR REPLACE FUNCTION terminate_backend(pid integer)
RETURNS boolean
LANGUAGE sql
Expand Down

0 comments on commit 3618a81

Please sign in to comment.