github-education-resources / classroom

GitHub Classroom automates repository creation and access control, making it easy for teachers to distribute starter code and collect assignments on GitHub.
https://classroom.github.com
1.34k stars 570 forks source link

Investigate automatically running DB migrations in Heroku #2012

Open d12 opened 4 years ago

d12 commented 4 years ago

Currently, we deploy migration PRs and then heroku run bundle exec rake db:migrate to run the migration. We may be able to use https://devcenter.heroku.com/articles/release-phase to automatically run these migrations after the deploy release finishes.

shaunakpp commented 4 years ago

We can add the following release command in our Procfile and get this working:

release: bin/rails db:migrate

Should we test it on a demo instance of classroom?

d12 commented 4 years ago

Nice, this should work. Do you know if this plays nicely with multiple dynos on Heroku?

shaunakpp commented 4 years ago

Good catch! I'll check it out.

shaunakpp commented 4 years ago

So the Heroku official blog about release phase mentions that release phases run in one-off dynos, which is equivalent to booting up the console and running the migration manually, but ensuring that the deployment will fail if the release phase failed. An example in their blog explains how this works for migrations, which I think is exactly what we need.