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?
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.
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 .
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 ...
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With