Add RegistryLock schema to Flyway deployment folder (#270)

* Add RegistryLock schema to Flyway deployment folder

Added creation script of RegistryLock to Flyway deployment folder.

Fixed previous scripts (PremiumList- and ClaimsList-related) for
FK name change (cause by table name changes: names are quoted now).
We should consider generating foreign key names by ourselves.

Since the alpha database is empty, we dropped and recreated the schema.

Added instructions on how to submit new database incremental changes
in the README file.

Updated RegistryLock.java, removing unnecessary annotations:
- For most fields, the 'name=' property is no longer necessary not that
  the naming strategy is in place. The exceptions are the two used in
  the unique index.
- The @Column annotation is implicit.
This commit is contained in:
Weimin Yu 2019-09-16 16:47:58 -04:00 committed by GitHub
parent f1360285d6
commit 04b076eb0a
6 changed files with 147 additions and 27 deletions

View file

@ -50,8 +50,13 @@ import org.joda.time.DateTime;
*/
@Entity
@Table(
// Unique constraint to get around Hibernate's failure to handle
// auto-increment field in composite primary key.
/**
* Unique constraint to get around Hibernate's failure to handle auto-increment field in
* composite primary key.
*
* <p>Note: because of this index, physical columns must be declared in the {@link Column}
* annotations for {@link RegistryLock#revisionId} and {@link RegistryLock#repoId} fields.
*/
indexes =
@Index(
name = "idx_registry_lock_repo_id_revision_id",
@ -75,29 +80,28 @@ public final class RegistryLock extends ImmutableObject implements Buildable {
private String repoId;
// TODO (b/140568328): remove this when everything is in Cloud SQL and we can join on "domain"
@Column(name = "domain_name", nullable = false)
@Column(nullable = false)
private String domainName;
/**
* The ID of the registrar that performed the action -- this may be the admin ID if this action
* was performed by a superuser.
*/
@Column(name = "registrar_id", nullable = false)
@Column(nullable = false)
private String registrarId;
/** The POC that performed the action, or null if it was a superuser. */
@Column(name = "registrar_poc_id")
private String registrarPocId;
/**
* Lock action is immutable and describes whether the action performed was a lock or an unlock.
*/
@Enumerated(EnumType.STRING)
@Column(name = "action", nullable = false)
@Column(nullable = false)
private Action action;
/** Creation timestamp is when the lock/unlock is first requested. */
@Column(name = "creation_timestamp", nullable = false)
@Column(nullable = false)
private ZonedDateTime creationTimestamp;
/**
@ -105,21 +109,20 @@ public final class RegistryLock extends ImmutableObject implements Buildable {
* becomes immutable. If this field is null, it means that the lock has not been verified yet (and
* thus not been put into effect).
*/
@Column(name = "completion_timestamp")
private ZonedDateTime completionTimestamp;
/**
* The user must provide the random verification code in order to complete the lock and move the
* status from PENDING to COMPLETED.
*/
@Column(name = "verification_code", nullable = false)
@Column(nullable = false)
private String verificationCode;
/**
* True iff this action was taken by a superuser, in response to something like a URS request. In
* this case, the action was performed by a registry admin rather than a registrar.
*/
@Column(name = "is_superuser", nullable = false)
@Column(nullable = false)
private boolean isSuperuser;
public String getRepoId() {