forked from foodcoops/foodsoft
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrations for new
received
order state (s. foodcoops#779)
- Loading branch information
Showing
2 changed files
with
12 additions
and
1 deletion.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
db/migrate/20210205090257_introduce_received_state_in_orders.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters