mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 14:44:47 +02:00
Add uniquie constraints to domain_contacts & nameservers
This commit is contained in:
parent
c20be4e029
commit
68833e11ab
4 changed files with 65 additions and 12 deletions
|
@ -0,0 +1,36 @@
|
|||
class AddUniqueConstraintsToDomainObjects < ActiveRecord::Migration[6.0]
|
||||
def up
|
||||
|
||||
execute <<-SQL
|
||||
alter table domain_contacts
|
||||
drop constraint if exists uniq_contact_of_type_per_domain;
|
||||
SQL
|
||||
|
||||
execute <<-SQL
|
||||
alter table nameservers
|
||||
drop constraint if exists uniq_hostname_per_domain;
|
||||
SQL
|
||||
|
||||
execute <<-SQL
|
||||
alter table domain_contacts
|
||||
add constraint uniq_contact_of_type_per_domain unique (domain_id, type, contact_id);
|
||||
SQL
|
||||
|
||||
execute <<-SQL
|
||||
alter table nameservers
|
||||
add constraint uniq_hostname_per_domain unique (domain_id, hostname);
|
||||
SQL
|
||||
end
|
||||
|
||||
def down
|
||||
execute <<-SQL
|
||||
alter table domain_contacts
|
||||
drop constraint if exists uniq_contact_of_type_per_domain;
|
||||
SQL
|
||||
|
||||
execute <<-SQL
|
||||
alter table nameservers
|
||||
drop constraint if exists uniq_hostname_per_domain;
|
||||
SQL
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue