【问题标题】:Running flyway migration on a DB with existing tables在具有现有表的数据库上运行 flyway 迁移
【发布时间】:2021-06-02 09:14:24
【问题描述】:

我正在使用现有表的 postgres 数据库上运行 flyway 迁移。这样做flyway抛出了这个错误

Found non-empty schema(s) "public" but no schema history table. Use baseline() or set baselineOnMigrate to true to initialize the schema history table.

阅读baselineOnMigrate 上的文档后,我们只需将其切换到true,我们就可以完成迁移了。

需要明确启用此功能: 我们是否只将FLYWAY_BASELINE_ON_MIGRATE 设置为TRUE 一次,并且在创建模式历史表时我们可以将其转回FALSE?还是我们必须坚持 TRUE 值?

【问题讨论】:

    标签: flyway


    【解决方案1】:

    是的,您只需设置一次。这种方法实际上仅用于 Flyway 从配置文件中获取其所有参数的情况......它仅用于一次性使用(例如,仅用于数据库的一个特定副本,在许多副本中)。通常,您从命令行中的操作作为基线,如下所示:

    Flyway baseline  @FlywayArgs -baselineVersion='1.3.1' -baselineDescription='Existing version of MyDatabase'
    

    本文使用的是 SQL Server 数据库而不是 Postgres,但可能会很好地了解 flyway 基线的工作原理:https://www.red-gate.com/hub/product-learning/flyway/flyway-baselines-and-consolidations。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-02-06
      • 2021-05-23
      • 2017-08-16
      • 2015-09-21
      • 2019-05-03
      • 2016-12-12
      • 2017-07-10
      • 2013-03-06
      相关资源
      最近更新 更多