Make ExpandRecurringBillingEventAction SQL-aware (#1181)

There is some complication regarding how the
CancellationMatchingBillingEvent of the generated OneTime can be
reconstructed when loading from SQL. I decided to only address it in
testing as there is no real value to fully reconstruct this VKey in
production where we are either in SQL or Ofy mode, both never in both.
Therefore the VKey in a particular mode only needs to contain the
corresponding key in order to function.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/google/nomulus/1181)
<!-- Reviewable:end -->
This commit is contained in:
Lai Jiang 2021-06-03 10:21:16 -04:00 committed by GitHub
parent 586189d7ee
commit aa2898ebfc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 4755 additions and 4438 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -94,3 +94,4 @@ V93__defer_all_fkeys.sql
V94__rename_lock_scope.sql
V95__add_contacts_indexes_on_domain.sql
V96__rename_sql_checkpoint_fields.sql
V97__add_recurrence_history_id_column_to_onetime.sql

View file

@ -0,0 +1,21 @@
-- Copyright 2021 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 "BillingEvent"
ADD COLUMN IF NOT EXISTS "recurrence_history_revision_id" INT8;
ALTER TABLE "BillingEvent" ADD CONSTRAINT fk_billing_event_recurrence_history
FOREIGN KEY (domain_repo_id, recurrence_history_revision_id)
REFERENCES "DomainHistory"(domain_repo_id, history_revision_id)
DEFERRABLE INITIALLY DEFERRED;

View file

@ -63,6 +63,7 @@
cost_amount numeric(19, 2),
cost_currency text,
period_years int4,
recurrence_history_revision_id int8,
synthetic_creation_time timestamptz,
primary key (billing_event_id)
);

View file

@ -97,7 +97,8 @@ CREATE TABLE public."BillingEvent" (
cost_amount numeric(19,2),
cost_currency text,
period_years integer,
synthetic_creation_time timestamp with time zone
synthetic_creation_time timestamp with time zone,
recurrence_history_revision_id bigint
);
@ -1985,6 +1986,14 @@ ALTER TABLE ONLY public."BillingEvent"
ADD CONSTRAINT fk_billing_event_domain_history FOREIGN KEY (domain_repo_id, domain_history_revision_id) REFERENCES public."DomainHistory"(domain_repo_id, history_revision_id) DEFERRABLE INITIALLY DEFERRED;
--
-- Name: BillingEvent fk_billing_event_recurrence_history; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public."BillingEvent"
ADD CONSTRAINT fk_billing_event_recurrence_history FOREIGN KEY (domain_repo_id, recurrence_history_revision_id) REFERENCES public."DomainHistory"(domain_repo_id, history_revision_id) DEFERRABLE INITIALLY DEFERRED;
--
-- Name: BillingEvent fk_billing_event_registrar_id; Type: FK CONSTRAINT; Schema: public; Owner: -
--