Sha256: cc902ef2b1a87a68f6fe6f4979e5ee78444000cba79e1807b85526e0402c67d8

Contents?: true

Size: 610 Bytes

Versions: 64

Compression:

Stored size: 610 Bytes

Contents

class MigrateOldPreferences < ActiveRecord::Migration
  def up
    migrate_preferences(Spree::Calculator)
    migrate_preferences(Spree::PaymentMethod)
    migrate_preferences(Spree::PromotionRule)
  end

  def down
  end

  private
  def migrate_preferences klass
    klass.reset_column_information
    klass.find_each do |record|
      store = Spree::Preferences::ScopedStore.new(record.class.name.underscore, record.id)
      record.defined_preferences.each do |key|
        value = store.fetch(key){}
        record.preferences[key] = value unless value.nil?
      end
      record.save!
    end
  end
end

Version data entries

64 entries across 64 versions & 2 rubygems

Version Path
spree_core-3.1.14 db/migrate/20140309023735_migrate_old_preferences.rb
spree_core-3.1.13 db/migrate/20140309023735_migrate_old_preferences.rb
spree_core-3.1.12 db/migrate/20140309023735_migrate_old_preferences.rb
spree_core-3.1.11 db/migrate/20140309023735_migrate_old_preferences.rb
spree_core-3.1.10 db/migrate/20140309023735_migrate_old_preferences.rb
spree_core-3.1.9 db/migrate/20140309023735_migrate_old_preferences.rb
spree_core-3.1.8 db/migrate/20140309023735_migrate_old_preferences.rb
spree_core-3.1.7 db/migrate/20140309023735_migrate_old_preferences.rb
spree_core-3.1.6 db/migrate/20140309023735_migrate_old_preferences.rb
spree_core-3.1.5 db/migrate/20140309023735_migrate_old_preferences.rb
spree_core-3.1.4 db/migrate/20140309023735_migrate_old_preferences.rb
spree_core-3.1.3 db/migrate/20140309023735_migrate_old_preferences.rb
spree_core-3.1.2 db/migrate/20140309023735_migrate_old_preferences.rb
spree_core-3.0.10 db/migrate/20140309023735_migrate_old_preferences.rb
spree_core-3.1.1 db/migrate/20140309023735_migrate_old_preferences.rb
spree_core-3.1.0 db/migrate/20140309023735_migrate_old_preferences.rb
spree_core-3.1.0.rc4 db/migrate/20140309023735_migrate_old_preferences.rb
spree_core-3.0.9 db/migrate/20140309023735_migrate_old_preferences.rb
spree_core-3.1.0.rc3 db/migrate/20140309023735_migrate_old_preferences.rb
spree_core-3.1.0.rc2 db/migrate/20140309023735_migrate_old_preferences.rb