class GenerateAnonymousUsers < ActiveRecord::Migration
  def self.up
    User.reset_column_information
    Order.where(:user_id => nil).each do |order|
      user = User.anonymous!
      user.email ||= order.email
      order.user = user
      order.save!
    end
  end

  def self.down
  end
end
class GenerateAnonymousUsers < ActiveRecord::Migration
  def self.up
    Spree::User.table_name = "users"
    Spree::Order.table_name = "orders"

    Spree::User.reset_column_information
    Spree::Order.where(:user_id => nil).each do |order|
      user = Spree::User.anonymous!
      user.email ||= order.email
      order.user = user
      order.save!
    end

    Spree::User.table_name = "spree_users"
    Spree::Order.table_name = "spree_orders"
  end

  def self.down
  end
end
Add legacy table support to generate anonymous users migration
Add legacy table support to generate anonymous users migration
