Liquibase include with context

2019-05-23 15:36发布

问题:

I need to include files in a databaseChangeLog, but these files may not exist, depending on the installation. My idea was to use something like includes with context, so Liquibase will only try to open the file when the appropriate context is given:

<include file=”myFile” context=”myContext”/>

But context is not used in an include tag, and Liquibase fails because the file is not present. I’ll rather not use includeAll because I need the files to be included at specific parts of my main file. Any ideas? Thanks!

回答1:

Which version of liquibase are you using?

The "context" was added to the include tag in this commit.

Also check out this jira ticket: CORE-155.

So maybe your version of liquibase is just too old (below 3.5.0)?



回答2:

Along with what Jens said, make sure you update your XML schema version. The one they have in the documentation (currently 3.1) doesn't not support this. Updating it to 3.5 works for me.

<databaseChangeLog
    xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">

(Note the 3.5 at the very end)



标签: liquibase