mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
migrate variants with nil unit_value
This commit is contained in:
13
db/migrate/20210202052337_migrate_variant_unit_values.rb
Normal file
13
db/migrate/20210202052337_migrate_variant_unit_values.rb
Normal file
@@ -0,0 +1,13 @@
|
||||
class MigrateVariantUnitValues < ActiveRecord::Migration
|
||||
def up
|
||||
Spree::Variant.all.select { |v|
|
||||
v.unit_value.nil? && v.product&.variant_unit == "items"
|
||||
}.each do |variant|
|
||||
variant.unit_value = 1
|
||||
variant.save
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user