Get persistence of DomainBase actually working (#438)

* Get persistence of DomainBase actually working

Fix all of the existing problems with DomainBase persistence:
- Remove "final" keywords on getters that cause errors during startup.
- Remove Transient from creationTime (since there's a converter for
  CreateAutoTimestamp)
- Fix DesignatedContext persistence so that it only creates a single table.
  This is a lot more efficient given that these are many-to-one with their
  domains.
- Add a flyway script, update the golden schema.
- Create a unit test, add it to the integration test suite.

* Changes request in review

* Regenerated generated schema file.

* Changes for review

* Persist status value enum set

* Changes in response to review

* Changes requested in review

* Fixes for #456

* Rename Domain "status" column to "statuses"
This commit is contained in:
Michael Muller 2020-01-28 11:32:26 -05:00 committed by GitHub
parent 1912453f4e
commit e386bf5bd8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 295 additions and 159 deletions

View file

@ -0,0 +1,44 @@
-- 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 "Domain" (
repo_id text not null,
creation_client_id text,
creation_time timestamptz,
current_sponsor_client_id text,
deletion_time timestamptz,
last_epp_update_client_id text,
last_epp_update_time timestamptz,
statuses text[],
auth_info_repo_id text,
auth_info_value text,
fully_qualified_domain_name text,
idn_table_name text,
last_transfer_time timestamptz,
launch_notice_accepted_time timestamptz,
launch_notice_expiration_time timestamptz,
launch_notice_tcn_id text,
launch_notice_validator_id text,
registration_expiration_time timestamptz,
smd_id text,
subordinate_hosts text[],
tld text,
primary key (repo_id)
);
create index IDX8nr0ke9mrrx4ewj6pd2ag4rmr on "Domain" (creation_time);
create index IDX8ffrqm27qtj20jac056j7yq07 on "Domain" (current_sponsor_client_id);
create index IDX5mnf0wn20tno4b9do88j61klr on "Domain" (deletion_time);
create index IDX1rcgkdd777bpvj0r94sltwd5y on "Domain" (fully_qualified_domain_name);
create index IDXrwl38wwkli1j7gkvtywi9jokq on "Domain" (tld);

View file

@ -42,25 +42,17 @@
primary key (key_tag)
);
create table "DesignatedContact" (
contact bytea not null,
type int4,
primary key (contact)
);
create table "Domain" (
repo_id text not null,
creation_client_id text,
creation_time timestamptz,
current_sponsor_client_id text,
deletion_time timestamptz,
last_epp_update_client_id text,
last_epp_update_time timestamptz,
revisions bytea,
statuses text[],
auth_info_repo_id text,
auth_info_value text,
autorenew_billing_event bytea,
autorenew_poll_message bytea,
delete_poll_message bytea,
fully_qualified_domain_name text,
idn_table_name text,
last_transfer_time timestamptz,
@ -70,56 +62,11 @@
launch_notice_validator_id text,
registration_expiration_time timestamptz,
smd_id text,
subordinate_hosts text[],
tld text,
transfer_data_server_approve_autorenrew_event bytea,
transfer_data_server_approve_autorenrew_poll_message bytea,
transfer_data_server_approve_billing_event bytea,
unit int4,
value int4,
client_transaction_id text,
server_transaction_id text,
transfer_data_registration_expiration_time timestamptz,
gaining_client_id text,
losing_client_id text,
pending_transfer_expiration_time timestamptz,
transfer_request_time timestamptz,
transfer_status int4,
primary key (repo_id)
);
create table "Domain_DelegationSignerData" (
domain_base_repo_id text not null,
ds_data_key_tag int4 not null,
primary key (domain_base_repo_id, ds_data_key_tag)
);
create table "Domain_DesignatedContact" (
domain_base_repo_id text not null,
all_contacts_contact bytea not null,
primary key (domain_base_repo_id, all_contacts_contact)
);
create table "Domain_GracePeriod" (
domain_base_repo_id text not null,
grace_periods_id int8 not null,
primary key (domain_base_repo_id, grace_periods_id)
);
create table "DomainBase_nsHosts" (
domain_base_repo_id text not null,
ns_hosts bytea
);
create table "DomainBase_serverApproveEntities" (
domain_base_repo_id text not null,
transfer_data_server_approve_entities bytea
);
create table "DomainBase_subordinateHosts" (
domain_base_repo_id text not null,
subordinate_hosts text
);
create table "GracePeriod" (
id bigserial not null,
billing_event_one_time bytea,
@ -177,15 +124,11 @@
should_publish boolean not null,
primary key (revision_id)
);
alter table if exists "Domain_DelegationSignerData"
add constraint UK_2yp55erx1i51pa7gnb8bu7tjn unique (ds_data_key_tag);
alter table if exists "Domain_DesignatedContact"
add constraint UK_4ys6wdxcmndimlr6af3tsl0ow unique (all_contacts_contact);
alter table if exists "Domain_GracePeriod"
add constraint UK_4ps2u4y8i5r91wu2n1x2xea28 unique (grace_periods_id);
create index IDX8nr0ke9mrrx4ewj6pd2ag4rmr on "Domain" (creation_time);
create index IDX8ffrqm27qtj20jac056j7yq07 on "Domain" (current_sponsor_client_id);
create index IDX5mnf0wn20tno4b9do88j61klr on "Domain" (deletion_time);
create index IDX1rcgkdd777bpvj0r94sltwd5y on "Domain" (fully_qualified_domain_name);
create index IDXrwl38wwkli1j7gkvtywi9jokq on "Domain" (tld);
create index premiumlist_name_idx on "PremiumList" (name);
create index idx_registry_lock_verification_code on "RegistryLock" (verification_code);
create index idx_registry_lock_registrar_id on "RegistryLock" (registrar_id);
@ -199,51 +142,6 @@ create index reservedlist_name_idx on "ReservedList" (name);
foreign key (revision_id)
references "ClaimsList";
alter table if exists "Domain_DelegationSignerData"
add constraint FKho8wxowo3f4e688ehdl4wpni5
foreign key (ds_data_key_tag)
references "DelegationSignerData";
alter table if exists "Domain_DelegationSignerData"
add constraint FK2nvqbovvy5wasa8arhyhy8mge
foreign key (domain_base_repo_id)
references "Domain";
alter table if exists "Domain_DesignatedContact"
add constraint FKqnnsrj0vi9eqhoth305cd4bi7
foreign key (all_contacts_contact)
references "DesignatedContact";
alter table if exists "Domain_DesignatedContact"
add constraint FK169lte99hlt3otom9di13ubfn
foreign key (domain_base_repo_id)
references "Domain";
alter table if exists "Domain_GracePeriod"
add constraint FKny62h7k1nd3910rp56gdo5pfi
foreign key (grace_periods_id)
references "GracePeriod";
alter table if exists "Domain_GracePeriod"
add constraint FKkpor7amcdp7gwe0hp3obng6do
foreign key (domain_base_repo_id)
references "Domain";
alter table if exists "DomainBase_nsHosts"
add constraint FKow28763fcl1ilx8unxrfjtbja
foreign key (domain_base_repo_id)
references "Domain";
alter table if exists "DomainBase_serverApproveEntities"
add constraint FK7vuyqcsmcfvpv5648femoxien
foreign key (domain_base_repo_id)
references "Domain";
alter table if exists "DomainBase_subordinateHosts"
add constraint FKkva2lb57ri8qf39hthcej538k
foreign key (domain_base_repo_id)
references "Domain";
alter table if exists "PremiumEntry"
add constraint FKo0gw90lpo1tuee56l0nb6y6g5
foreign key (revision_id)

