| 
20 | 20 | 
 
  | 
21 | 21 | import javax.sql.DataSource;  | 
22 | 22 | 
 
  | 
 | 23 | +import org.apache.commons.lang3.reflect.MethodUtils;  | 
23 | 24 | import org.flywaydb.core.Flyway;  | 
24 | 25 | import org.flywaydb.core.api.configuration.FluentConfiguration;  | 
25 | 26 | 
 
  | 
 | 
29 | 30 | 
 
  | 
30 | 31 | public final class FlywayPreparer implements DatabasePreparer {  | 
31 | 32 | 
 
  | 
32 |  | -    private final FluentConfiguration flyway;  | 
 | 33 | +    private final FluentConfiguration configuration;  | 
33 | 34 |     private final List<String> locations;  | 
34 | 35 | 
 
  | 
35 | 36 |     public static FlywayPreparer forClasspathLocation(String... locations) {  | 
36 |  | -        FluentConfiguration f = Flyway.configure()  | 
37 |  | -            .locations(locations);  | 
38 |  | -        return new FlywayPreparer(f, Arrays.asList(locations));  | 
 | 37 | +        FluentConfiguration config = Flyway.configure().locations(locations);  | 
 | 38 | +        return new FlywayPreparer(config, Arrays.asList(locations));  | 
39 | 39 |     }  | 
40 | 40 | 
 
  | 
41 |  | -    private FlywayPreparer(FluentConfiguration flyway, List<String> locations) {  | 
42 |  | -        this.flyway = flyway;  | 
 | 41 | +    private FlywayPreparer(FluentConfiguration configuration, List<String> locations) {  | 
 | 42 | +        this.configuration = configuration;  | 
43 | 43 |         this.locations = locations;  | 
44 | 44 |     }  | 
45 | 45 | 
 
  | 
46 | 46 |     @Override  | 
47 | 47 |     public void prepare(DataSource ds) throws SQLException {  | 
48 |  | -        flyway.dataSource(ds);  | 
49 |  | -        flyway.load().migrate();  | 
 | 48 | +        configuration.dataSource(ds);  | 
 | 49 | +        Flyway flyway = configuration.load();  | 
 | 50 | +        try {  | 
 | 51 | +            MethodUtils.invokeMethod(flyway, "migrate");  | 
 | 52 | +        } catch (Exception e) {  | 
 | 53 | +            throw new RuntimeException(e);  | 
 | 54 | +        }  | 
50 | 55 |     }  | 
51 | 56 | 
 
  | 
52 | 57 |     @Override  | 
 | 
0 commit comments