Adding more jinja2 template macros for the default previleges.
parent
637a5838a8
commit
dc51baefcc
|
@ -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 %}
|
Loading…
Reference in New Issue