Skip to content

Commit c33f0dc

Browse files
authored
Remove all foreign key constraints pointing to contact tables (#2857)
This affects FKs pointing to both Contact and ContactHistory. This is in preparation to us deleting all rows in those two tables, and then subsequently removing all application logic having to do with contacts entirely.
1 parent 969353d commit c33f0dc

File tree

7 files changed

+437
-868
lines changed

7 files changed

+437
-868
lines changed

db/src/main/resources/sql/er_diagram/brief_er_diagram.html

Lines changed: 191 additions & 411 deletions
Large diffs are not rendered by default.

db/src/main/resources/sql/er_diagram/full_er_diagram.html

Lines changed: 191 additions & 401 deletions
Large diffs are not rendered by default.

db/src/main/resources/sql/flyway.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,6 @@ V211__domainhistoryhost_history_revision_id_hash.sql
212212
V212__domaindsdatahistory_history_revision_id_hash.sql
213213
V213__graceperiodhistory_history_revision_id_hash.sql
214214
V214__domain_unique_domain_name_active.sql
215+
V215__drop_contact_fks_contacthistory.sql
216+
V216__drop_contact_fks_domain.sql
217+
V217__drop_contact_fks_pollmessage.sql
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-- Copyright 2025 The Nomulus Authors. All Rights Reserved.
2+
--
3+
-- Licensed under the Apache License, Version 2.0 (the "License");
4+
-- you may not use this file except in compliance with the License.
5+
-- You may obtain a copy of the License at
6+
--
7+
-- http://www.apache.org/licenses/LICENSE-2.0
8+
--
9+
-- Unless required by applicable law or agreed to in writing, software
10+
-- distributed under the License is distributed on an "AS IS" BASIS,
11+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
-- See the License for the specific language governing permissions and
13+
-- limitations under the License.
14+
15+
ALTER TABLE ONLY "ContactHistory"
16+
DROP CONSTRAINT fk_contact_history_contact_repo_id;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
-- Copyright 2025 The Nomulus Authors. All Rights Reserved.
2+
--
3+
-- Licensed under the Apache License, Version 2.0 (the "License");
4+
-- you may not use this file except in compliance with the License.
5+
-- You may obtain a copy of the License at
6+
--
7+
-- http://www.apache.org/licenses/LICENSE-2.0
8+
--
9+
-- Unless required by applicable law or agreed to in writing, software
10+
-- distributed under the License is distributed on an "AS IS" BASIS,
11+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
-- See the License for the specific language governing permissions and
13+
-- limitations under the License.
14+
15+
ALTER TABLE ONLY "Domain"
16+
DROP CONSTRAINT fk_domain_admin_contact,
17+
DROP CONSTRAINT fk_domain_billing_contact,
18+
DROP CONSTRAINT fk_domain_registrant_contact,
19+
DROP CONSTRAINT fk_domain_tech_contact;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
-- Copyright 2025 The Nomulus Authors. All Rights Reserved.
2+
--
3+
-- Licensed under the Apache License, Version 2.0 (the "License");
4+
-- you may not use this file except in compliance with the License.
5+
-- You may obtain a copy of the License at
6+
--
7+
-- http://www.apache.org/licenses/LICENSE-2.0
8+
--
9+
-- Unless required by applicable law or agreed to in writing, software
10+
-- distributed under the License is distributed on an "AS IS" BASIS,
11+
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
-- See the License for the specific language governing permissions and
13+
-- limitations under the License.
14+
15+
ALTER TABLE ONLY "PollMessage"
16+
DROP CONSTRAINT fk_poll_message_contact_history,
17+
DROP CONSTRAINT fk_poll_message_contact_repo_id;

db/src/main/resources/sql/schema/nomulus.golden.sql

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2940,14 +2940,6 @@ ALTER TABLE ONLY public."ConsoleUpdateHistory"
29402940
ADD CONSTRAINT fk_console_update_history_acting_user FOREIGN KEY (acting_user) REFERENCES public."User"(email_address);
29412941

29422942

2943-
--
2944-
-- Name: ContactHistory fk_contact_history_contact_repo_id; Type: FK CONSTRAINT; Schema: public; Owner: -
2945-
--
2946-
2947-
ALTER TABLE ONLY public."ContactHistory"
2948-
ADD CONSTRAINT fk_contact_history_contact_repo_id FOREIGN KEY (contact_repo_id) REFERENCES public."Contact"(repo_id) DEFERRABLE INITIALLY DEFERRED;
2949-
2950-
29512943
--
29522944
-- Name: ContactHistory fk_contact_history_registrar_id; Type: FK CONSTRAINT; Schema: public; Owner: -
29532945
--
@@ -2972,22 +2964,6 @@ ALTER TABLE ONLY public."Contact"
29722964
ADD CONSTRAINT fk_contact_transfer_losing_registrar_id FOREIGN KEY (transfer_losing_registrar_id) REFERENCES public."Registrar"(registrar_id) DEFERRABLE INITIALLY DEFERRED;
29732965

29742966

2975-
--
2976-
-- Name: Domain fk_domain_admin_contact; Type: FK CONSTRAINT; Schema: public; Owner: -
2977-
--
2978-
2979-
ALTER TABLE ONLY public."Domain"
2980-
ADD CONSTRAINT fk_domain_admin_contact FOREIGN KEY (admin_contact) REFERENCES public."Contact"(repo_id) DEFERRABLE INITIALLY DEFERRED;
2981-
2982-
2983-
--
2984-
-- Name: Domain fk_domain_billing_contact; Type: FK CONSTRAINT; Schema: public; Owner: -
2985-
--
2986-
2987-
ALTER TABLE ONLY public."Domain"
2988-
ADD CONSTRAINT fk_domain_billing_contact FOREIGN KEY (billing_contact) REFERENCES public."Contact"(repo_id) DEFERRABLE INITIALLY DEFERRED;
2989-
2990-
29912967
--
29922968
-- Name: Domain fk_domain_billing_recurrence_id; Type: FK CONSTRAINT; Schema: public; Owner: -
29932969
--
@@ -3028,22 +3004,6 @@ ALTER TABLE ONLY public."DomainHistory"
30283004
ADD CONSTRAINT fk_domain_history_registrar_id FOREIGN KEY (history_registrar_id) REFERENCES public."Registrar"(registrar_id) DEFERRABLE INITIALLY DEFERRED;
30293005

30303006

3031-
--
3032-
-- Name: Domain fk_domain_registrant_contact; Type: FK CONSTRAINT; Schema: public; Owner: -
3033-
--
3034-
3035-
ALTER TABLE ONLY public."Domain"
3036-
ADD CONSTRAINT fk_domain_registrant_contact FOREIGN KEY (registrant_contact) REFERENCES public."Contact"(repo_id) DEFERRABLE INITIALLY DEFERRED;
3037-
3038-
3039-
--
3040-
-- Name: Domain fk_domain_tech_contact; Type: FK CONSTRAINT; Schema: public; Owner: -
3041-
--
3042-
3043-
ALTER TABLE ONLY public."Domain"
3044-
ADD CONSTRAINT fk_domain_tech_contact FOREIGN KEY (tech_contact) REFERENCES public."Contact"(repo_id) DEFERRABLE INITIALLY DEFERRED;
3045-
3046-
30473007
--
30483008
-- Name: Domain fk_domain_tld; Type: FK CONSTRAINT; Schema: public; Owner: -
30493009
--
@@ -3188,22 +3148,6 @@ ALTER TABLE ONLY public."HostHistory"
31883148
ADD CONSTRAINT fk_hosthistory_host FOREIGN KEY (host_repo_id) REFERENCES public."Host"(repo_id) DEFERRABLE INITIALLY DEFERRED;
31893149

31903150

3191-
--
3192-
-- Name: PollMessage fk_poll_message_contact_history; Type: FK CONSTRAINT; Schema: public; Owner: -
3193-
--
3194-
3195-
ALTER TABLE ONLY public."PollMessage"
3196-
ADD CONSTRAINT fk_poll_message_contact_history FOREIGN KEY (contact_repo_id, contact_history_revision_id) REFERENCES public."ContactHistory"(contact_repo_id, history_revision_id) DEFERRABLE INITIALLY DEFERRED;
3197-
3198-
3199-
--
3200-
-- Name: PollMessage fk_poll_message_contact_repo_id; Type: FK CONSTRAINT; Schema: public; Owner: -
3201-
--
3202-
3203-
ALTER TABLE ONLY public."PollMessage"
3204-
ADD CONSTRAINT fk_poll_message_contact_repo_id FOREIGN KEY (contact_repo_id) REFERENCES public."Contact"(repo_id) DEFERRABLE INITIALLY DEFERRED;
3205-
3206-
32073151
--
32083152
-- Name: PollMessage fk_poll_message_domain_repo_id; Type: FK CONSTRAINT; Schema: public; Owner: -
32093153
--

0 commit comments

Comments
 (0)