Adding more jinja2 template macros for the default previleges.

pull/3/head
Murtuza Zabuawala 2016-02-10 13:00:19 +05:30 committed by Ashesh Vashi
parent 637a5838a8
commit dc51baefcc
1 changed files with 15 additions and 0 deletions

View File

@ -11,4 +11,19 @@ GRANT {{ with_grant }} ON {{ type }} TO {{ conn|qtIdent(role) }} WITH GRANT OPTI
{% macro RESETALL(conn, type, role) -%}
ALTER DEFAULT PRIVILEGES
REVOKE ALL ON {{ type }} FROM {{ conn|qtIdent(role) }};
{%- endmacro %}
{### To allow create macro for specific database object ###}
{% macro SET(conn, db_object_type, db_object_name, type, role, priv, with_grant) -%}
{% if priv %}
ALTER DEFAULT PRIVILEGES IN {{ db_object_type }} {{ conn|qtIdent(db_object_name) }}
GRANT {{ priv }} ON {{ type }} TO {{ conn|qtIdent(role) }};
{% endif %}
{% if with_grant %}
ALTER DEFAULT PRIVILEGES IN {{ db_object_type }} {{ conn|qtIdent(db_object_name) }}
GRANT {{ with_grant }} ON {{ type }} TO {{ conn|qtIdent(role) }} WITH GRANT OPTION;
{% endif %}
{%- endmacro %}
{% macro UNSET(conn, db_object_type, db_object_name, type, role) -%}
ALTER DEFAULT PRIVILEGES IN {{ db_object_type }} {{ conn|qtIdent(db_object_name) }}
REVOKE ALL ON {{ type }} FROM {{ conn|qtIdent(role) }};
{%- endmacro %}