Method: ActiveRecord::Migration::CommandRecorder#revert

Defined in:
activerecord/lib/active_record/migration/command_recorder.rb

#revertObject

While executing the given block, the recorded will be in reverting mode. All commands recorded will end up being recorded reverted and in reverse order. For example:

recorder.revert{ recorder.record(:rename_table, [:old, :new]) }
# same effect as recorder.record(:rename_table, [:new, :old])


76
77
78
79
80
81
82
83
84
# File 'activerecord/lib/active_record/migration/command_recorder.rb', line 76

def revert
  @reverting = !@reverting
  previous = @commands
  @commands = []
  yield
ensure
  @commands = previous.concat(@commands.reverse)
  @reverting = !@reverting
end