class ActiveRecord::ConnectionAdapters::PostgreSQLGrantPrivilege
Creates queries for granting PostgreSQL role privileges.
This class is meant to be used by the grant_*_privileges methods in the PostgreSQLAdapter
. Different database objects have different privileges that you can apply to a role. See the PostgreSQLPrivilege
PRIVILEGE_TYPES constant for usage. Generally speaking, you usually don’t want to use this class directly, but rather the aforementioned wrapped methods.
When using the grant_*_privileges methods, you can specify multiple permissions, objects and roles by using Arrays for the appropriate argument. You can also apply the privileges to all objects within a schema by using the :all option in the options Hash and supply the schema name as the first argument.
Examples¶ ↑
grant_table_privileges([ :table1, :table2 ], :select, :joe) # => GRANT SELECT ON TABLE "table1", "table2" TO "joe" grant_sequence_privileges(:my_seq, [ :select, :update ], :public) # => GRANT SELECT, UPDATE ON SEQUENCE "my_seq" TO PUBLIC grant_sequence_privileges(:public, [ :select, :update ], :joe, :all => true) # => GRANT SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA PUBLIC TO "joe"
You can specify the :with_grant_option
in any of the grant_*_privilege methods to add a WITH GRANT OPTION clause to the command.