Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PGError: Error: column of relation does not exist

I'm trying to change the value of a column "isGroup" to the value "public".

I created a migration:

Post.connection.execute("update Posts set isgroup='public'") 

However, I get the following error:

PGError: ERROR:  column "isgroup" of relation "posts" does not exist 

I had unfortunately ran the column creating migration at the same time as the connection.execute migration. However, the "isGroup" column does exist on Heroku, so it is weird that the column is not showing as appearing.

Any advice?

like image 951
user749798 Avatar asked Jan 07 '13 02:01

user749798


People also ask

Does not exist Postgres?

Definition of PostgreSQL column does not exist exception. PostgreSQL column does not exist exception occurs when we have used column did not exist in the table or it will occur when the used column name has lower case name and we have used upper case in our query.

Was aborted error relation does not exist?

In PostgreSQL, a relation does not exist error happens when you reference a table name that can't be found in the database you currently connect to. In the case above, the error happens because Sequelize is trying to find Users table with an s , while the existing table is named User without an s .


1 Answers

If you are sure that column isGroup exists, then you should quote it like:

UPDATE posts SET "isGroup" = 'public' 

Note that PostgreSQL by default folds all unquoted named to lowercase.

To avoid this confusion and necessity to quote, you might want to rename isGroup to isgroup using ALTER TABLE ... RENAME COLUMN ....

like image 108
mvp Avatar answered Sep 18 '22 18:09

mvp