回滚失败的Rails迁移
如何回滚失败的Rails迁移?我希望这rake db:rollback会撤消失败的迁移,但是不,它会回滚以前的迁移(失败的迁移减去一个)。而且rake db:migrate:down VERSION=myfailedmigration也不起作用。我已经遇到过几次了,这非常令人沮丧。这是我做的一个简单的测试,可以重复该问题: class SimpleTest < ActiveRecord::Migration def self.up add_column :assets, :test, :integer # the following syntax error will cause the migration to fail add_column :asset, :test2, :integer end def self.down remove_column :assets, :test remove_column :assets, :test2 end end 结果: == SimpleTest:迁移============================================= ======== -add_column(:assets,:test,:integer) -> 0.0932秒 -add_column(:asset,:error) 耙子流产了! 发生错误,所有后来的迁移都被取消: …