gpt4 book ai didi

flyway - 我应该担心在使用 Flyway 时创建幂等迁移吗?

转载 作者:行者123 更新时间:2023-12-01 11:24:59 30 4
gpt4 key购买 nike

我一直在阅读一篇关于 Flyway 的博客文章,名为 Lessons Learned Using Flyway DB with Distributed Version Control .作者的建议之一是创建幂等迁移。

引自文章:

In a perfect world, each migration will only be run once against each database.

In a perfect world, that is.

In actuality, there will be cases where you’ll need to re-run migrations against the same database. Often this will be due to a failed migration somewhere along the line, causing you to have to retrace your steps of successful migrations before to get the database back in a working state. When this happens, it’s incredibly helpful for the migration to be written in an idempotent manner.



假设我使用的是支持 DDL 事务的数据库,我是否应该在创建这些迁移 sql 时担心幂等性?

最佳答案

通常不会,尤其是当您拥有支持 DDL 事务的数据库时。

版本化迁移旨在只运行一次并且可以运行,但不必是幂等的(几乎没有任何好处)。

另一方面,可重复迁移必须是幂等的,因为它们会一遍又一遍地运行。

Flyway 让您可以非常轻松地从头开始重新创建您的数据库,这是您在试验时应该喜欢的方法。

关于flyway - 我应该担心在使用 Flyway 时创建幂等迁移吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38133309/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com