即日起在codingBlog上分享您的技术经验即可获得积分,积分可兑换现金哦。

Heroku Postgres错误:错误:关系pgerror:“组织”不存在(ActiveRecord::statementinvalid)

栈溢出 tereško 22℃ 0评论
本文目录
[隐藏]

1.原始问题:Heroku Postgres Error: PGError: ERROR: relation “organizations” does not exist (ActiveRecord::StatementInvalid)

I’m having a problem deploying my Rails app to Heroku, where this error is thrown when trying to access the app:

PGError: ERROR: relation “organizations” does not exist (ActiveRecord::StatementInvalid)

SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
FROM pg_attribute a LEFT JOIN pg_attrdef d
  ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"organizations"'::regclass
  AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum

Anybody have any ideas? This is a first for me, especially because I’ve been working with Heroku for a year on other apps, and haven’t see anything like this. Of course, everything works on local SQLite.

Thanks in advance for any help!

–Mark

2.被采纳答案

I had the same problem. To solve it, resetting the database is more easier.

  • heroku rake db:reset (‘heroku run rake db:reset’ if you’re on cedar)
  • heroku rake db:migrate (‘heroku run rake db:migrate’ if you’re on cedar)

Then, migration was done successfully for my case 🙂

3.While this is a good solution in this context, don’t do it on production. It will delete all the records from your database

4.其他高票答案

4.1.第1个答案

According to my experience (Rails 3.1, Sedar stack) after running pg:reset and db:migrate you might have to run heroku restart.

4.2.第2个答案

I’ve had the same problem until I realized that I had to do:

heroku rake db:migrate

🙂

4.3.第3个答案

My heroku version:

heroku --version
#=> heroku-gem/2.29.0 (x86_64-linux) ruby/1.9.3

In order to fix it just open your terminal and run:

heroku pg:reset DATABASE --confirm YOUR_APP_NAME
heroku run rake db:setup
heroku restart
heroku open

4.4.第4个答案

In my case, I also had to destroy and recreate my app. I had run a rake db:migrate with a migration file not committed and for whatever reason, the pg:reset wasn’t working.

转载请注明:CodingBlog » Heroku Postgres错误:错误:关系pgerror:“组织”不存在(ActiveRecord::statementinvalid)

喜欢 (0)or分享 (0)
发表我的评论
取消评论

*

表情