google-nomulus/db
gbrodman 1e7d4bded9 Add RegistryLock SQL schema (#243)
* Add RegistryLock SQL schema

* Refactor a bit

* Move registrylock -> domain

* Clearing up lock workflow

* Add more docs and remove LockStatus

* Responses to CR

* Add repoId javadoc

* Add registry lock to persistence xml file

* Quote rather than backtick

* Remove unnecessary check

* File TODO

* Remove uniqueness constraint on verification code

* Remove import

* add index

* Add to SQL generation task

* Move fields around to be the same order as Hibernate's generated sql
2019-09-10 18:17:36 -04:00
..
gradle/dependency-locks Use Flyway to deploy SQL schema to non-prod (#255) 2019-09-06 16:29:49 -04:00
src/main/resources/sql Add RegistryLock SQL schema (#243) 2019-09-10 18:17:36 -04:00
build.gradle Use Flyway to deploy SQL schema to non-prod (#255) 2019-09-06 16:29:49 -04:00
README.md Use Flyway to deploy SQL schema to non-prod (#255) 2019-09-06 16:29:49 -04:00

Summary

This project contains Nomulus's Cloud SQL schema and schema deployment utilities.

Schema Creation DDL

Currently we use Flywaydb for schema deployment. Versioned migration scripts are organized in the src/main/resources/sql/flyway folder. Scripts must follow the V{id}__{description text}.sql naming pattern (Note the double underscore).

The 'nomulus.golden.sql' file in src/main/resources/sql/schema folder is mainly informational. It is generated by Hibernate and should not be reformatted. We will use it in validation tests later.

Non-production Schema Push

To manage schema in a non-production environment, use the 'flywayMigration' task. You will need Cloud SDK and login once.

# One time login
gcloud auth login

# Deploy the current schema to alpha
gradlew :db:flywayMigrate -PdbServer=alpha

# Delete the entire schema in alpha
gradlew :db:flywayClean -PdbServer=alpha

The flywayMigrate task is idempotent. Repeated runs will not introduce problems.

The Flyway tasks may also be used to deploy to local instances, e.g, your own test instance. E.g.,

# Deploy to a local instance at standard port as the super user.
gradlew :db:flywayMigrate -PdbServer=192.168.9.2 -PdbPassword=domain-registry

# Full specification of all parameters
gradlew :db:flywayMigrate -PdbServer=192.168.9.2:5432 -PdbUser=postgres \
    -PdbPassword=domain-registry

Production Schema Deployment

Schema deployment to production and sandbox is under development.