[英]ActiveRecord::StatementInvalid PG::UndefinedColumn: ERROR
[英]ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR
尝试运行rake db:migrate
时出现错误:
ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR: column "plus_ids" of relation "comments" does not exist
我想在尝试从评论模型中删除属性plus_ids时确实做了一些时髦的事情。 我不确定发生了什么。
如果我执行rake db:reset
然后获取实时数据库,则所有这些都将再次在本地工作,但是如果我尝试执行rake db:migrate
它将再次引发错误。
如何正确去除plus_ids以便迁移?
编辑1:这是我添加(和删除)属性后的迁移文件:
class RemovePlusIdsFromComments < ActiveRecord::Migration
def change
remove_column :comments, :plus_ids, :integer
end
end
接着
class AddPlusIdsToComments < ActiveRecord::Migration
def change
add_column :comments, :plus_ids, :integer
end
end
它们在迁移列表中的顺序错误,不确定原因。
编辑2:我认为上/下有问题,如果我运行rake db:migrate:status
我会得到:
down 20150305203336 Remove plus ids from comments
down 20150305204404 Add plus ids to comments
可以解决吗?
答案是跑
rake db:migrate:up VERSION=20150305204404
在现场和本地,然后
rake db:migrate
再次上。 现在,实时数据库和本地数据库再次同步,并且迁移数据库不会引发任何错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.