The extension provides the ability to declare dependencies between changeSets and run them in the order of resolving dependencies.
Simply download the liquibase-dependson jar and add it to your classpath.
The extension allows you to organize migration files relative to the database structure, which can simplifies the long-term support of migrations.
db
├── changelog
│ ├── db.changelog-master.xml
│ ├── db.changelog-1.0.xml
│ ├── db.changelog-1.1.xml
│ └── db.changelog-2.0.xml
db
├── db.changelog-master.xml
├── tables
│ ├── dbo.basket.xml
│ ├── dbo.discount.xml
│ ├── dbo.product.xml
│ ├── dbo.user.xml
│ └── dbo.wallet.xml
├── triggers
Ordering will be applied to child changeSets.
<databaseChangeLog
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.7.xsd">
<!-- Enable depends on extension -->
<property name="useDependsOnExtension" value="true"/>
<includeAll path="./tables"/>
</databaseChangeLog>
<databaseChangeLog
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext/dependsOn"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.7.xsd">
<changeSet id="user-table-creating" author="mikhail">
<createTable tableName="user">
...
</createTable>
</changeSet>
<changeSet id="user-table-adding-column" author="mikhail">
<preConditions>
<ext:dependsOn id="user-table-creating" author="mikhail" />
<ext:dependsOn id="product-table-creating" author="mikhail" changeLogFile="dbo.product.xml"/>
</preConditions>
<addColumn tableName="user">
...
</addColumn>
</changeSet>
</databaseChangeLog>