No inverse to liquibase.change.core.RawSQLChange created

牧云@^-^@ 提交于 2019-12-05 08:06:23

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.

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

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.

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>

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!