Bobby Meyer
developer/designer

heroku | postgresql | rails | ruby

Automatic Database Migration on Heroku

March 17, 2021

More than once, I have pushed a new release to Heroku and forgot to migrate the database. This can be avoided by adding a release command to your Procfile:

# Procfile
web: bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-development}
web: bundle exec puma -C config/puma.rb
worker: rake jobs:work

# Add this...
release: bundle exec rake db:migrate

Now, the database migrations are run immediately upon release.

back to posts
bobbymeyer.com © 2023 Bobby Meyer