BitcrowdEcto.Migration (bitcrowd_ecto v0.7.0) View Source
Utilities for migrations.
Link to this section Summary
Functions
This function grants data manipulation privileges to configured dmlroles for a given schema.
This function grants data manipulation privileges for a given schema to a given role.
Link to this section Functions
Specs
This function grants data manipulation privileges to configured dmlroles for a given schema.
See grant_privileges_on_schema/3
for details and options.
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")
end
end
Configuration
In order to not repeat your roles in every schema-creating migration, roles are configured for
the :carbonite
OTP app and are read at runtime.
config :carbonite, dmlroles: ["mydmlrole"]
This can also be used to disarm this function in development, by passing an empty list.
Specs
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