回滚在使用liquibase的oracle中不起作用 [英] Rollback is not working in oracle using liquibase

查看:100
本文介绍了回滚在使用liquibase的oracle中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Liquibase的新手.我可以使用liquibase将(具有创建表的changeset)更新到Oracle数据库.在进行更新时,我也创建了标签.但是,当我尝试使用标签回滚更新的更改(即删除创建的表)时.该表未删除.

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.

我正在使用liquibase-maven插件3.4.2.下面是maven中的代码.

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>

下面是我回滚数据库时的changelog.xml.

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>

我尝试使用"rollbackSQL".但是尚未创建要删除表的查询.

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

找到下面的代码.

-- *********************************************************************
-- 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;

DATABASECHANGELOG表中的条目

请帮助我解决问题.

推荐答案

根据Liquibase文档: http://www.liquibase.org/documentation/rollback.html

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

标签

指定要回滚的标签将回滚所有 在给定标签之后,针对目标数据库执行了 已应用.

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.

但是您的createTable操作不在标记"checkpoint"之后,而是使用该标记本身进行了标记.如果要回滚此操作,则需要在createTable之前在单独的变更集中包含一个tagDatabase.

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.

为什么还要使用空的changelog进行回滚?它应该包含您用于更新命令的更改(创建表等).

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

这篇关于回滚在使用liquibase的oracle中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