View Source migraterl_runner (migraterl v0.5.0)
The migration runner, modelled as a gen_statem.
A run is a short-lived, linear lifecycle where each phase is an
explicit state and any failure routes to failed. The caller starts a
runner and blocks on a single run call that is answered only once a
terminal state is reached:
idle -> ensuring_journal -> locking -> reading_state
-> scanning -> planning -> applying -> done
| |
(dry_run) failedThe namespace advisory lock is acquired in locking and released
before the caller is answered (with terminate/3 as a crash-path
safety net), so it is held for the whole run regardless of the
transaction mode. Transaction boundaries themselves are emitted from
the applying loop, which lets one code path serve per_script, single
and none modes.
Summary
Functions
Run a migration to completion and return its result. Blocks the caller until the runner reaches a terminal state.
Types
-type namespace() :: binary().
-type ooo_policy() :: warn | error | ignore.
-type script_class() :: once | on_change | always.
-type txn_mode() :: per_script | single | none.
Functions
-spec run(epgsql:connection(), #opts{namespace :: namespace(), sources :: [{script_class(), file:filename_all()}], txn :: txn_mode(), on_out_of_order :: ooo_policy(), variables :: #{binary() => binary()}, dry_run :: boolean(), notify :: boolean()}, timeout()) -> {ok, #{applied := [binary()], skipped := [binary()], warnings := [warning()]}} | {error, term()}.
Run a migration to completion and return its result. Blocks the caller until the runner reaches a terminal state.