我们有一个生产中的数据库,“用户”表中已经有很多行。考虑 flyway 网站上的以下声明:
If you have an existing database that has not been filled by Flyway this is the way to go:
- Create an initial migration script that will recreate your current state and give it a low version number.
- Use flyway:init to create the metadata table and set this script as the current version.
我想使用 flyway 来管理我的模式和数据库中的各种常量,但我不希望 V1__Base_version.sql 包含我们当前生产用户的帐户信息,尤其是考虑到它存储在 SCM 中。不过,如果我正确理解了这些说明,我将需要能够使用 V1__Base_version.sql 来“重新创建 [我的] 当前状态”。
那么仅使用模式和常量创建初始迁移是否可行?或者我们工作站上的数据库是否需要与生产中的数据库 100% 匹配?
最佳答案
你是对的。 init 命令用于用版本标记生产数据库。
您创建的初始迁移(使用 PROD 数据库的结构)是针对其他环境的。它永远不会在 PROD 上运行,因为它的版本将低于初始版本。然而,它将对齐所有环境,以便后续迁移可以平等地应用于所有环境。
关于database - 生产数据库中的 Flyway 集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12569565/