liquibase.changelog.DatabaseChangeLog Java Examples

The following examples show how to use liquibase.changelog.DatabaseChangeLog. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LiquibaseProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
/**
 * Finds all resource files for the given change log file
 */
private Set<String> findAllChangeLogs(String file, ChangeLogParserFactory changeLogParserFactory,
        ClassLoaderResourceAccessor classLoaderResourceAccessor,
        ChangeLogParameters changeLogParameters) {
    try {
        ChangeLogParser parser = changeLogParserFactory.getParser(file, classLoaderResourceAccessor);
        DatabaseChangeLog changelog = parser.parse(file, changeLogParameters, classLoaderResourceAccessor);

        if (changelog != null) {
            Set<String> result = new LinkedHashSet<>();
            // get all changeSet files
            for (ChangeSet changeSet : changelog.getChangeSets()) {
                result.add(changeSet.getFilePath());

                // get all parents of the changeSet
                DatabaseChangeLog parent = changeSet.getChangeLog();
                while (parent != null) {
                    result.add(parent.getFilePath());
                    parent = parent.getParentChangeLog();
                }
            }
            result.add(changelog.getFilePath());
            return result;
        }
    } catch (LiquibaseException ex) {
        throw new IllegalStateException(ex);
    }
    return Collections.emptySet();
}
 
Example #2
Source File: LiquibaseExtensionLoadChangeLogTest.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@Test
@DisplayName("Load the change log config correctly")
public void testLiquibaseConfigInjection() throws Exception {
    try (Liquibase liquibase = liquibaseFactory.createLiquibase()) {
        DatabaseChangeLog changelog = liquibase.getDatabaseChangeLog();
        assertEquals("db/xml/changeLog.xml", changelog.getFilePath());
        assertNotNull(changelog.getChangeSets());
        assertEquals("db/xml/create-tables.xml", changelog.getChangeSets().get(0).getFilePath());
        assertEquals("db/xml/test/test.xml", changelog.getChangeSets().get(1).getFilePath());
    }
}
 
Example #3
Source File: ChangeLogParserTest.java    From liquibase-percona with Apache License 2.0 5 votes vote down vote up
@Test
public void testReadLiquibaseUsePerconaFlagYAML() throws Exception {
    DatabaseChangeLog changelog = loadChangeLog("test-changelog.yaml");
    Assertions.assertEquals(2, changelog.getChangeSets().size());
    ChangeSet addColumnChangeset = changelog.getChangeSets().get(1);
    Change change = addColumnChangeset.getChanges().get(0);
    Assertions.assertEquals(PerconaAddColumnChange.class, change.getClass());
    Assertions.assertNotNull(((PerconaAddColumnChange)change).getUsePercona());
    Assertions.assertFalse(((PerconaAddColumnChange)change).getUsePercona());
}
 
Example #4
Source File: ChangeLogParserTest.java    From liquibase-percona with Apache License 2.0 5 votes vote down vote up
@Test
public void testReadLiquibaseUsePerconaFlagXML() throws Exception {
    DatabaseChangeLog changelog = loadChangeLog("test-changelog.xml");
    Assertions.assertEquals(2, changelog.getChangeSets().size());
    ChangeSet addColumnChangeset = changelog.getChangeSets().get(1);
    Change change = addColumnChangeset.getChanges().get(0);
    Assertions.assertEquals(PerconaAddColumnChange.class, change.getClass());
    Assertions.assertNotNull(((PerconaAddColumnChange)change).getUsePercona());
    Assertions.assertFalse(((PerconaAddColumnChange)change).getUsePercona());
}
 
Example #5
Source File: ChangeLogParserTest.java    From liquibase-percona with Apache License 2.0 5 votes vote down vote up
@Test
public void testReadLiquibaseUsePerconaFlagXMLPercona() throws Exception {
    DatabaseChangeLog changelog = loadChangeLog("test-changelog-percona.xml");
    Assertions.assertEquals(2, changelog.getChangeSets().size());
    ChangeSet addColumnChangeset = changelog.getChangeSets().get(1);
    Change change = addColumnChangeset.getChanges().get(0);
    Assertions.assertEquals(PerconaAddColumnChange.class, change.getClass());
    Assertions.assertNotNull(((PerconaAddColumnChange)change).getUsePercona());
    Assertions.assertFalse(((PerconaAddColumnChange)change).getUsePercona());
}
 
Example #6
Source File: AbstractJdbcDatabase.java    From jweb-cms with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void executeStatements(final Change change, final DatabaseChangeLog changeLog, final List<SqlVisitor> sqlVisitors) throws LiquibaseException {
    SqlStatement[] statements = change.generateStatements(this);

    execute(statements, sqlVisitors);
}
 
Example #7
Source File: HiveStandardChangeLogHistoryService.java    From liquibase-impala with Apache License 2.0 4 votes vote down vote up
@Override
public void upgradeChecksums(final DatabaseChangeLog databaseChangeLog, final Contexts contexts, LabelExpression labels) throws DatabaseException {
    super.upgradeChecksums(databaseChangeLog, contexts, labels);
    getDatabase().commit();
}
 
Example #8
Source File: LiquibaseLogger.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void setChangeLog (DatabaseChangeLog databaseChangeLog)
{
}
 
Example #9
Source File: Slf4jLogger.java    From telekom-workflow-engine with MIT License 4 votes vote down vote up
@Override
public void setChangeLog( DatabaseChangeLog databaseChangeLog ){
    changeLogName = (databaseChangeLog == null) ? null : databaseChangeLog.getFilePath();
}
 
Example #10
Source File: ChangeLogParserTest.java    From liquibase-percona with Apache License 2.0 4 votes vote down vote up
private DatabaseChangeLog loadChangeLog(String filename) throws Exception {
    ChangeLogParserFactory parserFactory = ChangeLogParserFactory.getInstance();
    ChangeLogParser parser = parserFactory.getParser(filename, resourceAccessor);
    return parser.parse(filename, new ChangeLogParameters(), resourceAccessor);
}
 
Example #11
Source File: DefaultLiquibaseConnectionProvider.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public void setChangeLog(DatabaseChangeLog databaseChangeLog) {
}
 
Example #12
Source File: KeycloakLogger.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public void setChangeLog(DatabaseChangeLog databaseChangeLog) {
}
 
Example #13
Source File: LiquibaseContext.java    From quarkus with Apache License 2.0 2 votes vote down vote up
/**
 * Implementation of the
 * {@link liquibase.Liquibase#checkLiquibaseTables(boolean, DatabaseChangeLog, Contexts, LabelExpression)}
 * method.
 *
 * @param updateExistingNullChecksums update existing null checksums
 * @param databaseChangeLog database change log
 * @throws LiquibaseException if the method fails.
 */
public void checkLiquibaseTables(boolean updateExistingNullChecksums, DatabaseChangeLog databaseChangeLog)
        throws LiquibaseException {
    checkLiquibaseTables(updateExistingNullChecksums, databaseChangeLog, createContexts(), createLabels());
}