3

I am using liquibase gradle plugin and I would like to specify multiple changelog files instead of just one. The changelogs to run depends on certain conditions.

liquibase {
   activities {
   main {      
      changeLogFile "liquibase-changelog.xml"
      url 'jdbc:mysql://localhost:3306/world'
      username 'XXX'
      password 'XXX'
     } 
  }
 runList = 'main'
}

Is it possible to have an array of changelog files?

Nabila
  • 191
  • 4
  • 19

1 Answers1

2

I guess the only out-of-the-box thing you can do is to make liquibase-changelog.xml a "master" changeLog file and include other changeLog files in it depending on the context.

Your master-liqbuiase-changelog.xml could look like this:

<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.8.xsd">

    <include file="liquibase-changelog-1.xml" relativeToChangelogFile="true" context="your_condition_based_on_context"/>
    <include file="liquibase-changelog-2.xml" relativeToChangelogFile="true" context="your_other_condition_based_on_context"/>
    <!-- other changeLog files -->
</databaseChangeLog>
htshame
  • 6,599
  • 5
  • 36
  • 56