use of liquibase.diff.DiffResult in project dropwizard by dropwizard.
the class DbDumpCommand method generateChangeLog.
private void generateChangeLog(final Database database, final CatalogAndSchema catalogAndSchema, final DiffToChangeLog changeLogWriter, PrintStream outputStream, final Set<Class<? extends DatabaseObject>> compareTypes) throws DatabaseException, IOException, ParserConfigurationException {
@SuppressWarnings({ "unchecked", "rawtypes" }) final SnapshotControl snapshotControl = new SnapshotControl(database, compareTypes.toArray(new Class[compareTypes.size()]));
final CompareControl compareControl = new CompareControl(new CompareControl.SchemaComparison[] { new CompareControl.SchemaComparison(catalogAndSchema, catalogAndSchema) }, compareTypes);
final CatalogAndSchema[] compareControlSchemas = compareControl.getSchemas(CompareControl.DatabaseRole.REFERENCE);
try {
final DatabaseSnapshot referenceSnapshot = SnapshotGeneratorFactory.getInstance().createSnapshot(compareControlSchemas, database, snapshotControl);
final DatabaseSnapshot comparisonSnapshot = SnapshotGeneratorFactory.getInstance().createSnapshot(compareControlSchemas, null, snapshotControl);
final DiffResult diffResult = DiffGeneratorFactory.getInstance().compare(referenceSnapshot, comparisonSnapshot, compareControl);
changeLogWriter.setDiffResult(diffResult);
changeLogWriter.print(outputStream);
} catch (InvalidExampleException e) {
throw new UnexpectedLiquibaseException(e);
}
}
use of liquibase.diff.DiffResult in project liquibase by liquibase.
the class DiffCommand method run.
@Override
protected CommandResult run() throws Exception {
DiffResult diffResult = createDiffResult();
new DiffToReport(diffResult, outputStream).print();
return new CommandResult("OK");
}
use of liquibase.diff.DiffResult in project liquibase by liquibase.
the class DiffToChangeLogCommand method run.
@Override
protected CommandResult run() throws Exception {
DiffResult diffResult = createDiffResult();
PrintStream outputStream = this.getOutputStream();
if (outputStream == null) {
outputStream = System.out;
}
if (StringUtils.trimToNull(changeLogFile) == null) {
createDiffToChangeLogObject(diffResult).print(outputStream);
} else {
createDiffToChangeLogObject(diffResult).print(changeLogFile);
}
return new CommandResult("OK");
}
use of liquibase.diff.DiffResult in project liquibase by liquibase.
the class GenerateChangeLogCommand method run.
@Override
protected CommandResult run() throws Exception {
DiffResult diffResult = createDiffResult();
DiffToChangeLog changeLogWriter = new DiffToChangeLog(diffResult, getDiffOutputControl());
changeLogWriter.setChangeSetAuthor(author);
changeLogWriter.setChangeSetContext(context);
changeLogWriter.setChangeSetPath(getChangeLogFile());
if (StringUtils.trimToNull(getChangeLogFile()) != null) {
changeLogWriter.print(getChangeLogFile());
} else {
PrintStream outputStream = getOutputStream();
if (outputStream == null) {
outputStream = System.out;
}
changeLogWriter.print(outputStream);
}
return new CommandResult("OK");
}
use of liquibase.diff.DiffResult in project liquibase by liquibase.
the class DiffToChangeLogTest method getOrderedOutputTypes_isConsistant.
@Test
public void getOrderedOutputTypes_isConsistant() throws Exception {
MySQLDatabase database = new MySQLDatabase();
DiffToChangeLog obj = new DiffToChangeLog(new DiffResult(new EmptyDatabaseSnapshot(database), new EmptyDatabaseSnapshot(database), new CompareControl()), null);
for (Class<? extends ChangeGenerator> type : new Class[] { UnexpectedObjectChangeGenerator.class, MissingObjectChangeGenerator.class, ChangedObjectChangeGenerator.class }) {
List<Class<? extends DatabaseObject>> orderedOutputTypes = obj.getOrderedOutputTypes(type);
for (int i = 0; i < 50; i++) {
assertThat("Error checking " + type.getName(), orderedOutputTypes, contains(obj.getOrderedOutputTypes(type).toArray()));
}
}
}
Aggregations