• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java DiffGeneratorFactory类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中liquibase.diff.DiffGeneratorFactory的典型用法代码示例。如果您正苦于以下问题:Java DiffGeneratorFactory类的具体用法?Java DiffGeneratorFactory怎么用?Java DiffGeneratorFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

DiffGeneratorFactory类属于liquibase.diff包,在下文中一共展示了DiffGeneratorFactory类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: recordSchemaDifferencesBetweenHbm2ddlAndLiquibase

点赞 3

import liquibase.diff.DiffGeneratorFactory; //导入依赖的package包/类
public void recordSchemaDifferencesBetweenHbm2ddlAndLiquibase() throws SQLException, LiquibaseException,
        IOException, ParserConfigurationException {
    Database referenceConnection = createDatabase(liquibaseDataSource.getConnection());
    Database comparisonConnection = createDatabase(hbm2ddlDataSource.getConnection());

    Liquibase liquibaseObject =
        new Liquibase("liquibase/changelog-master.xml", new ClassLoaderResourceAccessor(), referenceConnection);
    liquibaseObject.dropAll();
    liquibaseObject.update("");

    DiffResult result =
        DiffGeneratorFactory.getInstance().compare(comparisonConnection, referenceConnection, new CompareControl());

    DiffToChangeLog changeLog = new DiffToChangeLog(result, new DiffOutputControl(false, false, false));

    changeLog.print(new File("target/schemaDifferences.xml").getAbsolutePath(), new XMLChangeLogSerializer());

    changeLog.print(System.out);
}
 

开发者ID:jhaood,
项目名称:github-job-keywords,
代码行数:20,
代码来源:LiquibaseActuator.java

示例2: testDiff

点赞 3

import liquibase.diff.DiffGeneratorFactory; //导入依赖的package包/类
@Test
public void testDiff() throws Exception {
    if (database == null) {
        return;
    }

    runCompleteChangeLog();

    DiffResult diffResult = DiffGeneratorFactory.getInstance().compare(database, database, new CompareControl());

    try {
        assertTrue(diffResult.areEqual());
    } catch (AssertionError e) {
        new DiffToReport(diffResult, System.err).print();
        throw e;
    }
}
 

开发者ID:lbitonti,
项目名称:liquibase-hana,
代码行数:18,
代码来源:AbstractIntegrationTest.java

示例3: diff

点赞 2

import liquibase.diff.DiffGeneratorFactory; //导入依赖的package包/类
/**
 * Compare 2 databases using diff liquibase function
 *
 * @param paasTestDbUrl
 * @param paasTestDbUser
 * @param paasTestDbPassword
 * @param paasTestDb2Url
 * @param paasTestDb2User
 * @param paasTestDb2Password
 * @return SimpleDiffResult containing a flag indicating if diffreneces have been found and a text representation of those differences
 * @throws SQLException
 * @throws LiquibaseException
 * @throws IOException
 * @throws ParserConfigurationException
 */
public DiffResult diff(String paasTestDbUrl, String paasTestDbUser, String paasTestDbPassword, String paasTestDb2Url, String paasTestDb2User,
                       String paasTestDb2Password) throws SQLException, LiquibaseException, IOException, ParserConfigurationException {

    logger.debug("Running liquibase diff between db: " + paasTestDbUrl + " and db: " + paasTestDb2Url);
    Database referenceDatabase = null;
    Database targetDatabase = null;

    try {
        referenceDatabase = createDatabase(paasTestDbUrl, paasTestDbUser, paasTestDbPassword);
        targetDatabase = createDatabase(paasTestDb2Url, paasTestDb2User, paasTestDb2Password);

        final DiffGeneratorFactory generatorFactory = DiffGeneratorFactory.getInstance();
        final CompareControl compareControl = new CompareControl();


        final DiffResult diffResult = generatorFactory.compare(referenceDatabase, targetDatabase, compareControl);

        boolean ignoreDefaultValueDifference = false;
        if (ignoreDefaultValueDifference) {
            Map<DatabaseObject, ObjectDifferences> changedObjects = diffResult.getChangedObjects();
            for (DatabaseObject changedDbObject : changedObjects.keySet()) {
                ObjectDifferences objectDifferences = changedObjects.get(changedDbObject);
                if (objectDifferences.removeDifference("defaultValue")) {
                    logger.info("Ignoring default value for {}", changedDbObject.toString());
                }
                if (!objectDifferences.hasDifferences()) {
                    logger.info("removing {}, no difference left.", changedDbObject.toString());
                    changedObjects.remove(objectDifferences);
                }
            }
        }

        return diffResult;

    } finally {
        closeDatabase(referenceDatabase);
        closeDatabase(targetDatabase);
    }
}
 

开发者ID:orange-cloudfoundry,
项目名称:elpaaso-core,
代码行数:55,
代码来源:LiquibaseTestWrapper.java

示例4: generateChangeLog_noChanges

点赞 2

