return ChangeSetVisitor.Direction.FORWARD;
}
@Override
public void visit(ChangeSet changeSet, DatabaseChangeLog databaseChangeLog, Database database, Set<ChangeSetFilterResult> filterResults) throws LiquibaseException {
RanChangeSet ranChangeSet = ranIndex.get(changeSet.toString(false));
boolean ran = ranChangeSet != null;
boolean shouldValidate = !ran || changeSet.shouldRunOnChange() || changeSet.shouldAlwaysRun();
for (Change change : changeSet.getChanges()) {
try {
change.finishInitialization();
} catch (SetupException se) {
setupExceptions.add(se);
}
if(shouldValidate){
warnings.addAll(change.warn(database));
try {
ValidationErrors foundErrors = change.validate(database);
if (foundErrors != null && foundErrors.hasErrors()) {
if (changeSet.getOnValidationFail().equals(ChangeSet.ValidationFailOption.MARK_RAN)) {
LogFactory.getLogger().info("Skipping changeSet "+changeSet+" due to validation error(s): "+ StringUtils.join(foundErrors.getErrorMessages(), ", "));
changeSet.setValidationFailed(true);
} else {
validationErrors.addAll(foundErrors, changeSet);
}
}
} catch (Throwable e) {
changeValidationExceptions.add(e);
}
}
}
if(ranChangeSet != null){
if (!changeSet.isCheckSumValid(ranChangeSet.getLastCheckSum())) {
if (!changeSet.shouldRunOnChange()) {
invalidMD5Sums.add(changeSet);
}
}
}