mirror of
https://github.com/google/nomulus.git
synced 2025-08-02 16:02:10 +02:00
Restore ofy keys in GracePeriod objects (#846)
* Restore ofy keys in GracePeriod objects Restore the ofy keys when loading GracePeriod object from SQL. There's no clear way to do this using the normal approach (fix-up during a PostLoad method) because fixups to these violate immutability after hibernate has already obtained their hash values. Instead, we force reconstitution of the ofy keys in all public methods that access them (including equals() and hashCode()) so that they can be generated before an invalid hash is generated. As part of this change, convert the GracePeriod id from an autogenerated sequence to a UUID allocated from ObjectifyService and enhance ImmutableObject to allow it to exclude certain fields from hash/equals and print. The ImmutableObject enhancements are necessary because we compare grace periods against locally created test objects in a number of unit tests and there's no way this can work with GracePeriods loaded from SQL currently, as they will have an identifier field generated from the database and the test objects will have an identifier field of null (or a new unique value, after this change). Removing autogeneration from GracePeriod ids ended up being likely not strictly necessary for this change (it was a consequence of an earlier iteration). However, it does alleviate the problem of mutation of an immutable object after creation and is more in line with how we've decided to allocate other identifiers. * Changed needed after rebase.
This commit is contained in:
parent
576c05ff5f
commit
86bdd154bc
20 changed files with 1625 additions and 1406 deletions
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -64,3 +64,4 @@ V63__add_schema_for_ds_data.sql
|
|||
V64__transfer_history_columns.sql
|
||||
V65__local_date_date_type.sql
|
||||
V66__create_rde_revision.sql
|
||||
V67__grace_period_history_ids.sql
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
-- 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" ADD COLUMN billing_event_history_id int8;
|
||||
ALTER TABLE "GracePeriod" ADD COLUMN billing_recurrence_history_id int8;
|
||||
|
||||
ALTER TABLE ONLY public."GracePeriod"
|
||||
DROP CONSTRAINT fk2mys4hojm6ev2g9tmy5aq6m7g;
|
||||
ALTER TABLE ONLY public."GracePeriod"
|
||||
ADD CONSTRAINT fk_grace_period_domain_repo_id
|
||||
FOREIGN KEY (domain_repo_id) REFERENCES public."Domain"(repo_id)
|
||||
DEFERRABLE INITIALLY DEFERRED;
|
||||
|
||||
ALTER TABLE "GracePeriod" ALTER COLUMN id drop default;
|
||||
DROP SEQUENCE "GracePeriod_id_seq";
|
|
@ -383,9 +383,11 @@
|
|||
);
|
||||
|
||||
create table "GracePeriod" (
|
||||
id bigserial not null,
|
||||
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,
|
||||
|
|
|
@ -515,29 +515,12 @@ CREATE TABLE public."GracePeriod" (
|
|||
registrar_id text NOT NULL,
|
||||
domain_repo_id text NOT NULL,
|
||||
expiration_time timestamp with time zone NOT NULL,
|
||||
type text NOT NULL
|
||||
type text NOT NULL,
|
||||
billing_event_history_id bigint,
|
||||
billing_recurrence_history_id bigint
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: GracePeriod_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE public."GracePeriod_id_seq"
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: GracePeriod_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE public."GracePeriod_id_seq" OWNED BY public."GracePeriod".id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: Host; Type: TABLE; Schema: public; Owner: -
|
||||
--
|
||||
|
@ -977,13 +960,6 @@ ALTER TABLE ONLY public."ClaimsList" ALTER COLUMN revision_id SET DEFAULT nextva
|
|||
ALTER TABLE ONLY public."DomainTransactionRecord" ALTER COLUMN id SET DEFAULT nextval('public."DomainTransactionRecord_id_seq"'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: GracePeriod id; Type: DEFAULT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public."GracePeriod" ALTER COLUMN id SET DEFAULT nextval('public."GracePeriod_id_seq"'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: PremiumList revision_id; Type: DEFAULT; Schema: public; Owner: -
|
||||
--
|
||||
|
@ -1640,14 +1616,6 @@ ALTER TABLE ONLY public."RegistryLock"
|
|||
ADD CONSTRAINT fk2lhcwpxlnqijr96irylrh1707 FOREIGN KEY (relock_revision_id) REFERENCES public."RegistryLock"(revision_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: GracePeriod fk2mys4hojm6ev2g9tmy5aq6m7g; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public."GracePeriod"
|
||||
ADD CONSTRAINT fk2mys4hojm6ev2g9tmy5aq6m7g FOREIGN KEY (domain_repo_id) REFERENCES public."Domain"(repo_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: Domain fk2u3srsfbei272093m3b3xwj23; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
@ -1896,6 +1864,14 @@ ALTER TABLE ONLY public."GracePeriod"
|
|||
ADD CONSTRAINT fk_grace_period_billing_recurrence_id FOREIGN KEY (billing_recurrence_id) REFERENCES public."BillingRecurrence"(billing_recurrence_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: GracePeriod fk_grace_period_domain_repo_id; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public."GracePeriod"
|
||||
ADD CONSTRAINT fk_grace_period_domain_repo_id FOREIGN KEY (domain_repo_id) REFERENCES public."Domain"(repo_id) DEFERRABLE INITIALLY DEFERRED;
|
||||
|
||||
|
||||
--
|
||||
-- Name: Host fk_host_superordinate_domain; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue