2016-05-12 51 views
2

我有一个MySQL 5.7实例,需要有两个具有相同模式的数据库。我试图用多个模式的flyway来实现这一点。我正在使用MySQL连接器的Maven插件和v5.1.38。这里是我的POM的配置:Flyway只迁移我的两个配置模式之一

   <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! 

回答

0

这不是我希望的答案,但是在尝试了其他所有方法后,我最终只复制了第二个模式的SQL,在各个部分之前添加了use public;use stage;

1

这似乎类似于以下内容:Flyway database migration to multiple schemas
正如方丹先生建议你应该为这种情况分割你的模式。
由于我是Flyway自己的新手,对于模式标记的正确用法我不确定。
希望这有助于!

+0

是的,我看过这个答案,并试图在Maven中创建单独的执行。我已经用这种努力的结果更新了我的问题。 – Jared

+0

看起来正确,但我认为应该将一个目标标签添加到您的执行块中。目标应该表达你的场景的迁移。 – Arphylion

+0

糟糕 - 更新以反映我已经添加了目标。相同的错误消息。我还尝试了在URL中和模式配置中包含模式名称的每种组合。没有运气。 – Jared