与liquibase.change.core.RawSQLChange无关

[英]No inverse to liquibase.change.core.RawSQLChange created


The problem consist in: When play the command maven, the seems problem find in https://liquibase.jira.com/browse/CORE-465, but is that 2009, can marked with "Cannot Reproduce", i'm use one file .xml type liquibase with one changeSet, but many createTable, addPrimaryKey, rollback, addForeignKeyConstraint, this file create always tables and your respective constraints, but i'm make a rollback this wrong happened, i'm tired find for Internet, then can't found solution for the problem, are you can solved this problem? share with the community!

问题在于:当播放命令maven时,似乎问题在https://liquibase.jira.com/browse/CORE-465中找到,但是在2009年,可以标记为“无法重现”,我使用一个文件.xml类型liquibase有一个changeSet,但是很多createTable,addPrimaryKey,rollback,addForeignKeyConstraint,这个文件总是创建表和你各自的约束,但是我做了回滚这个错误发生了,我累了找到互联网,然后可以找不到问题的解决方案,你能解决这个问题吗?与社区分享!

The plugin and command use for a maven at this:

插件和命令用于maven:

liquibase:rollback -Dliquibase.rollbackTag=payScript -PproductionPostgreSql

the plugin at this

这个插件

<plugin>
    <groupId>org.liquibase</groupId>
    <artifactId>liquibase-maven-plugin</artifactId>
    <version>3.4.1</version>
    <configuration>
        <changeLogFile>${basedir}/src/main/resources/changelogs/db.changelog-master.xml</changeLogFile>
        <driver>${driver}</driver>
        <url> ${host.db}</url>
        <username>${user.db}</username>
        <password>${password.db}</password>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-core</artifactId>
            <version>3.4.1</version>
        </dependency>
    </dependencies>
</plugin>

this produced the stack trace below

这产生了下面的堆栈跟踪

[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.4.1:rollback (default-cli) on project generic: Error setting up or running Liquibase: liquibase.exception.RollbackImpossibleException: No inverse to liquibase.change.core.RawSQLChange created -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.liquibase:liquibase-maven-plugin:3.4.1:rollback (default-cli) on project generic: Error setting up or running Liquibase: liquibase.exception.RollbackImpossibleException: No inverse to liquibase.change.core.RawSQLChange created at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286) at org.apache.maven.cli.MavenCli.main(MavenCli.java:197) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) Caused by: org.apache.maven.plugin.MojoExecutionException: Error setting up or running Liquibase: liquibase.exception.RollbackImpossibleException: No inverse to liquibase.change.core.RawSQLChange created at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:398) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) ... 20 more Caused by: liquibase.exception.RollbackFailedException: liquibase.exception.RollbackImpossibleException: No inverse to liquibase.change.core.RawSQLChange created at liquibase.changelog.ChangeSet.rollback(ChangeSet.java:648) at liquibase.changelog.visitor.RollbackVisitor.visit(RollbackVisitor.java:39) at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:73) at liquibase.Liquibase.rollback(Liquibase.java:656) at org.liquibase.maven.plugins.LiquibaseRollback.performLiquibaseTask(LiquibaseRollback.java:121) at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:394) ... 22 more Caused by: liquibase.exception.RollbackImpossibleException: No inverse to liquibase.change.core.RawSQLChange created at liquibase.change.AbstractChange.generateRollbackStatementsFromInverse(AbstractChange.java:424) at liquibase.change.AbstractChange.generateRollbackStatements(AbstractChange.java:397) at liquibase.database.AbstractJdbcDatabase.executeRollbackStatements(AbstractJdbcDatabase.java:1269) at liquibase.changelog.ChangeSet.rollback(ChangeSet.java:634) ... 27 more [ERROR] [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

[错误]无法执行目标org.liquibase:liquibase-maven-plugin:3.4.1:rollback(default-cli)on project generic:设置或运行Liquibase时出错:liquibase.exception.RollbackImpossibleException:与liquibase.change无反转.core.RawSQLChange created - > [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException:无法执行目标org.liquibase:liquibase-maven-plugin:3.4.1:rollback(default-cli)on project generic:Error设置或运行Liquibase:liquibase.exception.RollbackImpossibleException:与在org.apache.maven的org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)创建的liquibase.change.core.RawSQLChange无反向.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)在org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:116)org.apache.maven.lifecycle.internal.LifecycleModuleBuild er.buildProject(LifecycleModuleBuilder.java:80)在org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)在org.apache.maven.lifecycle.internal.LifecycleStarter.execute( LifecycleStarter.java:128)org.apache.maven.maven.DefaultMaven.doExecute(DefaultMaven.java:307)org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)atg.apache.maven.DefaultMaven.execute (DefaultMaven.java:106)org.apache.maven.cli.MavenCli.exe(MavenCli.java:862)org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)org.apache上的org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)。 maven.cli.MavenCli.main(MavenCli.java:197)在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)在sun.reflect.DelegatingMethodAccessorImpl.invoke( DelegatingMethodAccessorImpl.java:43)在org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:2)的java.lang.reflect.Method.invoke(Method.java:497) 89)org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)at org.codehaus.plexus .classworlds.launcher.Launcher.main(Launcher.java:356)引起:org.apache.maven.plugin.MojoExecutionException:设置或运行Liquibase时出错:liquibase.exception.RollbackImpossibleException:与liquibase.change.core无反转。 RawSQLChange在org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:398)创建于org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)在org.apache.maven.lifecycle.internal .MojoExecutor.execute(MojoExecutor.java:208)... 20更多引起:liquibase.exception.RollbackFailedException:liquibase.exception.RollbackImpossibleException:与liquibase.changelog.ChangeSet.rollback中创建的liquibase.change.core.RawSQLChange无反向(ChangeSet.java:648)在liquibase.changelog.visitor.Rol lbackVisitor.visit(RollbackVisitor.java:39)在liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:73)在liquibase.Liquibase.rollback(Liquibase.java:656)在org.liquibase.maven.plugins.LiquibaseRollback.performLiquibaseTask liquibase.exception.RollbackImpossibleException::(LiquibaseRollback.java:121)在org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:394)...... 22多由没有造成逆liquibase.change.core.RawSQLChange liquibase.change.AbstractChange.generateRollbackStatementsFromInverse(AbstractChange.java:424)在liquibase.changelog上的liquibase.change.AbstractChange.generateRollbackStatements(AbstractChange.java:397)liquibase.AbstractJdbcDatabase.executeRollbackStatements(AbstractJdbcDatabase.java:1269)创建.ChangeSet.rollback(ChangeSet.java:634)... 27更多[错误] [错误] [错误]有关错误和可能的解决方案的更多信息,请阅读以下文章:[错误] [帮助1] http: // cwiki。 apache.org/confluence/display/MAVEN/MojoExecutionException

