mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Simplify stock configuration in existing variant overrides
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
# This simplifies variant overrides to have only the following combinations:
|
||||
#
|
||||
# on_demand | count_on_hand
|
||||
# -----------+---------------
|
||||
# true | nil
|
||||
# false | set
|
||||
# nil | nil
|
||||
#
|
||||
# Refer to the table {here}[https://github.com/openfoodfoundation/openfoodnetwork/issues/3067] for
|
||||
# the effect of different variant and variant override stock configurations.
|
||||
#
|
||||
# Furthermore, this will allow all existing variant overrides to satisfy the newly added model
|
||||
# validation rules.
|
||||
class SimplifyVariantOverrideOnDemandAndCountOnHand < ActiveRecord::Migration
|
||||
def up
|
||||
# When on_demand is nil but count_on_hand is set, force limited stock.
|
||||
VariantOverride.where(on_demand: nil).where("count_on_hand IS NOT NULL")
|
||||
.update_all(on_demand: false)
|
||||
|
||||
# Clear count_on_hand if forcing on demand.
|
||||
VariantOverride.where(on_demand: true).update_all(count_on_hand: nil)
|
||||
|
||||
# When on_demand is false but count on hand is not specified, set this to use producer stock
|
||||
# settings.
|
||||
VariantOverride.where(on_demand: false, count_on_hand: nil).update_all(on_demand: nil)
|
||||
end
|
||||
|
||||
def down; end
|
||||
end
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20181123012635) do
|
||||
ActiveRecord::Schema.define(:version => 20181128054803) do
|
||||
|
||||
create_table "account_invoices", :force => true do |t|
|
||||
t.integer "user_id", :null => false
|
||||
|
||||
Reference in New Issue
Block a user