我在 heroku 中托管了一个 Rails 应用程序。我有一个带有内容列的问题表。内容列包含问题的词。因此,例如,如果您查询。 Question.first.content,你会得到“你好,你好吗?”。我总共有8个问题。我想手动进入数据库并更改这些问题。
我尝试使用以下命令在 heroku 上运行终端:
heroku pg:psql
并且我使用这个查询来更改记录的内容列
UPDATE Questions
SET content="What country does this story orginate? (Japan)"
但是我收到这个错误信息:
ERROR: column "What country does this story orginate? (Japan)" does not exist
LINE 2: SET content="What country does this story orginate? (Japan)"...
更改问题内容栏的正确查询是什么?
最佳答案
事实证明我可以heroku run console
。进入控制台后,我可以进行事件记录查询,例如 Question.find(1).update_attributes(:content=>'how are you?')
并进行更新。无论出于何种原因,heroku run rails console
都没有使用事件记录查询更新记录,只是返回查询成功。
关于postgresql - 如何手动更改heroku数据库中的记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30279202/