title: Flyway and Spring Boot integration
body: <p>I trying to integrate Flyway for migrations in a Spring Boot project with Hibernate and Spring JPA. I'm getting the following Exception:</p>
  
  <pre><code>org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flyway' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.api.FlywayException: Found non-empty schema "PUBLIC" without metadata table! Use init() or set initOnMigrate to true to initialize the metadata table.
  </code></pre>
  
  <p>My <code>pom.xml</code> is looking like this:  </p>
  
  <pre><code>&lt;dependency&gt;
    &lt;groupId&gt;org.flywaydb&lt;/groupId&gt;
    &lt;artifactId&gt;flyway-core&lt;/artifactId&gt;
    &lt;version&gt;3.2&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>I'm using Hibernate and a config java file for postgres (dev stage) and h2 (local). The signatures are looking like this:</p>
  
  <pre><code>  @Bean(initMethod = "migrate")
    public Flyway flyway() {
      Flyway fly = new Flyway();
      fly.clean();
      fly.init();
      //flyway.setInitOnMigrate(true);
      fly.setSchemas("SBA_DIALOG");
      //flyway.setLocations("filesystem:src/main/resources/db/migration");
      fly.setDataSource(this.dataSource());
      fly.migrate();
      return fly;
    }
  @Bean(name = "sbaEntityManagerFactory") @DependsOn("flyway")
    public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
  ...
  </code></pre>
  
  <p>I can't find anything about my problem described in this question. 
  Can anybody help?</p>