diff --git a/core/src/main/java/google/registry/model/tld/Tld.java b/core/src/main/java/google/registry/model/tld/Tld.java index d3be2d3de..9985cce74 100644 --- a/core/src/main/java/google/registry/model/tld/Tld.java +++ b/core/src/main/java/google/registry/model/tld/Tld.java @@ -458,10 +458,10 @@ public class Tld extends ImmutableObject implements Buildable, UnsafeSerializabl @JsonDeserialize(using = CurrencyDeserializer.class) CurrencyUnit currency = DEFAULT_CURRENCY; - // TODO(sarahbot@): Remove this field and make createBillingCostTransitions not-null once all TLDs - // are populated with a create cost transition map + // TODO(sarahbot@): Remove this field once all saved configuration files have this field removed /** The per-year billing cost for registering a new domain name. */ @Deprecated + @JsonIgnore @Type(type = JodaMoneyType.TYPE_NAME) @Columns( columns = { @@ -470,10 +470,10 @@ public class Tld extends ImmutableObject implements Buildable, UnsafeSerializabl }) Money createBillingCost = DEFAULT_CREATE_BILLING_COST; - // TODO(sarahbot@): Make this field not null in the database // TODO(sarahbot@): Rename this field to createBillingCost once the old createBillingCost has been // removed /** A property that transitions to different create billing costs at different times. */ + @Column(nullable = false) @JsonDeserialize(using = TimedTransitionPropertyMoneyDeserializer.class) TimedTransitionProperty createBillingCostTransitions = TimedTransitionProperty.withInitialValue(DEFAULT_CREATE_BILLING_COST); @@ -1165,10 +1165,6 @@ public class Tld extends ImmutableObject implements Buildable, UnsafeSerializabl // here to catch cases where we loaded an invalid TimedTransitionProperty from the database // and cloned it into a new builder, to block re-building a Tld in an invalid state. instance.tldStateTransitions.checkValidity(); - // TODO(sarahbot@): Remove null check when createBillingCostTransitions field is made not-null - checkArgumentNotNull( - instance.getCreateBillingCostTransitions(), - "CreateBillingCostTransitions cannot be null"); instance.createBillingCostTransitions.checkValidity(); instance.renewBillingCostTransitions.checkValidity(); instance.eapFeeSchedule.checkValidity(); diff --git a/core/src/test/java/google/registry/model/tld/TldTest.java b/core/src/test/java/google/registry/model/tld/TldTest.java index ae401b14d..d18e0cd7c 100644 --- a/core/src/test/java/google/registry/model/tld/TldTest.java +++ b/core/src/test/java/google/registry/model/tld/TldTest.java @@ -45,7 +45,6 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedMap; import google.registry.dns.writer.VoidDnsWriter; import google.registry.model.EntityTestCase; -import google.registry.model.common.TimedTransitionProperty; import google.registry.model.domain.token.AllocationToken; import google.registry.model.tld.Tld.TldNotFoundException; import google.registry.model.tld.Tld.TldState; @@ -149,8 +148,8 @@ public final class TldTest extends EntityTestCase { .asBuilder() .setDnsAPlusAaaaTtl(Duration.standardHours(1)) .setDnsWriters(ImmutableSet.of("baz", "bang")) - .setCreateBillingCostTransitions( - TimedTransitionProperty.withInitialValue(Money.of(USD, 13)).toValueMap()) + // set create billing cost back to the default (database helper sets it to $13) + .setCreateBillingCost(Money.of(USD, 8)) .setEapFeeSchedule( ImmutableSortedMap.of( START_OF_TIME, @@ -172,12 +171,7 @@ public final class TldTest extends EntityTestCase { @Test void testSuccess_tldYamlRoundtrip() throws Exception { - Tld testTld = - createTld("test") - .asBuilder() - .setCreateBillingCostTransitions( - TimedTransitionProperty.withInitialValue(Money.of(USD, 8)).toValueMap()) - .build(); + Tld testTld = createTld("test").asBuilder().setCreateBillingCost(Money.of(USD, 8)).build(); ObjectMapper mapper = createObjectMapper(); String yaml = mapper.writeValueAsString(testTld); Tld constructedTld = mapper.readValue(yaml, Tld.class); diff --git a/core/src/test/java/google/registry/tools/ConfigureTldCommandTest.java b/core/src/test/java/google/registry/tools/ConfigureTldCommandTest.java index 26b335b93..389ecfad8 100644 --- a/core/src/test/java/google/registry/tools/ConfigureTldCommandTest.java +++ b/core/src/test/java/google/registry/tools/ConfigureTldCommandTest.java @@ -187,6 +187,16 @@ public class ConfigureTldCommandTest extends CommandTestCase generated on - 2024-03-28 21:10:10.784013213 + 2024-04-17 19:49:33.30624492 last flyway file - V166__drop_should_publish_column.sql + V167__creat_billing_cost_transitions_not_null.sql @@ -277,11 +277,11 @@ td.section { SchemaCrawler_Diagram - generated by - SchemaCrawler 16.10.1 - generated on - 2024-03-28 21:10:10.784013213 - + generated by + SchemaCrawler 16.10.1 + generated on + 2024-04-17 19:49:33.30624492 + allocationtoken_a08ccbef diff --git a/db/src/main/resources/sql/er_diagram/full_er_diagram.html b/db/src/main/resources/sql/er_diagram/full_er_diagram.html index d50eb827e..4587f50ac 100644 --- a/db/src/main/resources/sql/er_diagram/full_er_diagram.html +++ b/db/src/main/resources/sql/er_diagram/full_er_diagram.html @@ -261,11 +261,11 @@ td.section { </tr> <tr> <td class="property_name">generated on</td> - <td class="property_value">2024-03-28 21:10:08.34519385</td> + <td class="property_value">2024-04-17 19:49:29.701469664</td> </tr> <tr> <td class="property_name">last flyway file</td> - <td id="lastFlywayFile" class="property_value">V166__drop_should_publish_column.sql</td> + <td id="lastFlywayFile" class="property_value">V167__creat_billing_cost_transitions_not_null.sql</td> </tr> </tbody> </table> @@ -277,11 +277,11 @@ td.section { SchemaCrawler_Diagram - generated by - SchemaCrawler 16.10.1 - generated on - 2024-03-28 21:10:08.34519385 - + generated by + SchemaCrawler 16.10.1 + generated on + 2024-04-17 19:49:29.701469664 + allocationtoken_a08ccbef @@ -1626,7 +1626,7 @@ td.section { <text text-anchor="start" x="1639" y="-3319.3" font-family="Helvetica,sans-Serif" font-size="14.00">timestamptz</text> <text text-anchor="start" x="1360" y="-3300.3" font-family="Helvetica,sans-Serif" font-size="14.00">create_billing_cost_transitions</text> <text text-anchor="start" x="1631" y="-3300.3" font-family="Helvetica,sans-Serif" font-size="14.00"> </text> - <text text-anchor="start" x="1639" y="-3300.3" font-family="Helvetica,sans-Serif" font-size="14.00">"hstore"</text> + <text text-anchor="start" x="1639" y="-3300.3" font-family="Helvetica,sans-Serif" font-size="14.00">"hstore" not null</text> <polygon fill="none" stroke="#888888" points="1356.5,-3294 1356.5,-4189 1763.5,-4189 1763.5,-3294 1356.5,-3294" /> </g> <!-- domain_6c51cffa->tld_f1fa57e2 --> <g id="edge83" class="edge"> @@ -12871,7 +12871,7 @@ td.section { <tr> <td class="spacer"></td> <td class="minwidth">create_billing_cost_transitions</td> - <td class="minwidth">"hstore"</td> + <td class="minwidth">"hstore" not null</td> </tr> <tr> <td colspan="3"></td> diff --git a/db/src/main/resources/sql/flyway.txt b/db/src/main/resources/sql/flyway.txt index 632ec0e9d..6d94ef472 100644 --- a/db/src/main/resources/sql/flyway.txt +++ b/db/src/main/resources/sql/flyway.txt @@ -164,3 +164,4 @@ V163__rename_console_registrar_history_time.sql V164__rename_console_user_history_time.sql V165__add_domain_repo_id_indexes_to_more_tables.sql V166__drop_should_publish_column.sql +V167__creat_billing_cost_transitions_not_null.sql diff --git a/db/src/main/resources/sql/flyway/V167__creat_billing_cost_transitions_not_null.sql b/db/src/main/resources/sql/flyway/V167__creat_billing_cost_transitions_not_null.sql new file mode 100644 index 000000000..ca36b16c5 --- /dev/null +++ b/db/src/main/resources/sql/flyway/V167__creat_billing_cost_transitions_not_null.sql @@ -0,0 +1,18 @@ +-- Copyright 2024 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. + +-- Note: we drop the not-null constraints from the history tables but we keep them in the +-- EPP resource tables since nothing inserted there should be null + +ALTER TABLE "Tld" ALTER COLUMN create_billing_cost_transitions SET NOT NULL; 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 6fd4bdd99..0633d5005 100644 --- a/db/src/main/resources/sql/schema/db-schema.sql.generated +++ b/db/src/main/resources/sql/schema/db-schema.sql.generated @@ -739,7 +739,7 @@ claims_period_end timestamptz not null, create_billing_cost_amount numeric(19, 2), create_billing_cost_currency text, - create_billing_cost_transitions hstore, + create_billing_cost_transitions hstore not null, creation_time timestamptz not null, currency text not null, default_promo_tokens text[], diff --git a/db/src/main/resources/sql/schema/nomulus.golden.sql b/db/src/main/resources/sql/schema/nomulus.golden.sql index 3968d47c6..d66f1689d 100644 --- a/db/src/main/resources/sql/schema/nomulus.golden.sql +++ b/db/src/main/resources/sql/schema/nomulus.golden.sql @@ -1286,7 +1286,7 @@ CREATE TABLE public."Tld" ( idn_tables text[], breakglass_mode boolean DEFAULT false NOT NULL, bsa_enroll_start_time timestamp with time zone, - create_billing_cost_transitions public.hstore + create_billing_cost_transitions public.hstore NOT NULL );