0

I'm trying to use Liquibase version 3.6 to maintain database version changes. I'm able to execute database version changes when i need to execute single file changes.

I have using below code to execute version changes successfully, but my intention is to dynamically execute the change logs from a folder and not single file. I'm using only Java for all configuration of Liquibase

@Startup
@Singleton
@TransactionManagement(TransactionManagementType.BEAN)
public class InitializerBean {
    @Resource(mappedName = "java:/M2M_RESOURCES")
    private DataSource ds;
    @PostConstruct
    protected void bootstrap() {
        ResourceAccessor resourceAccessor = new ClassLoaderResourceAccessor(getClass().getClassLoader());
        try (Connection connection = ds.getConnection()) {
            JdbcConnection jdbcConnection = new JdbcConnection(connection);
            Database db = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(jdbcConnection);
            Liquibase liquiBase = new Liquibase("data/liquibase/", resourceAccessor, db);
            liquiBase.update("Development");
        } catch (SQLException | LiquibaseException e) {
        }
    }
}

When the first parameter of Liquibase class is single file , liquibase is able to execute changes but when I intent to execute all file of single folder is not able to track and execute changes.

I'm using JDK 1.8 and file in data/liquibase/ is dbChangelog.sql and dbChangelog_2.sq. This all code is deployed on Wildfly 10 as part of ear archive

Chaitan Yadav
  • 105
  • 10
  • 1
    Why don't you create a single changeLog that ``s all changelogs you need. Maybe even using ``? –  Jun 27 '19 at 09:29
  • thanks for replying. I was trying to do every thing in java including configuration parts also. I tried looking it online but documentation of Liquibase is poor. Certainly i can use xml type for changelog but first preference is to java for configuration. Can you explain how to do it in java only? – Chaitan Yadav Jun 27 '19 at 10:12
  • No idea. I exclusively use XML changeLog files. –  Jun 27 '19 at 10:23
  • thanks buddy for replying – Chaitan Yadav Jun 27 '19 at 10:27

0 Answers0