Fix flyway invocation in Gradle script (#993)

* Fix flyway invocation in Gradle script

Script wrongly assumed that Flyway task is invoked if --environment is
set.

Bug was introduced in go/r3pr/940
This commit is contained in:
Weimin Yu 2021-03-08 13:59:28 -05:00 committed by GitHub
parent f29219cbb7
commit 1fa57de5ac
2 changed files with 12 additions and 12 deletions

View file

@ -111,8 +111,9 @@ PROPERTIES = [
# Cloud SQL properties # Cloud SQL properties
Property('dbServer', Property('dbServer',
'The host[:port] of a database that accepts direct IP access. ' 'Sets the target database of a Flyway task. This may be a '
'This is typically used with a testing database.'), 'registry environment name (e.g., alpha) or the host[:port] '
'of a database that accepts direct IP access.'),
Property('dbName', Property('dbName',
'Database name to use in connection.', 'Database name to use in connection.',
'postgres'), 'postgres'),

View file

@ -55,8 +55,8 @@ ext {
} }
getJdbcAccessInfo = { getJdbcAccessInfo = {
if (rootProject.projects.keySet().contains(environment)) { if (rootProject.projects.keySet().contains(dbServer)) {
return getSocketFactoryAccessInfo(environment) return getSocketFactoryAccessInfo(dbServer)
} else if (!dbServer.isEmpty()) { } else if (!dbServer.isEmpty()) {
return getAccessInfoByHostPort(dbServer) return getAccessInfoByHostPort(dbServer)
} else { } else {
@ -72,10 +72,8 @@ ext {
// production. The role parameter may be superuser. (More roles will be added // production. The role parameter may be superuser. (More roles will be added
// later). // later).
getCloudSqlCredential = { env, role -> getCloudSqlCredential = { env, role ->
def devProject = project.hasProperty('devProject') def devProject = rootProject.devProject
? project.getProperty('devProject') : rootProject.devProject def gcpProject = rootProject.projects[env]
def gcpProject = project.hasProperty('gcpProject')
? project.getProperty('gcpProject') : rootProject.gcpProject
def keyProject = env in restrictedDbEnv? devProject : gcpProject def keyProject = env in restrictedDbEnv? devProject : gcpProject
def command = def command =
"""gsutil cp \ """gsutil cp \
@ -135,12 +133,13 @@ publishing {
} }
} }
// Adds flyway tasks such as: flywayInfo, flywayValidate, flywayMigrate (deploying the schema in // Adds flyway tasks such as: flywayInfo, flywayValidate, flywayMigrate (
// local repository), and flywayClean (dropping all data in the database). The latter two commands // deploying the schema in local repository), and flywayClean (dropping all data
// are disallowed in environments listed in ext.restrictedDbEnv. // in the database). The latter two commands are disallowed in environments
// listed in ext.restrictedDbEnv.
// //
// Examples: // Examples:
// Get info in alpha: nom_build :db:flywayInfo --environment=alpha // Get info in alpha: nom_build :db:flywayInfo --dbServer=alpha
// Deploy schema to a local test instance and override the database name: // Deploy schema to a local test instance and override the database name:
// nom_build :db:flywayMigrate --dbServer=localhost:5432 --dbName=not-default \ // nom_build :db:flywayMigrate --dbServer=localhost:5432 --dbName=not-default \
// --dbUser=... --dbPassword=... // --dbUser=... --dbPassword=...