Module: PGTrunk::Operation::Inversion

Included in:
PGTrunk::Operation
Defined in:
lib/pg_trunk/core/operation/inversion.rb

Overview

Enable operations to be invertible

Instance Method Summary collapse

Instance Method Details

#invert!Object



56
57
58
59
60
# File 'lib/pg_trunk/core/operation/inversion.rb', line 56

def invert!
  invert&.tap do |i|
    i.valid? || raise(IrreversibleMigration.new(self, i, *i.error_messages))
  end
end

#irreversible!(option) ⇒ Object



63
64
65
66
67
68
# File 'lib/pg_trunk/core/operation/inversion.rb', line 63

def irreversible!(option)
  raise IrreversibleMigration.new(self, nil, <<~MSG.squish)
    The operation with the `#{option}` option cannot be reversed
      due to uncertainty of the previous state of the database.
  MSG
end