Flyway 似乎无法使用不在其 sql 文件夹中的迁移

dam*_*ebb 1 mysql command-line-tool flyway

我从一些较旧的问题和回复中看到,Flyway 不太擅长处理除默认路径(Flyway 主文件夹中的 sql 文件夹)以外的路径,但那又回到了 V2,现在是版本 3。我发现了这个仍然无法使用以下设置;

  • 在 ubuntu 14.04 上运行,昨天下载了 mysql 5.6 和 java 7 以及 Flyway 3.1。
  • Flyway 安装(从 tgz 文件解压)在 ~/bin/flyway-3.1
  • 有一个符号链接 flyway -> ~/bin/flyway
  • 在 ~/flyway-testing 中设置了一个带有 con 和 sql 子文件夹的虚拟项目

在conf文件夹中是flyway.properties文件,配置如下;

flyway.user=flyway1
flyway.schemas=flyway1
flyway.url=jdbc:mysql://localhost
flyway.driver=com.mysql.jdbc.Driver
flyway.password=flyway1
flyway.baseDir=/home/vagrant/flyway-testing/sql
Run Code Online (Sandbox Code Playgroud)

我在 sql 文件夹中有一个迁移文件,其中有一个 DDL:

CREATE TABLE table1 (
column1 VARCHAR(10),
column2 DATE)
Run Code Online (Sandbox Code Playgroud)

我正在运行这个命令;

flyway -X -configFile=${HOME}/flyway-testing/conf/flyway.properties validate
Run Code Online (Sandbox Code Playgroud)

结果如下:

DEBUG: Adding location to classpath: /home/vagrant/bin/flyway-3.1/drivers/hsqldb-2.3.2.jar
DEBUG: Adding location to classpath: /home/vagrant/bin/flyway-3.1/drivers/jtds-1.3.1.jar
DEBUG: Adding location to classpath: /home/vagrant/bin/flyway-3.1/drivers/jna-3.3.0-platform.jar
DEBUG: Adding location to classpath: /home/vagrant/bin/flyway-3.1/drivers/h2-1.3.170.jar
DEBUG: Adding location to classpath: /home/vagrant/bin/flyway-3.1/drivers/postgresql-9.3-1102-jdbc4.jar
DEBUG: Adding location to classpath: /home/vagrant/bin/flyway-3.1/drivers/derby-10.11.1.1.jar
DEBUG: Adding location to classpath: /home/vagrant/bin/flyway-3.1/drivers/mariadb-java-client-1.1.7.jar
DEBUG: Adding location to classpath: /home/vagrant/bin/flyway-3.1/drivers/jna-3.3.0.jar
DEBUG: Adding location to classpath: /home/vagrant/bin/flyway-3.1/drivers/sqlite-jdbc-3.7.15-M1.jar
Database: jdbc:mysql://localhost:3306/ (MySQL 5.5)
DEBUG: DDL Transactions Supported: false
DEBUG: Schema: flyway1
DEBUG: Scanning for filesystem resources at '/home/vagrant/bin/flyway-3.1/sql' (Prefix: '', Suffix: '.sql')
DEBUG: Scanning for resources in path: /home/vagrant/bin/flyway-3.1/sql (/home/vagrant/bin/flyway-3.1/sql)
DEBUG: Filtering out resource: /home/vagrant/bin/flyway-3.1/sql/put-your-sql-migrations-here.txt (filename: put-your-sql-migrations-here.txt)
DEBUG: Spring Jdbc available: false
DEBUG: Validating migrations ...
DEBUG: Scanning for filesystem resources at '/home/vagrant/bin/flyway-3.1/sql' (Prefix: 'V', Suffix: '.sql')
DEBUG: Scanning for resources in path: /home/vagrant/bin/flyway-3.1/sql (/home/vagrant/bin/flyway-3.1/sql)
DEBUG: Filtering out resource: /home/vagrant/bin/flyway-3.1/sql/put-your-sql-migrations-here.txt (filename: put-your-sql-migrations-here.txt)
Validated 0 migrations (execution time 00:00.007s)
Run Code Online (Sandbox Code Playgroud)

这表明,尽管将 flyway.baseDir 属性设置为我的虚拟项目的根目录,但应用程序仍使用二进制安装的根目录作为搜索迁移的位置。我可能期望从他的设置中得到错误的结果,但我无法在任何地方找到命令行可用属性的明确列表。我正在松散地关注这个博客!但它已经很旧了,并且建议的配置与我的想法很接近(我试图使这个测试尽可能地少,所以排除了一些我认为我需要默认值的东西)。

谁能解释如何正确配置 Flyway 以从未嵌入应用程序文件夹层次结构的文件夹中使用配置和迁移等(应用程序本身未提供的任何内容)?

Axe*_*ine 5

使用正确的属性,事情应该可以工作。

替换flyway.baseDir=/home/vagrant/flyway-testing/sqlflyway.locations=filesystem:/home/vagrant/flyway-testing/sql

更多信息:http : //flywaydb.org/documentation/commandline/migrate.html#locations