Compare commits

...

4 Commits

Author SHA1 Message Date
Andy Brett
7ad165ee3c remove migration 2021-02-10 18:45:58 +01:00
Pau Perez
3c8aa875a0 Update db/schema's timestamp after migration 2021-02-09 14:53:52 +01:00
Andy Brett
49c8cb82c7 use #destroy_all 2021-02-09 14:53:49 +01:00
Andy Brett
ef70bfdc3c remove variants with no product 2021-02-09 14:53:44 +01:00
2 changed files with 1 additions and 29 deletions

View File

@@ -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

View File

@@ -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"