mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-12 18:36:49 +00:00
Compare commits
4 Commits
RachL-patc
...
v3.5.8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ad165ee3c | ||
|
|
3c8aa875a0 | ||
|
|
49c8cb82c7 | ||
|
|
ef70bfdc3c |
@@ -1,27 +0,0 @@
|
||||
class MigrateVariantUnitValues < ActiveRecord::Migration
|
||||
def up
|
||||
Spree::Variant.where(unit_value: [nil, Float::NAN]).find_each do |variant|
|
||||
variant.unit_value = 1
|
||||
variant.save
|
||||
end
|
||||
Spree::Variant.where(weight: [nil, Float::NAN]).find_each do |variant|
|
||||
variant.weight = 0
|
||||
variant.save
|
||||
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
|
||||
|
||||
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
|
||||
end
|
||||
@@ -11,8 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
|
||||
ActiveRecord::Schema.define(version: 20210203215049) do
|
||||
ActiveRecord::Schema.define(version: 20210203214304) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
Reference in New Issue
Block a user