Skip to content

Commit

Permalink
Improved configuration option printout in KapuaLiquibaseClient
Browse files Browse the repository at this point in the history
Signed-off-by: coduz <alberto.codutti@eurotech.com>
  • Loading branch information
Coduz committed Apr 3, 2020
1 parent dbb50e7 commit e894c90
Showing 1 changed file with 19 additions and 6 deletions.
Expand Up @@ -115,9 +115,17 @@ public KapuaLiquibaseClient(String jdbcUrl, String username, String password, St

runTimestampsFix = (currentLiquibaseVersion.afterOrMatches(LIQUIBASE_TIMESTAMP_FIX_VERSION) || forceTimestampFix);

LOG.info("Liquibase Version: {}", currentLiquibaseVersionString);
LOG.info("Force timestamp fix: {}", forceTimestampFix);
LOG.info("Apply timestamp fix: {}", runTimestampsFix);
LOG.info("=================== KapuaLiquibaseClient configuration ===================");
LOG.info("|\tLiquibase Version: {}", currentLiquibaseVersionString);
LOG.info("|\tDB connection info");
LOG.info("|\t\tJDBC URL: {}", jdbcUrl);
LOG.info("|\t\tUsername: {}", username);
LOG.info("|\t\tPassword: ******");
LOG.info("|\t\tSchema: {}", schema);
LOG.info("|\tTimestamp(3) fix info (eclipse/kapua#2889)");
LOG.info("|\t\tForce timestamp fix: {}", forceTimestampFix);
LOG.info("|\t\tApply timestamp fix: {}", runTimestampsFix);
LOG.info("==========================================================================");
}

/**
Expand All @@ -127,8 +135,9 @@ public KapuaLiquibaseClient(String jdbcUrl, String username, String password, St
*/
public void update() {
try {
LOG.info("Running Liquibase scripts...");
if (Boolean.parseBoolean(System.getProperty("LIQUIBASE_ENABLED", "true")) || Boolean.parseBoolean(System.getenv("LIQUIBASE_ENABLED"))) {
LOG.info("Running Liquibase update with schema: {}", schema);

try (Connection connection = DriverManager.getConnection(jdbcUrl, username, password)) {
File changelogDir = loadChangelogs();

Expand All @@ -139,10 +148,14 @@ public void update() {

executeMasters(connection, schema, changelogDir, contexts);
}

LOG.info("Running Liquibase scripts... DONE!");
} else {
LOG.info("Running Liquibase scripts... SKIPPED! Liquibase disabled by System property 'LIQUIBASE_ENABLED'...");
}
} catch (LiquibaseException | SQLException | IOException e) {
LOG.error("Error while running Liquibase scripts: {}", e.getMessage(), e);
throw new RuntimeException(e);
LOG.error("Running Liquibase scripts... ERROR! Error: {}", e.getMessage(), e);
throw new RuntimeException(e); // TODO: throw an appropriate exception!
}
}

Expand Down

0 comments on commit e894c90

Please sign in to comment.