Sha256: 618de3b2d0ce01027052a355a4e99e7ca513362684614eed14ab6231b9cc37e8

Contents?: true

Size: 536 Bytes

Versions: 4

Compression:

Stored size: 536 Bytes

Contents

# This migration comes from spree (originally 20101026184959)
class GenerateAnonymousUsers < ActiveRecord::Migration
  def 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 down
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
datashift_spree-0.3.0 spec/sandbox/db/migrate/20121023154427_generate_anonymous_users.spree.rb
datashift_spree-0.2.1 spec/sandbox/db/migrate/20121015151220_generate_anonymous_users.spree.rb
datashift_spree-0.2.0 spec/sandbox/db/migrate/20120925192788_generate_anonymous_users.spree.rb
datashift_spree-0.1.0 spec/sandbox/db/migrate/20120918081519_generate_anonymous_users.spree.rb