迁移不回滚
migration not rolling back
我有 运行 这个迁移:
class AddUniqueToLocationColumnName < ActiveRecord::Migration
def change
remove_index :locations, :name
add_index :locations, :name, unique: true
end
end
现在我正在尝试回滚,但它显示错误:
StandardError: An error has occurred, this and all later migrations
canceled: remove_index is only reversible if given a :column option.
如何将此迁移回滚到我以前的版本?
尝试明确定义上下:
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
我有 运行 这个迁移:
class AddUniqueToLocationColumnName < ActiveRecord::Migration
def change
remove_index :locations, :name
add_index :locations, :name, unique: true
end
end
现在我正在尝试回滚,但它显示错误:
StandardError: An error has occurred, this and all later migrations canceled: remove_index is only reversible if given a :column option.
如何将此迁移回滚到我以前的版本?
尝试明确定义上下:
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