Heroku: The Never-Ending Battle

Diana M.
3 min readMay 24, 2021

My experience with Heroku so far has been full of turmoil as I navigate issues with deployment and learn to understand the logs. There may even have been an existential crisis….or two (only half-kidding).

This post will discuss the most recent log error I solved, thus successfully deploying an application I’ve been working on.

The Error:

ActionView::Template::Error (PG::UndefinedTable: ERROR:  relation "products" does not exist

The Situation:

These last few days I’ve been working on a pure Ruby on Rails application that serves as an online platform for pet owners to create review posts of their favorite products. Other users are able to leave comments on these posts much like you see on sites like Shein and Amazon. My database for the table ‘products’ has the attributes of image, title, description, and rating. As I’ve set up my application with Postgresql, I did not expect any hiccups.

As I thought, the site deployed successfully. However, when I clicked on “Open App”, it didn’t load. Instead I was presented with an error stating “Could not load app, please see logs.” For those of you who haven’t done so yet, you can access the logs on the top right corner of the app dashboard under the “More” button. Once there, this is what my log looked like:

At first I went through the ritual head-scratching, eye squinting mannerisms as I processed what I was looking at. I noticed two things: a 500 Internal Server Error and then a more specific error that seemed to tell me my table didn’t exist. I checked my Rails app….it definitely existed. Did my tables not upload? If so, why?

The Solution:

After some googling, I realized that I had to migrate my database using the Heroku CLI command:

heroku run rake db:migrate --app rockyscorner

If you try this, make sure to change “rockyscorner” with the name of your application as you have it in Heroku.

Once I ran this command, all my tables (products, reviews, and users tables) were migrated to Heroku and my app successfully displayed!

Navigating Heroku errors has been time consuming for me, as I don’t always seem to find answers to my specific errors. This could also be part of the learning curve of knowing how to research Heroku errors. Regardless, I hope this is useful to anyone who encounters this error and wants a straight-to-the-point answer of how to resolve.

Thanks for reading!

-D.M.

--

--

Diana M.

Software Engineering graduate with a penchant for matcha lattes and baked goods. Most of my content will consist of RoR, JS, HTML/CSS, and React.