1
votes

I'm new to Liquibase. I can able to update(changeset which has create table) to the Oracle database using liquibase. while doing update i've created the tag also. But when i try to rollback the updated changes(ie dropping the created table)using the tag. The table was not dropped.

I'm using liquibase-maven plugin 3.4.2. Below are the code in maven.

 <plugins>
  <plugin>
  <groupId>org.liquibase</groupId>
  <artifactId>liquibase-maven-plugin</artifactId>
  <version>3.4.2</version>
   <executions>
   <execution>
    <id>execution1</id>
      <phase>process-resources</phase>
      <configuration>

                 <changeLogFile>src/main/resources/changelog.xml</changeLogFile>  
                 <rollbackTag>checkpoint</rollbackTag>  

                     <driver>oracle.jdbc.OracleDriver</driver>
                    <url>jdbc:oracle:thin:@10.86.24.2:1521:claim</url>
                    <username>Test</username>
                    <password>Test</password>  


        </configuration>
         <goals>

           <goal>rollback</goal>   
           <!--  <goal>rollbackSQL</goal>   -->

         </goals>
    </execution> 
    </executions>
</plugin>

Below are my changelog.xml while rolling back the database.

 <?xml version="1.0" encoding="UTF-8"?>
 <databaseChangeLog xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.liquibase.org/xml/ns/dbchangelog"></databaseChangeLog>

I tried with "rollbackSQL" . But the query to drop table has not be created.

find the below code.

-- *********************************************************************
-- Rollback to 'checkpoint' Script
-- *********************************************************************
-- Change Log: src/main/resources/changelog.xml
-- Ran at: 2/10/16 6:24 PM
-- Against: TEST@jdbc:oracle:thin:@10.86.24.2:1521:claim
-- Liquibase version: 3.4.2
-- *********************************************************************

SET DEFINE OFF;

-- Lock Database
UPDATE DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = 'KannanSDTW864', LOCKGRANTED = to_timestamp('2016-02-10 18:24:08.593', 'YYYY-MM-DD HH24:MI:SS.FF') WHERE ID = 1 AND LOCKED = 0;

-- Release Database Lock
UPDATE DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1;

Entries in the DATABASECHANGELOG table

Please help me to fix the issues.

2
Do you have autocommit turned on?Alex Poole
What does "not working" mean? Can you edit your question and elaborate a bit more about the error that come up?Jens
Please post a command that you are using to run liquibase and output.dbf
Hi Alex- Thanks for reply. I've checked Autocommit is in off.sangeetha kannan
Could you also add a content of DATABASECHANGELOG table?dbf

2 Answers

0
votes

It appears to be working as designed, as far as I can tell. You have an empty changelog table, so no changes have been deployed. Therefore, there are no changes to roll back.

0
votes

According to Liquibase doc: http://www.liquibase.org/documentation/rollback.html

Tag

Specifying a tag to rollback to will roll back all change-sets that were executed against the target database after the given tag was applied.

But your createTable action is not after the tag "checkpoint", but is marked with this tag itself. If you want to rollback this action you need to have a tagDatabase in separate changeset before createTable.

Also why are you using empty changelog for rollback? It should contains changes that you used for update command (create table, etc).