【发布时间】:2016-05-17 12:23:37
【问题描述】:
我已经运行了这个迁移:
class AddUniqueToLocationColumnName < ActiveRecord::Migration
def change
remove_index :locations, :name
add_index :locations, :name, unique: true
end
end
现在我正在尝试回滚,但它显示错误:
StandardError:发生错误,此迁移和所有后续迁移 取消:remove_index 只有在给定 :column 选项时才可逆。
如何将此迁移回滚到以前的版本?
【问题讨论】:
-
试试改成
remove_index :locations, column: :name -
我认为现在您必须使用 remove_index 方法从迁移中手动删除位置和名称的索引。为此,您可以创建新的迁移或更改为 up 和 down 状态。
-
非常感谢。有效。只需指定“列::名称”,而不仅仅是“名称”:)
标签: ruby-on-rails rollback rails-migrations