Flyway迁移:使flyway停止寻找已经迁移的文件

问题描述 投票:0回答:1

我目前正在开发多个共享相同数据库的项目,但每个项目都有自己的目的。它们没有通过网关重新组合,它们只是 3 个独立的项目。 因此,每个项目都有自己的实体,并且应该拥有其他项目没有的迁移文件。但是当我想运行project_2 的迁移时,flyway 说它找不到project_1 中的迁移文件。我怎样才能告诉它不进行此检查而只应用迁移。

我知道让一个独立机负责所有迁移可以解决问题,但这不是这里的目的,因为它们可以彼此独立部署,并且一个独立机的更改不会影响另一个独立机的运行。

spring-boot migration flyway
1个回答
0
投票

您遇到此问题是因为 Flyway 使用它在数据库内部创建的

history
表来检查已应用的迁移。

为了避免冲突,您应该定义一个单独的模式和/或表名称供 Flyway 使用。

docu中所述,在您的项目中创建一个

flyway.conf
并为每个项目定义值:

# Name of Flyway's schema history table (default: flyway_schema_history)
# By default (single-schema mode) the schema history table is placed in the default schema for the connection
# provided by the datasource.
# When the flyway.schemas property is set (multi-schema mode), the schema history table is placed in the first
# schema of the list.
flyway.table=MigrationHistory
flyway.placeholders.historyTable=MigrationHistory
flyway.schemas=flyway,dbo,classic,people
flyway.defaultSchema=flyway
© www.soinside.com 2019 - 2024. All rights reserved.