2021-02-05 11:42:50 +01:00
|
|
|
class IntroduceReceivedStateInOrders < ActiveRecord::Migration[5.2]
|
|
|
|
def up
|
|
|
|
Order.where(state: 'finished').each do |order|
|
2023-05-12 13:01:12 +02:00
|
|
|
order.update_attribute(:state, 'received') if order.order_articles.where.not(units_received: nil).any?
|
2021-02-05 11:42:50 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
Order.where(state: 'received').update_all(state: 'finished')
|
|
|
|
end
|
|
|
|
end
|