abh*_*hek 5 ruby-on-rails rollback rails-migrations
我已经运行了这个迁移:
class AddUniqueToLocationColumnName < ActiveRecord::Migration
def change
remove_index :locations, :name
add_index :locations, :name, unique: true
end
end
Run Code Online (Sandbox Code Playgroud)
现在我正在尝试回滚,但显示错误:
标准错误:发生错误,此迁移和所有后续迁移均已取消:remove_index 仅在给定 :column 选项时才可逆。
如何将此迁移回滚到我以前的版本?
尝试明确定义向上和向下:
class AddUniqueToLocationColumnName < ActiveRecord::Migration
def self.up
remove_index :locations, column: :name
add_index :locations, :name, unique: true
end
def self.down
remove_index :locations, column: :name # remove unique index
add_index :locations, :name # adds just index, without unique
end
end
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2692 次 |
| 最近记录: |