use of liquibase.command.CommandExecutionException in project liquibase by liquibase.
the class CommandLineUtils method doDiffToChangeLog.
public static void doDiffToChangeLog(String changeLogFile, Database referenceDatabase, Database targetDatabase, DiffOutputControl diffOutputControl, String snapshotTypes, CompareControl.SchemaComparison[] schemaComparisons) throws LiquibaseException, IOException, ParserConfigurationException {
DiffToChangeLogCommand command = (DiffToChangeLogCommand) CommandFactory.getInstance().getCommand("diffChangeLog");
command.setReferenceDatabase(referenceDatabase).setTargetDatabase(targetDatabase).setSnapshotTypes(snapshotTypes).setCompareControl(new CompareControl(schemaComparisons, snapshotTypes)).setOutputStream(System.out);
command.setChangeLogFile(changeLogFile).setDiffOutputControl(diffOutputControl);
try {
command.execute();
} catch (CommandExecutionException e) {
throw new LiquibaseException(e);
}
}
use of liquibase.command.CommandExecutionException in project liquibase by liquibase.
the class CommandLineUtils method doDiff.
public static void doDiff(Database referenceDatabase, Database targetDatabase, String snapshotTypes, CompareControl.SchemaComparison[] schemaComparisons) throws LiquibaseException {
DiffCommand diffCommand = (DiffCommand) CommandFactory.getInstance().getCommand("diff");
diffCommand.setReferenceDatabase(referenceDatabase).setTargetDatabase(targetDatabase).setCompareControl(new CompareControl(schemaComparisons, snapshotTypes)).setSnapshotTypes(snapshotTypes).setOutputStream(System.out);
System.out.println("");
System.out.println("Diff Results:");
try {
diffCommand.execute();
} catch (CommandExecutionException e) {
throw new LiquibaseException(e);
}
}
use of liquibase.command.CommandExecutionException in project liquibase by liquibase.
the class Liquibase method dropAll.
/**
* Drops all database objects in the passed schema(s).
*/
public final void dropAll(CatalogAndSchema... schemas) throws DatabaseException {
if (schemas == null || schemas.length == 0) {
schemas = new CatalogAndSchema[] { new CatalogAndSchema(getDatabase().getDefaultCatalogName(), getDatabase().getDefaultSchemaName()) };
}
DropAllCommand dropAll = (DropAllCommand) CommandFactory.getInstance().getCommand("dropAll");
dropAll.setDatabase(this.getDatabase());
dropAll.setSchemas(schemas);
try {
dropAll.execute();
} catch (CommandExecutionException e) {
throw new DatabaseException(e);
}
}
use of liquibase.command.CommandExecutionException in project liquibase by liquibase.
the class CommandLineUtils method doGenerateChangeLog.
public static void doGenerateChangeLog(String changeLogFile, Database originalDatabase, CatalogAndSchema[] schemas, String snapshotTypes, String author, String context, String dataDir, DiffOutputControl diffOutputControl) throws DatabaseException, IOException, ParserConfigurationException, InvalidExampleException, LiquibaseException {
CompareControl.SchemaComparison[] comparisons = new CompareControl.SchemaComparison[schemas.length];
int i = 0;
for (CatalogAndSchema schema : schemas) {
comparisons[i++] = new CompareControl.SchemaComparison(schema, schema);
}
CompareControl compareControl = new CompareControl(comparisons, snapshotTypes);
diffOutputControl.setDataDir(dataDir);
GenerateChangeLogCommand command = (GenerateChangeLogCommand) CommandFactory.getInstance().getCommand("generateChangeLog");
command.setReferenceDatabase(originalDatabase).setSnapshotTypes(snapshotTypes).setOutputStream(System.out).setCompareControl(compareControl);
command.setChangeLogFile(changeLogFile).setDiffOutputControl(diffOutputControl);
command.setAuthor(author).setContext(context);
try {
command.execute();
} catch (CommandExecutionException e) {
throw new LiquibaseException(e);
}
}
Aggregations