我从一些较早的问题和答案中看到,Flyway除了默认路径(Flyway主文件夹中的sql文件夹)以外,还不能很好地处理路径,但是那是V2的版本,现在是版本3。仍然不适用于以下设置;


昨天在mysql 5.6和Java 7和Flyway 3.1的ubuntu 14.04上运行。
Flyway已安装(从tgz文件解压缩)在〜/ bin / flyway-3.1中
有一个符号链接飞行通道->〜/ bin / flyway
使用con和sql子文件夹在〜/ flyway-testing中设置一个虚拟项目


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


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

CREATE TABLE table1 (
column1 VARCHAR(10),
column2 DATE)


我正在运行此命令;

flyway -X -configFile=${HOME}/flyway-testing/conf/flyway.properties validate


结果如下:

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)


这表明尽管将flyway.baseDir属性设置为我的虚拟项目的根目录,但该应用程序仍使用二进制安装的根目录作为搜索迁移的位置。我可能从他的设置中得到了错误的提示,但是我无法在任何地方找到命令行可用属性的明确列表。我很随意地跟随this blog!但是它已经很老了,建议的配置与我的想法很接近(我正尝试将测试保持在最低水平,因此排除了一些我认为需要默认值的东西)。

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

最佳答案

使用正确的属性,并且一切正常。

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

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

关于mysql - Flyway似乎无法使用不在其sql文件夹中的迁移,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28770098/

10-16 08:14