View Source BitcrowdEcto.Migration (bitcrowd_ecto v1.0.0)
Utilities for migrations.
Summary
Functions
This function grants data manipulation privileges for a given schema to a given role.
Functions
Link to this function
grant_dml_privileges_on_schema(schema, role, opts \\ [])
View Source (since 0.7.0)This function grants data manipulation privileges for a given schema to a given role.
Use this when you have a setup where your "runtime" user is deprived of all DDL privileges (i.e., it can't create or modify tables, etc.), but your migration user is allowed to do so.
In particular, the following GRANTS are executed:
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES
GRANT ALL ON ALL FUNCTIONS
GRANT ALL ON ALL SEQUENCES
Usage
The easiest way of using this is to issue the command after every CREATE SCHEMA
call:
def change do
execute("CREATE SCHEMA foo;", "DROP SCHEMA foo;")
if direction() == :up do
BitcrowdEcto.Migration.grant_dml_privileges_on_schema("foo", "mydmlrole")
end
end
Options
default
boolean indicating whether the privileges should automatically be granted forfuture objects, defaults to true