Add contacts.code constraints

This commit is contained in:
Artur Beljajev 2018-01-26 12:52:58 +02:00
parent 46f11155cb
commit 76782c72e3
3 changed files with 31 additions and 1 deletions

View file

@ -0,0 +1,13 @@
class AddUniqueConstraintToContactsCode < ActiveRecord::Migration
def up
execute <<-SQL
ALTER TABLE contacts ADD CONSTRAINT unique_contact_code UNIQUE (code)
SQL
end
def down
execute <<-SQL
ALTER TABLE contacts DROP CONSTRAINT unique_contact_code
SQL
end
end