Use composite primary key for HostHistory and ContactHistory (#809)

* Use composite primary key for HostHistory and ContactHistory

* Update flyway file version

* Make getters private

* Add javadoc

* Rebase on HEAD
This commit is contained in:
Shicong Huang 2020-10-01 11:01:57 -04:00 committed by GitHub
parent 71f86c9970
commit fd40a6a2b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 248 additions and 89 deletions

View file

@ -56,3 +56,4 @@ V55__domain_history_fields.sql
V56__rename_host_table.sql
V57__history_null_content.sql
V58__drop_default_value_and_sequences_for_billing_event.sql
V59__use_composite_primary_key_for_contact_and_host_history_table.sql

View file

@ -0,0 +1,23 @@
-- 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 "ContactHistory" drop constraint "ContactHistory_pkey";
alter table "ContactHistory"
add constraint "ContactHistory_pkey" primary key (contact_repo_id, history_revision_id);
alter table "HostHistory" drop constraint "HostHistory_pkey";
alter table "HostHistory"
add constraint "HostHistory_pkey" primary key (host_repo_id, history_revision_id);

View file

@ -151,7 +151,8 @@ create sequence temp_history_id_sequence start 1 increment 50;
);
create table "ContactHistory" (
history_revision_id int8 not null,
contact_repo_id text not null,
history_revision_id int8 not null,
history_by_superuser boolean not null,
history_registrar_id text,
history_modification_time timestamptz not null,
@ -215,8 +216,7 @@ create sequence temp_history_id_sequence start 1 increment 50;
last_epp_update_time timestamptz,
statuses text[],
update_timestamp timestamptz,
contact_repo_id text not null,
primary key (history_revision_id)
primary key (contact_repo_id, history_revision_id)
);
create table "Cursor" (
@ -400,7 +400,8 @@ create sequence temp_history_id_sequence start 1 increment 50;
);
create table "HostHistory" (
history_revision_id int8 not null,
host_repo_id text not null,
history_revision_id int8 not null,
history_by_superuser boolean not null,
history_registrar_id text,
history_modification_time timestamptz not null,
@ -423,8 +424,7 @@ create sequence temp_history_id_sequence start 1 increment 50;
last_epp_update_time timestamptz,
statuses text[],
update_timestamp timestamptz,
host_repo_id text not null,
primary key (history_revision_id)
primary key (host_repo_id, history_revision_id)
);
create table "Lock" (

View file

@ -1084,7 +1084,7 @@ ALTER TABLE ONLY public."ClaimsList"
--
ALTER TABLE ONLY public."ContactHistory"
ADD CONSTRAINT "ContactHistory_pkey" PRIMARY KEY (history_revision_id);
ADD CONSTRAINT "ContactHistory_pkey" PRIMARY KEY (contact_repo_id, history_revision_id);
--
@ -1140,7 +1140,7 @@ ALTER TABLE ONLY public."GracePeriod"
--
ALTER TABLE ONLY public."HostHistory"
ADD CONSTRAINT "HostHistory_pkey" PRIMARY KEY (history_revision_id);
ADD CONSTRAINT "HostHistory_pkey" PRIMARY KEY (host_repo_id, history_revision_id);
--