Add a new recurrenceLastExpansion column to the BillingRecurrence table (#1650)

* Add a new recurrenceLastExpansion column to the BillingRecurrence table

This will be used to determine which recurrences are in scope for
expansion. Anything that has already been expanded within the past year is
automatically out of scope.

Note that the default value is set to just over a year ago, so that, initially,
everything is in scope for expansion, and then will gradually be winnowed down
over time so that most recurrences at any given point are out of scope. Newly
created recurrings (after the subsequent code change goes in) will have their
last expansion time set to the same as the event time of when the recurring is
written, such that they'll first be considered in-scope precisely one year
later.
This commit is contained in:
Ben McIlwain 2022-06-01 14:23:56 -04:00 committed by GitHub
parent c50af0beab
commit c3b64b0931
5 changed files with 1617 additions and 1554 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -114,3 +114,4 @@ V113__add_host_missing_indexes.sql
V114__add_allocation_token_indexes.sql
V115__add_renewal_columns_to_billing_recurrence.sql
V116__add_renewal_column_to_allocation_token.sql
V117__add_billing_recurrence_last_expansion_column.sql

View file

@ -0,0 +1,16 @@
-- Copyright 2022 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 "BillingRecurrence" add column recurrence_last_expansion timestamptz default '2021-06-01T00:00:00Z' not null;
create index IDXp0pxi708hlu4n40qhbtihge8x on "BillingRecurrence" (recurrence_last_expansion);

View file

@ -120,7 +120,8 @@ CREATE TABLE public."BillingRecurrence" (
recurrence_time_of_year text,
renewal_price_behavior text DEFAULT 'DEFAULT'::text NOT NULL,
renewal_price_currency text,
renewal_price_amount numeric(19,2)
renewal_price_amount numeric(19,2),
recurrence_last_expansion timestamp with time zone DEFAULT '2021-06-01 00:00:00+00'::timestamp with time zone NOT NULL
);
@ -1879,6 +1880,13 @@ CREATE INDEX idxoqttafcywwdn41um6kwlt0n8b ON public."BillingRecurrence" USING bt
CREATE INDEX idxovmntef6l45tw2bsfl56tcugx ON public."Host" USING btree (deletion_time);
--
-- Name: idxp0pxi708hlu4n40qhbtihge8x; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX idxp0pxi708hlu4n40qhbtihge8x ON public."BillingRecurrence" USING btree (recurrence_last_expansion);
--
-- Name: idxp3usbtvk0v1m14i5tdp4xnxgc; Type: INDEX; Schema: public; Owner: -
--