Sha256: 83a8385f47eaef52755008177bd1a13ec0de3ad51835c25aebc10795f6432c68
Contents?: true
Size: 754 Bytes
Versions: 11
Compression:
Stored size: 754 Bytes
Contents
class CreateDefaultStock < ActiveRecord::Migration class Variant < ActiveRecord::Base self.table_name = 'spree_variants' end class StockLocation < ActiveRecord::Base self.table_name = 'spree_stock_locations' end class StockItem < ActiveRecord::Base self.table_name = 'spree_stock_items' end def up unless column_exists? :spree_stock_locations, :default add_column :spree_stock_locations, :default, :boolean, null: false, default: false end location = StockLocation.create!(name: 'default') Spree::Variant.find_each do |variant| StockItem.create!(stock_location: location, variant: variant, count_on_hand: variant.count_on_hand) end remove_column :spree_variants, :count_on_hand end end
Version data entries
11 entries across 11 versions & 1 rubygems