method
inverse_of
v7.1.3.4 -
Show latest stable
- Class:
ActiveRecord::Migration::CommandRecorder
inverse_of(command, args, &block)public
Returns the inverse of the given command. For example:
recorder.inverse_of(:rename_table, [:old, :new]) # => [:rename_table, [:new, :old]]
If the inverse of a command requires several commands, returns array of commands.
recorder.inverse_of(:remove_columns, [:some_table, :foo, :bar, type: :string]) # => [[:add_column, :some_table, :foo, :string], [:add_column, :some_table, :bar, :string]]
This method will raise an IrreversibleMigration exception if it cannot invert the command.