class MakeStateEventsPolymorphic < ActiveRecord::Migration
  def self.up
    rename_column :state_events, :order_id, :stateful_id
    add_column :state_events, :stateful_type, :string
    StateEvent.update_all(:stateful_type => 'Order')
  end

  def self.down
    rename_column :state_events, :stateful_id, :order_id
    remove_column :state_events, :stateful_type
  end
end

class MakeStateEventsPolymorphic < ActiveRecord::Migration
  # Legacy model support
  class StateEvent < ActiveRecord::Base

  end

  def self.up
    rename_column :state_events, :order_id, :stateful_id
    add_column :state_events, :stateful_type, :string
    StateEvent.update_all(:stateful_type => 'Order')
  end

  def self.down
    rename_column :state_events, :stateful_id, :order_id
    remove_column :state_events, :stateful_type
  end
end

Add a legacy model to make_states_events_polymorphic migration
Add a legacy model to make_states_events_polymorphic migration
