Liquibase auto-rollback if fails

Hello, i want to know if is possible how to rollback to a tag when liquibase detects an error.

My changelog-master is like this

<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-4.1.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd">

<include file="liquibase/db.changelog-3.2.0.xml" />
<changeSet id="tagDataModel-3.2.0">  
	<tagDatabase tag="3.2.0"/>  
</changeSet>
<include file="liquibase/db.changelog-3.3.0.xml" />
<changeSet  id="tagDataModel-3.3.0">  
	<tagDatabase tag="3.3.0"/>  
</changeSet>

</databaseChangeLog>

If for example db.changelog-3.3.0.xml fails, i want to automatically rollback to db.changelog-3.2.0.xml.

Is there any option to handle this in my changelog-master?

I don’t believe there is a way to automatically rollback on failure. I think you need to run a liquibase rollback command after the failure, which will allow you to rollback to a prior changeset.

You need to add this to the changeset in db.changelog-3.3.0.xml, settiing the changeset ID and Author that you have defined in db.changelog-3.2.0.xml.

<rollback changeSetId="changesetID" changeSetAuthor="changesetauthor"/>

Then run the liquibase rollback command.

As per my knowledge, there is no functionality as “Auto rollback the database changes”. Liquibase supports creating auto rollback statements. If you want to rollback to a previous changeset on failure of a next one, you need to have a rollback statement written.
Please refer to this documentation of liquibase auto rollback for better explanation.

Please let us know if you need more help.

Thanks,
Rakhi Agrawal