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.
@stevenharman is
bin-heroku_release.shsaved in thebin/directory or the root folder? Shouldn't it be namedheroku_release.shsince the command in the Procfile isbin/heroku_release? I'm having trouble getting my review apps to correctly run the release phase and execute this file.EDIT: I was finally able to get this to work. The filename has to match what is called in the Procfile release command.
i.e. file name and path:
bin/heroku_release.sh, Procfile:release: bin/heroku_release.shThe above config has the file named as
bin-heroku_release.shand then called withrelease: bin/heroku_releasein the Procfile, this should probably be updated to reflect the correct naming. Thanks for all of this config, it's 💯!