postgresql PGError:错误:关系列不存在

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14189254/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 23:57:40  来源:igfitidea点击:

PGError: Error: column of relation does not exist

ruby-on-rails-3postgresqlherokumigration

提问by user749798

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

我正在尝试将列“isGroup”的值更改为值“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.

不幸的是,我在 connection.execute 迁移的同时运行了创建迁移的列。但是,Heroku 上确实存在“isGroup”列,所以奇怪的是该列没有显示为出现。

Any advice?

有什么建议吗?

回答by mvp

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

如果您确定该列isGroup存在,那么您应该像这样引用它:

UPDATE posts SET "isGroup" = 'public'

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

请注意,PostgreSQL 默认将所有未加引号的名称折叠为小写。

To avoid this confusion and necessity to quote, you might want to rename isGroupto isgroupusing ALTER TABLE ... RENAME COLUMN ....

为了避免这种混淆和引用的必要性,您可能需要重命名isGroupisgroupusing ALTER TABLE ... RENAME COLUMN ...