From 33c20a6017757f25efced4b3d126161816062d7a Mon Sep 17 00:00:00 2001 From: Shicong Huang Date: Mon, 27 Jul 2020 13:32:39 -0400 Subject: [PATCH] Add remaining columns to Domain's SQL schema (#702) --- .../flows/domain/DomainCreateFlow.java | 4 +- .../flows/domain/DomainDeleteFlow.java | 12 ++--- .../flows/domain/DomainFlowUtils.java | 6 +-- .../flows/domain/DomainRenewFlow.java | 5 +- .../domain/DomainRestoreRequestFlow.java | 9 ++-- .../domain/DomainTransferApproveFlow.java | 4 +- .../registry/model/billing/BillingEvent.java | 4 +- .../registry/model/domain/DomainBase.java | 37 ++++++-------- .../registry/model/domain/GracePeriod.java | 38 +++++++-------- .../registry/tools/UnrenewDomainCommand.java | 5 +- .../google/registry/flows/FlowTestCase.java | 8 ++-- .../flows/domain/DomainCreateFlowTest.java | 4 +- .../flows/domain/DomainDeleteFlowTest.java | 22 ++++----- .../flows/domain/DomainInfoFlowTest.java | 12 +++-- .../flows/domain/DomainRenewFlowTest.java | 14 ++---- .../domain/DomainRestoreRequestFlowTest.java | 13 +++-- .../domain/DomainTransferApproveFlowTest.java | 9 ++-- .../domain/DomainTransferRequestFlowTest.java | 20 +++----- .../model/billing/BillingEventTest.java | 17 +++---- .../registry/model/domain/DomainBaseTest.java | 48 +++++++++---------- .../model/domain/GracePeriodTest.java | 27 ++++++----- .../rde/DomainBaseToXjcConverterTest.java | 13 +++-- .../java/google/registry/rde/RdeFixtures.java | 13 +++-- .../registry/testing/DatastoreHelper.java | 10 ++-- .../tools/UnrenewDomainCommandTest.java | 6 ++- .../google/registry/model/schema.txt | 10 ++-- .../sql/flyway/V40__add_columns_to_domain.sql | 32 +++++++++++++ .../sql/schema/db-schema.sql.generated | 7 ++- .../resources/sql/schema/nomulus.golden.sql | 29 ++++++++++- 29 files changed, 239 insertions(+), 199 deletions(-) create mode 100644 db/src/main/resources/sql/flyway/V40__add_columns_to_domain.sql diff --git a/core/src/main/java/google/registry/flows/domain/DomainCreateFlow.java b/core/src/main/java/google/registry/flows/domain/DomainCreateFlow.java index c3a002a48..87e4811b0 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainCreateFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainCreateFlow.java @@ -347,8 +347,8 @@ public class DomainCreateFlow implements TransactionalFlow { .setRepoId(repoId) .setIdnTableName(validateDomainNameWithIdnTables(domainName)) .setRegistrationExpirationTime(registrationExpirationTime) - .setAutorenewBillingEvent(Key.create(autorenewBillingEvent)) - .setAutorenewPollMessage(Key.create(autorenewPollMessage)) + .setAutorenewBillingEvent(autorenewBillingEvent.createVKey()) + .setAutorenewPollMessage(autorenewPollMessage.createVKey()) .setLaunchNotice(hasClaimsNotice ? launchCreate.get().getNotice() : null) .setSmdId(signedMarkId) .setDsData(secDnsCreate.isPresent() ? secDnsCreate.get().getDsData() : null) diff --git a/core/src/main/java/google/registry/flows/domain/DomainDeleteFlow.java b/core/src/main/java/google/registry/flows/domain/DomainDeleteFlow.java index c48e410c2..059c3f590 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainDeleteFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainDeleteFlow.java @@ -31,7 +31,6 @@ import static google.registry.model.ResourceTransferUtils.handlePendingTransferO import static google.registry.model.ResourceTransferUtils.updateForeignKeyIndexDeletionTime; import static google.registry.model.eppoutput.Result.Code.SUCCESS; import static google.registry.model.eppoutput.Result.Code.SUCCESS_WITH_ACTION_PENDING; -import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.reporting.DomainTransactionRecord.TransactionReportField.ADD_FIELDS; import static google.registry.model.reporting.DomainTransactionRecord.TransactionReportField.RENEW_FIELDS; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; @@ -209,7 +208,7 @@ public final class DomainDeleteFlow implements TransactionalFlow { PollMessage.OneTime deletePollMessage = createDeletePollMessage(existingDomain, historyEntry, deletionTime); entitiesToSave.add(deletePollMessage); - builder.setDeletePollMessage(Key.create(deletePollMessage)); + builder.setDeletePollMessage(deletePollMessage.createVKey()); } // Cancel any grace periods that were still active, and set the expiration time accordingly. @@ -222,8 +221,7 @@ public final class DomainDeleteFlow implements TransactionalFlow { if (gracePeriod.getOneTimeBillingEvent() != null) { // Take the amount of amount of registration time being refunded off the expiration time. // This can be either add grace periods or renew grace periods. - BillingEvent.OneTime oneTime = - ofy().load().key(gracePeriod.getOneTimeBillingEvent()).now(); + BillingEvent.OneTime oneTime = tm().load(gracePeriod.getOneTimeBillingEvent()); newExpirationTime = newExpirationTime.minusYears(oneTime.getPeriodYears()); } else if (gracePeriod.getRecurringBillingEvent() != null) { // Take 1 year off the registration if in the autorenew grace period (no need to load the @@ -370,12 +368,12 @@ public final class DomainDeleteFlow implements TransactionalFlow { private Money getGracePeriodCost(GracePeriod gracePeriod, DateTime now) { if (gracePeriod.getType() == GracePeriodStatus.AUTO_RENEW) { DateTime autoRenewTime = - ofy().load().key(checkNotNull(gracePeriod.getRecurringBillingEvent())).now() + tm().load(checkNotNull(gracePeriod.getRecurringBillingEvent())) .getRecurrenceTimeOfYear() - .getLastInstanceBeforeOrAt(now); + .getLastInstanceBeforeOrAt(now); return getDomainRenewCost(targetId, autoRenewTime, 1); } - return ofy().load().key(checkNotNull(gracePeriod.getOneTimeBillingEvent())).now().getCost(); + return tm().load(checkNotNull(gracePeriod.getOneTimeBillingEvent())).getCost(); } @Nullable diff --git a/core/src/main/java/google/registry/flows/domain/DomainFlowUtils.java b/core/src/main/java/google/registry/flows/domain/DomainFlowUtils.java index 32616c7bc..00b4a8fdf 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainFlowUtils.java +++ b/core/src/main/java/google/registry/flows/domain/DomainFlowUtils.java @@ -517,14 +517,14 @@ public class DomainFlowUtils { */ public static void updateAutorenewRecurrenceEndTime(DomainBase domain, DateTime newEndTime) { Optional autorenewPollMessage = - Optional.ofNullable(ofy().load().key(domain.getAutorenewPollMessage()).now()); + tm().maybeLoad(domain.getAutorenewPollMessage()); // Construct an updated autorenew poll message. If the autorenew poll message no longer exists, // create a new one at the same id. This can happen if a transfer was requested on a domain // where all autorenew poll messages had already been delivered (this would cause the poll // message to be deleted), and then subsequently the transfer was canceled, rejected, or deleted // (which would cause the poll message to be recreated here). - Key existingAutorenewKey = domain.getAutorenewPollMessage(); + Key existingAutorenewKey = domain.getAutorenewPollMessage().getOfyKey(); PollMessage.Autorenew updatedAutorenewPollMessage = autorenewPollMessage.isPresent() ? autorenewPollMessage.get().asBuilder().setAutorenewEndTime(newEndTime).build() @@ -542,7 +542,7 @@ public class DomainFlowUtils { ofy().save().entity(updatedAutorenewPollMessage); } - Recurring recurring = ofy().load().key(domain.getAutorenewBillingEvent()).now(); + Recurring recurring = tm().load(domain.getAutorenewBillingEvent()); ofy().save().entity(recurring.asBuilder().setRecurrenceEndTime(newEndTime).build()); } diff --git a/core/src/main/java/google/registry/flows/domain/DomainRenewFlow.java b/core/src/main/java/google/registry/flows/domain/DomainRenewFlow.java index d8871853a..1267f9b9f 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainRenewFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainRenewFlow.java @@ -33,7 +33,6 @@ import static google.registry.util.DateTimeUtils.leapSafeAddYears; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; -import com.googlecode.objectify.Key; import google.registry.flows.EppException; import google.registry.flows.EppException.ParameterValueRangeErrorException; import google.registry.flows.ExtensionManager; @@ -181,8 +180,8 @@ public final class DomainRenewFlow implements TransactionalFlow { .setLastEppUpdateTime(now) .setLastEppUpdateClientId(clientId) .setRegistrationExpirationTime(newExpirationTime) - .setAutorenewBillingEvent(Key.create(newAutorenewEvent)) - .setAutorenewPollMessage(Key.create(newAutorenewPollMessage)) + .setAutorenewBillingEvent(newAutorenewEvent.createVKey()) + .setAutorenewPollMessage(newAutorenewPollMessage.createVKey()) .addGracePeriod( GracePeriod.forBillingEvent(GracePeriodStatus.RENEW, explicitRenewEvent)) .build(); diff --git a/core/src/main/java/google/registry/flows/domain/DomainRestoreRequestFlow.java b/core/src/main/java/google/registry/flows/domain/DomainRestoreRequestFlow.java index 24606095c..f7899a372 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainRestoreRequestFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainRestoreRequestFlow.java @@ -26,7 +26,6 @@ import static google.registry.flows.domain.DomainFlowUtils.verifyNotReserved; import static google.registry.flows.domain.DomainFlowUtils.verifyPremiumNameIsNotBlocked; import static google.registry.flows.domain.DomainFlowUtils.verifyRegistrarIsActive; import static google.registry.model.ResourceTransferUtils.updateForeignKeyIndexDeletionTime; -import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.util.DateTimeUtils.END_OF_TIME; @@ -174,8 +173,8 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow { existingDomain, newExpirationTime, autorenewEvent, autorenewPollMessage, now, clientId); updateForeignKeyIndexDeletionTime(newDomain); entitiesToSave.add(newDomain, historyEntry, autorenewEvent, autorenewPollMessage); - ofy().save().entities(entitiesToSave.build()); - ofy().delete().key(existingDomain.getDeletePollMessage()); + tm().saveNewOrUpdateAll(entitiesToSave.build()); + tm().delete(existingDomain.getDeletePollMessage()); dnsQueue.addDomainRefreshTask(existingDomain.getDomainName()); return responseBuilder .setExtensions(createResponseExtensions(feesAndCredits, feeUpdate, isExpired)) @@ -232,8 +231,8 @@ public final class DomainRestoreRequestFlow implements TransactionalFlow { .setStatusValues(null) .setGracePeriods(null) .setDeletePollMessage(null) - .setAutorenewBillingEvent(Key.create(autorenewEvent)) - .setAutorenewPollMessage(Key.create(autorenewPollMessage)) + .setAutorenewBillingEvent(autorenewEvent.createVKey()) + .setAutorenewPollMessage(autorenewPollMessage.createVKey()) .setLastEppUpdateTime(now) .setLastEppUpdateClientId(clientId) .build(); diff --git a/core/src/main/java/google/registry/flows/domain/DomainTransferApproveFlow.java b/core/src/main/java/google/registry/flows/domain/DomainTransferApproveFlow.java index a86392ef8..3865af460 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainTransferApproveFlow.java +++ b/core/src/main/java/google/registry/flows/domain/DomainTransferApproveFlow.java @@ -186,8 +186,8 @@ public final class DomainTransferApproveFlow implements TransactionalFlow { .setTransferredRegistrationExpirationTime(newExpirationTime) .build()) .setRegistrationExpirationTime(newExpirationTime) - .setAutorenewBillingEvent(Key.create(autorenewEvent)) - .setAutorenewPollMessage(Key.create(gainingClientAutorenewPollMessage)) + .setAutorenewBillingEvent(autorenewEvent.createVKey()) + .setAutorenewPollMessage(gainingClientAutorenewPollMessage.createVKey()) // Remove all the old grace periods and add a new one for the transfer. .setGracePeriods( billingEvent.isPresent() diff --git a/core/src/main/java/google/registry/model/billing/BillingEvent.java b/core/src/main/java/google/registry/model/billing/BillingEvent.java index 40f43d037..043d2ce9c 100644 --- a/core/src/main/java/google/registry/model/billing/BillingEvent.java +++ b/core/src/main/java/google/registry/model/billing/BillingEvent.java @@ -630,9 +630,9 @@ public abstract class BillingEvent extends ImmutableObject .setParent(historyEntry); // Set the grace period's billing event using the appropriate Cancellation builder method. if (gracePeriod.getOneTimeBillingEvent() != null) { - builder.setOneTimeEventKey(VKey.from(gracePeriod.getOneTimeBillingEvent())); + builder.setOneTimeEventKey(gracePeriod.getOneTimeBillingEvent()); } else if (gracePeriod.getRecurringBillingEvent() != null) { - builder.setRecurringEventKey(VKey.from(gracePeriod.getRecurringBillingEvent())); + builder.setRecurringEventKey(gracePeriod.getRecurringBillingEvent()); } return builder.build(); } diff --git a/core/src/main/java/google/registry/model/domain/DomainBase.java b/core/src/main/java/google/registry/model/domain/DomainBase.java index 3f7d82ad4..b0ed78094 100644 --- a/core/src/main/java/google/registry/model/domain/DomainBase.java +++ b/core/src/main/java/google/registry/model/domain/DomainBase.java @@ -227,7 +227,8 @@ public class DomainBase extends EppResource * refer to a {@link PollMessage} timed to when the domain is fully deleted. If the domain is * restored, the message should be deleted. */ - @Transient Key deletePollMessage; + @Column(name = "deletion_poll_message_id") + VKey deletePollMessage; /** * The recurring billing event associated with this domain's autorenewals. @@ -237,7 +238,8 @@ public class DomainBase extends EppResource * {@link #registrationExpirationTime} is changed the recurrence should be closed, a new one * should be created, and this field should be updated to point to the new one. */ - @Transient Key autorenewBillingEvent; + @Column(name = "billing_recurrence_id") + VKey autorenewBillingEvent; /** * The recurring poll message associated with this domain's autorenewals. @@ -247,7 +249,8 @@ public class DomainBase extends EppResource * {@link #registrationExpirationTime} is changed the recurrence should be closed, a new one * should be created, and this field should be updated to point to the new one. */ - @Transient Key autorenewPollMessage; + @Column(name = "autorenew_poll_message_id") + VKey autorenewPollMessage; /** The unexpired grace periods for this domain (some of which may not be active yet). */ @Transient @ElementCollection Set gracePeriods; @@ -316,15 +319,15 @@ public class DomainBase extends EppResource return registrationExpirationTime; } - public Key getDeletePollMessage() { + public VKey getDeletePollMessage() { return deletePollMessage; } - public Key getAutorenewBillingEvent() { + public VKey getAutorenewBillingEvent() { return autorenewBillingEvent; } - public Key getAutorenewPollMessage() { + public VKey getAutorenewPollMessage() { return autorenewPollMessage; } @@ -453,14 +456,8 @@ public class DomainBase extends EppResource .setRegistrationExpirationTime(expirationDate) // Set the speculatively-written new autorenew events as the domain's autorenew // events. - .setAutorenewBillingEvent( - transferData.getServerApproveAutorenewEvent() == null - ? null - : transferData.getServerApproveAutorenewEvent().getOfyKey()) - .setAutorenewPollMessage( - transferData.getServerApproveAutorenewPollMessage() == null - ? null - : transferData.getServerApproveAutorenewPollMessage().getOfyKey()); + .setAutorenewBillingEvent(transferData.getServerApproveAutorenewEvent()) + .setAutorenewPollMessage(transferData.getServerApproveAutorenewPollMessage()); if (transferData.getTransferPeriod().getValue() == 1) { // Set the grace period using a key to the prescheduled transfer billing event. Not using // GracePeriod.forBillingEvent() here in order to avoid the actual Datastore fetch. @@ -471,9 +468,7 @@ public class DomainBase extends EppResource transferExpirationTime.plus( Registry.get(getTld()).getTransferGracePeriodLength()), transferData.getGainingClientId(), - transferData.getServerApproveBillingEvent() == null - ? null - : transferData.getServerApproveBillingEvent().getOfyKey()))); + transferData.getServerApproveBillingEvent()))); } else { // There won't be a billing event, so we don't need a grace period builder.setGracePeriods(ImmutableSet.of()); @@ -801,19 +796,17 @@ public class DomainBase extends EppResource return this; } - public Builder setDeletePollMessage(Key deletePollMessage) { + public Builder setDeletePollMessage(VKey deletePollMessage) { getInstance().deletePollMessage = deletePollMessage; return this; } - public Builder setAutorenewBillingEvent( - Key autorenewBillingEvent) { + public Builder setAutorenewBillingEvent(VKey autorenewBillingEvent) { getInstance().autorenewBillingEvent = autorenewBillingEvent; return this; } - public Builder setAutorenewPollMessage( - Key autorenewPollMessage) { + public Builder setAutorenewPollMessage(VKey autorenewPollMessage) { getInstance().autorenewPollMessage = autorenewPollMessage; return this; } diff --git a/core/src/main/java/google/registry/model/domain/GracePeriod.java b/core/src/main/java/google/registry/model/domain/GracePeriod.java index e8c4c977c..5b5aa12a5 100644 --- a/core/src/main/java/google/registry/model/domain/GracePeriod.java +++ b/core/src/main/java/google/registry/model/domain/GracePeriod.java @@ -17,12 +17,13 @@ package google.registry.model.domain; import static com.google.common.base.Preconditions.checkArgument; import static google.registry.util.PreconditionsUtils.checkArgumentNotNull; -import com.googlecode.objectify.Key; import com.googlecode.objectify.annotation.Embed; import com.googlecode.objectify.annotation.Ignore; import google.registry.model.ImmutableObject; import google.registry.model.billing.BillingEvent; +import google.registry.model.billing.BillingEvent.Recurring; import google.registry.model.domain.rgp.GracePeriodStatus; +import google.registry.persistence.VKey; import javax.annotation.Nullable; import javax.persistence.Column; import javax.persistence.GeneratedValue; @@ -57,18 +58,18 @@ public class GracePeriod extends ImmutableObject { /** * The one-time billing event corresponding to the action that triggered this grace period, or - * null if not applicable. Not set for autorenew grace periods (which instead use the field - * {@code billingEventRecurring}) or for redemption grace periods (since deletes have no cost). + * null if not applicable. Not set for autorenew grace periods (which instead use the field {@code + * billingEventRecurring}) or for redemption grace periods (since deletes have no cost). */ // NB: Would @IgnoreSave(IfNull.class), but not allowed for @Embed collections. - Key billingEventOneTime = null; + VKey billingEventOneTime = null; /** * The recurring billing event corresponding to the action that triggered this grace period, if * applicable - i.e. if the action was an autorenew - or null in all other cases. */ // NB: Would @IgnoreSave(IfNull.class), but not allowed for @Embed collections. - Key billingEventRecurring = null; + VKey billingEventRecurring = null; public GracePeriodStatus getType() { return type; @@ -91,8 +92,7 @@ public class GracePeriod extends ImmutableObject { * Returns the one time billing event. The value will only be non-null if the type of this grace * period is not AUTO_RENEW. */ - - public Key getOneTimeBillingEvent() { + public VKey getOneTimeBillingEvent() { return billingEventOneTime; } @@ -100,16 +100,16 @@ public class GracePeriod extends ImmutableObject { * Returns the recurring billing event. The value will only be non-null if the type of this grace * period is AUTO_RENEW. */ - public Key getRecurringBillingEvent() { + public VKey getRecurringBillingEvent() { return billingEventRecurring; } private static GracePeriod createInternal( - GracePeriodStatus type, - DateTime expirationTime, - String clientId, - @Nullable Key billingEventOneTime, - @Nullable Key billingEventRecurring) { + GracePeriodStatus type, + DateTime expirationTime, + String clientId, + @Nullable VKey billingEventOneTime, + @Nullable VKey billingEventRecurring) { checkArgument((billingEventOneTime == null) || (billingEventRecurring == null), "A grace period can have at most one billing event"); checkArgument( @@ -127,15 +127,15 @@ public class GracePeriod extends ImmutableObject { /** * Creates a GracePeriod for an (optional) OneTime billing event. * - *

Normal callers should always use {@link #forBillingEvent} instead, assuming they do not - * need to avoid loading the BillingEvent from Datastore. This method should typically be - * called only from test code to explicitly construct GracePeriods. + *

Normal callers should always use {@link #forBillingEvent} instead, assuming they do not need + * to avoid loading the BillingEvent from Datastore. This method should typically be called only + * from test code to explicitly construct GracePeriods. */ public static GracePeriod create( GracePeriodStatus type, DateTime expirationTime, String clientId, - @Nullable Key billingEventOneTime) { + @Nullable VKey billingEventOneTime) { return createInternal(type, expirationTime, clientId, billingEventOneTime, null); } @@ -144,7 +144,7 @@ public class GracePeriod extends ImmutableObject { GracePeriodStatus type, DateTime expirationTime, String clientId, - Key billingEventRecurring) { + VKey billingEventRecurring) { checkArgumentNotNull(billingEventRecurring, "billingEventRecurring cannot be null"); return createInternal(type, expirationTime, clientId, null, billingEventRecurring); } @@ -159,6 +159,6 @@ public class GracePeriod extends ImmutableObject { public static GracePeriod forBillingEvent( GracePeriodStatus type, BillingEvent.OneTime billingEvent) { return create( - type, billingEvent.getBillingTime(), billingEvent.getClientId(), Key.create(billingEvent)); + type, billingEvent.getBillingTime(), billingEvent.getClientId(), billingEvent.createVKey()); } } diff --git a/core/src/main/java/google/registry/tools/UnrenewDomainCommand.java b/core/src/main/java/google/registry/tools/UnrenewDomainCommand.java index 2b776e617..20ec9c497 100644 --- a/core/src/main/java/google/registry/tools/UnrenewDomainCommand.java +++ b/core/src/main/java/google/registry/tools/UnrenewDomainCommand.java @@ -31,7 +31,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; -import com.googlecode.objectify.Key; import google.registry.model.billing.BillingEvent; import google.registry.model.domain.DomainBase; import google.registry.model.domain.Period; @@ -224,8 +223,8 @@ class UnrenewDomainCommand extends ConfirmingCommand implements CommandWithRemot .setRegistrationExpirationTime(newExpirationTime) .setLastEppUpdateTime(now) .setLastEppUpdateClientId(domain.getCurrentSponsorClientId()) - .setAutorenewBillingEvent(Key.create(newAutorenewEvent)) - .setAutorenewPollMessage(Key.create(newAutorenewPollMessage)) + .setAutorenewBillingEvent(newAutorenewEvent.createVKey()) + .setAutorenewPollMessage(newAutorenewPollMessage.createVKey()) .build(); // In order to do it'll need to write out a new HistoryEntry (likely of type SYNTHETIC), a new // autorenew billing event and poll message, and a new one time poll message at the present time diff --git a/core/src/test/java/google/registry/flows/FlowTestCase.java b/core/src/test/java/google/registry/flows/FlowTestCase.java index 8d0932448..b1bafc52f 100644 --- a/core/src/test/java/google/registry/flows/FlowTestCase.java +++ b/core/src/test/java/google/registry/flows/FlowTestCase.java @@ -22,6 +22,7 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; import static google.registry.model.eppcommon.EppXmlTransformer.marshal; import static google.registry.model.ofy.ObjectifyService.ofy; +import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.testing.DatastoreHelper.POLL_MESSAGE_ID_STRIPPER; import static google.registry.testing.DatastoreHelper.getPollMessages; import static google.registry.testing.DatastoreHelper.stripBillingEventId; @@ -196,12 +197,9 @@ public abstract class FlowTestCase { assertWithMessage("Billing event is present for grace period: " + gracePeriod) .that(gracePeriod.hasBillingEvent()) .isTrue(); - return ofy() - .load() - .key( + return tm().load( firstNonNull( - gracePeriod.getOneTimeBillingEvent(), gracePeriod.getRecurringBillingEvent())) - .now(); + gracePeriod.getOneTimeBillingEvent(), gracePeriod.getRecurringBillingEvent())); } /** diff --git a/core/src/test/java/google/registry/flows/domain/DomainCreateFlowTest.java b/core/src/test/java/google/registry/flows/domain/DomainCreateFlowTest.java index 81a105a59..2349b7509 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainCreateFlowTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainCreateFlowTest.java @@ -31,6 +31,7 @@ import static google.registry.model.registry.Registry.TldState.GENERAL_AVAILABIL import static google.registry.model.registry.Registry.TldState.PREDELEGATION; import static google.registry.model.registry.Registry.TldState.QUIET_PERIOD; import static google.registry.model.registry.Registry.TldState.START_DATE_SUNRISE; +import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.pricing.PricingEngineProxy.isDomainPremium; import static google.registry.testing.DatastoreHelper.assertBillingEvents; import static google.registry.testing.DatastoreHelper.assertPollMessagesForResource; @@ -257,8 +258,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase historyEntry = + Key.create(domain.createVKey().getOfyKey(), HistoryEntry.class, 67890); + VKey recurringVKey = + VKey.from(Key.create(historyEntry, Recurring.class, 12345)); // Add an AUTO_RENEW grace period to the saved resource. persistResource( domain .asBuilder() .addGracePeriod( GracePeriod.createForRecurring( - GracePeriodStatus.AUTO_RENEW, - clock.nowUtc().plusDays(1), - "foo", - Key.create(Recurring.class, 12345))) + GracePeriodStatus.AUTO_RENEW, clock.nowUtc().plusDays(1), "foo", recurringVKey)) .build()); doSuccessfulTest("domain_info_response_autorenewperiod.xml", false); } diff --git a/core/src/test/java/google/registry/flows/domain/DomainRenewFlowTest.java b/core/src/test/java/google/registry/flows/domain/DomainRenewFlowTest.java index eb7910884..ba981aaa1 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainRenewFlowTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainRenewFlowTest.java @@ -16,7 +16,7 @@ package google.registry.flows.domain; import static com.google.common.truth.Truth.assertThat; import static google.registry.flows.domain.DomainTransferFlowTestCase.persistWithPendingTransfer; -import static google.registry.model.ofy.ObjectifyService.ofy; +import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.testing.DatastoreHelper.assertBillingEvents; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.getOnlyHistoryEntryOfType; @@ -38,7 +38,6 @@ import static org.junit.Assert.assertThrows; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSortedMap; -import com.googlecode.objectify.Key; import google.registry.flows.EppException; import google.registry.flows.FlowUtils.UnknownCurrencyEppException; import google.registry.flows.ResourceFlowTestCase; @@ -137,8 +136,8 @@ class DomainRenewFlowTest extends ResourceFlowTestCase existingAutorenewEvent = domain.getAutorenewBillingEvent(); + VKey existingAutorenewEvent = domain.getAutorenewBillingEvent(); // Set domain to have auto-renewed just before the transfer request, so that it will have an // active autorenew grace period spanning the entire transfer window. DateTime autorenewTime = clock.nowUtc().minusDays(1); diff --git a/core/src/test/java/google/registry/flows/domain/DomainTransferRequestFlowTest.java b/core/src/test/java/google/registry/flows/domain/DomainTransferRequestFlowTest.java index 04cd97a71..ecb2cd475 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainTransferRequestFlowTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainTransferRequestFlowTest.java @@ -318,8 +318,7 @@ class DomainTransferRequestFlowTest BillingEvent.class), Sets.union(expectedServeApproveBillingEvents, extraBillingEvents)); // The domain's autorenew billing event should still point to the losing client's event. - BillingEvent.Recurring domainAutorenewEvent = - ofy().load().key(domain.getAutorenewBillingEvent()).now(); + BillingEvent.Recurring domainAutorenewEvent = tm().load(domain.getAutorenewBillingEvent()); assertThat(domainAutorenewEvent.getClientId()).isEqualTo("TheRegistrar"); assertThat(domainAutorenewEvent.getRecurrenceEndTime()).isEqualTo(implicitTransferTime); // The original grace periods should remain untouched. @@ -446,12 +445,7 @@ class DomainTransferRequestFlowTest .hasLastEppUpdateTime(implicitTransferTime) .and() .hasLastEppUpdateClientId("NewRegistrar"); - assertThat( - ofy() - .load() - .key(domainAfterAutomaticTransfer.getAutorenewBillingEvent()) - .now() - .getEventTime()) + assertThat(tm().load(domainAfterAutomaticTransfer.getAutorenewBillingEvent()).getEventTime()) .isEqualTo(expectedExpirationTime); // And after the expected grace time, the grace period should be gone. DomainBase afterGracePeriod = @@ -955,7 +949,7 @@ class DomainTransferRequestFlowTest void testSuccess_superuserExtension_zeroPeriod_autorenewGraceActive() throws Exception { eppRequestSource = EppRequestSource.TOOL; setupDomain("example", "tld"); - Key existingAutorenewEvent = domain.getAutorenewBillingEvent(); + VKey existingAutorenewEvent = domain.getAutorenewBillingEvent(); // Set domain to have auto-renewed just before the transfer request, so that it will have an // active autorenew grace period spanning the entire transfer window. DateTime autorenewTime = clock.nowUtc().minusDays(1); @@ -1110,7 +1104,7 @@ class DomainTransferRequestFlowTest @Test void testSuccess_autorenewGraceActive_throughoutTransferWindow() throws Exception { setupDomain("example", "tld"); - Key existingAutorenewEvent = domain.getAutorenewBillingEvent(); + VKey existingAutorenewEvent = domain.getAutorenewBillingEvent(); // Set domain to have auto-renewed just before the transfer request, so that it will have an // active autorenew grace period spanning the entire transfer window. DateTime autorenewTime = clock.nowUtc().minusDays(1); @@ -1142,13 +1136,13 @@ class DomainTransferRequestFlowTest .setEventTime(clock.nowUtc().plus(Registry.get("tld").getAutomaticTransferLength())) .setBillingTime(autorenewTime.plus(Registry.get("tld").getAutoRenewGracePeriodLength())) // The cancellation should refer to the old autorenew billing event. - .setRecurringEventKey(VKey.from(existingAutorenewEvent))); + .setRecurringEventKey(existingAutorenewEvent)); } @Test void testSuccess_autorenewGraceActive_onlyAtAutomaticTransferTime() throws Exception { setupDomain("example", "tld"); - Key existingAutorenewEvent = domain.getAutorenewBillingEvent(); + VKey existingAutorenewEvent = domain.getAutorenewBillingEvent(); // Set domain to expire in 1 day, so that it will be in the autorenew grace period by the // automatic transfer time, even though it isn't yet. DateTime expirationTime = clock.nowUtc().plusDays(1); @@ -1170,7 +1164,7 @@ class DomainTransferRequestFlowTest .setBillingTime( expirationTime.plus(Registry.get("tld").getAutoRenewGracePeriodLength())) // The cancellation should refer to the old autorenew billing event. - .setRecurringEventKey(VKey.from(existingAutorenewEvent))); + .setRecurringEventKey(existingAutorenewEvent)); } @Test diff --git a/core/src/test/java/google/registry/model/billing/BillingEventTest.java b/core/src/test/java/google/registry/model/billing/BillingEventTest.java index 8275617fd..ae3b8da12 100644 --- a/core/src/test/java/google/registry/model/billing/BillingEventTest.java +++ b/core/src/test/java/google/registry/model/billing/BillingEventTest.java @@ -396,14 +396,15 @@ public class BillingEventTest extends EntityTestCase { @Test void testSuccess_cancellation_forGracePeriod_withRecurring() { - BillingEvent.Cancellation newCancellation = BillingEvent.Cancellation.forGracePeriod( - GracePeriod.createForRecurring( - GracePeriodStatus.AUTO_RENEW, - now.plusYears(1).plusDays(45), - "a registrar", - Key.create(recurring)), - historyEntry2, - "foo.tld"); + BillingEvent.Cancellation newCancellation = + BillingEvent.Cancellation.forGracePeriod( + GracePeriod.createForRecurring( + GracePeriodStatus.AUTO_RENEW, + now.plusYears(1).plusDays(45), + "a registrar", + recurring.createVKey()), + historyEntry2, + "foo.tld"); // Set ID to be the same to ignore for the purposes of comparison. newCancellation = newCancellation.asBuilder().setId(cancellationRecurring.getId()).build(); assertThat(newCancellation).isEqualTo(cancellationRecurring); diff --git a/core/src/test/java/google/registry/model/domain/DomainBaseTest.java b/core/src/test/java/google/registry/model/domain/DomainBaseTest.java index e1db6b079..8c03174a6 100644 --- a/core/src/test/java/google/registry/model/domain/DomainBaseTest.java +++ b/core/src/test/java/google/registry/model/domain/DomainBaseTest.java @@ -64,19 +64,19 @@ import org.junit.jupiter.api.Test; public class DomainBaseTest extends EntityTestCase { private DomainBase domain; - private Key oneTimeBillKey; - private Key recurringBillKey; - private Key domainKey; + private VKey oneTimeBillKey; + private VKey recurringBillKey; + private VKey domainKey; @BeforeEach void setUp() { createTld("com"); - domainKey = Key.create(null, DomainBase.class, "4-COM"); + domainKey = VKey.from(Key.create(null, DomainBase.class, "4-COM")); VKey hostKey = persistResource( new HostResource.Builder() .setHostName("ns1.example.com") - .setSuperordinateDomain(VKey.from(domainKey)) + .setSuperordinateDomain(domainKey) .setRepoId("1-COM") .build()) .createVKey(); @@ -95,13 +95,14 @@ public class DomainBaseTest extends EntityTestCase { .build()) .createVKey(); Key historyEntryKey = - Key.create(persistResource(new HistoryEntry.Builder().setParent(domainKey).build())); - oneTimeBillKey = Key.create(historyEntryKey, BillingEvent.OneTime.class, 1); - recurringBillKey = Key.create(historyEntryKey, BillingEvent.Recurring.class, 2); - Key autorenewPollKey = - Key.create(historyEntryKey, PollMessage.Autorenew.class, 3); - Key onetimePollKey = - Key.create(historyEntryKey, PollMessage.OneTime.class, 1); + Key.create( + persistResource(new HistoryEntry.Builder().setParent(domainKey.getOfyKey()).build())); + oneTimeBillKey = VKey.from(Key.create(historyEntryKey, BillingEvent.OneTime.class, 1)); + recurringBillKey = VKey.from(Key.create(historyEntryKey, BillingEvent.Recurring.class, 2)); + VKey autorenewPollKey = + VKey.from(Key.create(historyEntryKey, PollMessage.Autorenew.class, 3)); + VKey onetimePollKey = + VKey.from(Key.create(historyEntryKey, PollMessage.OneTime.class, 1)); // Set up a new persisted domain entity. domain = persistResource( @@ -138,13 +139,10 @@ public class DomainBaseTest extends EntityTestCase { .setLosingClientId("losing") .setPendingTransferExpirationTime(fakeClock.nowUtc()) .setServerApproveEntities( - ImmutableSet.of( - VKey.from(oneTimeBillKey), - VKey.from(recurringBillKey), - VKey.from(autorenewPollKey))) - .setServerApproveBillingEvent(VKey.from(oneTimeBillKey)) - .setServerApproveAutorenewEvent(VKey.from(recurringBillKey)) - .setServerApproveAutorenewPollMessage(VKey.from(autorenewPollKey)) + ImmutableSet.of(oneTimeBillKey, recurringBillKey, autorenewPollKey)) + .setServerApproveBillingEvent(oneTimeBillKey) + .setServerApproveAutorenewEvent(recurringBillKey) + .setServerApproveAutorenewPollMessage(autorenewPollKey) .setTransferRequestTime(fakeClock.nowUtc().plusDays(1)) .setTransferStatus(TransferStatus.SERVER_APPROVED) .setTransferRequestTrid(Trid.create("client-trid", "server-trid")) @@ -327,7 +325,7 @@ public class DomainBaseTest extends EntityTestCase { private void assertTransferred( DomainBase domain, DateTime newExpirationTime, - Key newAutorenewEvent) { + VKey newAutorenewEvent) { assertThat(domain.getTransferData().getTransferStatus()) .isEqualTo(TransferStatus.SERVER_APPROVED); assertThat(domain.getCurrentSponsorClientId()).isEqualTo("winner"); @@ -377,8 +375,8 @@ public class DomainBaseTest extends EntityTestCase { .build(); DomainBase afterTransfer = domain.cloneProjectedAtTime(fakeClock.nowUtc().plusDays(1)); DateTime newExpirationTime = oldExpirationTime.plusYears(1); - Key serverApproveAutorenewEvent = - domain.getTransferData().getServerApproveAutorenewEvent().getOfyKey(); + VKey serverApproveAutorenewEvent = + domain.getTransferData().getServerApproveAutorenewEvent(); assertTransferred(afterTransfer, newExpirationTime, serverApproveAutorenewEvent); assertThat(afterTransfer.getGracePeriods()) .containsExactly( @@ -389,7 +387,7 @@ public class DomainBaseTest extends EntityTestCase { .plusDays(1) .plus(Registry.get("com").getTransferGracePeriodLength()), "winner", - Key.create(transferBillingEvent))); + transferBillingEvent.createVKey())); // If we project after the grace period expires all should be the same except the grace period. DomainBase afterGracePeriod = domain.cloneProjectedAtTime( @@ -747,8 +745,8 @@ public class DomainBaseTest extends EntityTestCase { .setPendingTransferExpirationTime(transferExpirationTime) .setTransferStatus(TransferStatus.PENDING) .setGainingClientId("TheRegistrar") - .setServerApproveAutorenewEvent(VKey.from(recurringBillKey)) - .setServerApproveBillingEvent(VKey.from(oneTimeBillKey)) + .setServerApproveAutorenewEvent(recurringBillKey) + .setServerApproveBillingEvent(oneTimeBillKey) .build(); domain = persistResource( diff --git a/core/src/test/java/google/registry/model/domain/GracePeriodTest.java b/core/src/test/java/google/registry/model/domain/GracePeriodTest.java index 3c49a9c3c..bc77a09b6 100644 --- a/core/src/test/java/google/registry/model/domain/GracePeriodTest.java +++ b/core/src/test/java/google/registry/model/domain/GracePeriodTest.java @@ -24,6 +24,7 @@ import google.registry.model.billing.BillingEvent.Reason; import google.registry.model.billing.BillingEvent.Recurring; import google.registry.model.domain.rgp.GracePeriodStatus; import google.registry.model.reporting.HistoryEntry; +import google.registry.persistence.VKey; import google.registry.testing.AppEngineRule; import org.joda.money.CurrencyUnit; import org.joda.money.Money; @@ -46,23 +47,25 @@ public class GracePeriodTest { @BeforeEach void before() { - onetime = new BillingEvent.OneTime.Builder() - .setEventTime(now) - .setBillingTime(now.plusDays(1)) - .setClientId("TheRegistrar") - .setCost(Money.of(CurrencyUnit.USD, 42)) - .setParent(Key.create(HistoryEntry.class, 12345)) - .setReason(Reason.CREATE) - .setPeriodYears(1) - .setTargetId("foo.google") - .build(); + onetime = + new BillingEvent.OneTime.Builder() + .setEventTime(now) + .setBillingTime(now.plusDays(1)) + .setClientId("TheRegistrar") + .setCost(Money.of(CurrencyUnit.USD, 42)) + .setParent( + Key.create(Key.create(DomainBase.class, "domain"), HistoryEntry.class, 12345)) + .setReason(Reason.CREATE) + .setPeriodYears(1) + .setTargetId("foo.google") + .build(); } @Test void testSuccess_forBillingEvent() { GracePeriod gracePeriod = GracePeriod.forBillingEvent(GracePeriodStatus.ADD, onetime); assertThat(gracePeriod.getType()).isEqualTo(GracePeriodStatus.ADD); - assertThat(gracePeriod.getOneTimeBillingEvent()).isEqualTo(Key.create(onetime)); + assertThat(gracePeriod.getOneTimeBillingEvent()).isEqualTo(onetime.createVKey()); assertThat(gracePeriod.getRecurringBillingEvent()).isNull(); assertThat(gracePeriod.getClientId()).isEqualTo("TheRegistrar"); assertThat(gracePeriod.getExpirationTime()).isEqualTo(now.plusDays(1)); @@ -100,7 +103,7 @@ public class GracePeriodTest { GracePeriodStatus.RENEW, now.plusDays(1), "TheRegistrar", - Key.create(Recurring.class, 12345))); + VKey.create(Recurring.class, 12345))); assertThat(thrown).hasMessageThat().contains("autorenew"); } } diff --git a/core/src/test/java/google/registry/rde/DomainBaseToXjcConverterTest.java b/core/src/test/java/google/registry/rde/DomainBaseToXjcConverterTest.java index 2ac43ad4e..62531db34 100644 --- a/core/src/test/java/google/registry/rde/DomainBaseToXjcConverterTest.java +++ b/core/src/test/java/google/registry/rde/DomainBaseToXjcConverterTest.java @@ -31,7 +31,6 @@ import static org.joda.money.CurrencyUnit.USD; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.net.InetAddresses; -import com.googlecode.objectify.Key; import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent.Flag; import google.registry.model.billing.BillingEvent.Reason; @@ -302,8 +301,7 @@ public class DomainBaseToXjcConverterTest { StatusValue.CLIENT_TRANSFER_PROHIBITED, StatusValue.SERVER_UPDATE_PROHIBITED)) .setAutorenewBillingEvent( - Key.create( - persistResource( + persistResource( new BillingEvent.Recurring.Builder() .setReason(Reason.RENEW) .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) @@ -312,10 +310,10 @@ public class DomainBaseToXjcConverterTest { .setEventTime(END_OF_TIME) .setRecurrenceEndTime(END_OF_TIME) .setParent(historyEntry) - .build()))) + .build()) + .createVKey()) .setAutorenewPollMessage( - Key.create( - persistResource( + persistResource( new PollMessage.Autorenew.Builder() .setTargetId("lol") .setClientId("TheRegistrar") @@ -323,7 +321,8 @@ public class DomainBaseToXjcConverterTest { .setAutorenewEndTime(END_OF_TIME) .setMsg("Domain was auto-renewed.") .setParent(historyEntry) - .build()))) + .build()) + .createVKey()) .setTransferData( new DomainTransferData.Builder() .setGainingClientId("gaining") diff --git a/core/src/test/java/google/registry/rde/RdeFixtures.java b/core/src/test/java/google/registry/rde/RdeFixtures.java index 528800c60..2dfe3fa92 100644 --- a/core/src/test/java/google/registry/rde/RdeFixtures.java +++ b/core/src/test/java/google/registry/rde/RdeFixtures.java @@ -26,7 +26,6 @@ import static org.joda.money.CurrencyUnit.USD; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.net.InetAddresses; -import com.googlecode.objectify.Key; import google.registry.model.billing.BillingEvent; import google.registry.model.billing.BillingEvent.Flag; import google.registry.model.billing.BillingEvent.Reason; @@ -147,8 +146,7 @@ final class RdeFixtures { StatusValue.CLIENT_TRANSFER_PROHIBITED, StatusValue.SERVER_UPDATE_PROHIBITED)) .setAutorenewBillingEvent( - Key.create( - persistResource( + persistResource( new BillingEvent.Recurring.Builder() .setReason(Reason.RENEW) .setFlags(ImmutableSet.of(Flag.AUTO_RENEW)) @@ -157,10 +155,10 @@ final class RdeFixtures { .setEventTime(END_OF_TIME) .setRecurrenceEndTime(END_OF_TIME) .setParent(historyEntry) - .build()))) + .build()) + .createVKey()) .setAutorenewPollMessage( - Key.create( - persistSimpleResource( + persistSimpleResource( new PollMessage.Autorenew.Builder() .setTargetId(tld) .setClientId("TheRegistrar") @@ -168,7 +166,8 @@ final class RdeFixtures { .setAutorenewEndTime(END_OF_TIME) .setMsg("Domain was auto-renewed.") .setParent(historyEntry) - .build()))) + .build()) + .createVKey()) .setTransferData( new DomainTransferData.Builder() .setGainingClientId("gaining") diff --git a/core/src/test/java/google/registry/testing/DatastoreHelper.java b/core/src/test/java/google/registry/testing/DatastoreHelper.java index fdbe52f55..4948a8c47 100644 --- a/core/src/test/java/google/registry/testing/DatastoreHelper.java +++ b/core/src/test/java/google/registry/testing/DatastoreHelper.java @@ -545,8 +545,8 @@ public class DatastoreHelper { return persistResource( domain .asBuilder() - .setAutorenewBillingEvent(Key.create(autorenewEvent)) - .setAutorenewPollMessage(Key.create(autorenewPollMessage)) + .setAutorenewBillingEvent(autorenewEvent.createVKey()) + .setAutorenewPollMessage(autorenewPollMessage.createVKey()) .build()); } @@ -588,13 +588,13 @@ public class DatastoreHelper { .build()); // Modify the existing autorenew event to reflect the pending transfer. persistResource( - ofy().load().key(domain.getAutorenewBillingEvent()).now().asBuilder() + tm().load(domain.getAutorenewBillingEvent()) + .asBuilder() .setRecurrenceEndTime(expirationTime) .build()); // Update the end time of the existing autorenew poll message. We must delete it if it has no // events left in it. - PollMessage.Autorenew autorenewPollMessage = - ofy().load().key(domain.getAutorenewPollMessage()).now(); + PollMessage.Autorenew autorenewPollMessage = tm().load(domain.getAutorenewPollMessage()); if (autorenewPollMessage.getEventTime().isBefore(expirationTime)) { persistResource( autorenewPollMessage.asBuilder() diff --git a/core/src/test/java/google/registry/tools/UnrenewDomainCommandTest.java b/core/src/test/java/google/registry/tools/UnrenewDomainCommandTest.java index e3dc984af..886bd464b 100644 --- a/core/src/test/java/google/registry/tools/UnrenewDomainCommandTest.java +++ b/core/src/test/java/google/registry/tools/UnrenewDomainCommandTest.java @@ -20,6 +20,7 @@ import static google.registry.model.eppcommon.StatusValue.PENDING_DELETE; import static google.registry.model.eppcommon.StatusValue.PENDING_TRANSFER; import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.reporting.HistoryEntry.Type.SYNTHETIC; +import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.testing.DatastoreHelper.assertBillingEventsEqual; import static google.registry.testing.DatastoreHelper.assertPollMessagesEqual; import static google.registry.testing.DatastoreHelper.createTld; @@ -119,7 +120,7 @@ public class UnrenewDomainCommandTest extends CommandTestCase> revisions; - com.googlecode.objectify.Key autorenewBillingEvent; - com.googlecode.objectify.Key autorenewPollMessage; - com.googlecode.objectify.Key deletePollMessage; google.registry.model.CreateAutoTimestamp creationTime; google.registry.model.UpdateAutoTimestamp updateTimestamp; google.registry.model.domain.DomainAuthInfo authInfo; google.registry.model.domain.launch.LaunchNotice launchNotice; google.registry.model.transfer.DomainTransferData transferData; + google.registry.persistence.VKey autorenewBillingEvent; + google.registry.persistence.VKey autorenewPollMessage; + google.registry.persistence.VKey deletePollMessage; java.lang.String creationClientId; java.lang.String currentSponsorClientId; java.lang.String fullyQualifiedDomainName; @@ -191,9 +191,9 @@ class google.registry.model.domain.DomainBase { org.joda.time.DateTime registrationExpirationTime; } class google.registry.model.domain.GracePeriod { - com.googlecode.objectify.Key billingEventOneTime; - com.googlecode.objectify.Key billingEventRecurring; google.registry.model.domain.rgp.GracePeriodStatus type; + google.registry.persistence.VKey billingEventOneTime; + google.registry.persistence.VKey billingEventRecurring; java.lang.String clientId; org.joda.time.DateTime expirationTime; } diff --git a/db/src/main/resources/sql/flyway/V40__add_columns_to_domain.sql b/db/src/main/resources/sql/flyway/V40__add_columns_to_domain.sql new file mode 100644 index 000000000..6ba3b3cad --- /dev/null +++ b/db/src/main/resources/sql/flyway/V40__add_columns_to_domain.sql @@ -0,0 +1,32 @@ +-- 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 "Domain" ADD COLUMN billing_recurrence_id int8; +ALTER TABLE "Domain" ADD COLUMN autorenew_poll_message_id int8; +ALTER TABLE "Domain" ADD COLUMN deletion_poll_message_id int8; + +ALTER TABLE IF EXISTS "Domain" + ADD CONSTRAINT fk_domain_billing_recurrence_id + FOREIGN KEY (billing_recurrence_id) + REFERENCES "BillingEvent"; + +ALTER TABLE IF EXISTS "Domain" + ADD CONSTRAINT fk_domain_autorenew_poll_message_id + FOREIGN KEY (autorenew_poll_message_id) + REFERENCES "PollMessage"; + +ALTER TABLE IF EXISTS "Domain" + ADD CONSTRAINT fk_domain_deletion_poll_message_id + FOREIGN KEY (deletion_poll_message_id) + REFERENCES "PollMessage"; 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 d968f1daf..288e25348 100644 --- a/db/src/main/resources/sql/schema/db-schema.sql.generated +++ b/db/src/main/resources/sql/schema/db-schema.sql.generated @@ -232,7 +232,10 @@ create sequence history_id_sequence start 1 increment 1; admin_contact text, auth_info_repo_id text, auth_info_value text, + billing_recurrence_id int8, + autorenew_poll_message_id int8, billing_contact text, + deletion_poll_message_id int8, domain_name text, idn_table_name text, last_transfer_time timestamptz, @@ -272,8 +275,8 @@ create sequence history_id_sequence start 1 increment 1; create table "GracePeriod" ( id bigserial not null, - billing_event_one_time bytea, - billing_event_recurring bytea, + billing_event_one_time int8, + billing_event_recurring int8, registrar_id text, expiration_time timestamptz, type int4, diff --git a/db/src/main/resources/sql/schema/nomulus.golden.sql b/db/src/main/resources/sql/schema/nomulus.golden.sql index 0933222d8..a3fcb0827 100644 --- a/db/src/main/resources/sql/schema/nomulus.golden.sql +++ b/db/src/main/resources/sql/schema/nomulus.golden.sql @@ -398,7 +398,10 @@ CREATE TABLE public."Domain" ( transfer_pending_expiration_time timestamp with time zone, transfer_request_time timestamp with time zone, transfer_status text, - update_timestamp timestamp with time zone + update_timestamp timestamp with time zone, + billing_recurrence_id bigint, + autorenew_poll_message_id bigint, + deletion_poll_message_id bigint ); @@ -1452,6 +1455,14 @@ ALTER TABLE ONLY public."Domain" ADD CONSTRAINT fk_domain_admin_contact FOREIGN KEY (admin_contact) REFERENCES public."Contact"(repo_id); +-- +-- Name: Domain fk_domain_autorenew_poll_message_id; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public."Domain" + ADD CONSTRAINT fk_domain_autorenew_poll_message_id FOREIGN KEY (autorenew_poll_message_id) REFERENCES public."PollMessage"(poll_message_id); + + -- -- Name: Domain fk_domain_billing_contact; Type: FK CONSTRAINT; Schema: public; Owner: - -- @@ -1460,6 +1471,22 @@ ALTER TABLE ONLY public."Domain" ADD CONSTRAINT fk_domain_billing_contact FOREIGN KEY (billing_contact) REFERENCES public."Contact"(repo_id); +-- +-- Name: Domain fk_domain_billing_recurrence_id; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public."Domain" + ADD CONSTRAINT fk_domain_billing_recurrence_id FOREIGN KEY (billing_recurrence_id) REFERENCES public."BillingEvent"(billing_event_id); + + +-- +-- Name: Domain fk_domain_deletion_poll_message_id; Type: FK CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public."Domain" + ADD CONSTRAINT fk_domain_deletion_poll_message_id FOREIGN KEY (deletion_poll_message_id) REFERENCES public."PollMessage"(poll_message_id); + + -- -- Name: Domain fk_domain_registrant_contact; Type: FK CONSTRAINT; Schema: public; Owner: - --