Files
openfoodnetwork/db/migrate/20210414171109_add_unit_value_constraint.rb
2021-04-15 09:43:57 -07:00

11 lines
350 B
Ruby

class AddUnitValueConstraint < ActiveRecord::Migration[5.0]
def up
execute "UPDATE spree_variants SET unit_value = 1 WHERE unit_value <= 0"
execute "ALTER TABLE spree_variants ADD CONSTRAINT positive_unit_value CHECK (unit_value > 0)"
end
def down
execute "ALTER TABLE spree_variants DROP CONSTRAINT positive_unit_value"
end
end