Correctly restore composite VKeys in DomainContent (#825)

* Restore composite vkeys in DomainContent

PollMessage/BillingEvent vkeys in DomainContent must have their ofy keys
restored from other fields in DomainContent (namely the repo id and their
specific history event ids).

Add PostLoad methods to DomainContent and DomainHistory to do the restoration.

* Fixes for review.

* Deal with foreign-key cycles
This commit is contained in:
Michael Muller 2020-10-07 12:42:01 -04:00 committed by GitHub
parent 96e9c1e0af
commit 151a2afb14
10 changed files with 343 additions and 5 deletions

View file

@ -353,7 +353,10 @@ CREATE TABLE public."Domain" (
billing_recurrence_id bigint,
autorenew_poll_message_id bigint,
deletion_poll_message_id bigint,
autorenew_end_time timestamp with time zone
autorenew_end_time timestamp with time zone,
billing_recurrence_history_id bigint,
autorenew_poll_message_history_id bigint,
deletion_poll_message_history_id bigint
);
@ -420,7 +423,10 @@ CREATE TABLE public."DomainHistory" (
autorenew_end_time timestamp with time zone,
history_other_registrar_id text,
history_period_unit text,
history_period_value integer
history_period_value integer,
billing_recurrence_history_id bigint,
autorenew_poll_message_history_id bigint,
deletion_poll_message_history_id bigint
);
@ -1768,7 +1774,7 @@ ALTER TABLE ONLY public."Domain"
--
ALTER TABLE ONLY public."DomainHistory"
ADD CONSTRAINT fk_domain_history_domain_repo_id FOREIGN KEY (domain_repo_id) REFERENCES public."Domain"(repo_id);
ADD CONSTRAINT fk_domain_history_domain_repo_id FOREIGN KEY (domain_repo_id) REFERENCES public."Domain"(repo_id) DEFERRABLE INITIALLY DEFERRED;
--
@ -1904,7 +1910,7 @@ ALTER TABLE ONLY public."PollMessage"
--
ALTER TABLE ONLY public."PollMessage"
ADD CONSTRAINT fk_poll_message_domain_repo_id FOREIGN KEY (domain_repo_id) REFERENCES public."Domain"(repo_id);
ADD CONSTRAINT fk_poll_message_domain_repo_id FOREIGN KEY (domain_repo_id) REFERENCES public."Domain"(repo_id) DEFERRABLE INITIALLY DEFERRED;
--