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

时间:2015-02-27 16:47:01

标签: mysql flyway command-line-tool

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

  • 在ubuntu 14.04上运行,昨天下载了mysql 5.6和java 7以及Flyway 3.1。
  • 在〜/ bin / flyway-3.1
  • 中安装了Flyway(从tgz文件中解压缩)
  • 有一个符号链接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以使用未嵌入应用程序文件夹层次结构的文件夹中的配置和迁移等(应用程序本身未提供的任何内容)吗?

1 个答案:

答案 0 :(得分:3)

使用正确的属性,事情应该有效。

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

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