Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion buildSrc/src/main/groovy/docker-common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ ext {
if (config.useDatabaseDB2 || config.useDatabaseSQLServer) {
List<String> results = waitForCommand("${getDatabaseAccessCommand(schema)} \"${sql}\"").split("\n").minus("")

if (results.size() <= 1) {
if (results.size() <= 1 || results.join("").contains("SQL0100W")) {
return Collections.emptyMap()
}

Expand Down Expand Up @@ -354,6 +354,10 @@ ext {
}
}

if (config.useDatabaseDB2 && (stdout.toString().contains("SQL0100W") || stdout.toString().contains("0 record(s) selected"))) {
return stdout.toString().trim()
}

execResult.assertNormalExitValue()

return stdout.toString().trim()
Expand Down
57 changes: 37 additions & 20 deletions buildSrc/src/main/groovy/docker-database-saas.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,12 @@ ext {
disableUserObjectValidations = {
String schema ->

executeSQLQuery("update ObjectValidationRule set active_ = 'false' where objectDefinitionId in (select objectDefinitionId from ObjectDefinition where externalReferenceCode = 'L_USER')", schema)
if (config.useDatabaseSQLServer) {
executeSQLQuery("update ObjectValidationRule set active_ = 'false' where objectDefinitionId in (select objectDefinitionId from ObjectDefinition where externalReferenceCode = 'L_USER')", schema)
}
else {
executeSQLQuery("update ObjectValidationRule set active_ = false where objectDefinitionId in (select objectDefinitionId from ObjectDefinition where externalReferenceCode = 'L_USER')", schema)
}

println "Disabled object validation users for User system object in schema ${schema}"
}
Expand Down Expand Up @@ -253,7 +258,12 @@ ext {

sanitizePortalPreferenceValues(schema, sanitizedPreferences)

executeSQLQuery("update MBMailingList set inServerName = 'fake-pop3-host', outServerName = 'fake-smtp-host', inPassword = 'fake-pop3-password', outPassword = 'fake-smtp-password', active_ = 'false'", schema)
if (config.useDatabaseSQLServer) {
executeSQLQuery("update MBMailingList set inServerName = 'fake-pop3-host', outServerName = 'fake-smtp-host', inPassword = 'fake-pop3-password', outPassword = 'fake-smtp-password', active_ = 'false'", schema)
}
else {
executeSQLQuery("update MBMailingList set inServerName = 'fake-pop3-host', outServerName = 'fake-smtp-host', inPassword = 'fake-pop3-password', outPassword = 'fake-smtp-password', active_ = false", schema)
}

println "Sanitized known POP and SMTP configurations in schema ${schema}"
}
Expand All @@ -271,7 +281,14 @@ ext {
truncateTables = {
String tableNamePattern, String schema ->

List<Map<String, String>> tableNames = executeSQLQuery("select TABLE_NAME from information_schema.TABLES WHERE TABLE_SCHEMA = '${schema}' and TABLE_NAME like '${tableNamePattern}' OR TABLE_NAME like '${tableNamePattern.toLowerCase()}'", schema)
List<Map<String, String>> tableNames

if (config.useDatabaseDB2) {
tableNames = executeSQLQuery("select TABLE_NAME from sysibm.tables WHERE TABLE_CATALOG = '" + schema.toUpperCase() + "' and TABLE_NAME like '${tableNamePattern}' OR TABLE_NAME like '${tableNamePattern.toLowerCase()}'", schema)
}
else {
tableNames = executeSQLQuery("select TABLE_NAME from information_schema.TABLES WHERE TABLE_SCHEMA = '${schema}' and TABLE_NAME like '${tableNamePattern}' OR TABLE_NAME like '${tableNamePattern.toLowerCase()}'", schema)
}

tableNames.each {
Map<String, String> resultRow ->
Expand Down Expand Up @@ -457,28 +474,28 @@ tasks.register("copyDatabaseDumpsToDumpsVolume") {
waitForCommand("docker compose create database")

fileTree("dumps") {
include "**/*.bak"
include "**/*.sql"
include "**/*.sql.gz"
include "**/*.gz"
include "**/*"
exclude "**/.gitkeep"
}.forEach {
File dumpFile ->

println dumpFile

String oldPath = dumpFile.absolutePath
String newPath = null

if (dumpFile.name.endsWith(".gz") && !dumpFile.name.endsWith(".sql.gz")) {
newPath = "${oldPath.substring(0, oldPath.length() - 3)}.sql.gz"
}
else if (!dumpFile.name.contains(".")) {
newPath = "${dumpFile.absolutePath}.sql"
}

if (newPath != null) {
dumpFile.renameTo(newPath)
dumpFile = file(newPath)
if (config.useDatabaseMariaDB || config.useDatabaseMySQL || config.useDatabasePostgreSQL) {
String oldPath = dumpFile.absolutePath
String newPath = null

if (dumpFile.name.endsWith(".gz") && !dumpFile.name.endsWith(".sql.gz")) {
newPath = "${oldPath.substring(0, oldPath.length() - 3)}.sql.gz"
}
else if (!dumpFile.name.contains(".")) {
newPath = "${dumpFile.absolutePath}.sql"
}

if (newPath != null) {
dumpFile.renameTo(newPath)
dumpFile = file(newPath)
}
}

addToVolume(dumpsVolumeName, dumpFile)
Expand Down