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 152
    152:     def initialize
    153:       @actions = []
    154:     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 159
    159:     def reverse(&block)
    160:       begin
    161:         instance_eval(&block)
    162:       rescue
    163:         just_raise = true
    164:       end
    165:       if just_raise
    166:         Proc.new{raise Sequel::Error, 'irreversible migration method used, you may need to write your own down method'}
    167:       else
    168:         actions = @actions.reverse
    169:         Proc.new do
    170:           actions.each do |a|
    171:             if a.last.is_a?(Proc)
    172:               pr = a.pop
    173:               send(*a, &pr)
    174:             else
    175:               send(*a)
    176:             end
    177:           end
    178:         end
    179:       end
    180:     end

[Validate]