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.

Methods

new   reverse  

Public Class methods

[Source]

     # File lib/sequel/extensions/migration.rb, line 165
165:     def initialize
166:       @actions = []
167:     end

Public Instance methods

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 172
172:     def reverse(&block)
173:       begin
174:         instance_exec(&block)
175:       rescue
176:         just_raise = true
177:       end
178:       if just_raise
179:         Proc.new{raise Sequel::Error, 'irreversible migration method used, you may need to write your own down method'}
180:       else
181:         actions = @actions.reverse
182:         Proc.new do
183:           actions.each do |a|
184:             pr = a.last.is_a?(Proc) ? a.pop : nil
185:             # Allow calling private methods as the reversing methods are private
186:             send(*a, &pr)
187:           end
188:         end
189:       end
190:     end

[Validate]