Sha256: 4591d76add500fd92bb51aa0bb9b0139fd937afb1b69e1d0a7d4c9c755844a35

Contents?: true

Size: 434 Bytes

Versions: 4

Compression:

Stored size: 434 Bytes

Contents

# This migration comes from spree (originally 20141023005240)
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

4 entries across 4 versions & 3 rubygems

Version Path
spree_weight_calculator-0.1.0 test/dummy/db/migrate/20160723192619_add_counter_cache_from_spree_variants_to_spree_stock_items.spree.rb
spree_order_reporting-0.0.3 spec/dummy/db/migrate/20160708163215_add_counter_cache_from_spree_variants_to_spree_stock_items.spree.rb
sprangular-0.1.0 spec/dummy/db/migrate/20141203183797_add_counter_cache_from_spree_variants_to_spree_stock_items.spree.rb
sprangular-0.0.1 spec/dummy/db/migrate/20141203183797_add_counter_cache_from_spree_variants_to_spree_stock_items.spree.rb