commanded / eventstore

Event store using PostgreSQL for persistence
MIT License
1.06k stars 146 forks source link

Perform unattended init and migration on application startup #270

Open yangm97 opened 1 year ago

yangm97 commented 1 year ago

I'm looking into using commanded on embedded/edge/IoT devices (i.e. nerves) so it is not possible to run the init/create mix tasks before starting the BEAM, even if compiled as a release task. So migrations need to run during application startup, as a process.

An implementation of such feature can be seen in Ecto.Migrator. It provides a process that can be attached to the supervision tree to ensure the database schema is up to date.

https://hexdocs.pm/ecto_sql/Ecto.Migrator.html#module-example-running-migrations-on-application-startup