mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
add database constraint for variant unit_value
This commit is contained in:
10
db/migrate/20210414171109_add_unit_value_constraint.rb
Normal file
10
db/migrate/20210414171109_add_unit_value_constraint.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
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
|
||||
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20210326094519) do
|
||||
ActiveRecord::Schema.define(version: 20210414171109) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
Reference in New Issue
Block a user