user749798
user749798

Reputation: 5370

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?

Upvotes: 31

Views: 59220

Answers (1)

mvp
mvp

Reputation: 116098

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 ....

Upvotes: 44

Related Questions