mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
add default to unit_value and weight
This commit is contained in:
@@ -10,6 +10,8 @@ class MigrateVariantUnitValues < ActiveRecord::Migration
|
||||
end
|
||||
change_column_null :spree_variants, :unit_value, false, 1
|
||||
change_column_null :spree_variants, :weight, false, 0.0
|
||||
change_column_default :spree_variants, :unit_value, 1
|
||||
change_column_default :spree_variants, :weight, 0.0
|
||||
execute "ALTER TABLE spree_variants ADD CONSTRAINT check_unit_value_for_nan CHECK (unit_value <> 'NaN')"
|
||||
execute "ALTER TABLE spree_variants ADD CONSTRAINT check_weight_for_nan CHECK (weight <> 'NaN')"
|
||||
end
|
||||
@@ -17,6 +19,8 @@ class MigrateVariantUnitValues < ActiveRecord::Migration
|
||||
def down
|
||||
change_column_null :spree_variants, :unit_value, true
|
||||
change_column_null :spree_variants, :weight, true
|
||||
change_column_default :spree_variants, :unit_value, nil
|
||||
change_column_default :spree_variants, :weight, nil
|
||||
execute "ALTER TABLE spree_variants DROP CONSTRAINT check_unit_value_for_nan"
|
||||
execute "ALTER TABLE spree_variants DROP CONSTRAINT check_weight_for_nan"
|
||||
end
|
||||
|
||||
@@ -1061,7 +1061,7 @@ ActiveRecord::Schema.define(version: 20210202052337) do
|
||||
|
||||
create_table "spree_variants", force: :cascade do |t|
|
||||
t.string "sku", limit: 255, default: "", null: false
|
||||
t.decimal "weight", precision: 8, scale: 2, null: false
|
||||
t.decimal "weight", precision: 8, scale: 2, default: 0.0, null: false
|
||||
t.decimal "height", precision: 8, scale: 2
|
||||
t.decimal "width", precision: 8, scale: 2
|
||||
t.decimal "depth", precision: 8, scale: 2
|
||||
@@ -1071,7 +1071,7 @@ ActiveRecord::Schema.define(version: 20210202052337) do
|
||||
t.decimal "cost_price", precision: 8, scale: 2
|
||||
t.integer "position"
|
||||
t.string "cost_currency", limit: 255
|
||||
t.float "unit_value", null: false
|
||||
t.float "unit_value", default: 1.0, null: false
|
||||
t.string "unit_description", limit: 255, default: ""
|
||||
t.string "display_name", limit: 255
|
||||
t.string "display_as", limit: 255
|
||||
|
||||
Reference in New Issue
Block a user