Heril Muratovic
Heril Muratovic

Reputation: 2018

Rollback Issue - Liquibase

I'm trying to do some rollback functions through terminal. I'm using Maven and Liquibase for my JHipster project.

I'm trying to tag database versions and at some time to do rollback on specific version by tag. Here is my liquibase configuration file (master - databasechangelog):

...(some change sets that alter tables, load data etc.)...

<!-- Tag database version 1.0 -->
<changeSet id="version1" author="jhipster">
    <tagDatabase tag="version_1_0" />
</changeSet>
<!-- Version 1.0 ends here -->

<!-- Version 2.0 starts here -->
<include file="../../config/liquibase/changelog/20170123151950_added_column_to_table.xml" relativeToChangelogFile="true"/>

New changelog file looks like this:

<changeSet id="20170123151950" author="jhipster">

    <addColumn tableName="sometable">
        <column name="somecolumn" type="varchar(32)"/>
    </addColumn>

</changeSet>  

I have tried commands:

mvn liquibase:rollback -Dliquibase.rollbackTag=version_1_0

and

mvn liquibase:rollbackSQL -Dliquibase.rollbackTag=version_1_0

but nothing happened.

Does anyone have an idea how to rollback to previous version of database?

Thank you in advance!

Upvotes: 0

Views: 1447

Answers (2)

awis
awis

Reputation: 51

I had the similar problem and my changelogFile uses the include tag to import other changelogs.

I found out that it fails silently when the filename column on your databasechangelog didn't match the filename where your script rollback is happening.

I'm running on liquibase version 3.5.3 and running the rollback thru maven

Upvotes: 2

khodayar J
khodayar J

Reputation: 914

you must add the rollback command to changeset : for example :

<rollback>
           <dropColumn 
            columnName="somecolumn"
            tableName="sometable"/>
        </rollback>

Upvotes: 1

Related Questions