I have a Rails app using Active record library. While on localhost, everything is getting saved corretly to the database. However, when the same code is uploaded to Heroku, and I click on the button that should save it to the database, I get the following error: We're sorry, but something went wrong.
From my logs I get the following error: ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation "messages" does not exist
Localhost database info:
Name | Owner |
messages | kari |
How do I fix my database in Heroku.
You'll need to migrate your database.
You need to have the Heroku command line interface (CLI) installed.
Then, in console, you'll do something like:
heroku run rake db:migrate
If you have more than one heroku remote defined (like, I tend to have heroku_staging and heroku_production), then it would be something like:
heroku run rake db:migrate --remote heroku_production
You can also do something like:
heroku run rake db:migrate --app your_app_name
If you prefer that.