diff --git a/core/src/main/java/google/registry/model/host/HostResource.java b/core/src/main/java/google/registry/model/host/HostResource.java index fb03e5c37..0338b8d1d 100644 --- a/core/src/main/java/google/registry/model/host/HostResource.java +++ b/core/src/main/java/google/registry/model/host/HostResource.java @@ -32,7 +32,7 @@ import javax.persistence.AccessType; */ @ReportedOn @Entity -@javax.persistence.Entity +@javax.persistence.Entity(name = "Host") @ExternalMessagingName("host") @WithStringVKey @Access(AccessType.FIELD) // otherwise it'll use the default if the repoId (property) diff --git a/db/src/main/resources/sql/flyway/V54__rename_host_table.sql b/db/src/main/resources/sql/flyway/V54__rename_host_table.sql new file mode 100644 index 000000000..862808f3f --- /dev/null +++ b/db/src/main/resources/sql/flyway/V54__rename_host_table.sql @@ -0,0 +1,21 @@ +-- 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 "HostResource" RENAME TO "Host"; + +ALTER TABLE "HostHistory" RENAME CONSTRAINT fk_hosthistory_hostresource TO fk_hosthistory_host; +ALTER TABLE "Host" + RENAME CONSTRAINT fk_host_resource_superordinate_domain TO fk_host_superordinate_domain; +ALTER TABLE "Host" RENAME CONSTRAINT "HostResource_pkey" TO "Host_pkey"; diff --git a/db/src/main/resources/sql/schema/db-schema.sql.generated b/db/src/main/resources/sql/schema/db-schema.sql.generated index 46ea00511..22740dc3f 100644 --- a/db/src/main/resources/sql/schema/db-schema.sql.generated +++ b/db/src/main/resources/sql/schema/db-schema.sql.generated @@ -381,6 +381,24 @@ create sequence temp_history_id_sequence start 1 increment 50; primary key (id) ); + create table "Host" ( + repo_id text not null, + update_timestamp timestamptz, + 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[], + host_name text, + inet_addresses text[], + last_superordinate_change timestamptz, + last_transfer_time timestamptz, + superordinate_domain text, + primary key (repo_id) + ); + create table "HostHistory" ( history_revision_id int8 not null, history_by_superuser boolean not null, @@ -409,24 +427,6 @@ create sequence temp_history_id_sequence start 1 increment 50; primary key (history_revision_id) ); - create table "HostResource" ( - repo_id text not null, - update_timestamp timestamptz, - 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[], - host_name text, - inet_addresses text[], - last_superordinate_change timestamptz, - last_transfer_time timestamptz, - superordinate_domain text, - primary key (repo_id) - ); - create table "Lock" ( resource_name text not null, tld text not null, diff --git a/db/src/main/resources/sql/schema/nomulus.golden.sql b/db/src/main/resources/sql/schema/nomulus.golden.sql index c286db816..14bad5f15 100644 --- a/db/src/main/resources/sql/schema/nomulus.golden.sql +++ b/db/src/main/resources/sql/schema/nomulus.golden.sql @@ -570,6 +570,28 @@ CREATE SEQUENCE public."GracePeriod_id_seq" ALTER SEQUENCE public."GracePeriod_id_seq" OWNED BY public."GracePeriod".id; +-- +-- Name: Host; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public."Host" ( + repo_id text NOT NULL, + creation_registrar_id text, + creation_time timestamp with time zone, + current_sponsor_registrar_id text, + deletion_time timestamp with time zone, + last_epp_update_registrar_id text, + last_epp_update_time timestamp with time zone, + statuses text[], + host_name text, + last_superordinate_change timestamp with time zone, + last_transfer_time timestamp with time zone, + superordinate_domain text, + inet_addresses text[], + update_timestamp timestamp with time zone +); + + -- -- Name: HostHistory; Type: TABLE; Schema: public; Owner: - -- @@ -602,28 +624,6 @@ CREATE TABLE public."HostHistory" ( ); --- --- Name: HostResource; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public."HostResource" ( - repo_id text NOT NULL, - creation_registrar_id text, - creation_time timestamp with time zone, - current_sponsor_registrar_id text, - deletion_time timestamp with time zone, - last_epp_update_registrar_id text, - last_epp_update_time timestamp with time zone, - statuses text[], - host_name text, - last_superordinate_change timestamp with time zone, - last_transfer_time timestamp with time zone, - superordinate_domain text, - inet_addresses text[], - update_timestamp timestamp with time zone -); - - -- -- Name: Lock; Type: TABLE; Schema: public; Owner: - -- @@ -1222,11 +1222,11 @@ ALTER TABLE ONLY public."HostHistory" -- --- Name: HostResource HostResource_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- Name: Host Host_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public."HostResource" - ADD CONSTRAINT "HostResource_pkey" PRIMARY KEY (repo_id); +ALTER TABLE ONLY public."Host" + ADD CONSTRAINT "Host_pkey" PRIMARY KEY (repo_id); -- @@ -1944,7 +1944,7 @@ ALTER TABLE ONLY public."Domain" -- ALTER TABLE ONLY public."DomainHost" - ADD CONSTRAINT fk_domainhost_host_valid FOREIGN KEY (host_repo_id) REFERENCES public."HostResource"(repo_id); + ADD CONSTRAINT fk_domainhost_host_valid FOREIGN KEY (host_repo_id) REFERENCES public."Host"(repo_id); -- @@ -1964,19 +1964,19 @@ ALTER TABLE ONLY public."GracePeriod" -- --- Name: HostResource fk_host_resource_superordinate_domain; Type: FK CONSTRAINT; Schema: public; Owner: - +-- Name: Host fk_host_superordinate_domain; Type: FK CONSTRAINT; Schema: public; Owner: - -- -ALTER TABLE ONLY public."HostResource" - ADD CONSTRAINT fk_host_resource_superordinate_domain FOREIGN KEY (superordinate_domain) REFERENCES public."Domain"(repo_id); +ALTER TABLE ONLY public."Host" + ADD CONSTRAINT fk_host_superordinate_domain FOREIGN KEY (superordinate_domain) REFERENCES public."Domain"(repo_id); -- --- Name: HostHistory fk_hosthistory_hostresource; Type: FK CONSTRAINT; Schema: public; Owner: - +-- Name: HostHistory fk_hosthistory_host; Type: FK CONSTRAINT; Schema: public; Owner: - -- ALTER TABLE ONLY public."HostHistory" - ADD CONSTRAINT fk_hosthistory_hostresource FOREIGN KEY (host_repo_id) REFERENCES public."HostResource"(repo_id); + ADD CONSTRAINT fk_hosthistory_host FOREIGN KEY (host_repo_id) REFERENCES public."Host"(repo_id); -- @@ -2000,7 +2000,7 @@ ALTER TABLE ONLY public."PollMessage" -- ALTER TABLE ONLY public."PollMessage" - ADD CONSTRAINT fk_poll_message_host_repo_id FOREIGN KEY (host_repo_id) REFERENCES public."HostResource"(repo_id); + ADD CONSTRAINT fk_poll_message_host_repo_id FOREIGN KEY (host_repo_id) REFERENCES public."Host"(repo_id); --