Search in sources :

Example 1 with GenerateChangeLogCommand

use of liquibase.command.core.GenerateChangeLogCommand 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

CatalogAndSchema (liquibase.CatalogAndSchema)1 CommandExecutionException (liquibase.command.CommandExecutionException)1 GenerateChangeLogCommand (liquibase.command.core.GenerateChangeLogCommand)1 CompareControl (liquibase.diff.compare.CompareControl)1