PGError:错误:关系列不存在 - Rails / Heroku [英] PGError: Error: column of relation does not exist - Rails / Heroku
问题描述
我试图将isGroup列的值更改为public值。
我创建了一个迁移:
Post.connection.execute 更新的帖子集isgroup ='public')
然而,我得到以下错误: p>
PGError:错误:关系posts的列isgroup不存在
不幸的是,在connection.execute迁移的同时运行了创建迁移的列。然而,Heroku中的isGroup列确实存在,所以奇怪的是该列没有出现。
有什么建议吗?如果您确定列 isGroup
存在,那么您可以使用
UPDATE posts SETisGroup='public'
请注意,PostgreSQL在默认情况下会将所有未加引号的名字都折叠为小写。 为了避免这种情况,混淆和引用的必要性,您可能需要使用 ALTER TABLE将
。 isGroup
重命名为 isgroup
。 .. RENAME COLUMN ...
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? Thank you.
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 ...
.
这篇关于PGError:错误:关系列不存在 - Rails / Heroku的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!