Skip to content

Commit

Permalink
Migrations for new received order state (s. foodcoops#779)
Browse files Browse the repository at this point in the history
  • Loading branch information
lentschi committed Feb 5, 2021
1 parent 6b98fb2 commit 674f0f7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions db/migrate/20210205090257_introduce_received_state_in_orders.rb
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
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2018_12_05_010000) do
ActiveRecord::Schema.define(version: 2021_02_05_090257) do

create_table "article_categories", force: :cascade do |t|
t.string "name", default: "", null: false
Expand Down

0 comments on commit 674f0f7

Please sign in to comment.