7

Currently I try to integrate Liquibase 3.3.3 into my project. In order to manage my database I call Liquibase from within my application while the changesets are in a JAR file with

final Liquibase liquibase = new Liquibase( "db/db_changelog_master.xml",
                                           new ClassLoaderResourceAccessor(),
                                           database );
liquibase.update( new Contexts() );

This call works and the master changeset is loaded. Within the master changeset further changesets are loaded:

<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
                   xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
                                       http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd
                                       http://www.liquibase.org/xml/ns/dbchangelog-ext
                                       http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
    <include file="classpath:db_changelog_1.0.xml"/>
</databaseChangeLog>

And here the problems start, because Liquibase cannot find and load the sub changesets. I also tried the <includeAll> tag and absolute and relative paths to the sub changeset without success.

Any suggestions what is the problem here?

Best regards!

  • Try this : http://www.liquibase.org/bestpractices.html – Prashant Jun 09 '15 at 07:20
  • Maybe you should add your folder structure of the changelog files. Is `db_changelog_1.0.xml` also within the `db` folder? Did you try `/db/db_changelog_1.0.xml` and `/db_changelog_1.0.xml` and `db/db_changelog_1.0.xml`? – Jens Jun 11 '15 at 06:28
  • did you found solution for this? – bilak May 23 '17 at 09:45

2 Answers2

5

I have my changelogs within other jar at src/main/resources/db/changelog/dbchange-master.xml and dbchange-2.xml

If I include dbchange-2.xml in master like this

<include file="classpath:/db/changelog/dbchange-2.xml" />

it works.

kqr
  • 406
  • 8
  • 12
2

The key to distributing changesets in jars and load them via the classpath is to suffix the classpath schema in your root changelog with *, thus <includeAll path="classpath*:/db/changelog/changesets"/>.

Note: This was broken in some versions ofLiquibase.

<databaseChangeLog  
                xmlns="http://www.liquibase.org/xml/ns/dbchangelog"  
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
                xmlns:pro="http://www.liquibase.org/xml/ns/pro"  
                xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd
                    http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-3.8.xsd">
  
  <includeAll path="classpath*:/db/changelog/changesets"/>

</databaseChangeLog>
Jeff
  • 3,712
  • 2
  • 22
  • 24