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
This commit is contained in:
mcilwain 2018-09-24 18:19:40 -07:00 committed by jianglai
parent c89cb6a3f3
commit 9faf7181c3
2 changed files with 3 additions and 1 deletions

View file

@ -41,7 +41,7 @@ public class AllocationToken extends BackupGroupRoot implements Buildable {
@Id String token; @Id String token;
/** The key of the history entry for which the token was used. Null if not yet used. */ /** The key of the history entry for which the token was used. Null if not yet used. */
Key<HistoryEntry> redemptionHistoryEntry; @Nullable @Index Key<HistoryEntry> redemptionHistoryEntry;
/** The fully-qualified domain name that this token is limited to, if any. */ /** The fully-qualified domain name that this token is limited to, if any. */
@Nullable @Index String domainName; @Nullable @Index String domainName;

View file

@ -48,10 +48,12 @@ public class AllocationTokenTest extends EntityTestCase {
persistResource( persistResource(
new AllocationToken.Builder() new AllocationToken.Builder()
.setToken("abc123") .setToken("abc123")
.setRedemptionHistoryEntry(Key.create(HistoryEntry.class, 1L))
.setDomainName("blahdomain.fake") .setDomainName("blahdomain.fake")
.setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z")) .setCreationTimeForTest(DateTime.parse("2010-11-12T05:00:00Z"))
.build()), .build()),
"token", "token",
"redemptionHistoryEntry",
"domainName"); "domainName");
} }