Created
August 17, 2013 03:26
-
-
Save Lordnibbler/6255113 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This migration comes from spree (originally 20130802022321) | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment