From eb7d779bc8846506b72daeab00565e8e90aa8665 Mon Sep 17 00:00:00 2001 From: Ben McIlwain Date: Mon, 6 Jan 2020 18:09:21 -0500 Subject: [PATCH] Relax premium list existence check to allow Cloud SQL migration (#428) * Relax premium list existence check to allow Cloud SQL migration We need to be able to simultaneously update premium lists that already exist in Datastore and create them in Cloud SQL (because they haven't been migrated over yet). This temporarily relaxes the existence check for Cloud SQL so that "updates" will work even when the list doesn't yet exist there. --- .../google/registry/schema/tld/PremiumListDao.java | 13 +++++++++---- .../registry/schema/tld/PremiumListDaoTest.java | 3 +++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/google/registry/schema/tld/PremiumListDao.java b/core/src/main/java/google/registry/schema/tld/PremiumListDao.java index 1ff71c9ef..508191c96 100644 --- a/core/src/main/java/google/registry/schema/tld/PremiumListDao.java +++ b/core/src/main/java/google/registry/schema/tld/PremiumListDao.java @@ -66,10 +66,15 @@ public class PremiumListDao { jpaTm() .transact( () -> { - checkArgument( - checkExists(premiumList.getName()), - "Can't update non-existent premium list '%s'", - premiumList.getName()); + // This check is currently disabled because, during the Cloud SQL migration, we need + // to be able to update premium lists in Datastore while simultaneously creating their + // first revision in Cloud SQL (i.e. if they haven't been migrated over yet). + // TODO(b/147246613): Reinstate this once all premium lists are migrated to Cloud SQL, + // and re-enable the test update_throwsWhenListDoesntExist(). + // checkArgument( + // checkExists(premiumList.getName()), + // "Can't update non-existent premium list '%s'", + // premiumList.getName()); jpaTm().getEntityManager().persist(premiumList); }); } diff --git a/core/src/test/java/google/registry/schema/tld/PremiumListDaoTest.java b/core/src/test/java/google/registry/schema/tld/PremiumListDaoTest.java index b3e50aeed..2a203de9f 100644 --- a/core/src/test/java/google/registry/schema/tld/PremiumListDaoTest.java +++ b/core/src/test/java/google/registry/schema/tld/PremiumListDaoTest.java @@ -35,6 +35,7 @@ import java.math.BigDecimal; import java.util.Optional; import org.joda.money.CurrencyUnit; import org.joda.money.Money; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -125,7 +126,9 @@ public class PremiumListDaoTest { assertThat(thrown).hasMessageThat().isEqualTo("Premium list 'testlist' already exists"); } + // TODO(b/147246613): Un-ignore this. @Test + @Ignore public void update_throwsWhenListDoesntExist() { IllegalArgumentException thrown = assertThrows(