sideplace_app/db/migrate/20150706151716_add_parts_to_orders.rb

13 lines
289 B
Ruby

class AddPartsToOrders < ActiveRecord::Migration
def change
add_column :orders, :nbr_parts, :integer
Order.all.each do |order|
if !order.nbr_parts?
order.nbr_parts = order.credit_product.parts
order.save(:validate => false)
end
end
end
end