title: How to use Flyway configuration to handle multiple databases
body: <p>we have a java application configured with maven that uses multiple databases. It is one app - many schemas.</p>
  
  <p>I've configured flyway, tested and it works well but my config is only for one database.</p>
  
  <p>Here is my pom.xml tested with one schema:</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;com.test&lt;/groupId&gt;
    &lt;artifactId&gt;test&lt;/artifactId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  
  
    &lt;build&gt;
          &lt;plugins&gt;
              &lt;!-- Flyway plugin configuration --&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.flywaydb&lt;/groupId&gt;
                  &lt;artifactId&gt;flyway-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;3.0&lt;/version&gt;
                  &lt;configuration&gt;
                      &lt;url&gt;jdbc:mysql://localhost:3306/argentina&lt;/url&gt;
                      &lt;user&gt;test&lt;/user&gt;
                  &lt;password&gt;test&lt;/password&gt;
                  &lt;/configuration&gt;
                  &lt;dependencies&gt;
                      &lt;dependency&gt;
                  &lt;groupId&gt;mysql&lt;/groupId&gt;
                  &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
                  &lt;version&gt;5.1.21&lt;/version&gt;
              &lt;/dependency&gt;
                  &lt;/dependencies&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
    &lt;dependencies&gt;
          &lt;dependency&gt;
                &lt;!-- alllll my dependency list --&gt;
          &lt;/dependency&gt;
  
          &lt;!-- DB dependencies --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;version&gt;5.1.21&lt;/version&gt;
          &lt;/dependency&gt;
  
    &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>Update: by using the answer provided now I have the following pom.xml configured with 2 schemas.</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;com.test&lt;/groupId&gt;
    &lt;artifactId&gt;test&lt;/artifactId&gt;
    &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  
  
    &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
              &lt;groupId&gt;org.flywaydb&lt;/groupId&gt;
                  &lt;artifactId&gt;flyway-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;3.0&lt;/version&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;argentina&lt;/id&gt;
                          &lt;phase&gt;compile&lt;/phase&gt; &lt;!--whatever phase you need--&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;migrate&lt;/goal&gt;
                          &lt;/goals&gt;
                          &lt;configuration&gt;
                              &lt;url&gt;jdbc:mysql://localhost:3306/argentina&lt;/url&gt;
                              &lt;user&gt;test&lt;/user&gt;
                              &lt;password&gt;test&lt;/password&gt;
                              &lt;locations&gt;
                                  &lt;location&gt;
                                      filesystem:src/main/resources/db/migration                                  
                                  &lt;/location&gt;
                              &lt;/locations&gt;
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
                      &lt;execution&gt;
                          &lt;id&gt;brazil&lt;/id&gt;
                          &lt;phase&gt;compile&lt;/phase&gt; &lt;!--whatever phase you need--&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;migrate&lt;/goal&gt;
                          &lt;/goals&gt;
                          &lt;configuration&gt;
                              &lt;url&gt;jdbc:mysql://localhost:3306/brazil&lt;/url&gt;
                              &lt;user&gt;test&lt;/user&gt;
                              &lt;password&gt;test&lt;/password&gt;
                              &lt;locations&gt;
                                  &lt;location&gt;
                                      filesystem:src/main/resources/test2/sql
                                  &lt;/location&gt;
                              &lt;/locations&gt;
                          &lt;/configuration&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
                  &lt;dependencies&gt;
                      &lt;dependency&gt;
                          &lt;groupId&gt;mysql&lt;/groupId&gt;
                          &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
                          &lt;version&gt;5.1.21&lt;/version&gt;
                      &lt;/dependency&gt;
                  &lt;/dependencies&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
    &lt;dependencies&gt;
          ...
    &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>I execute flyway operations but none worked, here is the error I got:</p>
  
  <pre><code>[INFO] Copying 5 resources
  [INFO] [compiler:compile {execution: default-compile}]
  [INFO] Nothing to compile - all classes are up to date
  [INFO] [flyway:migrate {execution: argentina}]
  [INFO] Database: jdbc:mysql://localhost:3306/argentina (MySQL 5.5)
  [INFO] Validated 4 migrations (execution time 00:00.006s)
  [INFO] Current version of schema `argentina`: 45678
  [INFO] Schema `argentina` is up to date. No migration necessary.
  [INFO] [flyway:migrate {execution: brazil}]
  [INFO] Database: jdbc:mysql://localhost:3306/brazil (MySQL 5.5)
  [INFO] Validated 1 migration (execution time 00:00.003s)
  [INFO] Current version of schema `brazil`: 1
  [INFO] Schema `brazil` is up to date. No migration necessary.
  [INFO] [flyway:migrate {execution: default-cli}]
  [INFO] ------------------------------------------------------------------------
  [ERROR] BUILD ERROR
  [INFO] ------------------------------------------------------------------------
  [INFO] org.flywaydb.core.api.FlywayException: DataSource not set! Check your configuration!
  </code></pre>
  
  <p>The database configuration is ok. Also I checked the schemas are ok What I am missing?</p>
  
  <p>UPDATE: I removed from the command line flyway: and it worked well. Thanks <code>Jk1</code></p>