View Source migraterl_watcher (migraterl v0.5.0)
Long-lived, supervised directory watcher (development workflow).
Modelled as a gen_statem with two states:
idle: steady state, waiting for filesystem activity.debouncing: a relevant change arrived; astate_timeoutcoalesces a burst of events (editor write-then-rename, formatters, git checkouts) into a single migration run.
One watcher is started per entry in the watchers application
environment (see migraterl_sup). It uses the optional fs
application to observe the source directories of a run configuration
and re-runs migraterl:migrate/2 after the debounce window.
Meant for local development ("apply on save"); production deploys
should call migraterl:migrate/2 explicitly at boot.
A watcher spec is a map:
#{conn => epgsql:connection() | epgsql:connect_opts(),
migrate => map(), % the migraterl:migrate/2 options map
debounce_ms => non_neg_integer()}