Migrations

Depending on the use-case, we can run migrations in various ways. The "safest" (not in terms of security but in terms of application stability) is to open a tunnel to the production database and update our repo.ex to use the tunnel. By default, our database tunnels runs on port 5438.

  1. Run tunnel-[staging,production]-database in a terminal

  2. Update repo.ex to reference postgresql://<db-username>:<db-password>@localhost:5438/[staging,production_rds. The credentials can be found in vault under secret/database.

  3. In an IEx terminal, run Peacemaker.ReleaseTasks.migrate([]).

  4. Close tunnels and revert the url key to reference the env variable.

We haven't had the need to rollback any migrations so there is no real defined strategy for this case. There is however, an example we could extend off of in the Phoenix documentation.