liquibase.command.core.ClearChecksumsCommandStep Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of liquibase-core Show documentation
Show all versions of liquibase-core Show documentation
Liquibase is a tool for managing and executing database changes.
package liquibase.command.core;
import liquibase.Scope;
import liquibase.changelog.ChangeLogHistoryService;
import liquibase.changelog.ChangeLogHistoryServiceFactory;
import liquibase.command.*;
import liquibase.database.Database;
import liquibase.lockservice.LockService;
import java.util.Arrays;
import java.util.List;
public class ClearChecksumsCommandStep extends AbstractCommandStep {
public static final String[] COMMAND_NAME = {"clearChecksums"};
@Override
public String[][] defineCommandNames() {
return new String[][] { COMMAND_NAME };
}
@Override
public void adjustCommandDefinition(CommandDefinition commandDefinition) {
commandDefinition.setShortDescription("Clears all checksums");
commandDefinition.setLongDescription("Clears all checksums and nullifies the MD5SUM column of the " +
"DATABASECHANGELOG table so that they will be re-computed on the next database update");
}
@Override
public void run(CommandResultsBuilder resultsBuilder) throws Exception {
CommandScope commandScope = resultsBuilder.getCommandScope();
final Database database = (Database) commandScope.getDependency(Database.class);
ChangeLogHistoryService changeLogService = ChangeLogHistoryServiceFactory.getInstance().getChangeLogService(database);
Scope.getCurrentScope().getLog(getClass()).info(String.format("Clearing database change log checksums for database %s", database.getShortName()));
changeLogService.clearAllCheckSums();
}
@Override
public List> requiredDependencies() {
return Arrays.asList(Database.class, LockService.class);
}
}