mirror of
https://github.com/google/nomulus
synced 2026-02-07 05:21:15 +00:00
Add missing foreign key constraints (#845)
* Add missing foreign key constraints * Fix failed unit tests
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -69,3 +69,4 @@ V68__make_reserved_list_nullable_in_registry.sql
|
||||
V69__change_primary_key_and_add_history_table_for_delegation_signer.sql
|
||||
V70__signed_mark_revocation_list.sql
|
||||
V71__create_kms_secret.sql
|
||||
V72__add_missing_foreign_keys.sql
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
-- Copyright 2020 The Nomulus Authors. All Rights Reserved.
|
||||
--
|
||||
-- Licensed under the Apache License, Version 2.0 (the "License");
|
||||
-- you may not use this file except in compliance with the License.
|
||||
-- You may obtain a copy of the License at
|
||||
--
|
||||
-- http://www.apache.org/licenses/LICENSE-2.0
|
||||
--
|
||||
-- Unless required by applicable law or agreed to in writing, software
|
||||
-- distributed under the License is distributed on an "AS IS" BASIS,
|
||||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
-- See the License for the specific language governing permissions and
|
||||
-- limitations under the License.
|
||||
|
||||
alter table if exists "RegistrarPoc"
|
||||
add constraint fk_registrar_poc_registrar_id
|
||||
foreign key (registrar_id)
|
||||
references "Registrar";
|
||||
|
||||
alter table if exists "Spec11ThreatMatch"
|
||||
add constraint fk_spec11_threat_match_domain_repo_id
|
||||
foreign key (domain_repo_id)
|
||||
references "Domain";
|
||||
|
||||
alter table if exists "Spec11ThreatMatch"
|
||||
add constraint fk_spec11_threat_match_registrar_id
|
||||
foreign key (registrar_id)
|
||||
references "Registrar";
|
||||
|
||||
alter table if exists "Spec11ThreatMatch"
|
||||
add constraint fk_spec11_threat_match_tld
|
||||
foreign key (tld)
|
||||
references "Tld";
|
||||
|
||||
alter table if exists "BillingEvent"
|
||||
add constraint fk_billing_event_domain_history
|
||||
foreign key (domain_repo_id, domain_history_revision_id)
|
||||
references "DomainHistory";
|
||||
|
||||
alter table "BillingEvent" rename allocation_token_id to allocation_token;
|
||||
|
||||
alter table if exists "BillingEvent"
|
||||
add constraint fk_billing_event_allocation_token
|
||||
foreign key (allocation_token)
|
||||
references "AllocationToken";
|
||||
|
||||
alter table if exists "BillingRecurrence"
|
||||
add constraint fk_billing_recurrence_domain_history
|
||||
foreign key (domain_repo_id, domain_history_revision_id)
|
||||
references "DomainHistory";
|
||||
|
||||
alter table if exists "BillingCancellation"
|
||||
add constraint fk_billing_cancellation_domain_history
|
||||
foreign key (domain_repo_id, domain_history_revision_id)
|
||||
references "DomainHistory";
|
||||
|
||||
alter table if exists "Contact"
|
||||
add constraint fk_contact_transfer_gaining_poll_message_id
|
||||
foreign key (transfer_gaining_poll_message_id)
|
||||
references "PollMessage";
|
||||
|
||||
alter table if exists "Contact"
|
||||
add constraint fk_contact_transfer_losing_poll_message_id
|
||||
foreign key (transfer_losing_poll_message_id)
|
||||
references "PollMessage";
|
||||
|
||||
alter table if exists "Domain"
|
||||
add constraint fk_domain_tld
|
||||
foreign key (tld)
|
||||
references "Tld";
|
||||
|
||||
alter table if exists "DomainTransactionRecord"
|
||||
add constraint fk_domain_transaction_record_tld
|
||||
foreign key (tld)
|
||||
references "Tld";
|
||||
|
||||
alter table if exists "GracePeriod"
|
||||
add constraint fk_grace_period_registrar_id
|
||||
foreign key (registrar_id)
|
||||
references "Registrar";
|
||||
|
||||
alter table if exists "Host"
|
||||
add constraint fk_host_creation_registrar_id
|
||||
foreign key (creation_registrar_id)
|
||||
references "Registrar";
|
||||
|
||||
alter table if exists "Host"
|
||||
add constraint fk_host_current_sponsor_registrar_id
|
||||
foreign key (current_sponsor_registrar_id)
|
||||
references "Registrar";
|
||||
|
||||
alter table if exists "Host"
|
||||
add constraint fk_host_last_epp_update_registrar_id
|
||||
foreign key (last_epp_update_registrar_id)
|
||||
references "Registrar";
|
||||
@@ -52,7 +52,7 @@
|
||||
flags text[],
|
||||
reason text not null,
|
||||
domain_name text not null,
|
||||
allocation_token_id text,
|
||||
allocation_token text,
|
||||
billing_time timestamptz,
|
||||
cancellation_matching_billing_recurrence_id int8,
|
||||
cost_amount numeric(19, 2),
|
||||
@@ -705,7 +705,7 @@ create index IDXqspv57gj2led8ly42fq01t7m7 on "BillingEvent" (registrar_id);
|
||||
create index IDX5yfbr88439pxw0v3j86c74fp8 on "BillingEvent" (event_time);
|
||||
create index IDX6py6ocrab0ivr76srcd2okpnq on "BillingEvent" (billing_time);
|
||||
create index IDXplxf9v56p0wg8ws6qsvd082hk on "BillingEvent" (synthetic_creation_time);
|
||||
create index IDXhmv411mdqo5ibn4vy7ykxpmlv on "BillingEvent" (allocation_token_id);
|
||||
create index IDXcesda59ssop44kklytpb292hn on "BillingEvent" (allocation_token);
|
||||
create index IDXd3gxhkh0jk694pjvh9pyn7wjc on "BillingRecurrence" (registrar_id);
|
||||
create index IDX6syykou4nkc7hqa5p8r92cpch on "BillingRecurrence" (event_time);
|
||||
create index IDXp3usbtvk0v1m14i5tdp4xnxgc on "BillingRecurrence" (recurrence_end_time);
|
||||
|
||||
@@ -86,7 +86,7 @@ CREATE TABLE public."BillingEvent" (
|
||||
flags text[],
|
||||
reason text NOT NULL,
|
||||
domain_name text NOT NULL,
|
||||
allocation_token_id text,
|
||||
allocation_token text,
|
||||
billing_time timestamp with time zone,
|
||||
cancellation_matching_billing_recurrence_id bigint,
|
||||
cost_amount numeric(19,2),
|
||||
@@ -1514,7 +1514,7 @@ CREATE INDEX idxhlqqd5uy98cjyos72d81x9j95 ON public."DelegationSignerData" USING
|
||||
-- Name: idxhmv411mdqo5ibn4vy7ykxpmlv; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX idxhmv411mdqo5ibn4vy7ykxpmlv ON public."BillingEvent" USING btree (allocation_token_id);
|
||||
CREATE INDEX idxhmv411mdqo5ibn4vy7ykxpmlv ON public."BillingEvent" USING btree (allocation_token);
|
||||
|
||||
|
||||
--
|
||||
@@ -1786,6 +1786,14 @@ ALTER TABLE ONLY public."BillingCancellation"
|
||||
ADD CONSTRAINT fk_billing_cancellation_billing_recurrence_id FOREIGN KEY (billing_recurrence_id) REFERENCES public."BillingRecurrence"(billing_recurrence_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: BillingCancellation fk_billing_cancellation_domain_history; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public."BillingCancellation"
|
||||
ADD CONSTRAINT fk_billing_cancellation_domain_history FOREIGN KEY (domain_repo_id, domain_history_revision_id) REFERENCES public."DomainHistory"(domain_repo_id, history_revision_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: BillingCancellation fk_billing_cancellation_registrar_id; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
@@ -1794,6 +1802,14 @@ ALTER TABLE ONLY public."BillingCancellation"
|
||||
ADD CONSTRAINT fk_billing_cancellation_registrar_id FOREIGN KEY (registrar_id) REFERENCES public."Registrar"(registrar_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: BillingEvent fk_billing_event_allocation_token; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public."BillingEvent"
|
||||
ADD CONSTRAINT fk_billing_event_allocation_token FOREIGN KEY (allocation_token) REFERENCES public."AllocationToken"(token);
|
||||
|
||||
|
||||
--
|
||||
-- Name: BillingEvent fk_billing_event_cancellation_matching_billing_recurrence_id; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
@@ -1802,6 +1818,14 @@ ALTER TABLE ONLY public."BillingEvent"
|
||||
ADD CONSTRAINT fk_billing_event_cancellation_matching_billing_recurrence_id FOREIGN KEY (cancellation_matching_billing_recurrence_id) REFERENCES public."BillingRecurrence"(billing_recurrence_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: BillingEvent fk_billing_event_domain_history; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public."BillingEvent"
|
||||
ADD CONSTRAINT fk_billing_event_domain_history FOREIGN KEY (domain_repo_id, domain_history_revision_id) REFERENCES public."DomainHistory"(domain_repo_id, history_revision_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: BillingEvent fk_billing_event_registrar_id; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
@@ -1810,6 +1834,14 @@ ALTER TABLE ONLY public."BillingEvent"
|
||||
ADD CONSTRAINT fk_billing_event_registrar_id FOREIGN KEY (registrar_id) REFERENCES public."Registrar"(registrar_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: BillingRecurrence fk_billing_recurrence_domain_history; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public."BillingRecurrence"
|
||||
ADD CONSTRAINT fk_billing_recurrence_domain_history FOREIGN KEY (domain_repo_id, domain_history_revision_id) REFERENCES public."DomainHistory"(domain_repo_id, history_revision_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: BillingRecurrence fk_billing_recurrence_registrar_id; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
@@ -1834,6 +1866,14 @@ ALTER TABLE ONLY public."ContactHistory"
|
||||
ADD CONSTRAINT fk_contact_history_registrar_id FOREIGN KEY (history_registrar_id) REFERENCES public."Registrar"(registrar_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: Contact fk_contact_transfer_gaining_poll_message_id; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public."Contact"
|
||||
ADD CONSTRAINT fk_contact_transfer_gaining_poll_message_id FOREIGN KEY (transfer_gaining_poll_message_id) REFERENCES public."PollMessage"(poll_message_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: Contact fk_contact_transfer_gaining_registrar_id; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
@@ -1842,6 +1882,14 @@ ALTER TABLE ONLY public."Contact"
|
||||
ADD CONSTRAINT fk_contact_transfer_gaining_registrar_id FOREIGN KEY (transfer_gaining_registrar_id) REFERENCES public."Registrar"(registrar_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: Contact fk_contact_transfer_losing_poll_message_id; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public."Contact"
|
||||
ADD CONSTRAINT fk_contact_transfer_losing_poll_message_id FOREIGN KEY (transfer_losing_poll_message_id) REFERENCES public."PollMessage"(poll_message_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: Contact fk_contact_transfer_losing_registrar_id; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
@@ -1922,6 +1970,22 @@ ALTER TABLE ONLY public."Domain"
|
||||
ADD CONSTRAINT fk_domain_tech_contact FOREIGN KEY (tech_contact) REFERENCES public."Contact"(repo_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: Domain fk_domain_tld; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public."Domain"
|
||||
ADD CONSTRAINT fk_domain_tld FOREIGN KEY (tld) REFERENCES public."Tld"(tld_name);
|
||||
|
||||
|
||||
--
|
||||
-- Name: DomainTransactionRecord fk_domain_transaction_record_tld; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public."DomainTransactionRecord"
|
||||
ADD CONSTRAINT fk_domain_transaction_record_tld FOREIGN KEY (tld) REFERENCES public."Tld"(tld_name);
|
||||
|
||||
|
||||
--
|
||||
-- Name: Domain fk_domain_transfer_billing_cancellation_id; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
@@ -1994,6 +2058,38 @@ ALTER TABLE ONLY public."GracePeriod"
|
||||
ADD CONSTRAINT fk_grace_period_domain_repo_id FOREIGN KEY (domain_repo_id) REFERENCES public."Domain"(repo_id) DEFERRABLE INITIALLY DEFERRED;
|
||||
|
||||
|
||||
--
|
||||
-- Name: GracePeriod fk_grace_period_registrar_id; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public."GracePeriod"
|
||||
ADD CONSTRAINT fk_grace_period_registrar_id FOREIGN KEY (registrar_id) REFERENCES public."Registrar"(registrar_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: Host fk_host_creation_registrar_id; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public."Host"
|
||||
ADD CONSTRAINT fk_host_creation_registrar_id FOREIGN KEY (creation_registrar_id) REFERENCES public."Registrar"(registrar_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: Host fk_host_current_sponsor_registrar_id; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public."Host"
|
||||
ADD CONSTRAINT fk_host_current_sponsor_registrar_id FOREIGN KEY (current_sponsor_registrar_id) REFERENCES public."Registrar"(registrar_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: Host fk_host_last_epp_update_registrar_id; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public."Host"
|
||||
ADD CONSTRAINT fk_host_last_epp_update_registrar_id FOREIGN KEY (last_epp_update_registrar_id) REFERENCES public."Registrar"(registrar_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: Host fk_host_superordinate_domain; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
@@ -2082,6 +2178,38 @@ ALTER TABLE ONLY public."PollMessage"
|
||||
ADD CONSTRAINT fk_poll_message_transfer_response_losing_registrar_id FOREIGN KEY (transfer_response_losing_registrar_id) REFERENCES public."Registrar"(registrar_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: RegistrarPoc fk_registrar_poc_registrar_id; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public."RegistrarPoc"
|
||||
ADD CONSTRAINT fk_registrar_poc_registrar_id FOREIGN KEY (registrar_id) REFERENCES public."Registrar"(registrar_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: Spec11ThreatMatch fk_spec11_threat_match_domain_repo_id; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public."Spec11ThreatMatch"
|
||||
ADD CONSTRAINT fk_spec11_threat_match_domain_repo_id FOREIGN KEY (domain_repo_id) REFERENCES public."Domain"(repo_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: Spec11ThreatMatch fk_spec11_threat_match_registrar_id; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public."Spec11ThreatMatch"
|
||||
ADD CONSTRAINT fk_spec11_threat_match_registrar_id FOREIGN KEY (registrar_id) REFERENCES public."Registrar"(registrar_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: Spec11ThreatMatch fk_spec11_threat_match_tld; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public."Spec11ThreatMatch"
|
||||
ADD CONSTRAINT fk_spec11_threat_match_tld FOREIGN KEY (tld) REFERENCES public."Tld"(tld_name);
|
||||
|
||||
|
||||
--
|
||||
-- Name: DomainHistoryHost fka9woh3hu8gx5x0vly6bai327n; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
Reference in New Issue
Block a user