This is a simplified, but fairly thorough, set of scripts and configuration to enable Heroku Release Phase for Rails apps.
Further, this particular set up plays nicely with Heroku Review Apps in that the release
phase script will:
- Fail, loudly, if the DB does not yet exist.
- Load the DB schema if the current schema version (as determined by
bin/rails db:version
) is0
. - Run DB migrations otherwise.
For a "normal" app that usually means it will run the DB migrations.
For a Review App, on the first deploy the release
phase will bin/rails db:schema:load
.
And then the postdeploy
script will seed data.
During subsequent deploys to the Review App, the release
phase will bin/rails db:migrate
.
@softwaregravy The
HEROKU_PARENT_APP_NAME
Config Var is defined as required in theapp.json
, meaning it inherited it from the parent app. So in the parent app (e.g., we always used our staging as the parent for Review Apps, so we'd set that Config Var there). As @thefotios said, all of this was build off of Review Apps v1 and I'm sure some things have changed in v2, but I've not updated this to reflect that.