View Source rebar3_strata

A rebar plugin to manage schema migrations with strata.

Build

rebar3 compile

Use

Create a migrations directory in your src folder of your application. In this example, the path will be apps/strata_example/src/migrations. We have a migrations folder in the source directory of an app with a default release structure.

Next in rebar.config set this config:

%% Install plugin
{project_plugins, [rebar3_strata]}.

%% Run strata compile command on compilation step
{provider_hooks, [{pre, [{compile, {strata, compile}}]}]}.

%% Set path read and write migrations at
{strata, [{path, "apps/strata_example/src/migrations"}]}.

New

Create a new schema migration with rebar3 strata new <migration>.

For example, in a todo app, you might creata schema like this:

rebar3 strata new create_todos

Compile

If the provider_hook is set you will not need to run the compile step manually. However, if you wanted to the command is:

rebar3 strata compile

The compilation step creates a strata_migrations module in the migrations folder. At runtime you can call:

strata_migrations:init()

Which will return the migrations map to be used by strata in the config step. For a more complete example might look like:

Migrations = strata_migrations:init(),
%% Using the strata_postgres backend for example purposes
Config = strata:config(Migrations, strata_postgres),
ok = strata:run(Config).

License

Apache V2