2015-06-14 9 views

risposta

25

È possibile sovrascrivere la configurazione automatica Flyway in questo modo:

@Bean 
@Profile("test") 
public Flyway flyway(DataSource theDataSource) { 
    Flyway flyway = new Flyway(); 
    flyway.setDataSource(theDataSource); 
    flyway.setLocations("classpath:db/migration"); 
    flyway.clean(); 
    flyway.migrate(); 

    return flyway; 
} 

Nella primavera del Boot 1.3 (la versione corrente è 1.3.0.M1, versione GA è prevista per settembre), è possibile utilizzare un fagiolo FlywayMigrationStrategy per definire le azioni che si desidera eseguire:

@Bean 
@Profile("test") 
public FlywayMigrationStrategy cleanMigrateStrategy() { 
    FlywayMigrationStrategy strategy = new FlywayMigrationStrategy() { 
     @Override 
     public void migrate(Flyway flyway) { 
      flyway.clean(); 
      flyway.migrate(); 
     } 
    }; 

    return strategy; 
} 
+0

Grazie mille @dunni, ha aiutato! – Barbadoss

Problemi correlati