Search in sources :

Example 1 with CommandExecutionException

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);
    }
}
Also used : DiffToChangeLogCommand(liquibase.command.core.DiffToChangeLogCommand) CompareControl(liquibase.diff.compare.CompareControl) CommandExecutionException(liquibase.command.CommandExecutionException)

Example 2 with CommandExecutionException

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);
    }
}
Also used : CompareControl(liquibase.diff.compare.CompareControl) CommandExecutionException(liquibase.command.CommandExecutionException) DiffCommand(liquibase.command.core.DiffCommand)

Example 3 with CommandExecutionException

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);
    }
}
Also used : DropAllCommand(liquibase.command.core.DropAllCommand) CommandExecutionException(liquibase.command.CommandExecutionException) DatabaseException(liquibase.exception.DatabaseException)

Example 4 with CommandExecutionException

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);
    }
}
Also used : GenerateChangeLogCommand(liquibase.command.core.GenerateChangeLogCommand) CompareControl(liquibase.diff.compare.CompareControl) CommandExecutionException(liquibase.command.CommandExecutionException) CatalogAndSchema(liquibase.CatalogAndSchema)

Aggregations

CommandExecutionException (liquibase.command.CommandExecutionException)4 CompareControl (liquibase.diff.compare.CompareControl)3 CatalogAndSchema (liquibase.CatalogAndSchema)1 DiffCommand (liquibase.command.core.DiffCommand)1 DiffToChangeLogCommand (liquibase.command.core.DiffToChangeLogCommand)1 DropAllCommand (liquibase.command.core.DropAllCommand)1 GenerateChangeLogCommand (liquibase.command.core.GenerateChangeLogCommand)1 DatabaseException (liquibase.exception.DatabaseException)1