Skip to content

Commit

Permalink
Merge branch 'feature/lambda-expressions' of https://github.com/artur…
Browse files Browse the repository at this point in the history
…obernalg/liquibase into arturobernalg-feature/lambda-expressions
  • Loading branch information
MalloD12 committed Feb 21, 2023
2 parents 0b20257 + 7c3041a commit 8db2820
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 52 deletions.
44 changes: 11 additions & 33 deletions liquibase-core/src/main/java/liquibase/Liquibase.java
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,7 @@ public void update(Contexts contexts, LabelExpression labelExpression, boolean c
//
ChangeLogIterator runChangeLogIterator = getStandardChangelogIterator(contexts, labelExpression, changeLog);
CompositeLogService compositeLogService = new CompositeLogService(true, bufferLog);
Scope.child(Scope.Attr.logService.name(), compositeLogService, () -> {
runChangeLogIterator.run(createUpdateVisitor(), new RuntimeEnvironment(database, contexts, labelExpression));
});
Scope.child(Scope.Attr.logService.name(), compositeLogService, () -> runChangeLogIterator.run(createUpdateVisitor(), new RuntimeEnvironment(database, contexts, labelExpression)));

showUpdateSummary(changeLog, statusVisitor);

Expand Down Expand Up @@ -828,12 +826,9 @@ public void run() throws Exception {
new CountChangeSetFilter(changesToApply));

CompositeLogService compositeLogService = new CompositeLogService(true, bufferLog);
Scope.child(Scope.Attr.logService.name(), compositeLogService, () -> {
runChangeLogIterator.run(createUpdateVisitor(), new RuntimeEnvironment(database, contexts, labelExpression));
});
Scope.child(Scope.Attr.logService.name(), compositeLogService, () -> runChangeLogIterator.run(createUpdateVisitor(), new RuntimeEnvironment(database, contexts, labelExpression)));

showUpdateSummary(changeLog, statusVisitor);

hubUpdater.postUpdateHub(updateOperation, bufferLog);
}
catch (Throwable e) {
Expand Down Expand Up @@ -963,12 +958,9 @@ public void run() throws Exception {
new UpToTagChangeSetFilter(tag, ranChangeSetList));

CompositeLogService compositeLogService = new CompositeLogService(true, bufferLog);
Scope.child(Scope.Attr.logService.name(), compositeLogService, () -> {
runChangeLogIterator.run(createUpdateVisitor(), new RuntimeEnvironment(database, contexts, labelExpression));
});
Scope.child(Scope.Attr.logService.name(), compositeLogService, () -> runChangeLogIterator.run(createUpdateVisitor(), new RuntimeEnvironment(database, contexts, labelExpression)));

showUpdateSummary(changeLog, statusVisitor);

hubUpdater.postUpdateHub(updateOperation, bufferLog);
}
catch (Throwable e) {
Expand Down Expand Up @@ -1221,17 +1213,13 @@ public void run() throws Exception {

CompositeLogService compositeLogService = new CompositeLogService(true, bufferLog);
if (rollbackScript == null) {
Scope.child(Scope.Attr.logService.name(), compositeLogService, () -> {
logIterator.run(createRollbackVisitor(), new RuntimeEnvironment(database, contexts, labelExpression));
});
Scope.child(Scope.Attr.logService.name(), compositeLogService, () -> logIterator.run(createRollbackVisitor(), new RuntimeEnvironment(database, contexts, labelExpression)));
} else {
List<ChangeSet> changeSets = determineRollbacks(logIterator, contexts, labelExpression);
Map<String, Object> values = new HashMap<>();
values.put(Scope.Attr.logService.name(), compositeLogService);
values.put(BufferedLogService.class.getName(), bufferLog);
Scope.child(values, () -> {
executeRollbackScript(rollbackScript, changeSets, contexts, labelExpression);
});
Scope.child(values, () -> executeRollbackScript(rollbackScript, changeSets, contexts, labelExpression));
removeRunStatus(changeSets, contexts, labelExpression);
}
hubUpdater.postUpdateHub(rollbackOperation, bufferLog);
Expand Down Expand Up @@ -1497,17 +1485,13 @@ public void run() throws Exception {

CompositeLogService compositeLogService = new CompositeLogService(true, bufferLog);
if (rollbackScript == null) {
Scope.child(Scope.Attr.logService.name(), compositeLogService, () -> {
logIterator.run(createRollbackVisitor(), new RuntimeEnvironment(database, contexts, labelExpression));
});
Scope.child(Scope.Attr.logService.name(), compositeLogService, () -> logIterator.run(createRollbackVisitor(), new RuntimeEnvironment(database, contexts, labelExpression)));
} else {
List<ChangeSet> changeSets = determineRollbacks(logIterator, contexts, labelExpression);
Map<String, Object> values = new HashMap<>();
values.put(Scope.Attr.logService.name(), compositeLogService);
values.put(BufferedLogService.class.getName(), bufferLog);
Scope.child(values, () -> {
executeRollbackScript(rollbackScript, changeSets, contexts, labelExpression);
});
Scope.child(values, () -> executeRollbackScript(rollbackScript, changeSets, contexts, labelExpression));
removeRunStatus(changeSets, contexts, labelExpression);
}
hubUpdater.postUpdateHub(rollbackOperation, bufferLog);
Expand Down Expand Up @@ -1665,17 +1649,13 @@ public void run() throws Exception {

CompositeLogService compositeLogService = new CompositeLogService(true, bufferLog);
if (rollbackScript == null) {
Scope.child(Scope.Attr.logService.name(), compositeLogService, () -> {
logIterator.run(createRollbackVisitor(), new RuntimeEnvironment(database, contexts, labelExpression));
});
Scope.child(Scope.Attr.logService.name(), compositeLogService, () -> logIterator.run(createRollbackVisitor(), new RuntimeEnvironment(database, contexts, labelExpression)));
} else {
List<ChangeSet> changeSets = determineRollbacks(logIterator, contexts, labelExpression);
Map<String, Object> values = new HashMap<>();
values.put(Scope.Attr.logService.name(), compositeLogService);
values.put(BufferedLogService.class.getName(), bufferLog);
Scope.child(values, () -> {
executeRollbackScript(rollbackScript, changeSets, contexts, labelExpression);
});
Scope.child(values, () -> executeRollbackScript(rollbackScript, changeSets, contexts, labelExpression));
removeRunStatus(changeSets, contexts, labelExpression);
}
hubUpdater.postUpdateHub(rollbackOperation, bufferLog);
Expand Down Expand Up @@ -1807,10 +1787,8 @@ public void run() throws Exception {

ChangeLogIterator runChangeLogIterator = buildChangeLogIterator(tag, changeLog, contexts, labelExpression);
CompositeLogService compositeLogService = new CompositeLogService(true, bufferLog);
Scope.child(Scope.Attr.logService.name(), compositeLogService, () -> {
runChangeLogIterator.run(new ChangeLogSyncVisitor(database, changeLogSyncListener),
new RuntimeEnvironment(database, contexts, labelExpression));
});
Scope.child(Scope.Attr.logService.name(), compositeLogService, () -> runChangeLogIterator.run(new ChangeLogSyncVisitor(database, changeLogSyncListener),
new RuntimeEnvironment(database, contexts, labelExpression)));
hubUpdater.postUpdateHub(changeLogSyncOperation, bufferLog);
}
catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ public void run() throws Exception {
Map<String, Object> values = new HashMap<>();
values.put(Scope.Attr.logService.name(), compositeLogService);
values.put(BufferedLogService.class.getName(), bufferLog);
Scope.child(values, () -> {
visitor.visit(changeSet, databaseChangeLog, env.getTargetDatabase(), reasonsAccepted);
});
Scope.child(values, () -> visitor.visit(changeSet, databaseChangeLog, env.getTargetDatabase(), reasonsAccepted));
markSeen(changeSet);
} else {
if (visitor instanceof SkippedChangeSetVisitor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ public void run(CommandResultsBuilder resultsBuilder) throws Exception {
" Integration Web URL: " + intUrl + System.lineSeparator());


Runtime.getRuntime().addShutdownHook(new Thread(() -> {
Scope.getCurrentScope().getUI().sendMessage("Shutting down H2 database...");
}));
Runtime.getRuntime().addShutdownHook(new Thread(() -> Scope.getCurrentScope().getUI().sendMessage("Shutting down H2 database...")));

Thread.sleep(Long.MAX_VALUE);
} catch (InterruptedException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@

public class DropDefaultValueGenerator extends AbstractSqlGenerator<DropDefaultValueStatement> {

public static BiFunction DROP_DF_MSSQL = (tableName, columnName) -> {
return "DECLARE @sql [nvarchar](MAX)\r\n" +
"SELECT @sql = N'ALTER TABLE " + tableName + " DROP CONSTRAINT ' + QUOTENAME([df].[name]) " +
"FROM [sys].[columns] AS [c] " +
"INNER JOIN [sys].[default_constraints] AS [df] " +
"ON [df].[object_id] = [c].[default_object_id] " +
"WHERE [c].[object_id] = OBJECT_ID(N'" + tableName + "') " +
"AND [c].[name] = N'" + columnName + "'\r\n" +
"EXEC sp_executesql @sql";
};
public static BiFunction DROP_DF_MSSQL = (tableName, columnName) -> "DECLARE @sql [nvarchar](MAX)\r\n" +
"SELECT @sql = N'ALTER TABLE " + tableName + " DROP CONSTRAINT ' + QUOTENAME([df].[name]) " +
"FROM [sys].[columns] AS [c] " +
"INNER JOIN [sys].[default_constraints] AS [df] " +
"ON [df].[object_id] = [c].[default_object_id] " +
"WHERE [c].[object_id] = OBJECT_ID(N'" + tableName + "') " +
"AND [c].[name] = N'" + columnName + "'\r\n" +
"EXEC sp_executesql @sql";

@Override
public boolean supports(DropDefaultValueStatement statement, Database database) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -779,9 +779,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
//
Map<String, Object> innerScopeValues = new HashMap<>();
innerScopeValues.put(key, preserveSchemaCase);
Scope.child(innerScopeValues, () -> {
performLiquibaseTask(liquibase);
});
Scope.child(innerScopeValues, () -> performLiquibaseTask(liquibase));
} catch (LiquibaseException e) {
cleanup(database);
throw new MojoExecutionException("\nError setting up or running Liquibase:\n" + e.getMessage(), e);
Expand Down

0 comments on commit 8db2820

Please sign in to comment.