【问题标题】:Flyway 5.0.7 not working with cockroach db V. 2.0Flyway 5.0.7 不适用于 cockroach db V. 2.0
【发布时间】:2018-04-12 11:46:36
【问题描述】:

这是我的场景。

  • Cockroach DB 版本 = 2.0
  • Flyway Ceriosn = 5.0.7
  • 平台 = Docker

我有一个 java 应用程序,它使用 flyway 来管理我的模式。

我的配置如下所示: 我的 flyway build.gradle 看起来像:

buildscript {
dependencies {
    classpath "org.postgresql:postgresql:42.1.4"
 }
}
 plugins {
     id "org.flywaydb.flyway" version "5.0.7"
 }

description = "test-app"

flyway {
    url = jdbc:postgresql://localhost:26257/test_dev?sslmode=disable
 user = root
password = 
}

我在本地主机上以不安全模式运行 cockroach v 2.0。

当我跑步时:

gradle flywayClean

我明白了

Flyway upgrade recommended: CockroachDB 2.0 is newer than this version of Flyway and support 
has not been tested.
Unable to clean unknown schema: "test_dev"

当我跑步时:

gradle flywayMigrate

我明白了:

Database: jdbc:postgresql://localhost:26257/test_dev (PostgreSQL 9.5)
Flyway upgrade recommended: CockroachDB 2.0 is newer than this version of Flyway and support has not been tested.
Creating schema "test_dev" ...
Creating schema "test_dev" ...
Creating schema "test_dev" ...
Creating schema "test_dev" ...
Creating schema "test_dev" ...
Creating schema "test_dev" ...
Creating schema "test_dev" ...
Creating schema "test_dev" ...
Creating schema "test_dev" ...
Creating schema "test_dev" ...

:test-migrations:flywayMigrate (Thread[Task worker for ':',5,main]) completed. Took 19.995 secs.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':test-migrations:flywayMigrate'.
> Error occurred while executing flywayMigrate

  Unable to create schema "test_dev"
  --------------------------------------------------
  SQL State  : 42P04
  Error Code : 0
  Message    : ERROR: database "test_dev" already exists

  ERROR: database "test_dev" already exists

我会在这里遗漏什么?

【问题讨论】:

  • 对蟑螂的支持已被推送并合并到master。如果您从源代码构建,您已经可以拥有它,或者您可以等待 5.1 版本:github.com/flyway/flyway/commit/…

标签: java flyway cockroachdb


【解决方案1】:

根据文档,仅支持 1.1 版本。

https://flywaydb.org/documentation/database/cockroachdb

Flyway 5.1 版本将支持 2.0 版。

https://github.com/flyway/flyway/issues/1970

【讨论】:

    【解决方案2】:

    有同样的问题,所以我为有同样问题的人构建了它。在 5.1 版本之前使用它,这是来自示例 gradle 文件的 sn-p。

    buildscript {
    //...
      repositories {
        //...
          maven { url 'https://jitpack.io' }
        //...
      }
    //..
    }
    
    plugins {
      //...
      id "com.radioafricagroup.plugins.flyway" version "0.6.7"
      //...
    }
    

    如果有兴趣,这里还有一个中等帖子,解释了我是如何以及为什么这样做的:https://medium.com/radio-africa-techblog/adventures-with-gradle-getting-flyway-to-work-with-cockroachdb-69aabf58cbd4

    【讨论】:

      猜你喜欢
      • 2018-08-10
      • 2020-09-16
      • 2015-04-13
      • 2017-05-14
      • 2019-07-19
      • 2016-11-16
      • 2016-11-14
      • 2022-01-03
      • 2020-08-22
      相关资源
      最近更新 更多