You should add preConditions
and rollback
to you liquibase script.
From the https://www.liquibase.org/documentation/changes/sql_file.html
<changeSet author="liquibase-docs" id="sqlFile-example">
<preConditions onFail="MARK_RAN">
<!-- your preconditions here -->
</preConditions>
<sqlFile dbms="h2, oracle"
encoding="utf8"
endDelimiter="\nGO"
path="my/path/file.sql"
relativeToChangelogFile="true"
splitStatements="true"
stripComments="true"/>
<rollback>
<!-- your rollback here -->
</rollback>
</changeSet>
If you want to rollback specifically on the 5th statement in demo.sql
, then perhaps you can split your demo.sql
into two files and execute them in separate changeSets
: the first will include statements 1-5, and the second will include statements 6-10.