Reputation: 81
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!
Upvotes: 8
Views: 8254
Reputation: 3882
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>
Upvotes: 2
Reputation: 503
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.
Upvotes: 6