liquibase.integration.ant.DatabaseRollbackFutureTask 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.
The newest version!
package liquibase.integration.ant;
import liquibase.Contexts;
import liquibase.Liquibase;
import liquibase.exception.LiquibaseException;
import org.apache.tools.ant.BuildException;
import java.io.IOException;
import java.io.Writer;
public class DatabaseRollbackFutureTask extends AbstractChangeLogBasedTask {
@Override
public void executeWithLiquibaseClassloader() throws BuildException {
Liquibase liquibase = getLiquibase();
try (Writer outputFileWriter = getOutputFileWriter()) {
liquibase.futureRollbackSQL(new Contexts(getContexts()), getLabelFilter(), outputFileWriter);
} catch (LiquibaseException e) {
throw new BuildException("Unable to generate future rollback SQL: " + e.getMessage(), e);
} catch (IOException e) {
throw new BuildException("Unable to generate future rollback SQL. Error creating output writer.", e);
}
}
@Override
protected void validateParameters() {
super.validateParameters();
if(getOutputFile() == null) {
throw new BuildException("Output file is required.");
}
}
}