【问题标题】:Flyway seems not to be able to use migrations that are not in its sql folderFlyway 似乎无法使用不在其 sql 文件夹中的迁移
【发布时间】:2015-02-28 05:27:55
【问题描述】:

我从一些较早的问题和回复中看到,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

我在 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 以使用未嵌入应用程序文件夹层次结构的文件夹中的配置和迁移等(应用程序本身未提供的任何内容)?

【问题讨论】:

    标签: mysql flyway command-line-tool


    【解决方案1】:

    使用正确的属性,一切都会正常。

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

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

    【讨论】:

      猜你喜欢
      • 2020-06-03
      • 2014-05-14
      • 2017-01-07
      • 2020-07-19
      • 2021-01-03
      • 2012-02-07
      • 2013-12-23
      • 1970-01-01
      • 2015-01-02
      相关资源
      最近更新 更多