Final result: automatically run migrations right when app is deployed!
When you deploy to production, afterwards you most likely write a console command like
heroku run rails db:migrate, right?
Well, there’s the
Procfile - a file where you list commands that should be run on deploy. Heroku automatically scans for it.
For other platforms (not heroku) you might need a tool like foreman.
How to use:
Create a file named
Procfilein your application root folder
Procfileadd these lines to run migrations right when the app gets deployed:
web: bundle exec rails s release: rails db:migrate
Bonus: also start sidekiq on deploy
web: bundle exec rails s worker: bundle exec sidekiq -c 2 release: rails db:migrate