mirror of
https://github.com/google/nomulus.git
synced 2025-07-14 23:15:18 +02:00
Refactor ContactResource into ContactBase and create ContactHistory (#634)
* Create ContactHistory class + table This is similar to #587, but with contacts instead of hosts. This also includes a couple cleanups for HostHistoryTest and RegistryLockDaoTest, just making code more proper (we shouldn't be referencing constant revision IDs when using a sequence that is used by multiple classes, and RLDT can extend EntityTest) Note as well that we set ContactHistory to use the same revision ID sequence as HostHistory. * Move ContactResource -> ContactBase * Alter ContactBase and ContactResource
This commit is contained in:
parent
806f3b2456
commit
c24a61f813
14 changed files with 908 additions and 365 deletions
|
@ -0,0 +1,99 @@
|
|||
-- 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.
|
||||
|
||||
CREATE TABLE "ContactHistory" (
|
||||
history_revision_id int8 NOT NULL,
|
||||
history_by_superuser boolean NOT NULL,
|
||||
history_registrar_id text,
|
||||
history_modification_time timestamptz NOT NULL,
|
||||
history_reason text NOT NULL,
|
||||
history_requested_by_registrar boolean NOT NULL,
|
||||
history_client_transaction_id text,
|
||||
history_server_transaction_id text,
|
||||
history_type text NOT NULL,
|
||||
history_xml_bytes bytea NOT NULL,
|
||||
auth_info_repo_id text,
|
||||
auth_info_value text,
|
||||
contact_id text,
|
||||
disclose_types_addr text[],
|
||||
disclose_show_email boolean,
|
||||
disclose_show_fax boolean,
|
||||
disclose_mode_flag boolean,
|
||||
disclose_types_name text[],
|
||||
disclose_types_org text[],
|
||||
disclose_show_voice boolean,
|
||||
email text,
|
||||
fax_phone_extension text,
|
||||
fax_phone_number text,
|
||||
addr_i18n_city text,
|
||||
addr_i18n_country_code text,
|
||||
addr_i18n_state text,
|
||||
addr_i18n_street_line1 text,
|
||||
addr_i18n_street_line2 text,
|
||||
addr_i18n_street_line3 text,
|
||||
addr_i18n_zip text,
|
||||
addr_i18n_name text,
|
||||
addr_i18n_org text,
|
||||
addr_i18n_type text,
|
||||
last_transfer_time timestamptz,
|
||||
addr_local_city text,
|
||||
addr_local_country_code text,
|
||||
addr_local_state text,
|
||||
addr_local_street_line1 text,
|
||||
addr_local_street_line2 text,
|
||||
addr_local_street_line3 text,
|
||||
addr_local_zip text,
|
||||
addr_local_name text,
|
||||
addr_local_org text,
|
||||
addr_local_type text,
|
||||
search_name text,
|
||||
transfer_gaining_poll_message_id int8,
|
||||
transfer_losing_poll_message_id int8,
|
||||
transfer_client_txn_id text,
|
||||
transfer_server_txn_id text,
|
||||
transfer_gaining_registrar_id text,
|
||||
transfer_losing_registrar_id text,
|
||||
transfer_pending_expiration_time timestamptz,
|
||||
transfer_request_time timestamptz,
|
||||
transfer_status text,
|
||||
voice_phone_extension text,
|
||||
voice_phone_number text,
|
||||
creation_registrar_id text NOT NULL,
|
||||
creation_time timestamptz NOT NULL,
|
||||
current_sponsor_registrar_id text NOT NULL,
|
||||
deletion_time timestamptz,
|
||||
last_epp_update_registrar_id text,
|
||||
last_epp_update_time timestamptz,
|
||||
statuses text[],
|
||||
contact_repo_id text NOT NULL,
|
||||
primary key (history_revision_id)
|
||||
);
|
||||
|
||||
create index IDXo1xdtpij2yryh0skxe9v91sep on "ContactHistory" (creation_time);
|
||||
create index IDXhp33wybmb6tbpr1bq7ttwk8je on "ContactHistory" (history_registrar_id);
|
||||
create index IDX9q53px6r302ftgisqifmc6put on "ContactHistory" (history_type);
|
||||
create index IDXsudwswtwqnfnx2o1hx4s0k0g5 on "ContactHistory" (history_modification_time);
|
||||
|
||||
ALTER TABLE IF EXISTS "ContactHistory"
|
||||
ADD CONSTRAINT fk_contact_history_registrar_id
|
||||
FOREIGN KEY (history_registrar_id)
|
||||
REFERENCES "Registrar";
|
||||
|
||||
ALTER TABLE IF EXISTS "ContactHistory"
|
||||
ADD CONSTRAINT fk_contact_history_contact_repo_id
|
||||
FOREIGN KEY (contact_repo_id)
|
||||
REFERENCES "Contact";
|
||||
|
||||
ALTER TABLE ONLY public."ContactHistory" ALTER COLUMN history_revision_id
|
||||
SET DEFAULT nextval('public."history_id_sequence"'::regclass);
|
|
@ -133,6 +133,74 @@ create sequence history_id_sequence start 1 increment 1;
|
|||
primary key (repo_id)
|
||||
);
|
||||
|
||||
create table "ContactHistory" (
|
||||
history_revision_id int8 not null,
|
||||
history_by_superuser boolean not null,
|
||||
history_registrar_id text,
|
||||
history_modification_time timestamptz not null,
|
||||
history_reason text not null,
|
||||
history_requested_by_registrar boolean not null,
|
||||
history_client_transaction_id text,
|
||||
history_server_transaction_id text,
|
||||
history_type text not null,
|
||||
history_xml_bytes bytea not null,
|
||||
auth_info_repo_id text,
|
||||
auth_info_value text,
|
||||
contact_id text,
|
||||
disclose_types_addr text[],
|
||||
disclose_show_email boolean,
|
||||
disclose_show_fax boolean,
|
||||
disclose_mode_flag boolean,
|
||||
disclose_types_name text[],
|
||||
disclose_types_org text[],
|
||||
disclose_show_voice boolean,
|
||||
email text,
|
||||
fax_phone_extension text,
|
||||
fax_phone_number text,
|
||||
addr_i18n_city text,
|
||||
addr_i18n_country_code text,
|
||||
addr_i18n_state text,
|
||||
addr_i18n_street_line1 text,
|
||||
addr_i18n_street_line2 text,
|
||||
addr_i18n_street_line3 text,
|
||||
addr_i18n_zip text,
|
||||
addr_i18n_name text,
|
||||
addr_i18n_org text,
|
||||
addr_i18n_type text,
|
||||
last_transfer_time timestamptz,
|
||||
addr_local_city text,
|
||||
addr_local_country_code text,
|
||||
addr_local_state text,
|
||||
addr_local_street_line1 text,
|
||||
addr_local_street_line2 text,
|
||||
addr_local_street_line3 text,
|
||||
addr_local_zip text,
|
||||
addr_local_name text,
|
||||
addr_local_org text,
|
||||
addr_local_type text,
|
||||
search_name text,
|
||||
transfer_gaining_poll_message_id int8,
|
||||
transfer_losing_poll_message_id int8,
|
||||
transfer_client_txn_id text,
|
||||
transfer_server_txn_id text,
|
||||
transfer_gaining_registrar_id text,
|
||||
transfer_losing_registrar_id text,
|
||||
transfer_pending_expiration_time timestamptz,
|
||||
transfer_request_time timestamptz,
|
||||
transfer_status text,
|
||||
voice_phone_extension text,
|
||||
voice_phone_number text,
|
||||
creation_registrar_id text not null,
|
||||
creation_time timestamptz not null,
|
||||
current_sponsor_registrar_id text not null,
|
||||
deletion_time timestamptz,
|
||||
last_epp_update_registrar_id text,
|
||||
last_epp_update_time timestamptz,
|
||||
statuses text[],
|
||||
contact_repo_id text not null,
|
||||
primary key (history_revision_id)
|
||||
);
|
||||
|
||||
create table "Cursor" (
|
||||
scope text not null,
|
||||
type text not null,
|
||||
|
@ -437,6 +505,10 @@ create index IDX1p3esngcwwu6hstyua6itn6ff on "Contact" (search_name);
|
|||
|
||||
alter table if exists "Contact"
|
||||
add constraint UKoqd7n4hbx86hvlgkilq75olas unique (contact_id);
|
||||
create index IDXo1xdtpij2yryh0skxe9v91sep on "ContactHistory" (creation_time);
|
||||
create index IDXhp33wybmb6tbpr1bq7ttwk8je on "ContactHistory" (history_registrar_id);
|
||||
create index IDX9q53px6r302ftgisqifmc6put on "ContactHistory" (history_type);
|
||||
create index IDXsudwswtwqnfnx2o1hx4s0k0g5 on "ContactHistory" (history_modification_time);
|
||||
create index IDX8nr0ke9mrrx4ewj6pd2ag4rmr on "Domain" (creation_time);
|
||||
create index IDXhsjqiy2lyobfymplb28nm74lm on "Domain" (current_sponsor_registrar_id);
|
||||
create index IDX5mnf0wn20tno4b9do88j61klr on "Domain" (deletion_time);
|
||||
|
|
|
@ -254,6 +254,90 @@ CREATE TABLE public."Contact" (
|
|||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: history_id_sequence; Type: SEQUENCE; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE public.history_id_sequence
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: ContactHistory; Type: TABLE; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE public."ContactHistory" (
|
||||
history_revision_id bigint DEFAULT nextval('public.history_id_sequence'::regclass) NOT NULL,
|
||||
history_by_superuser boolean NOT NULL,
|
||||
history_registrar_id text,
|
||||
history_modification_time timestamp with time zone NOT NULL,
|
||||
history_reason text NOT NULL,
|
||||
history_requested_by_registrar boolean NOT NULL,
|
||||
history_client_transaction_id text,
|
||||
history_server_transaction_id text,
|
||||
history_type text NOT NULL,
|
||||
history_xml_bytes bytea NOT NULL,
|
||||
auth_info_repo_id text,
|
||||
auth_info_value text,
|
||||
contact_id text,
|
||||
disclose_types_addr text[],
|
||||
disclose_show_email boolean,
|
||||
disclose_show_fax boolean,
|
||||
disclose_mode_flag boolean,
|
||||
disclose_types_name text[],
|
||||
disclose_types_org text[],
|
||||
disclose_show_voice boolean,
|
||||
email text,
|
||||
fax_phone_extension text,
|
||||
fax_phone_number text,
|
||||
addr_i18n_city text,
|
||||
addr_i18n_country_code text,
|
||||
addr_i18n_state text,
|
||||
addr_i18n_street_line1 text,
|
||||
addr_i18n_street_line2 text,
|
||||
addr_i18n_street_line3 text,
|
||||
addr_i18n_zip text,
|
||||
addr_i18n_name text,
|
||||
addr_i18n_org text,
|
||||
addr_i18n_type text,
|
||||
last_transfer_time timestamp with time zone,
|
||||
addr_local_city text,
|
||||
addr_local_country_code text,
|
||||
addr_local_state text,
|
||||
addr_local_street_line1 text,
|
||||
addr_local_street_line2 text,
|
||||
addr_local_street_line3 text,
|
||||
addr_local_zip text,
|
||||
addr_local_name text,
|
||||
addr_local_org text,
|
||||
addr_local_type text,
|
||||
search_name text,
|
||||
transfer_gaining_poll_message_id bigint,
|
||||
transfer_losing_poll_message_id bigint,
|
||||
transfer_client_txn_id text,
|
||||
transfer_server_txn_id text,
|
||||
transfer_gaining_registrar_id text,
|
||||
transfer_losing_registrar_id text,
|
||||
transfer_pending_expiration_time timestamp with time zone,
|
||||
transfer_request_time timestamp with time zone,
|
||||
transfer_status text,
|
||||
voice_phone_extension text,
|
||||
voice_phone_number text,
|
||||
creation_registrar_id text NOT NULL,
|
||||
creation_time timestamp with time zone NOT NULL,
|
||||
current_sponsor_registrar_id text NOT NULL,
|
||||
deletion_time timestamp with time zone,
|
||||
last_epp_update_registrar_id text,
|
||||
last_epp_update_time timestamp with time zone,
|
||||
statuses text[],
|
||||
contact_repo_id text NOT NULL
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: Cursor; Type: TABLE; Schema: public; Owner: -
|
||||
--
|
||||
|
@ -325,18 +409,6 @@ CREATE TABLE public."DomainHost" (
|
|||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: history_id_sequence; Type: SEQUENCE; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE public.history_id_sequence
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: HostHistory; Type: TABLE; Schema: public; Owner: -
|
||||
--
|
||||
|
@ -793,6 +865,14 @@ ALTER TABLE ONLY public."ClaimsList"
|
|||
ADD CONSTRAINT "ClaimsList_pkey" PRIMARY KEY (revision_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: ContactHistory ContactHistory_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public."ContactHistory"
|
||||
ADD CONSTRAINT "ContactHistory_pkey" PRIMARY KEY (history_revision_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: Contact Contact_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
@ -1013,6 +1093,13 @@ CREATE INDEX idx73l103vc5900ig3p4odf0cngt ON public."BillingEvent" USING btree (
|
|||
CREATE INDEX idx8nr0ke9mrrx4ewj6pd2ag4rmr ON public."Domain" USING btree (creation_time);
|
||||
|
||||
|
||||
--
|
||||
-- Name: idx9q53px6r302ftgisqifmc6put; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX idx9q53px6r302ftgisqifmc6put ON public."ContactHistory" USING btree (history_type);
|
||||
|
||||
|
||||
--
|
||||
-- Name: idx_registry_lock_registrar_id; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
@ -1069,6 +1156,13 @@ CREATE INDEX idxfg2nnjlujxo6cb9fha971bq2n ON public."HostHistory" USING btree (c
|
|||
CREATE INDEX idxhmv411mdqo5ibn4vy7ykxpmlv ON public."BillingEvent" USING btree (allocation_token_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: idxhp33wybmb6tbpr1bq7ttwk8je; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX idxhp33wybmb6tbpr1bq7ttwk8je ON public."ContactHistory" USING btree (history_registrar_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: idxj77pfwhui9f0i7wjq6lmibovj; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
@ -1111,6 +1205,13 @@ CREATE INDEX idxn1f711wicdnooa2mqb7g1m55o ON public."Contact" USING btree (delet
|
|||
CREATE INDEX idxn898pb9mwcg359cdwvolb11ck ON public."BillingRecurrence" USING btree (registrar_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: idxo1xdtpij2yryh0skxe9v91sep; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX idxo1xdtpij2yryh0skxe9v91sep ON public."ContactHistory" USING btree (creation_time);
|
||||
|
||||
|
||||
--
|
||||
-- Name: idxp3usbtvk0v1m14i5tdp4xnxgc; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
@ -1139,6 +1240,13 @@ CREATE INDEX idxqa3g92jc17e8dtiaviy4fet4x ON public."BillingCancellation" USING
|
|||
CREATE INDEX idxrwl38wwkli1j7gkvtywi9jokq ON public."Domain" USING btree (tld);
|
||||
|
||||
|
||||
--
|
||||
-- Name: idxsudwswtwqnfnx2o1hx4s0k0g5; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX idxsudwswtwqnfnx2o1hx4s0k0g5 ON public."ContactHistory" USING btree (history_modification_time);
|
||||
|
||||
|
||||
--
|
||||
-- Name: premiumlist_name_idx; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
@ -1299,6 +1407,22 @@ ALTER TABLE ONLY public."BillingRecurrence"
|
|||
ADD CONSTRAINT fk_billing_recurrence_registrar_id FOREIGN KEY (registrar_id) REFERENCES public."Registrar"(registrar_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: ContactHistory fk_contact_history_contact_repo_id; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public."ContactHistory"
|
||||
ADD CONSTRAINT fk_contact_history_contact_repo_id FOREIGN KEY (contact_repo_id) REFERENCES public."Contact"(repo_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: ContactHistory fk_contact_history_registrar_id; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
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_registrar_id; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue