Sha256: d309a314e97fde70591bffb85616aca031a5372f16790fbab4501745f6caa80f

Contents?: true

Size: 372 Bytes

Versions: 49

Compression:

Stored size: 372 Bytes

Contents

class AddCounterCacheFromSpreeVariantsToSpreeStockItems < ActiveRecord::Migration
  def up
    add_column :spree_variants, :stock_items_count, :integer, default: 0, null: false

    Spree::Variant.find_each do |variant|
      Spree::Variant.reset_counters(variant.id, :stock_items)
    end
  end

  def down
    remove_column :spree_variants, :stock_items_count
  end
end

Version data entries

49 entries across 49 versions & 2 rubygems

Version Path
spree_core-3.0.0.rc4 db/migrate/20141023005240_add_counter_cache_from_spree_variants_to_spree_stock_items.rb
spree_core-3.0.0.rc3 db/migrate/20141023005240_add_counter_cache_from_spree_variants_to_spree_stock_items.rb
spree_core-2.4.4 db/migrate/20141023005240_add_counter_cache_from_spree_variants_to_spree_stock_items.rb
spree_core-3.0.0.rc1 db/migrate/20141023005240_add_counter_cache_from_spree_variants_to_spree_stock_items.rb
spree_core-2.4.3 db/migrate/20141023005240_add_counter_cache_from_spree_variants_to_spree_stock_items.rb
spree_core-2.4.2 db/migrate/20141023005240_add_counter_cache_from_spree_variants_to_spree_stock_items.rb
spree_core-2.4.1 db/migrate/20141023005240_add_counter_cache_from_spree_variants_to_spree_stock_items.rb
spree_core-2.4.0 db/migrate/20141023005240_add_counter_cache_from_spree_variants_to_spree_stock_items.rb
spree_core-2.4.0.rc3 db/migrate/20141023005240_add_counter_cache_from_spree_variants_to_spree_stock_items.rb