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
.
👋 @eri-b. Thanks for the kind words!
Seeding the DB in so far as Heroku deploys are concerned is only done for Review Apps. And to handle that, we leverage the
app.json
'spostdeploy
script:This ensures the seeding only happens once, only happens for Review Apps, and is consistent with how you'd seed a Review App DB without a Release Phase setup. Hope that helps. Please let me know if you have more questions.