Files
openfoodnetwork/db/migrate/20120327000620_remove_shipped_state.rb
Andrew Spinks cd1938a74e spree install.
2012-03-27 11:06:49 +11:00

13 lines
429 B
Ruby

class RemoveShippedState < ActiveRecord::Migration
def up
execute "UPDATE orders SET state = 'complete' WHERE state = 'shipped'"
shipments = select_all "SELECT shipments.id FROM shipments WHERE order_id IN (SELECT orders.id FROM orders WHERE orders.state = 'shipped')"
shipments.each do |shipment|
execute "UPDATE shipments SET state='shipped' WHERE id = #{shipment[:id]}"
end
end
def down
end
end