Migrations for new received order state (s. #779)

This commit is contained in:
Florian Lentsch 2021-02-05 11:42:50 +01:00 committed by Patrick Gansterer
parent 64113ab7f6
commit a96dbd563b
2 changed files with 12 additions and 1 deletions

View file

@ -0,0 +1,11 @@
class IntroduceReceivedStateInOrders < ActiveRecord::Migration[5.2]
def up
Order.where(state: 'finished').each do |order|
order.update_attribute(:state, 'received') if order.order_articles.where('units_received IS NOT NULL').any?
end
end
def down
Order.where(state: 'received').update_all(state: 'finished')
end
end