简体   繁体   中英

PG Database works great on localhost but not on heroku

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM