【发布时间】:2016-09-08 10:51:43
【问题描述】:
我有一个 MySQL 5.7 实例,它需要两个具有相同架构的数据库。我正在尝试使用具有多个模式的 flyway 来实现这一点。我正在使用 Maven 插件和 MySQL 连接器的 v5.1.38。这是我的 POM 配置:
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>4.0</version>
<configuration>
<url>jdbc:mysql://192.168.99.100:3306</url>
<user>root</user>
<password>mypassword</password>
<schemas>
<schema>stage</schema>
<schema>public</schema>
</schemas>
</configuration>
</plugin>
从空数据库运行,这是输出:
[INFO] Database: jdbc:mysql://192.168.99.100:3306 (MySQL 5.7)
[INFO] Successfully validated 3 migrations (execution time 00:00.013s)
[INFO] Creating schema `stage` ...
[INFO] Creating schema `public` ...
[INFO] Creating Metadata table: `stage`.`schema_version`
[INFO] Current version of schema `stage`: 0
[INFO] Migrating schema `stage` to version 1 - initialize schema
[INFO] Migrating schema `stage` to version 2 - seed users
[INFO] Migrating schema `stage` to version 3 - create read items proc
[WARNING] DB: PROCEDURE stage.read_items does not exist (SQL State: 42000 - Error Code: 1305)
[INFO] Successfully applied 3 migrations to schema `stage` (execution time 00:01.824s).
它创建了两个模式,但只运行第一个模式的迁移。是我做错了什么,还是 Flyway 中的错误?
更新:
我尝试使用此配置为 Maven 插件创建两个执行:
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>4.0.1</version>
<executions>
<execution>
<id>migrate-stage</id>
<goals>
<goal>migrate</goal>
</goals>
<configuration>
<url>jdbc:mysql://192.168.99.100:3306/stage</url>
<user>root</user>
<password>password</password>
<schemas>
<schema>stage</schema>
</schemas>
</configuration>
</execution>
<execution>
<id>migrate-pub</id>
<goals>
<goal>migrate</goal>
</goals>
<configuration>
<url>jdbc:mysql://192.168.99.100:3306/public</url>
<user>root</user>
<password>password</password>
<schemas>
<schema>public</schema>
</schemas>
</configuration>
</execution>
</executions>
</plugin>
这给了我以下错误:
Unable to connect to the database. Configure the url, user and password!
【问题讨论】:
标签: java mysql maven jdbc flyway