Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 3 PGError:错误:关系的列不存在_Ruby On Rails 3_Postgresql_Heroku_Migration - Fatal编程技术网

Ruby on rails 3 PGError:错误:关系的列不存在

Ruby on rails 3 PGError:错误:关系的列不存在,ruby-on-rails-3,postgresql,heroku,migration,Ruby On Rails 3,Postgresql,Heroku,Migration,我正在尝试将列“isGroup”的值更改为“public” 我创建了一个迁移: Post.connection.execute("update Posts set isgroup='public'") 但是,我得到以下错误: PGError:错误:关系“posts”的“isgroup”列不存在 不幸的是,我在运行connection.execute migration的同时运行了creating migration列。但是,Heroku上确实存在“isGroup”列,因此该列没有显示为“正在

我正在尝试将列“isGroup”的值更改为“public”

我创建了一个迁移:

Post.connection.execute("update Posts set isgroup='public'")
但是,我得到以下错误:

PGError:错误:关系“posts”的“isgroup”列不存在
不幸的是,我在运行connection.execute migration的同时运行了creating migration列。但是,Heroku上确实存在“isGroup”列,因此该列没有显示为“正在出现”,这很奇怪


有什么建议吗?

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

UPDATE posts SET "isGroup" = 'public'
请注意,PostgreSQL默认情况下会将所有未加引号的命名折叠为小写


为了避免这种混淆和引用的必要性,您可能需要使用
altertable将
isGroup
重命名为
isGroup
。。。重命名列…

您是否执行了
heroku运行rake db:migrate
?是的,错误是我在运行该命令时得到的…我不确定是否理解。。。那么命令是这样的?Post.connection.execute(“UPDATE posts SET“isGroup”='public')引号会导致语法错误,意外的tIDENTIFIER,expected')此外,该列肯定存在,因为我可以在rails_admin中更改单个值……此外,我还可以运行其他列更改……如果
SELECT*FROM posts LIMIT 1
显示
isGroup
column,那么它肯定存在。在这种情况下,您必须使用类似于
…execute(“UPDATE posts SET\“isGroup\”=“public”)
,或者将列重命名为
isGroup
,很高兴它对您有所帮助。这只是为了说明,在Postgres下,表和列应该始终使用小写名称——否则,你可能会得到像这样令人讨厌的惊喜!通过将所有列设置为小写来解决此问题