用于迁移的 Flywaydb 多个配置文件失败

Flywaydb multiple config files for migration is failing

我们已尝试在单个数据库中迁移一些 SQL 版本,并且进展顺利。何时尝试通过传递多个配置文件同时为多个数据库实施迁移失败。

问题是当在“-configFiles”参数中传递多个配置文件时,它只需要最后一个配置文件并且只对最后一个配置文件中提到的数据库执行迁移。

下面是同样的截图,它只带了 flywayconfdb.conf 个文件而留下了其他文件。

[oracle@localhost flyway-5.1.4]$ ./flyway -configFiles=/home/oracle/flyway/flyway-5.1.4/conf/flyway.conf,/home/oracle/flyway/flyway-5.1.4/conf/flywayjiradb.conf,/home/oracle/flyway/flyway-5.1.4/conf/flywayconfdb.conf info
Flyway Community Edition 5.1.4 by Boxfuse

Database: jdbc:oracle:thin:@//XXXXXXXXX:1521/confdb (Oracle 12.2)
Schema version: << Empty Schema >>

+----------+---------+-------------+------+--------------+-------+
| Category | Version | Description | Type | Installed On | State |
+----------+---------+-------------+------+--------------+-------+
| No migrations found                                            |
+----------+---------+-------------+------+--------------+-------+

请帮助我们解决同样的问题。

Flyway 合并配置文件。它不会为每个单独迁移。

对于每个配置文件,Flyway adds the content to a Properties mapProperties 每个键只有一个值,因此如果相同的键出现在第二个配置文件中,它将覆盖以前的值。这就是为什么似乎只使用了最后一个配置文件中的设置。

它允许您在某处定义一些通用设置,例如在 ~/flyway.conf 中,这些设置可以与一些更具体的设置合并,例如在个别项目中。

但它不允许您在单个 运行 中迁移多个数据库。每个数据库需要 运行 Flyway 一次:

./flyway -configFiles=/home/oracle/flyway/flyway-5.1.4/conf/flywayjiradb.conf info
./flyway -configFiles=/home/oracle/flyway/flyway-5.1.4/conf/flywayconfdb.conf info

文档将 Overriding Order 描述为:

  • 命令行参数
  • 环境变量
  • 自定义配置文件
  • <current-dir>/flyway.conf
  • <user-home>/flyway.conf
  • <install-dir>/conf/flyway.conf
  • Flyway 命令行默认值

设置定义在列表的较高位置,具有更高的优先级。

文档给出了以下示例:

The means that if for example flyway.url is both present in a config file and passed as -url= from the command-line, the command-line argument will take precedence and be used.

自定义配置文件 (-configFiles) 行可以扩展为:

  • 命令行参数
  • 环境变量
  • 自定义配置文件 n
  • ...
  • 自定义配置文件 2
  • 自定义配置文件 1
  • <current-dir>/flyway.conf
  • <user-home>/flyway.conf
  • <install-dir>/conf/flyway.conf
  • Flyway 命令行默认值

相应的例子可以是:

The means that if for example flyway.url is both present in custom config file 1 and custom config file 2, the custom config file 2 settings will take precedence and be used.

类似地,如果 flyway.url 也在 自定义配置文件 n 中,这将覆盖 自定义配置文件 2[=78= 中的设置].