Liquibase - 回滚一组变更集

发布于 2024-09-30 13:50:34 字数 763 浏览 4 评论 0原文

我们进行的数据库版本由一组更改集组成,我们的数据库更改日志按以下方式组织

   MasterChangeLog.xml

           ---> Release0001.XML
                    ---> AddCustomerTable.XML
                    ---> AddOrderTable.XML

           ---> Release0002.XML
                    ---> AddNewColumnsToCustomerTable.XML
                    ---> AlterOrderTableXML

           ---> Release0003.XML
                    ---> AddPreferedCustomerTable.XML

我想知道如何回滚一组更改集。我希望我可以将 tagDatabase 与版本号(Release001、Release002 或 Release003)一起使用,然后使用标签回滚,

如果我想将所有更改回滚到 Release001,我希望能够执行类似的操作,

java -jar "liquibase.jar" --changeLogFile="MasterChangeLog.xml" Rollback "Release0002"

请告诉我我该如何让它与 Liquibase 一起工作?

谢谢

We do database releases which are made up of a group of change sets and our database change logs are organised in the following way

   MasterChangeLog.xml

           ---> Release0001.XML
                    ---> AddCustomerTable.XML
                    ---> AddOrderTable.XML

           ---> Release0002.XML
                    ---> AddNewColumnsToCustomerTable.XML
                    ---> AlterOrderTableXML

           ---> Release0003.XML
                    ---> AddPreferedCustomerTable.XML

I would like to know how I would go about rolling back a set of change sets. I was hoping that I could use tagDatabase with the release number (Release001, Release002 or Release003) and just roll back using the tag

I would expect to be able to do something like this if I wanted to rollback all change to Release001

java -jar "liquibase.jar" --changeLogFile="MasterChangeLog.xml" Rollback "Release0002"

Could you please tell me how I would go about getting this to work with Liquibase?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一抹淡然 2024-10-07 13:50:34

如果 Release002 是有效标签,则您列出的命令有效。不过,您可能不希望/不需要在 Release0002 标签周围加上引号。

使用标签回滚时,liquibase 将从执行的变更集末尾开始,并以相反的顺序回滚每个变更集,直到到达之前标记的变更集。从你的描述中我不确定这是否是你想要的。

在您的示例中,如果您在 Realease002.xml 运行后标记数据库,则运行“rollback Release0002”将回滚 Release0003 中的所有内容。如果您想回滚 Release0002 中的所有内容,则需要运行“rollback Release0001”或在执行 Release0002 变更集之前创建 Release0002 标记。但无论哪种方式,您都会回滚 Release0003,因为它是在 Release0002 之后发布的。

liquibase 不支持挑选和选择要回滚的变更集的原因是,变更集之间通常存在依赖关系,因为它们通常相互构建,因此回滚中间的任意一组变更集通常会产生意想不到的后果。

The command you listed is valid if Release002 is a valid tag. You probably don't want/need quotes around the Release0002 tag, though.

When rolling back using a tag, liquibase will start at the end of your executed changesets and roll back each in reverse order until it gets to the changeset that was tagged before. I am not sure from your description if that is what you want.

In your example, if you tagged the database after Realease002.xml ran, running "rollback Release0002" would roll back everything in Release0003. If you wanted to rollback everything in Release0002 you would need to run "rollback Release0001" or make the Release0002 tag before executing the Release0002 changesets. Either way, however, you will have Release0003 rolled back because it came after Release0002.

The reason liquibase does not support picking and choosing changeSets to roll back is because there is often dependencies between changesets because they often build upon each other, and so rolling back an arbitrary group of changesets in the middle often has unexpected consequences.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文