foodsoft/db/migrate/20090317175355_add_profit_to_orders.rb
Benjamin Meichsner da08365816 Fixed bug order.profit calculation.
Order.profit will also be saved, when order is closed.
2009-03-17 19:43:41 +01:00

13 lines
329 B
Ruby

class AddProfitToOrders < ActiveRecord::Migration
def self.up
add_column :orders, :foodcoop_result, :decimal, :precision => 8, :scale => 2
Order.closed.each do |order|
order.update_attribute(:foodcoop_result, order.profit)
end
end
def self.down
remove_column :orders, :foodcoop_result
end
end