class ActiveRecord::Migration

def reversible

end
end
revert { add_column :users, :full_name, :string }

end
end
u.save
dir.down { u.full_name = "#{u.first_name} #{u.last_name}" }
dir.up { u.first_name, u.last_name = u.full_name.split(' ') }
User.all.each do |u|
User.reset_column_information
reversible do |dir|

add_column :users, :last_name, :string
add_column :users, :first_name, :string
def change
class SplitNameMigration < ActiveRecord::Migration[7.0]

even when migrating down:
when the three columns 'first_name', 'last_name' and 'full_name' exist,
In the following example, the looping on users will always be done

The whole block will be called in the right order within the migration.
only in one given direction.
Call the methods +up+ and +down+ of the yielded object to run a block
Used to specify an operation that can be run in one direction or another.
def reversible
  helper = ReversibleBlockHelper.new(reverting?)
  execute_block { yield helper }
end