From b20e31f3c8f87bda63b5fb2b47af110d29d6354e Mon Sep 17 00:00:00 2001 From: Artur Beljajev Date: Tue, 6 Jun 2017 17:17:16 +0300 Subject: [PATCH] Add registrar and registrant foreign key constraints to domains #480 --- ...1_add_foreign_key_constraints_to_domains.rb | 6 ++++++ db/structure.sql | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 db/migrate/20170606133501_add_foreign_key_constraints_to_domains.rb diff --git a/db/migrate/20170606133501_add_foreign_key_constraints_to_domains.rb b/db/migrate/20170606133501_add_foreign_key_constraints_to_domains.rb new file mode 100644 index 000000000..5494d77ab --- /dev/null +++ b/db/migrate/20170606133501_add_foreign_key_constraints_to_domains.rb @@ -0,0 +1,6 @@ +class AddForeignKeyConstraintsToDomains < ActiveRecord::Migration + def change + add_foreign_key :domains, :registrars, name: 'domains_registrar_id_fk' + add_foreign_key :domains, :contacts, column: :registrant_id, name: 'domains_registrant_id_fk' + end +end diff --git a/db/structure.sql b/db/structure.sql index a124ca56f..2e0ee39dd 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -4646,6 +4646,22 @@ CREATE UNIQUE INDEX unique_data_migrations ON data_migrations USING btree (versi CREATE UNIQUE INDEX unique_schema_migrations ON schema_migrations USING btree (version); +-- +-- Name: domains_registrant_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY domains + ADD CONSTRAINT domains_registrant_id_fk FOREIGN KEY (registrant_id) REFERENCES contacts(id); + + +-- +-- Name: domains_registrar_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY domains + ADD CONSTRAINT domains_registrar_id_fk FOREIGN KEY (registrar_id) REFERENCES registrars(id); + + -- -- Name: fk_rails_78c376257f; Type: FK CONSTRAINT; Schema: public; Owner: - -- @@ -5136,3 +5152,5 @@ INSERT INTO schema_migrations (version) VALUES ('20170424115801'); INSERT INTO schema_migrations (version) VALUES ('20170509215614'); +INSERT INTO schema_migrations (version) VALUES ('20170606133501'); +