Class | Sequel::MigrationReverser |
In: |
lib/sequel/extensions/pg_enum.rb
lib/sequel/extensions/migration.rb |
Parent: | Object |
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 165 165: def reverse(&block) 166: begin 167: instance_eval(&block) 168: rescue 169: just_raise = true 170: end 171: if just_raise 172: Proc.new{raise Sequel::Error, 'irreversible migration method used, you may need to write your own down method'} 173: else 174: actions = @actions.reverse 175: Proc.new do 176: actions.each do |a| 177: if a.last.is_a?(Proc) 178: pr = a.pop 179: send(*a, &pr) 180: else 181: send(*a) 182: end 183: end 184: end 185: end 186: end