From 9faf7181c3ec14ca4507f4e4b1d52e9dfaf73af7 Mon Sep 17 00:00:00 2001 From: mcilwain Date: Mon, 24 Sep 2018 18:19:40 -0700 Subject: [PATCH] Index the allocation token's redemption history entry field We need this to efficiently query which tokens have and have not been redeemed. I'm also marking it as nullable for consistency with the domain name field (it's already null for unredeemed tokens). ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=214366534 --- java/google/registry/model/domain/token/AllocationToken.java | 2 +- .../google/registry/model/domain/token/AllocationTokenTest.java | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/java/google/registry/model/domain/token/AllocationToken.java b/java/google/registry/model/domain/token/AllocationToken.java index aa783b918..cc82cb6fb 100644 --- a/java/google/registry/model/domain/token/AllocationToken.java +++ b/java/google/registry/model/domain/token/AllocationToken.java @@ -41,7 +41,7 @@ public class AllocationToken extends BackupGroupRoot implements Buildable { @Id String token; /** The key of the history entry for which the token was used. Null if not yet used. */ - Key redemptionHistoryEntry; + @Nullable @Index Key redemptionHistoryEntry; /** The fully-qualified domain name that this token is limited to, if any. */ @Nullable @Index String domainName; diff --git a/javatests/google/registry/model/domain/token/AllocationTokenTest.java b/javatests/google/registry/model/domain/token/AllocationTokenTest.java index 4395dcc68..ea4abcb79 100644 --- a/javatests/google/registry/model/domain/token/AllocationTokenTest.java +++ b/javatests/google/registry/model/domain/token/AllocationTokenTest.java @@ -48,10 +48,12 @@ public class AllocationTokenTest extends EntityTestCase { persistResource( new AllocationToken.Builder() .setToken("abc123") + .setRedemptionHistoryEntry(Key.create(HistoryEntry.class, 1L)) .setDomainName("blahdomain.fake") .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) .build()), "token", + "redemptionHistoryEntry", "domainName"); }