diff --git a/core/src/main/java/google/registry/model/rde/RdeRevision.java b/core/src/main/java/google/registry/model/rde/RdeRevision.java index 2b50840d7..9fbad8f8b 100644 --- a/core/src/main/java/google/registry/model/rde/RdeRevision.java +++ b/core/src/main/java/google/registry/model/rde/RdeRevision.java @@ -15,17 +15,32 @@ package google.registry.model.rde; import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Verify.verify; -import static com.google.common.base.Verify.verifyNotNull; -import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.rde.RdeNamingUtils.makePartialName; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import com.google.common.base.VerifyException; +import com.google.common.collect.ImmutableList; +import com.googlecode.objectify.Key; import com.googlecode.objectify.annotation.Entity; import com.googlecode.objectify.annotation.Id; +import com.googlecode.objectify.annotation.Ignore; +import google.registry.model.BackupGroupRoot; import google.registry.model.ImmutableObject; +import google.registry.model.rde.RdeRevision.RdeRevisionId; +import google.registry.persistence.VKey; +import google.registry.persistence.converter.LocalDateConverter; +import google.registry.schema.replay.DatastoreEntity; +import google.registry.schema.replay.SqlEntity; +import java.io.Serializable; +import java.util.Optional; +import javax.persistence.Column; +import javax.persistence.Convert; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.IdClass; +import javax.persistence.Transient; import org.joda.time.DateTime; +import org.joda.time.LocalDate; /** * Datastore entity for tracking RDE revisions. @@ -35,32 +50,67 @@ import org.joda.time.DateTime; * flag is included in the generated XML. */ @Entity -public final class RdeRevision extends ImmutableObject { +@javax.persistence.Entity +@IdClass(RdeRevisionId.class) +public final class RdeRevision extends BackupGroupRoot implements DatastoreEntity, SqlEntity { /** String triplet of tld, date, and mode, e.g. {@code soy_2015-09-01_full}. */ - @Id - String id; + @Id @Transient String id; + + @javax.persistence.Id @Ignore String tld; + + @javax.persistence.Id @Ignore LocalDate date; + + @javax.persistence.Id @Ignore RdeMode mode; /** * Number of last revision successfully staged to GCS. * *

This values begins at zero upon object creation and thenceforth incremented transactionally. */ + @Column(nullable = false) int revision; + /** Hibernate requires an empty constructor. */ + private RdeRevision() {} + + public static RdeRevision create( + String id, String tld, LocalDate date, RdeMode mode, int revision) { + RdeRevision instance = new RdeRevision(); + instance.id = id; + instance.tld = tld; + instance.date = date; + instance.mode = mode; + instance.revision = revision; + return instance; + } + public int getRevision() { return revision; } + @Override + public ImmutableList toSqlEntities() { + return ImmutableList.of(); // we don't care about RdeRevision history + } + + @Override + public ImmutableList toDatastoreEntities() { + return ImmutableList.of(); // we don't care about RdeRevision history + } + /** * Returns next revision ID to use when staging a new deposit file for the given triplet. * * @return {@code 0} for first deposit generation and {@code >0} for resends */ public static int getNextRevision(String tld, DateTime date, RdeMode mode) { - RdeRevision object = - ofy().load().type(RdeRevision.class).id(makePartialName(tld, date, mode)).now(); - return object == null ? 0 : object.revision + 1; + String id = makePartialName(tld, date, mode); + RdeRevisionId sqlKey = RdeRevisionId.create(tld, date.toLocalDate(), mode); + Key ofyKey = Key.create(RdeRevision.class, id); + Optional revisionOptional = + tm().maybeLoad(VKey.create(RdeRevision.class, sqlKey, ofyKey)); + return revisionOptional.map(rdeRevision -> rdeRevision.revision + 1).orElse(0); } /** @@ -76,17 +126,56 @@ public final class RdeRevision extends ImmutableObject { checkArgument(revision >= 0, "Negative revision: %s", revision); String triplet = makePartialName(tld, date, mode); tm().assertInTransaction(); - RdeRevision object = ofy().load().type(RdeRevision.class).id(triplet).now(); + RdeRevisionId sqlKey = RdeRevisionId.create(tld, date.toLocalDate(), mode); + Key ofyKey = Key.create(RdeRevision.class, triplet); + Optional revisionOptional = + tm().maybeLoad(VKey.create(RdeRevision.class, sqlKey, ofyKey)); if (revision == 0) { - verify(object == null, "RdeRevision object already created: %s", object); + revisionOptional.ifPresent( + rdeRevision -> { + throw new IllegalArgumentException( + String.format( + "RdeRevision object already created and revision 0 specified: %s", + rdeRevision)); + }); } else { - verifyNotNull(object, "RDE revision object missing for %s?! revision=%s", triplet, revision); - verify(object.revision == revision - 1, - "RDE revision object should be at %s but was: %s", revision - 1, object); + checkArgument( + revisionOptional.isPresent(), + "Couldn't find existing RDE revision %s when trying to save new revision %s", + triplet, + revision); + checkArgument( + revisionOptional.get().revision == revision - 1, + "RDE revision object should be at revision %s but was: %s", + revision - 1, + revisionOptional.get()); + } + RdeRevision object = RdeRevision.create(triplet, tld, date.toLocalDate(), mode, revision); + tm().put(object); + } + + /** Class to represent the composite primary key of {@link RdeRevision} entity. */ + static class RdeRevisionId extends ImmutableObject implements Serializable { + + String tld; + + // Auto-conversion doesn't work for ID classes, we must specify @Column and @Convert + @Column(columnDefinition = "date") + @Convert(converter = LocalDateConverter.class) + LocalDate date; + + @Enumerated(EnumType.STRING) + RdeMode mode; + + /** Hibernate requires this default constructor. */ + private RdeRevisionId() {} + + static RdeRevisionId create(String tld, LocalDate date, RdeMode mode) { + RdeRevisionId instance = new RdeRevisionId(); + instance.tld = tld; + instance.date = date; + instance.mode = mode; + return instance; } - object = new RdeRevision(); - object.id = triplet; - object.revision = revision; - ofy().save().entity(object); } } diff --git a/core/src/main/resources/META-INF/persistence.xml b/core/src/main/resources/META-INF/persistence.xml index 1d41fc06e..33f44f824 100644 --- a/core/src/main/resources/META-INF/persistence.xml +++ b/core/src/main/resources/META-INF/persistence.xml @@ -53,6 +53,7 @@ google.registry.model.poll.PollMessage google.registry.model.poll.PollMessage$OneTime google.registry.model.poll.PollMessage$Autorenew + google.registry.model.rde.RdeRevision google.registry.model.registrar.Registrar google.registry.model.registrar.RegistrarContact google.registry.model.registry.label.PremiumList diff --git a/core/src/test/java/google/registry/model/rde/RdeRevisionTest.java b/core/src/test/java/google/registry/model/rde/RdeRevisionTest.java index 3ae9a1193..f9e27548b 100644 --- a/core/src/test/java/google/registry/model/rde/RdeRevisionTest.java +++ b/core/src/test/java/google/registry/model/rde/RdeRevisionTest.java @@ -15,118 +15,116 @@ package google.registry.model.rde; import static com.google.common.truth.Truth.assertThat; -import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.rde.RdeMode.FULL; import static google.registry.model.rde.RdeRevision.getNextRevision; import static google.registry.model.rde.RdeRevision.saveRevision; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static org.junit.jupiter.api.Assertions.assertThrows; -import com.google.common.base.VerifyException; -import google.registry.testing.AppEngineExtension; +import google.registry.model.EntityTestCase; +import google.registry.testing.DualDatabaseTest; import org.joda.time.DateTime; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.TestTemplate; /** Unit tests for {@link RdeRevision}. */ -public class RdeRevisionTest { +@DualDatabaseTest +public class RdeRevisionTest extends EntityTestCase { - @RegisterExtension - final AppEngineExtension appEngine = - AppEngineExtension.builder().withDatastoreAndCloudSql().build(); + public RdeRevisionTest() { + super(JpaEntityCoverageCheck.ENABLED); + } - @Test + @BeforeEach + void beforeEach() { + fakeClock.setTo(DateTime.parse("1984-12-18TZ")); + } + + @TestTemplate void testGetNextRevision_objectDoesntExist_returnsZero() { - assertThat(getNextRevision("torment", DateTime.parse("1984-12-18TZ"), FULL)).isEqualTo(0); + tm().transact( + () -> assertThat(getNextRevision("torment", fakeClock.nowUtc(), FULL)).isEqualTo(0)); } - @Test + @TestTemplate void testGetNextRevision_objectExistsAtZero_returnsOne() { - save("sorrow", DateTime.parse("1984-12-18TZ"), FULL, 0); - assertThat(getNextRevision("sorrow", DateTime.parse("1984-12-18TZ"), FULL)).isEqualTo(1); + save("sorrow", fakeClock.nowUtc(), FULL, 0); + tm().transact( + () -> assertThat(getNextRevision("sorrow", fakeClock.nowUtc(), FULL)).isEqualTo(1)); } - @Test + @TestTemplate void testSaveRevision_objectDoesntExist_newRevisionIsZero_nextRevIsOne() { - tm().transact(() -> saveRevision("despondency", DateTime.parse("1984-12-18TZ"), FULL, 0)); + tm().transact(() -> saveRevision("despondency", fakeClock.nowUtc(), FULL, 0)); tm().transact( () -> - assertThat(getNextRevision("despondency", DateTime.parse("1984-12-18TZ"), FULL)) - .isEqualTo(1)); + assertThat(getNextRevision("despondency", fakeClock.nowUtc(), FULL)).isEqualTo(1)); } - @Test + @TestTemplate void testSaveRevision_objectDoesntExist_newRevisionIsOne_throwsVe() { - VerifyException thrown = + IllegalArgumentException thrown = assertThrows( - VerifyException.class, - () -> - tm().transact( - () -> - saveRevision("despondency", DateTime.parse("1984-12-18TZ"), FULL, 1))); - assertThat(thrown).hasMessageThat().contains("object missing"); + IllegalArgumentException.class, + () -> tm().transact(() -> saveRevision("despondency", fakeClock.nowUtc(), FULL, 1))); + assertThat(thrown) + .hasMessageThat() + .isEqualTo( + "Couldn't find existing RDE revision despondency_1984-12-18_full " + + "when trying to save new revision 1"); } - @Test + @TestTemplate void testSaveRevision_objectExistsAtZero_newRevisionIsZero_throwsVe() { - save("melancholy", DateTime.parse("1984-12-18TZ"), FULL, 0); - VerifyException thrown = + save("melancholy", fakeClock.nowUtc(), FULL, 0); + IllegalArgumentException thrown = assertThrows( - VerifyException.class, - () -> - tm().transact( - () -> saveRevision("melancholy", DateTime.parse("1984-12-18TZ"), FULL, 0))); + IllegalArgumentException.class, + () -> tm().transact(() -> saveRevision("melancholy", fakeClock.nowUtc(), FULL, 0))); assertThat(thrown).hasMessageThat().contains("object already created"); } - @Test + @TestTemplate void testSaveRevision_objectExistsAtZero_newRevisionIsOne_nextRevIsTwo() { - save("melancholy", DateTime.parse("1984-12-18TZ"), FULL, 0); - tm().transact(() -> saveRevision("melancholy", DateTime.parse("1984-12-18TZ"), FULL, 1)); - tm().transact( - () -> - assertThat(getNextRevision("melancholy", DateTime.parse("1984-12-18TZ"), FULL)) - .isEqualTo(2)); + DateTime startOfDay = fakeClock.nowUtc().withTimeAtStartOfDay(); + save("melancholy", startOfDay, FULL, 0); + fakeClock.advanceOneMilli(); + tm().transact(() -> saveRevision("melancholy", startOfDay, FULL, 1)); + tm().transact(() -> assertThat(getNextRevision("melancholy", startOfDay, FULL)).isEqualTo(2)); } - @Test + @TestTemplate void testSaveRevision_objectExistsAtZero_newRevisionIsTwo_throwsVe() { - save("melancholy", DateTime.parse("1984-12-18TZ"), FULL, 0); - VerifyException thrown = + save("melancholy", fakeClock.nowUtc(), FULL, 0); + IllegalArgumentException thrown = assertThrows( - VerifyException.class, - () -> - tm().transact( - () -> saveRevision("melancholy", DateTime.parse("1984-12-18TZ"), FULL, 2))); - assertThat(thrown).hasMessageThat().contains("should be at 1 "); + IllegalArgumentException.class, + () -> tm().transact(() -> saveRevision("melancholy", fakeClock.nowUtc(), FULL, 2))); + assertThat(thrown) + .hasMessageThat() + .contains("RDE revision object should be at revision 1 but was"); } - @Test + @TestTemplate void testSaveRevision_negativeRevision_throwsIae() { IllegalArgumentException thrown = assertThrows( IllegalArgumentException.class, - () -> - tm().transact( - () -> - saveRevision("melancholy", DateTime.parse("1984-12-18TZ"), FULL, -1))); + () -> tm().transact(() -> saveRevision("melancholy", fakeClock.nowUtc(), FULL, -1))); assertThat(thrown).hasMessageThat().contains("Negative revision"); } - @Test + @TestTemplate void testSaveRevision_callerNotInTransaction_throwsIse() { IllegalStateException thrown = assertThrows( - IllegalStateException.class, - () -> saveRevision("frenzy", DateTime.parse("1984-12-18TZ"), FULL, 1)); + IllegalStateException.class, () -> saveRevision("frenzy", fakeClock.nowUtc(), FULL, 1)); assertThat(thrown).hasMessageThat().contains("transaction"); } public static void save(String tld, DateTime date, RdeMode mode, int revision) { String triplet = RdeNamingUtils.makePartialName(tld, date, mode); - RdeRevision object = new RdeRevision(); - object.id = triplet; - object.revision = revision; - ofy().saveWithoutBackup().entity(object).now(); + RdeRevision object = RdeRevision.create(triplet, tld, date.toLocalDate(), mode, revision); + tm().transact(() -> tm().put(object)); } } diff --git a/core/src/test/java/google/registry/schema/integration/SqlIntegrationTestSuite.java b/core/src/test/java/google/registry/schema/integration/SqlIntegrationTestSuite.java index 5f5df6983..22757d034 100644 --- a/core/src/test/java/google/registry/schema/integration/SqlIntegrationTestSuite.java +++ b/core/src/test/java/google/registry/schema/integration/SqlIntegrationTestSuite.java @@ -24,6 +24,7 @@ import google.registry.model.history.ContactHistoryTest; import google.registry.model.history.DomainHistoryTest; import google.registry.model.history.HostHistoryTest; import google.registry.model.poll.PollMessageTest; +import google.registry.model.rde.RdeRevisionTest; import google.registry.model.registry.RegistryLockDaoTest; import google.registry.model.registry.RegistryTest; import google.registry.model.registry.label.ReservedListSqlDaoTest; @@ -86,6 +87,7 @@ import org.junit.runner.RunWith; LockDaoTest.class, PollMessageTest.class, PremiumListDaoTest.class, + RdeRevisionTest.class, RegistrarDaoTest.class, RegistryTest.class, ReservedListSqlDaoTest.class, diff --git a/core/src/test/resources/google/registry/model/schema.txt b/core/src/test/resources/google/registry/model/schema.txt index eaae1ad5c..579806eb9 100644 --- a/core/src/test/resources/google/registry/model/schema.txt +++ b/core/src/test/resources/google/registry/model/schema.txt @@ -523,6 +523,7 @@ class google.registry.model.poll.PollMessage$OneTime { } class google.registry.model.rde.RdeRevision { @Id java.lang.String id; + google.registry.model.UpdateAutoTimestamp updateTimestamp; int revision; } class google.registry.model.registrar.Registrar { diff --git a/db/src/main/resources/sql/er_diagram/brief_er_diagram.html b/db/src/main/resources/sql/er_diagram/brief_er_diagram.html index fc9083f0f..d26bf52e5 100644 --- a/db/src/main/resources/sql/er_diagram/brief_er_diagram.html +++ b/db/src/main/resources/sql/er_diagram/brief_er_diagram.html @@ -261,19 +261,19 @@ td.section { generated on - 2020-10-19 18:49:22.440463 + 2020-10-21 14:40:52.221127 last flyway file - V65__local_date_date_type.sql + V66__create_rde_revision.sql

 

 

- + SchemaCrawler_Diagram - + generated by @@ -284,7 +284,7 @@ td.section { generated on - 2020-10-19 18:49:22.440463 + 2020-10-21 14:40:52.221127 @@ -521,7 +521,7 @@ td.section { fk_billing_cancellation_billing_recurrence_id - + registrar_6e1503e3 @@ -2203,280 +2203,316 @@ td.section { fko0gw90lpo1tuee56l0nb6y6g5 + + + rderevision_83396864 + + + public.RdeRevision + + + + [table] + + + tld + + + + + text not null + + + mode + + + + + text not null + + + "date" + + + + + date not null + + - + registrarpoc_ab47054d - - + + public.RegistrarPoc - - + + [table] - + email_address - + - + text not null - + gae_user_id - + - + text - + registrar_id - + - + text not null - + - + registrylock_ac88663e - - + + public.RegistryLock - - + + [table] - + revision_id - + - + bigserial not null - + - + auto-incremented - + registrar_id - + - + text not null - + repo_id - + - + text not null - + verification_code - + - + text not null - + relock_revision_id - + - + int8 - + registrylock_ac88663e:w->registrylock_ac88663e:e - - - - - - - - + + + + + + + + fk2lhcwpxlnqijr96irylrh1707 - + reservedentry_1a7b8520 - - + + public.ReservedEntry - - + + [table] - + revision_id - + - + int8 not null - + domain_label - + - + text not null - + - + reservedlist_b97c3f1c - - + + public.ReservedList - - + + [table] - + revision_id - + - + bigserial not null - + - + auto-incremented - + name - + - + text not null - + reservedentry_1a7b8520:w->reservedlist_b97c3f1c:e - - - - - - - - + + + + + + + + fkgq03rk0bt1hb915dnyvd3vnfc - + spec11threatmatch_a61228a6 - - + + public.Spec11ThreatMatch - - + + [table] - + id - + - + bigserial not null - + - + auto-incremented - + check_date - + - + date not null - + registrar_id - + - + text not null - + tld - + - + text not null - + - + tld_f1fa57e2 - - + + public.Tld - - + + [table] - + tld_name - + - + text not null - + - + transaction_d50389d4 - - + + public.Transaction - - + + [table] - + id - + - + bigserial not null - + - + auto-incremented - + @@ -4774,6 +4810,56 @@ td.section {

 

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
public.RdeRevision [table] +
tldtext not null
modetext not null
"date"date not null
Primary Key
RdeRevision_pkey[primary key]
tld
mode
"date"
+

 

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 de5614630..29d12af1a 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,19 +261,19 @@ td.section { - + - +
public.Registrar [table]
generated on2020-10-19 18:49:20.7838122020-10-21 14:40:50.371645
last flyway fileV65__local_date_date_type.sqlV66__create_rde_revision.sql

 

 

- + SchemaCrawler_Diagram - + generated by @@ -284,7 +284,7 @@ td.section { generated on - 2020-10-19 18:49:20.783812 + 2020-10-21 14:40:50.371645 @@ -745,7 +745,7 @@ td.section { fk_billing_cancellation_billing_recurrence_id - + registrar_6e1503e3 @@ -4851,800 +4851,852 @@ td.section { fko0gw90lpo1tuee56l0nb6y6g5 + + + rderevision_83396864 + + + public.RdeRevision + + + + [table] + + + tld + + + + + text not null + + + mode + + + + + text not null + + + "date" + + + + + date not null + + + update_timestamp + + + + + timestamptz + + + revision + + + + + int4 not null + + - + registrarpoc_ab47054d - - + + public.RegistrarPoc - - + + [table] - + email_address - + - + text not null - + allowed_to_set_registry_lock_password - + - + bool not null - + fax_number - + - + text - + gae_user_id - + - + text - + name - + - + text - + phone_number - + - + text - + registry_lock_password_hash - + - + text - + registry_lock_password_salt - + - + text - + types - + - + _text - + visible_in_domain_whois_as_abuse - + - + bool not null - + visible_in_whois_as_admin - + - + bool not null - + visible_in_whois_as_tech - + - + bool not null - + registry_lock_email_address - + - + text - + registrar_id - + - + text not null - + - + registrylock_ac88663e - - + + public.RegistryLock - - + + [table] - + revision_id - + - + bigserial not null - + - + auto-incremented - + lock_completion_timestamp - + - + timestamptz - + lock_request_timestamp - + - + timestamptz not null - + domain_name - + - + text not null - + is_superuser - + - + bool not null - + registrar_id - + - + text not null - + registrar_poc_id - + - + text - + repo_id - + - + text not null - + verification_code - + - + text not null - + unlock_request_timestamp - + - + timestamptz - + unlock_completion_timestamp - + - + timestamptz - + last_update_timestamp - + - + timestamptz - + relock_revision_id - + - + int8 - + relock_duration - + - + interval - + registrylock_ac88663e:w->registrylock_ac88663e:e - - - - - - - - + + + + + + + + fk2lhcwpxlnqijr96irylrh1707 - + reservedentry_1a7b8520 - - + + public.ReservedEntry - - + + [table] - + revision_id - + - + int8 not null - + comment - + - + text - + reservation_type - + - + int4 not null - + domain_label - + - + text not null - + - + reservedlist_b97c3f1c - - + + public.ReservedList - - + + [table] - + revision_id - + - + bigserial not null - + - + auto-incremented - + creation_timestamp - + - + timestamptz not null - + name - + - + text not null - + should_publish - + - + bool not null - + reservedentry_1a7b8520:w->reservedlist_b97c3f1c:e - - - - - - - - + + + + + + + + fkgq03rk0bt1hb915dnyvd3vnfc - + spec11threatmatch_a61228a6 - - + + public.Spec11ThreatMatch - - + + [table] - + id - + - + bigserial not null - + - + auto-incremented - + check_date - + - + date not null - + domain_name - + - + text not null - + domain_repo_id - + - + text not null - + registrar_id - + - + text not null - + threat_types - + - + _text not null - + tld - + - + text not null - + - + tld_f1fa57e2 - - + + public.Tld - - + + [table] - + tld_name - + - + text not null - + add_grace_period_length - + - + interval not null - + allowed_fully_qualified_host_names - + - + _text - + allowed_registrant_contact_ids - + - + _text - + anchor_tenant_add_grace_period_length - + - + interval not null - + auto_renew_grace_period_length - + - + interval not null - + automatic_transfer_length - + - + interval not null - + claims_period_end - + - + timestamptz not null - + create_billing_cost_amount - + - + numeric(19, 2) - + create_billing_cost_currency - + - + text - + creation_time - + - + timestamptz not null - + currency - + - + text not null - + dns_paused - + - + bool not null - + dns_writers - + - + _text not null - + drive_folder_id - + - + text - + eap_fee_schedule - + - + "hstore" not null - + escrow_enabled - + - + bool not null - + invoicing_enabled - + - + bool not null - + lordn_username - + - + text - + num_dns_publish_locks - + - + int4 not null - + pending_delete_length - + - + interval not null - + premium_list_name - + - + text - + pricing_engine_class_name - + - + text - + redemption_grace_period_length - + - + interval not null - + registry_lock_or_unlock_cost_amount - + - + numeric(19, 2) - + registry_lock_or_unlock_cost_currency - + - + text - + renew_billing_cost_transitions - + - + "hstore" not null - + renew_grace_period_length - + - + interval not null - + reserved_list_names - + - + _text not null - + restore_billing_cost_amount - + - + numeric(19, 2) - + restore_billing_cost_currency - + - + text - + roid_suffix - + - + text - + server_status_change_billing_cost_amount - + - + numeric(19, 2) - + server_status_change_billing_cost_currency - + - + text - + tld_state_transitions - + - + "hstore" not null - + tld_type - + - + text not null - + tld_unicode - + - + text not null - + transfer_grace_period_length - + - + interval not null - + - + transaction_d50389d4 - - + + public.Transaction - - + + [table] - + id - + - + bigserial not null - + - + auto-incremented - + contents - + - + bytea - + @@ -10291,6 +10343,94 @@ td.section {

 

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
public.RdeRevision [table] +
tldtext not null
modetext not null
"date"date not null
update_timestamptimestamptz
revisionint4 not null
Primary Key
RdeRevision_pkey[primary key]
tld
mode
"date"
Indexes
RdeRevision_pkey[unique index]
tldascending
modeascending
"date"ascending
+

 

diff --git a/db/src/main/resources/sql/flyway.txt b/db/src/main/resources/sql/flyway.txt index 22291e74b..db47392ef 100644 --- a/db/src/main/resources/sql/flyway.txt +++ b/db/src/main/resources/sql/flyway.txt @@ -63,3 +63,4 @@ V62__disable_key_auto_generation_for_history_tables.sql V63__add_schema_for_ds_data.sql V64__transfer_history_columns.sql V65__local_date_date_type.sql +V66__create_rde_revision.sql diff --git a/db/src/main/resources/sql/flyway/V66__create_rde_revision.sql b/db/src/main/resources/sql/flyway/V66__create_rde_revision.sql new file mode 100644 index 000000000..1a59e4f25 --- /dev/null +++ b/db/src/main/resources/sql/flyway/V66__create_rde_revision.sql @@ -0,0 +1,22 @@ +-- 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. + +CREATE TABLE "RdeRevision" ( + tld TEXT NOT NULL, + mode TEXT NOT NULL, + date date NOT NULL, + update_timestamp timestamptz, + revision int4 NOT NULL, + PRIMARY KEY (tld, mode, date) +); 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 ab2e488e2..6e7a72f18 100644 --- a/db/src/main/resources/sql/schema/db-schema.sql.generated +++ b/db/src/main/resources/sql/schema/db-schema.sql.generated @@ -494,6 +494,15 @@ primary key (revision_id) ); + create table "RdeRevision" ( + date date not null, + mode text not null, + tld text not null, + update_timestamp timestamptz, + revision int4 not null, + primary key (date, mode, tld) + ); + create table "Registrar" ( registrar_id text not null, allowed_tlds text[], diff --git a/db/src/main/resources/sql/schema/nomulus.golden.sql b/db/src/main/resources/sql/schema/nomulus.golden.sql index ec065c91b..0298bc968 100644 --- a/db/src/main/resources/sql/schema/nomulus.golden.sql +++ b/db/src/main/resources/sql/schema/nomulus.golden.sql @@ -682,6 +682,19 @@ CREATE SEQUENCE public."PremiumList_revision_id_seq" ALTER SEQUENCE public."PremiumList_revision_id_seq" OWNED BY public."PremiumList".revision_id; +-- +-- Name: RdeRevision; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public."RdeRevision" ( + tld text NOT NULL, + mode text NOT NULL, + date date NOT NULL, + update_timestamp timestamp with time zone, + revision integer NOT NULL +); + + -- -- Name: Registrar; Type: TABLE; Schema: public; Owner: - -- @@ -1166,6 +1179,14 @@ ALTER TABLE ONLY public."PremiumList" ADD CONSTRAINT "PremiumList_pkey" PRIMARY KEY (revision_id); +-- +-- Name: RdeRevision RdeRevision_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public."RdeRevision" + ADD CONSTRAINT "RdeRevision_pkey" PRIMARY KEY (tld, mode, date); + + -- -- Name: RegistrarPoc RegistrarPoc_pkey; Type: CONSTRAINT; Schema: public; Owner: - --
public.Registrar [table]