我正在尝试将列"isGroup"的值更改为值"public".
I'm trying to change the value of a column "isGroup" to the value "public".
我创建了一个迁移:
Post.connection.execute("update Posts set isgroup='public'")但是,出现以下错误:
PGError: ERROR: column "isgroup" of relation "posts" does not exist不幸的是,我在连接和执行迁移的同时运行了创建迁移的列.但是,"isGroup"列确实存在于Heroku上,因此很奇怪该列未显示为出现.
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.
有什么建议吗?
推荐答案如果您确定列isGroup存在,则应使用以下方式对其进行引用:
If you are sure that column isGroup exists, then you should quote it like:
UPDATE posts SET "isGroup" = 'public'请注意,默认情况下,PostgreSQL会将所有未加引号的名称折叠成小写.
Note that PostgreSQL by default folds all unquoted named to lowercase.
为避免这种混淆和引用的必要性,您可能希望使用ALTER TABLE ... RENAME COLUMN ...将isGroup重命名为isgroup.
To avoid this confusion and necessity to quote, you might want to rename isGroup to isgroup using ALTER TABLE ... RENAME COLUMN ....
更多推荐
PGError:错误:关系列不存在
发布评论