Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add additional MDC properties to update and diff mojos (DAT-14672) #4420

Merged
merged 2 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -6,6 +6,7 @@
import liquibase.ThreadLocalScopeManager;
import liquibase.changelog.visitor.ChangeExecListener;
import liquibase.changelog.visitor.DefaultChangeExecListener;
import liquibase.command.core.helpers.DbUrlConnectionCommandStep;
import liquibase.configuration.LiquibaseConfiguration;
import liquibase.configuration.core.DefaultsFileValueProvider;
import liquibase.database.Database;
Expand Down Expand Up @@ -783,6 +784,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
changelogSchemaName,
databaseChangeLogTableName,
databaseChangeLogLockTableName);
DbUrlConnectionCommandStep.logMdc(url, database);
liquibase = createLiquibase(database);

configureChangeLogProperties();
Expand Down
Expand Up @@ -243,6 +243,7 @@ protected void performLiquibaseTask(Liquibase liquibase) throws LiquibaseExcepti
Database db = liquibase.getDatabase();

try (Database referenceDatabase = CommandLineUtils.createDatabaseObject(resourceAccessor, referenceUrl, referenceUsername, referencePassword, referenceDriver, referenceDefaultCatalogName, referenceDefaultSchemaName, outputDefaultCatalog, outputDefaultSchema, null, null, propertyProviderClass, null, null, databaseChangeLogTableName, databaseChangeLogLockTableName)) {
ReferenceDbUrlConnectionCommandStep.logMdc(referenceUrl, referenceUsername, referenceDefaultSchemaName, referenceDefaultCatalogName);

getLog().info("Performing Diff on database " + db.toString());
if ((diffExcludeObjects != null) && (diffIncludeObjects != null)) {
Expand Down Expand Up @@ -296,6 +297,7 @@ private CompareControl.SchemaComparison[] createSchemaComparisons(Database datab
defaultCatalogName, defaultSchemaName,
referenceDefaultCatalogName, referenceDefaultSchemaName,
database);
PreCompareCommandStep.logMdcProperties(schemas, outputSchemas, referenceSchemas);

return computedSchemas.finalSchemaComparisons;
}
Expand Down
Expand Up @@ -97,7 +97,7 @@ private Database obtainDatabase(CommandScope commandScope) throws DatabaseExcept
}
}

private void logMdc(String url, Database database) {
public static void logMdc(String url, Database database) {
Scope.getCurrentScope().addMdcValue(MdcKey.LIQUIBASE_TARGET_URL, url);
Scope.getCurrentScope().addMdcValue(MdcKey.LIQUIBASE_CATALOG_NAME, database.getLiquibaseCatalogName());
Scope.getCurrentScope().addMdcValue(MdcKey.LIQUIBASE_SCHEMA_NAME, database.getLiquibaseSchemaName());
Expand Down
Expand Up @@ -157,7 +157,7 @@ private CompareControl getCompareControl(CommandScope commandScope, Database dat
return new CompareControl(finalSchemaComparisons, diffTypes);
}

private void logMdcProperties(String schemas, String outputSchemas, String referenceSchemas) {
public static void logMdcProperties(String schemas, String outputSchemas, String referenceSchemas) {
Scope.getCurrentScope().addMdcValue(MdcKey.SCHEMAS, schemas);
Scope.getCurrentScope().addMdcValue(MdcKey.OUTPUT_SCHEMAS, outputSchemas);
Scope.getCurrentScope().addMdcValue(MdcKey.REFERENCE_SCHEMAS, referenceSchemas);
Expand Down
Expand Up @@ -83,7 +83,7 @@ private Database obtainDatabase(CommandScope commandScope) throws DatabaseExcept
}
}

private void logMdc(String url, String username, String defaultSchemaName, String defaultCatalogName) {
public static void logMdc(String url, String username, String defaultSchemaName, String defaultCatalogName) {
Scope.getCurrentScope().addMdcValue(MdcKey.LIQUIBASE_REF_URL, url);
Scope.getCurrentScope().addMdcValue(MdcKey.REFERENCE_USERNAME, username);
Scope.getCurrentScope().addMdcValue(MdcKey.REFERENCE_DEFAULT_SCHEMA_NAME, defaultSchemaName);
Expand Down