Reputation: 75
I am trying to run a bunch of sql script in the Liquibase. But, be default, liquibase executes all the scripts in the order they are placed in the directory. Is there any way by which I can alter the execution default execution of these scripts i..e, execute by create table script first and then all the insert script.
My master changelog file :
<?xml version="1.0" encoding="UTF-8"?>
<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.1.xsd">
<includeAll path="../migration/" relativeToChangelogFile="true"/>
</databaseChangeLog>
I am placing all the sql script in migration folder.
Upvotes: 1
Views: 2123
Reputation: 7330
You can't modify the execution order. The only thing you can do is to change the order of files in your /migration
directory by renaming them.
As far as I know, Liquibase sorts files in alphabetical order.
And inside the files Liquibase executes changeSets one by one from top to bottom.
OR
You can use <include>
instead of <includeAll>
. This way you'd be able to include changeLog files in the order you need.
<?xml version="1.0" encoding="UTF-8"?>
<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.1.xsd">
<include file="../migration/changeLog_3.xml" relativeToChangelogFile="true"/>
<include file="../migration/changeLog_1.xml" relativeToChangelogFile="true"/>
<include file="../migration/changeLog_2.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>
Upvotes: 2