Sha256: 21b8bb6858661a4821e2fb141a3d770064b2c42bef28862edce62c27e4eae830
Contents?: true
Size: 759 Bytes
Versions: 21
Compression:
Stored size: 759 Bytes
Contents
class CreateDefaultStock < ActiveRecord::Migration[4.2] 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
21 entries across 21 versions & 1 rubygems