Checklist for deploying your Rails app to production on Heroku

Last updated on December 20, 2021

Ever since I started working with my client, I had to deploy to staging and then production. On staging, even if I deploy a breaking change or I mess up something in during deployment, I have time to fix it, as nobody but me and my client will see the mess I have created.

But production is different - I have to be sure that things are going to work after I deploy. So I decided to create a quick checklist which I can follow every time I deploy my Rails app to production. Take notes.

I will assume that you are doing database migrations.

1. Put your app to maintenance mode

It is not necessary to do this if you are not doing any database migrations.

But if you are, you don’t want any information to be lost during the deployment process. It is easy to turn maintenance mode on - head over Heroku -> Settings -> Maintenance Mode -> Switch ON.

2. Make a backup of your Postgres database

Go to your production project on Heroku -> Resources -> Postgres database -> Durability -> Create a manual backup -> Download

This will ensure you that you have the latest version of your database after you have turned maintenance mode on. Even if you do something terribly wrong, you can go back and upload the latest stable version of your database. Then you can try again!

3. Merge develop to master

First checkout to master

git checkout master

and then merge from develop to master:

git merge develop

Hopefully there won’t be any merge conflicts!

4. Push to heroku

git push heroku master

If you have multiple heroku apps (for example, staging and production), you will need to specify the name of the app using --app app_name.

To get a list of your heroku apps and their names, run:

heroku apps

5. Run migrations

Now that you have pushed, you can migrate

heroku run rake db:migrate

6. Run any tasks

If you have any tasks that need to be ran, now it is a good opportunity to do so.

heroku run rake my_namespace:task_name

7. Update environment variables

Now that you have pushed your commits, migrated and run your tasks, you can go in your settings panel on Heroku, press Reveal Config Vars and add any new environment variables that you might have added since your last deployment.

8. Turn off maintenance mode

Now that everything is ready, you can go in your settings panel and turn the maintenance mode off in the same way you turned it on.

9. Test that the new feature is working

Everything should be up and running. But I always like to go and test the app is working as expected.

That’s it! You can now push to deployment with confidence!

Invite us to your inbox.

Articles, guides and interviews about web development and career progression.

Max 1-2x times per month.