Class | Sequel::MigrationReverser |
In: |
lib/sequel/extensions/migration.rb
lib/sequel/extensions/pg_enum.rb |
Parent: | Sequel::BasicObject |
Handles the reversing of reversible migrations. Basically records supported methods calls, translates them to reversed calls, and returns them in reverse order.
Reverse the actions for the given block. Takes the block given and returns a new block that reverses the actions taken by the given block.
# File lib/sequel/extensions/migration.rb, line 171 171: def reverse(&block) 172: begin 173: instance_eval(&block) 174: rescue 175: just_raise = true 176: end 177: if just_raise 178: Proc.new{raise Sequel::Error, 'irreversible migration method used, you may need to write your own down method'} 179: else 180: actions = @actions.reverse 181: Proc.new do 182: actions.each do |a| 183: if a.last.is_a?(Proc) 184: pr = a.pop 185: send(*a, &pr) 186: else 187: send(*a) 188: end 189: end 190: end 191: end 192: end