mirror of
https://github.com/google/nomulus.git
synced 2025-04-29 19:47:51 +02:00
Clean up Gradle Flyway tasks in :db (#990)
* Clean up Gradle Flyway tasks in :db Simplified the command line by revising the semantics of some properties. Added examples of Flyway task invocations. This script still uses the GCS file-based credential. We will migrate it to the Secret Manager soon.
This commit is contained in:
parent
f997f64169
commit
db16a2c679
2 changed files with 15 additions and 7 deletions
|
@ -111,8 +111,8 @@ PROPERTIES = [
|
|||
|
||||
# Cloud SQL properties
|
||||
Property('dbServer',
|
||||
'A registry environment name (e.g., "alpha") or a host[:port] '
|
||||
'string'),
|
||||
'The host[:port] of a database that accepts direct IP access. '
|
||||
'This is typically used with a testing database.'),
|
||||
Property('dbName',
|
||||
'Database name to use in connection.',
|
||||
'postgres'),
|
||||
|
|
|
@ -20,8 +20,6 @@ plugins {
|
|||
ext {
|
||||
Set restrictedDbEnv =
|
||||
[ 'sandbox', 'production' ].asUnmodifiable()
|
||||
Set allDbEnv =
|
||||
[ 'alpha', 'crash' ].plus(restrictedDbEnv).asUnmodifiable()
|
||||
|
||||
def dbServerProperty = 'dbServer'
|
||||
def dbNameProperty = 'dbName'
|
||||
|
@ -57,12 +55,12 @@ ext {
|
|||
}
|
||||
|
||||
getJdbcAccessInfo = {
|
||||
if (allDbEnv.contains(dbServer)) {
|
||||
return getSocketFactoryAccessInfo(dbServer)
|
||||
if (rootProject.projects.keySet().contains(environment)) {
|
||||
return getSocketFactoryAccessInfo(environment)
|
||||
} else if (!dbServer.isEmpty()) {
|
||||
return getAccessInfoByHostPort(dbServer)
|
||||
} else {
|
||||
// Not connecting to a database. Return a dummy object for Flyway config.
|
||||
// Not running flyway tasks. Return a dummy object for Flyway config.
|
||||
return [ url: '', user: '', password: '' ]
|
||||
}
|
||||
}
|
||||
|
@ -137,6 +135,16 @@ publishing {
|
|||
}
|
||||
}
|
||||
|
||||
// Adds flyway tasks such as: flywayInfo, flywayValidate, flywayMigrate (deploying the schema in
|
||||
// local repository), and flywayClean (dropping all data in the database). The latter two commands
|
||||
// are disallowed in environments listed in ext.restrictedDbEnv.
|
||||
//
|
||||
// Examples:
|
||||
// Get info in alpha: nom_build :db:flywayInfo --environment=alpha
|
||||
// Deploy schema to a local test instance and override the database name:
|
||||
// nom_build :db:flywayMigrate --dbServer=localhost:5432 --dbName=not-default \
|
||||
// --dbUser=... --dbPassword=...
|
||||
|
||||
flyway {
|
||||
def accessInfo = project.ext.getJdbcAccessInfo()
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue