codekingpro/portable-devtools
114k
1{% macro APPLY(conn, type, role, privs, with_grant_privs, grantor) -%}2{% if privs %}3ALTER DEFAULT PRIVILEGES FOR ROLE {{grantor}}4GRANT {{ privs|join(', ') }} ON {{ type }} TO {{ role }};5{% endif %}6{% if with_grant_privs %}7ALTER DEFAULT PRIVILEGES FOR ROLE {{grantor}}8GRANT {{ with_grant_privs|join(', ') }} ON {{ type }} TO {{ role }} WITH GRANT OPTION;9{% endif %}10{%- endmacro %}11{% macro RESETALL(conn, type, role, grantor) -%}12ALTER DEFAULT PRIVILEGES FOR ROLE {{grantor}}13 REVOKE ALL ON {{ type }} FROM {{ role }};14{%- endmacro %}15{### To allow create macro for specific database object ###}16{% macro SET(conn, db_object_type, db_object_name, type, role, privs, with_grant_privs, grantor) -%}17{% if privs %}18ALTER DEFAULT PRIVILEGES FOR ROLE {{grantor}} IN {{ db_object_type }} {{ conn|qtIdent(db_object_name) }}19GRANT {{ privs|join(', ') }} ON {{ type }} TO {{ role }};20{% endif %}21{% if with_grant_privs %}22ALTER DEFAULT PRIVILEGES FOR ROLE {{grantor}} IN {{ db_object_type }} {{ conn|qtIdent(db_object_name) }}23GRANT {{ with_grant_privs|join(', ') }} ON {{ type }} TO {{ role }} WITH GRANT OPTION;24{% endif %}25{%- endmacro %}26{% macro UNSET(conn, db_object_type, db_object_name, type, role, grantor) -%}27ALTER DEFAULT PRIVILEGES FOR ROLE {{grantor}} IN {{ db_object_type }} {{ conn|qtIdent(db_object_name) }}28 REVOKE ALL ON {{ type }} FROM {{ role }};29{%- endmacro %}30 31{% macro REMOVE(conn, type, role, privs, with_grant_privs, grantor) -%}32{% if privs %}33ALTER DEFAULT PRIVILEGES FOR ROLE {{grantor}} REVOKE {{ privs|join(', ') }} ON {{ type }} FROM {{ role }};34{% endif %}35{% if with_grant_privs %}36ALTER DEFAULT PRIVILEGES FOR ROLE {{grantor}} REVOKE {{ with_grant_privs|join(', ') }} ON {{ type }} FROM {{ role }} WITH GRANT OPTION;37{% endif %}38{%- endmacro %}39 