Reversable Data Migration
Need to update a small amount of data in migration? But still want to make it reversable? Reversable Data Migration comes to the rescue.
Example usage
class RemoveStateFromProduct < ActiveRecord::Migration def self.up backup_data = [] Product.all.each do |product| backup_data << => product.id, :state => product.state end backup backup_data remove_column :products, :state end
def self.down add_column :products, :state, :string restore Permission end end