Add SQL schema for GracePeriodHistory (#746)

* Add schema for GracePeriodHistory

Rebase on HEAD

Rebase on HEAD

Rebase on HEAD and rename column

Use OfyService to generate id

Refactor GracePeriodsSubject

Rebase on HEAD

Remove GracePeriodSubject and GracePeriodsSubject

Rebase on HEAD

Rebase on HEAD

Rebase on HEAD

Add gracePeriodHistoryRevisionId and remove some foreign key

* Rebase on HEAD
This commit is contained in:
Shicong Huang 2020-11-12 10:06:58 -05:00 committed by GitHub
parent 1349fa4cfc
commit 8625e44cfd
23 changed files with 4813 additions and 4091 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -72,3 +72,4 @@ V71__create_kms_secret.sql
V72__add_missing_foreign_keys.sql
V73__singleton_entities.sql
V74__sql_replay_checkpoint.sql
V75__add_grace_period_history.sql

View file

@ -0,0 +1,37 @@
-- 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 "GracePeriod" rename column "id" to "grace_period_id";
create table "GracePeriodHistory" (
grace_period_history_revision_id int8 not null,
billing_event_id int8,
billing_event_history_id int8,
billing_recurrence_id int8,
billing_recurrence_history_id int8,
registrar_id text not null,
domain_repo_id text not null,
expiration_time timestamptz not null,
type text not null,
domain_history_revision_id int8,
grace_period_id int8 not null,
primary key (grace_period_history_revision_id)
);
alter table if exists "GracePeriodHistory"
add constraint FK7w3cx8d55q8bln80e716tr7b8
foreign key (domain_repo_id, domain_history_revision_id)
references "DomainHistory";
create index IDXd01j17vrpjxaerxdmn8bwxs7s on "GracePeriodHistory" (domain_repo_id);

View file

@ -394,7 +394,7 @@
);
create table "GracePeriod" (
id int8 not null,
grace_period_id int8 not null,
billing_event_id int8,
billing_event_history_id int8,
billing_recurrence_id int8,
@ -403,7 +403,22 @@
domain_repo_id text not null,
expiration_time timestamptz not null,
type text not null,
primary key (id)
primary key (grace_period_id)
);
create table "GracePeriodHistory" (
grace_period_history_revision_id int8 not null,
billing_event_id int8,
billing_event_history_id int8,
billing_recurrence_id int8,
billing_recurrence_history_id int8,
registrar_id text not null,
domain_repo_id text not null,
expiration_time timestamptz not null,
type text not null,
domain_history_revision_id int8,
grace_period_id int8 not null,
primary key (grace_period_history_revision_id)
);
create table "Host" (
@ -749,6 +764,7 @@ create index IDXaro1omfuaxjwmotk3vo00trwm on "DomainHistory" (history_registrar_
create index IDXsu1nam10cjes9keobapn5jvxj on "DomainHistory" (history_type);
create index IDX6w3qbtgce93cal2orjg1tw7b7 on "DomainHistory" (history_modification_time);
create index IDXj1mtx98ndgbtb1bkekahms18w on "GracePeriod" (domain_repo_id);
create index IDXd01j17vrpjxaerxdmn8bwxs7s on "GracePeriodHistory" (domain_repo_id);
create index IDXfg2nnjlujxo6cb9fha971bq2n on "HostHistory" (creation_time);
create index IDX1iy7njgb7wjmj9piml4l2g0qi on "HostHistory" (history_registrar_id);
create index IDXkkwbwcwvrdkkqothkiye4jiff on "HostHistory" (host_name);
@ -806,6 +822,11 @@ create index spec11threatmatch_check_date_idx on "Spec11ThreatMatch" (check_date
foreign key (domain_repo_id)
references "Domain";
alter table if exists "GracePeriodHistory"
add constraint FK7w3cx8d55q8bln80e716tr7b8
foreign key (domain_repo_id, domain_history_revision_id)
references "DomainHistory";
alter table if exists "PremiumEntry"
add constraint FKo0gw90lpo1tuee56l0nb6y6g5
foreign key (revision_id)

View file

@ -524,7 +524,7 @@ ALTER SEQUENCE public."DomainTransactionRecord_id_seq" OWNED BY public."DomainTr
--
CREATE TABLE public."GracePeriod" (
id bigint NOT NULL,
grace_period_id bigint NOT NULL,
billing_event_id bigint,
billing_recurrence_id bigint,
registrar_id text NOT NULL,
@ -536,6 +536,25 @@ CREATE TABLE public."GracePeriod" (
);
--
-- Name: GracePeriodHistory; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public."GracePeriodHistory" (
grace_period_history_revision_id bigint NOT NULL,
billing_event_id bigint,
billing_event_history_id bigint,
billing_recurrence_id bigint,
billing_recurrence_history_id bigint,
registrar_id text NOT NULL,
domain_repo_id text NOT NULL,
expiration_time timestamp with time zone NOT NULL,
type text NOT NULL,
domain_history_revision_id bigint,
grace_period_id bigint NOT NULL
);
--
-- Name: Host; Type: TABLE; Schema: public; Owner: -
--
@ -1212,12 +1231,20 @@ ALTER TABLE ONLY public."Domain"
ADD CONSTRAINT "Domain_pkey" PRIMARY KEY (repo_id);
--
-- Name: GracePeriodHistory GracePeriodHistory_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public."GracePeriodHistory"
ADD CONSTRAINT "GracePeriodHistory_pkey" PRIMARY KEY (grace_period_history_revision_id);
--
-- Name: GracePeriod GracePeriod_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public."GracePeriod"
ADD CONSTRAINT "GracePeriod_pkey" PRIMARY KEY (id);
ADD CONSTRAINT "GracePeriod_pkey" PRIMARY KEY (grace_period_id);
--
@ -1536,6 +1563,13 @@ CREATE INDEX idxaydgox62uno9qx8cjlj5lauye ON public."PollMessage" USING btree (e
CREATE INDEX idxbn8t4wp85fgxjl8q4ctlscx55 ON public."Contact" USING btree (current_sponsor_registrar_id);
--
-- Name: idxd01j17vrpjxaerxdmn8bwxs7s; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX idxd01j17vrpjxaerxdmn8bwxs7s ON public."GracePeriodHistory" USING btree (domain_repo_id);
--
-- Name: idxe7wu46c7wpvfmfnj4565abibp; Type: INDEX; Schema: public; Owner: -
--
@ -1816,6 +1850,14 @@ ALTER TABLE ONLY public."ClaimsEntry"
ADD CONSTRAINT fk6sc6at5hedffc0nhdcab6ivuq FOREIGN KEY (revision_id) REFERENCES public."ClaimsList"(revision_id);
--
-- Name: GracePeriodHistory fk7w3cx8d55q8bln80e716tr7b8; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public."GracePeriodHistory"
ADD CONSTRAINT fk7w3cx8d55q8bln80e716tr7b8 FOREIGN KEY (domain_repo_id, domain_history_revision_id) REFERENCES public."DomainHistory"(domain_repo_id, history_revision_id);
--
-- Name: Contact fk93c185fx7chn68uv7nl6uv2s0; Type: FK CONSTRAINT; Schema: public; Owner: -
--