Auto-run database migrations on deployment of Rails applications in Heroku.
heroku buildpacks:add https://github.com/alphasights/buildpack-migrations.git --app <my-heroku-app>
Once this is executed, redeploy your application.
This buildpack uses the
schema_migrations table in your PostgreSQL database and compares it to the file structure in the
db/migrate directory on your Rails app. It looks for files whose timestamps are not present as rows in
schema_migrations and runs
bundle exec rake db:migrate if it notices a discrepancy.
This also outputs a random Mad Max quote, because why not.
Fork this repository. Then, run:
cd buildpack-migrations git checkout -b my-update git commit -m "My Update"
Then make a PR into this repository.
Protip: PRs are more likely to get merged if there is at least one new quote from Mad Max added to the list.
To test your changes on this buildpack using your application, follow these steps:
heroku buildpacks:remove https://github.com/alphasights/buildpack-migrations.git --app <my-heroku-app> heroku buildpacks:add https://github.com/<username>/buildpack-migrations.git#my-update --app <my-heroku-app>
Copyright AlphaSights and Contributors, 2015
Copy the snippet above into CLI.