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 buildpacksto 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.