mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-02 21:57:17 +00:00
VariantOverrides require hub and variant
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
class VariantOverride < ActiveRecord::Base
|
||||
belongs_to :variant, class_name: 'Spree::Variant'
|
||||
belongs_to :hub, class_name: 'Enterprise'
|
||||
belongs_to :variant, class_name: 'Spree::Variant'
|
||||
|
||||
validates_presence_of :hub_id, :variant_id
|
||||
|
||||
scope :for_hubs, lambda { |hubs|
|
||||
where(hub_id: hubs)
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
class AddNotNullToVariantOverrideRelations < ActiveRecord::Migration
|
||||
def change
|
||||
change_column :variant_overrides, :hub_id, :integer, null: false
|
||||
change_column :variant_overrides, :variant_id, :integer, null: false
|
||||
end
|
||||
end
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20141113053004) do
|
||||
ActiveRecord::Schema.define(:version => 20141210233407) do
|
||||
|
||||
create_table "adjustment_metadata", :force => true do |t|
|
||||
t.integer "adjustment_id"
|
||||
@@ -1034,8 +1034,8 @@ ActiveRecord::Schema.define(:version => 20141113053004) do
|
||||
end
|
||||
|
||||
create_table "variant_overrides", :force => true do |t|
|
||||
t.integer "variant_id"
|
||||
t.integer "hub_id"
|
||||
t.integer "variant_id", :null => false
|
||||
t.integer "hub_id", :null => false
|
||||
t.decimal "price", :precision => 8, :scale => 2
|
||||
t.integer "count_on_hand"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user