Sha256: d01b1b574404db29b733396a10b738d0c8802dc0e7a034bdec304f28579702da

Contents?: true

Size: 456 Bytes

Versions: 3

Compression:

Stored size: 456 Bytes

Contents

class MigrateTaxCategoriesToLineItems < ActiveRecord::Migration
  def change
    Spree::LineItem.includes(:variant => { :product => :tax_category }).find_in_batches do |line_items|
      line_items.each do |line_item|
        next if line_item.variant.nil?
        next if line_item.variant.product.nil?
        next if line_item.product.nil?
        line_item.update_column(:tax_category_id, line_item.product.tax_category_id)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
spree_core-2.2.0 db/migrate/20130802022321_migrate_tax_categories_to_line_items.rb
spree_core-2.1.5 db/migrate/20130802022321_migrate_tax_categories_to_line_items.rb
spree_core-2.1.4 db/migrate/20130802022321_migrate_tax_categories_to_line_items.rb