View file

@ -87,6 +87,35 @@ CREATE TABLE public."Cursor" (
);
--
-- Name: Domain; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public."Domain" (
repo_id text NOT NULL,
creation_client_id text,
creation_time timestamp with time zone,
current_sponsor_client_id text,
deletion_time timestamp with time zone,
last_epp_update_client_id text,
last_epp_update_time timestamp with time zone,
statuses text[],
auth_info_repo_id text,
auth_info_value text,
fully_qualified_domain_name text,
idn_table_name text,
last_transfer_time timestamp with time zone,
launch_notice_accepted_time timestamp with time zone,
launch_notice_expiration_time timestamp with time zone,
launch_notice_tcn_id text,
launch_notice_validator_id text,
registration_expiration_time timestamp with time zone,
smd_id text,
subordinate_hosts text[],
tld text
);
--
-- Name: PremiumEntry; Type: TABLE; Schema: public; Owner: -
--
@ -264,6 +293,14 @@ ALTER TABLE ONLY public."Cursor"
ADD CONSTRAINT "Cursor_pkey" PRIMARY KEY (scope, type);
--
-- Name: Domain Domain_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public."Domain"
ADD CONSTRAINT "Domain_pkey" PRIMARY KEY (repo_id);
--
-- Name: PremiumEntry PremiumEntry_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
@ -312,6 +349,34 @@ ALTER TABLE ONLY public."RegistryLock"
ADD CONSTRAINT idx_registry_lock_repo_id_revision_id UNIQUE (repo_id, revision_id);
--
-- Name: idx1rcgkdd777bpvj0r94sltwd5y; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX idx1rcgkdd777bpvj0r94sltwd5y ON public."Domain" USING btree (fully_qualified_domain_name);
--
-- Name: idx5mnf0wn20tno4b9do88j61klr; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX idx5mnf0wn20tno4b9do88j61klr ON public."Domain" USING btree (deletion_time);
--
-- Name: idx8ffrqm27qtj20jac056j7yq07; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX idx8ffrqm27qtj20jac056j7yq07 ON public."Domain" USING btree (current_sponsor_client_id);
--
-- Name: idx8nr0ke9mrrx4ewj6pd2ag4rmr; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX idx8nr0ke9mrrx4ewj6pd2ag4rmr ON public."Domain" USING btree (creation_time);
--
-- Name: idx_registry_lock_registrar_id; Type: INDEX; Schema: public; Owner: -
--
@ -326,6 +391,13 @@ CREATE INDEX idx_registry_lock_registrar_id ON public."RegistryLock" USING btree
CREATE INDEX idx_registry_lock_verification_code ON public."RegistryLock" USING btree (verification_code);
--
-- Name: idxrwl38wwkli1j7gkvtywi9jokq; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX idxrwl38wwkli1j7gkvtywi9jokq ON public."Domain" USING btree (tld);
--
-- Name: premiumlist_name_idx; Type: INDEX; Schema: public; Owner: -
--