Lack of production / hero: WHERE a.attrelid = '"school"' :: regclass

I added a table to my local env called schools and it works fine in dev. In fact, he even works great in the production (heroics), but does not have time in production, and rake db:migrate gives an error below.

I cannot even pre-compile assest (with RAILS_ENV = production), get access to any part of my application, including the rails console in production (heroku). Everything throws an error below. I lost a few hours on this, but don't feel any closer to figure it out. (Note: I have a '"..."' link to table_name, which I think is part of the problem)

I switched from rails 3.1.0 to 3.1.3 to have something with this.

 PGError: ERROR: relation "schools" does not exist LINE 4: WHERE a.attrelid = '"schools"'::regclass ^ : 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 = '"schools"'::regclass AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum 

I am lost, how can this be. I read a few more questions on this topic, but no solution was visible. Thanks for the help. Any insight is greatly appreciated.

UPDATE --------------------------------------- ---------- -----

I just created a brand new application on heroku and ran rake db:migrate and got the same error.

UPDATE 2

I cloned the application from the hero, and the "school" - in the scheme.

 create_table "schools", :force => true do |t| ... ... end 

UPDATE 3

I tried to return to rails 3.1.0, but this did not help.

UPDATE 4

Still working on it. I have not heard from the support of the hero.

UPDATE 5

Heroku support was able to verify that โ€œschoolsโ€ are not a table in the database, but I still canโ€™t access the console and the application.

+7
source share
4 answers

Heroku support helped me solve this problem, although it was not related to a problem related to the heroku platform, as we found out.

I had a problem with a chicken and an egg, where the migration was not performed because the restart-restart tried to talk to the table, and the table was not created because the migration could not be performed. ActiveAdmin initialized when loading rails and tried to find schools. Thanks to everyone who helped.

+4
source

I solved this by commenting

 #ActiveAdmin.routes(self) 

in routes before migration. After the migration is complete, I just uncomment this line and everything works fine.

+5
source

No, quoting should not be a problem. Although double quotes are not needed in this case, they are not mistaken:

 SELECT '"schools"'::regclass 

I would think that PostgreSQL is right, and the schools relation does not exist - in your database and in the schema that is part of your search_path .

If you can connect to your database, you can run this query to diagnose your problem:

 SELECT n.nspname AS schema_name ,c.relname AS table_name ,c.relhastriggers ,c.reltuples FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE c.relname ~~* '%schools%' AND c.relkind = 'r' AND nspname <> 'pg_catalog'; 

Finds every table where the name contains the string schools . Like the psql meta psql :

 \dt *schools* 

Make sure you are connected to the same user in the same database where you have the problem.

+1
source

I ran into this problem when running tests.

Just reset the database for the test environment:

 rake db:reset RAILS_ENV=test 
0
source

All Articles