1 个解决方案

#1


11  

This is expected behavior. Somewhere in your changelog, you have a changeset that uses raw SQL. You didn't include it here, but the actual contents don't matter - as long as it is raw SQL, Liquibase cannot determine how to 'undo' or rollback that change. The way to fix this is to look at that changeset and add a rollback tag to that changeset that describes how to rollback the change made.

这是预期的行为。在更改日志中的某个位置,您有一个使用原始SQL的变更集。您没有在此处包含它,但实际内容无关紧要 - 只要它是原始SQL,Liquibase无法确定如何“撤消”或回滚该更改。解决此问题的方法是查看该更改集并向该更改集添加回滚标记,该变量集描述如何回滚所做的更改。

The docs here http://www.liquibase.org/documentation/changes/sql.html are for the SQL tag. Rollback in general is described here: http://www.liquibase.org/documentation/rollback.html

这里的文档http://www.liquibase.org/documentation/changes/sql.html用于SQL标记。回滚一般在这里描述:http://www.liquibase.org/documentation/rollback.html

In particular, note this paragraph:

特别要注意这一段:

Other refactorings such as “drop table” and “insert data” have no corresponding rollback commands that can be automatically generated. In these cases, and cases where you want to override the default generated rollback commands, you can specify the rollback commands via the tag within the changeSet tag. If you do not want anything done to undo a change in rollback mode, use an empty tag.

其他重构例如“drop table”和“insert data”没有相应的可以自动生成的回滚命令。在这些情况下,以及要覆盖默认生成的回滚命令的情况下,可以通过changeSet标记内的标记指定回滚命令。如果您不希望执行任何操作来撤消回滚模式中的更改,请使用空标记。

Here is an example that shows a raw SQL changeset and a corresponding rollback tag.

下面是一个示例,显示原始SQL变更集和相应的回滚标记。

<changeSet author="liquibase-docs" id="sql-example">
    <sql dbms="h2, oracle"
            endDelimiter="\nGO"
            splitStatements="true"
            stripComments="true">insert into person (name) values ('Bob')
        <comment>What about Bob?</comment>
    </sql>
    <rollback>
        delete from person where name='Bob';
    </rollback>
</changeSet>

Note that this is a VERY naive example - you probably wouldn't want to use this in a real scenario, because it is possible that after you had run liquibase update to deploy this change that whatever programs using the database might insert rows into the person table with the name 'Bob', and this rollback statement would remove ALL the rows with name 'Bob'.

请注意,这是一个非常简单的示例 - 您可能不希望在真实场景中使用它,因为在您运行liquibase update以部署此更改之后,使用该数据库的任何程序都可能会向该行插入行名为'Bob'的表,此回滚语句将删除所有名为'Bob'的行。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.itdaan.com/blog/2015/08/23/d1f19fd5417103a67635fe52ada45e07.html



 
© 2014-2018 ITdaan.com 粤ICP备14056181号