Heroku Postgres error: PGError: ERROR: "organization" relationships do not exist (ActiveRecord :: StatementInvalid)

I had a problem deploying my Rails application to Heroku, where this error occurs when trying to access the application:

PGError: ERROR: "organization" relationships do 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 

Does anyone have any idea? This is the first for me, especially because I have been working with Heroku for a year in other applications and do not see anything like it. Of course, everything works on local SQLite.

+43
ruby-on-rails postgresql rails-activerecord heroku
Mar 27 '11 at 17:28
source share
13 answers

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

  • heroku rake db: reset ('heroku run rake db: reset' if you're on a cedar)
  • heroku rake db: migrate ('heroku run rake db: migrate' if you're on a cedar)

Then the migration was successful for my case :)

Although this is a good solution in this context, do not do this in production. It will delete all records from your database.

+80
Jul 13 '11 at 8:01
source share
β€” -

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

+19
Jan 08 '12 at 23:28
source share

I had the same problem until I realized what I needed to do:

 heroku rake db:migrate 

:)

+17
Apr 08 '11 at 12:00 a.m.
source share

My version of the hero:

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

To fix this, just open a terminal and run:

 heroku pg:reset DATABASE --confirm YOUR_APP_NAME heroku run rake db:setup heroku restart heroku open 
+7
Oct 24
source share

In my case, I also had to destroy and recreate my application. I ran rake db: migrate with a migration file that was not committed, and for some reason pg: reset did not work.

+1
Jan 05 '12 at 16:59
source share

Do you use a lesson? I had this exact problem when upgrading to version 2.0. You need to manually modify the migration file.

https://github.com/plataformatec/devise/wiki/How-To:-Upgrade-to-Devise-2.0-migration-schema-style

+1
Jun 12 2018-12-12T00:
source share

Apparently, uninstalling my entire application and then redeploying from scratch fixed it. I have no idea what the problem is.

0
Mar 27 '11 at 18:25
source share

In my case, the symptoms were the same, but the root cause and the remedy were slightly different. Spent on it. Hope this post saves someone else in those hours! I use:

Everything works fine on SQLite, but gets the same PG error on Heroku. It turns out that ActiveScaffold somehow impedes the successful completion of Heroku rake tasks due to an error similar to the previous one. This way you get cache 22, where you get the same error if you try to run heroku rake db: migrate or the like.

Now the fix:

  • Comment out code blocks that are similar to the following of all controllers that use "active_scaffold":

     active_scaffold :<model_name> do |conf| end 
  • Commit, push to heroku
  • heroku run rake db:migrate
  • Make sure everything is in order by running heroku run rails console , and then say create a model and save it.
  • Now revert the changes (i.e. return the active_scaffold block above)
  • commit, push to heroku
  • You are in business!
0
Apr 13 2018-12-12T00:
source share

I support local configuration as close to production as possible, including using the postgresql database, so I had this problem on my local machine. In any case, I can’t delete my production base. It turned out that my question was only in the test, so I used: rake db: test: get ready to fix it.

0
Oct 24
source share
 rake db:drop rake db:create rake db:migrate 
0
Oct 30 '13 at 10:30
source share

After hours of sifting through the answer, I realized that when you specify

 rails new MYAPP -database POSTGRESQL 

it modifies the .gitignore file, ignoring the whole /db/ directory , so my database never came up with a hero. Delete it with care, or at least do not enter your username and password where you click.

0
Jun 24 '14 at 3:12
source share

I had a similar problem and I decided heroku run rake db:reset and heroku run rake db:migrate to fix the problem. I think I just did not perform the correct migrations to fix this problem.

0
Jun 22 '15 at 21:02
source share

There can be many reasons for this error. However, for my application, the problem was that I did not exit the application before starting the migration (?). So, let's move on to this path: http://name_of_my_app.herokuapp.com/logout fixed the problem for me.

0
Feb 15 '16 at 23:42 on
source share



All Articles