【问题标题】:Cannot migrate mysql scripts with flyway config file无法使用 flyway 配置文件迁移 mysql 脚本
【发布时间】:2021-01-03 02:17:31
【问题描述】:

我有一个 maven 项目,我正在尝试使用 MySQL 脚本创建带有 flyway 的表。

下面是我的文件夹结构。

我的配置文件包括

flyway.driver=com.mysql.jdbc.Driver
flyway.url=jdbc:mysql://127.0.0.1:3306/atm
flyway.user=root
flyway.password=root1234
flyway.locations=filesystem:/flyway/migrations
flyway.sqlMigrationPrefix=V
flyway.sqlMigrationSeparator=__
flyway.validateOnMigrate=true

这是 SQL 脚本文件。

CREATE TABLE `atm_table` (
  `id` int(11) NOT NULL,
  `name` varchar(45) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

当我执行命令mvn flyway:migrate -X 时,它只会创建flyway_schema_history 表。在日志中显示为

[DEBUG] Unable to load config file: /Users/name/flyway.conf
[DEBUG] Loading config file: /Users/name/my-project/flyway/conf/flyway.conf
Loading class 'com.mysql.jdbc.Driver'. This is deprecated. The new driver class is 'com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
[INFO] Flyway Community Edition 6.5.0 by Redgate
[DEBUG] Scanning for filesystem resources at '/my-project/flyway/migrations'
[WARNING] Skipping filesystem location:/my-project/flyway/migrations (not found). Note this warning will become an error in Flyway 7.
Wed Sep 16 16:32:45 IST 2020 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

似乎它不是指正确的文件位置(配置文件中给出的位置)。如何解决这个问题?

【问题讨论】:

    标签: mysql maven flyway


    【解决方案1】:

    这是文件上的命名。看起来您在版本之后有一个下划线。您需要有两 (2) 个。这是一个容易犯的错误。我知道,因为我把它搞砸了。 Here's an article on it.

    如果您没有正确的命名标准,Flyway 将忽略该文件。

    【讨论】:

    • 很高兴听到。正如我在文章中概述的那样,我完全搞砸了。
    • 哈哈这里也一样。花 5 小时寻找解决方案
    猜你喜欢
    • 2018-02-28
    • 2020-04-19
    • 2011-11-05
    • 2020-08-17
    • 2020-05-01
    • 2015-01-03
    • 1970-01-01
    • 2016-03-12
    • 2021-11-20
    相关资源
    最近更新 更多