diff --git a/db/README.md b/db/README.md index 297b9fd2d..a082a5c44 100644 --- a/db/README.md +++ b/db/README.md @@ -47,18 +47,19 @@ Below are the steps to submit a schema change: following the existing scripts in that folder. Note the double underscore in the naming pattern. -4. Run `./nom_build :nom:generate_golden_file`. This is a pseudo-task +4. Run `./nom_build :nom:generate_golden_file`. This is a pseudo-task implemented in the `nom_build` script that does the following: + - Runs the `:db:test` task from the Gradle root project. The SchemaTest will fail because the new schema does not match the golden file. - - Copies `db/build/resources/test/testcontainer/mount/dump.txt` to the golden - file `db/src/main/resources/sql/schema/nomulus.golden.sql`. + - Copies `db/build/resources/test/testcontainer/mount/dump.txt` to the + golden file `db/src/main/resources/sql/schema/nomulus.golden.sql`. - Re-runs the `:db:test` task. This time all tests should pass. - You'll want to have a look at the diffs in the golden schema to verify - that all changes are intentional. + You'll want to have a look at the diffs in the golden schema to verify that + all changes are intentional. Relevant files (under db/src/main/resources/sql/schema/): @@ -102,6 +103,13 @@ gcloud builds submit --config=release/cloudbuild-schema-deploy.yaml \ ./nom_build :db:flywayInfo --dbServer=${SQL_ENV} ``` +To test unsubmitted schema changes in the alpha or crash environments, use the +following command to deploy the local schema, + +```shell +./nom_build :db:flywayMigrate --dbServer=[alpha|crash] --environment=[alpha|crash] +``` + #### Glass Breaking If you need to deploy a schema off-cycle, try making a release first, then diff --git a/db/build.gradle b/db/build.gradle index aef61925f..04705c801 100644 --- a/db/build.gradle +++ b/db/build.gradle @@ -29,8 +29,8 @@ ext { def dbServer = findProperty(dbServerProperty).toString().toLowerCase() def dbName = findProperty(dbNameProperty) - isCloudSql = { - return allDbEnv.contains(dbServer) + isRestricted = { + return restrictedDbEnv.contains(dbServer) } getAccessInfoByHostPort = { hostAndPort -> @@ -169,8 +169,8 @@ dependencies { flywayInfo.dependsOn('buildNeeded') flywayValidate.dependsOn('buildNeeded') -if (ext.isCloudSql()) { - // Disable dangerous Flyway tasks. Only allow info and validate. +if (ext.isRestricted()) { + // Disable dangerous Flyway tasks in sandbox and production. Only allow info and validate. tasks.findAll { task -> task.group.equals('Flyway')}.each { if (it.name == 'flywayMigrate') { it.doFirst {