没有创建与liquibase.change.core.RawSQLChange相反的东西 [英] No inverse to liquibase.change.core.RawSQLChange created

查看:361
本文介绍了没有创建与liquibase.change.core.RawSQLChange相反的东西的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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的插件和命令在此使用:

The plugin and command use for a maven at this:

liquibase:rollback -Dliquibase.rollbackTag=payScript -PproductionPostgreSql

此插件

<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

[错误]无法在通用项目上执行目标org.liquibase:liquibase-maven-plugin:3.4.1:rollback(default-cli):设置或运行Liquibase时出错:liquibase.exception.RollbackImpossibleException:没有与之相反的结果liquibase.change.core.RawSQLChange已创建-> [帮助1] org.apache.maven.lifecycle.LifecycleExecutionException:无法在通用项目上执行目标org.liquibase:liquibase-maven-plugin:3.4.1:rollback(default-cli):设置或运行Liquibase时出错:liquibase.exception.RollbackImpossibleException :未与liquibase.change.core.RawSQLChange创建相反 在org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216) 在org.apache.maven.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.LifecycleModuleBuilder.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.DefaultMaven.doExecute(DefaultMaven.java:307) 在org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) 在org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) 在org.apache.maven.cli.MavenCli.execute(MavenCli.java:862) 在org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286) 在org.apache.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) 在java.lang.reflect.Method.invoke(Method.java:497) 在org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) 在org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) 在org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) 在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.change.core.RawSQLChange相反的逆 在liquibase.changelog.ChangeSet.rollback(ChangeSet.java:648) 在liquibase.changelog.visitor.RollbackVisitor.visit(RollbackVisitor.java:39) 在liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:73) 在liquibase.Liquibase.rollback(Liquibase.java:656) 在org.liquibase.maven.plugins.LiquibaseRollback.performLiquibaseTask(LiquibaseRollback.java:121) 在org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:394) ...另外22个 原因:liquibase.exception.RollbackImpossibleException:没有创建与liquibase.change.core.RawSQLChange相反的逆 在liquibase.change.AbstractChange.generateRollbackStatementsFromInverse(AbstractChange.java:424) 在liquibase.change.AbstractChange.generateRollbackStatements(AbstractChange.java:397) 在liquibase.database.AbstractJdbcDatabase.executeRollbackStatements(AbstractJdbcDatabase.java:1269) 在liquibase.changelog.ChangeSet.rollback(ChangeSet.java:634) ...另外27个 [错误] [错误] [ERROR]有关错误和可能的解决方案的详细信息,请阅读以下文章: [错误] [帮助1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

[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

推荐答案

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

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.

此处的文档 http://www.liquibase.org/documentation/changes/sql .html 用于SQL标记.此处通常描述了回滚: http://www.liquibase.org/documentation/rollback.html

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

尤其要注意此段:

其他重构(例如放置表"和插入数据")没有 可以自动生成的相应回滚命令. 在这些情况下,以及您要覆盖默认值的情况下 生成的回滚命令,您可以通过以下命令指定回滚命令 changeSet标记内的标记.如果您不想做任何事情 撤消回滚模式的更改,请使用空标记.

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.

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

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

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

请注意,这是一个 VERY 天真的示例-您可能不希望在实际场景中使用此示例,因为运行liquibase update后可能会部署该更改,任何使用该数据库的程序都可能会将行插入名为'Bob'的人员表中,并且此回滚语句将删除所有名为'Bob'的行.

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.change.core.RawSQLChange相反的东西的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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