import liquibase.diff.DiffGeneratorFactory; //导入依赖的package包/类
@Test
public void generateChangeLog_noChanges() throws Exception{
    if (database == null) {
        return;
    }

    runCompleteChangeLog();

    DiffResult diffResult = DiffGeneratorFactory.getInstance().compare(database, database, new CompareControl());

    DiffToChangeLog changeLogWriter = new DiffToChangeLog(diffResult, new DiffOutputControl(false, false, false));
    assertEquals(0, changeLogWriter.generateChangeSets().size());
}
 

开发者ID:lbitonti,
项目名称:liquibase-hana,
代码行数:14,
代码来源:AbstractIntegrationTest.java

示例5: generateMigrations

点赞 2

import liquibase.diff.DiffGeneratorFactory; //导入依赖的package包/类
private File generateMigrations(final Database referenceDatabase, final Database targetDatabase)
        throws LiquibaseException, IOException {

    if (!resourcesDir.exists()) {
        resourcesDir.mkdirs();
    }

    if (!migrationsDir.exists()) {
        migrationsDir.mkdirs();
    }

    if (masterChangeLogFile.exists()) {
        LOG.info("Checking current database state");
        validateDatabaseState(targetDatabase);

    } else {
        LOG.info("Creating new master changelog");
        writeChangeSets(masterChangeLogFile, emptyList());
    }

    @SuppressWarnings("unchecked")
    final SnapshotControl snapshotControl = new SnapshotControl(
            referenceDatabase,
            liquibase.structure.core.Schema.class,
            liquibase.structure.core.Table.class,
            liquibase.structure.core.Column.class,
            liquibase.structure.core.PrimaryKey.class,
            liquibase.structure.core.Index.class);

    LOG.info("Executing diff");
    final CompareControl compareControl = new CompareControl(snapshotControl.getTypesToInclude());
    final DiffResult diffResult = DiffGeneratorFactory.getInstance().compare(
            referenceDatabase,
            targetDatabase,
            compareControl);

    LOG.info("Converting diff to changelog");
    final DiffOutputControl diffOutputControl = new DiffOutputControl(false, false, true, null);
    final DiffToChangeLog diffToChangeLog = new DiffToChangeLog(diffResult, diffOutputControl);
    diffToChangeLog.setChangeSetAuthor(System.getProperty("user.name"));

    final List<ChangeSet> changeSets = filterChangeSets(diffToChangeLog.generateChangeSets());
    LOG.info("Found {} changes", changeSets.size());
    if (changeSets.isEmpty()) {
        return null;
    }

    final File generatedChangeLogFile = new File(migrationsDir, generateFileName(masterChangeLogFile));
    LOG.info("Writing new changelog: {}", generatedChangeLogFile);
    writeChangeSets(generatedChangeLogFile, changeSets);

    LOG.info("Add migration to master changelog: {}", masterChangeLogFile);
    addIncludeFile(generatedChangeLogFile);

    LOG.info("Cleaning changelog");
    cleanXmlFile(masterChangeLogFile);
    cleanXmlFile(generatedChangeLogFile);

    LOG.info("Diff complete");
    return generatedChangeLogFile;
}
 

开发者ID:minijax,
项目名称:minijax,
代码行数:62,
代码来源:LiquibaseHelper.java

示例6: run

点赞 2

import liquibase.diff.DiffGeneratorFactory; //导入依赖的package包/类
@Override
public void run(Namespace namespace, Liquibase liquibase) throws Exception {
    final Set<Class<? extends DatabaseObject>> compareTypes = new HashSet<>();

    if (namespace.getBoolean("columns")) {
        compareTypes.add(Column.class);
    }
    if (namespace.getBoolean("data")) {
        compareTypes.add(Data.class);
    }
    if (namespace.getBoolean("foreign-keys")) {
        compareTypes.add(ForeignKey.class);
    }
    if (namespace.getBoolean("indexes")) {
        compareTypes.add(Index.class);
    }
    if (namespace.getBoolean("primary-keys")) {
        compareTypes.add(PrimaryKey.class);
    }
    if (namespace.getBoolean("sequences")) {
        compareTypes.add(Sequence.class);
    }
    if (namespace.getBoolean("tables")) {
        compareTypes.add(Table.class);
    }
    if (namespace.getBoolean("unique-constraints")) {
        compareTypes.add(UniqueConstraint.class);
    }
    if (namespace.getBoolean("views")) {
        compareTypes.add(View.class);
    }

    final DiffResult diffResult = DiffGeneratorFactory.getInstance().compare(liquibase.getDatabase(), null,
            new CompareControl(compareTypes));
    final DiffToChangeLog diffToChangeLog = new DiffToChangeLog(diffResult, new DiffOutputControl());
    final String filename = namespace.getString("output");

    if (filename != null) {
        try (PrintStream file = new PrintStream(filename, Charsets.UTF_8.name())) {
            diffToChangeLog.print(file);
        }
    } else {
        diffToChangeLog.print(System.out);
    }
}
 

开发者ID:Astonish-Results,
项目名称:dropwizard-routing,
代码行数:46,
代码来源:RoutingDbDumpCommand.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)