Buildpacks are scripts that run after your app is deployed to Heroku. Heroku is smart enough to figure out what buildpacks to use depending on your app. For example, assets are automatically prepared when you deploy your Rails app.
For added functionality, Heroku lets you add additional buildpacks. So, to automatically run any pending database migration after your Rails app deploys:
- Go to your app’s directory and run
heroku buildpacks
to see the list of current buildpacks. - Add a rake tasks buildpack with:
heroku buildpacks:add https://github.com/gunpowderlabs/buildpack-ruby-rake-deploy-tasks
- Configure this buildpack:
heroku config:set DEPLOY_TASKS='db:migrate cache:clear'
- You are all done! Any pending migrations will automatically run the next time you deploy to Heroku.
More resources:
Tags:
Ruby on Rails (1)
Last Updated: 11 September 2016
Previous: Confirm before pushing to Git master branch
Next: Mental Models for Product Developers, Part 1: Engineering