gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 10:47:55 25 4
gpt4 key购买 nike

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

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

最佳答案

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

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com