Class | Sequel::MigrationReverser
In: | lib/sequel/extensions/migration.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.

### Methods

new reverse

### Public Class methods

new()

[Source]

         # File lib/sequel/extensions/migration.rb, line 124
    124:     def initialize
    125:       @actions = []
    126:     end

### Public Instance methods

reverse(&block)

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.

[Source]

         # File lib/sequel/extensions/migration.rb, line 131
    131:     def reverse(&block)
    132:       begin
    133:         instance_eval(&block)
    134:       rescue
    135:         just_raise = true
    136:       end
    137:       if just_raise
    138:         Proc.new{raise Sequel::Error, 'irreversible migration method used, you may need to write your own down method'}
    139:       else
    140:         actions = @actions.reverse
    141:         Proc.new do
    142:           actions.each do |a|
    143:             if a.last.is_a?(Proc)
    144:               pr = a.pop
    145:               send(*a, &pr)
    146:             else
    147:               send(*a)
    148:             end
    149:           end
    150:         end
    151:       end
    152:     end

[Validate]