The include tag allows you to break up your changelogs into more manageable pieces. To easily include multiple files, use the includeAll tag.
As projects grow, the number of changesets in a changelog can grow unwieldy. To help ease this problem,
and to make management of changes easier, DATABASECHANGELOG can be included to create a tree of changelogs.
In the example above, the root change log includes first the changes in
the changes in
Included changelogs are run in the order they are found so care does need to be taken to make sure that the included changelogs are either completely independent, or that any required changelogs are run first.
Any Preconditions defined at the changelog level in sub changelog files will be evaluated before any changesets are ran.
The reason to use the
<include> tag rather than using XML's built-in include functionality is that
with the built-in functionality the parser sees just one big XML document. Liquibase needs to uniquely identify each changeset with
the id, the author, and the file name. By using the
<includeAll> tags Liquibase makes it so you only have to
ensure that the id/author combinations are unique within each file, not across all change logs.
|file||Name of the file to import required|
|relativeToChangelogFile||Is the file path relative to the changelog file containing the element rather than to the classpath. Defaults to "false" since 1.9|
|context||Append context (using AND) to all contained changesets since 3.5|
Currently there is no checking for looping changelogs or double inclusion of changelogs.
If you include a changelog twice, you shouldn't run into problems because the second time around, Liquibase will know that the changesets have been run and won't run them again (even if there is a runAlways tag).
If you create a changelog loop (root.changelog.xml includes news.changelog.xml which includes root.changelog.xml) you will get an infinite loop. Checks for loops is a feature on our list of enhancements, but is currently not implemented.