|
|
@ -26,6 +26,7 @@ import javax.sql.DataSource;
|
|
|
|
|
|
|
|
|
|
|
|
import org.flywaydb.core.Flyway;
|
|
|
|
import org.flywaydb.core.Flyway;
|
|
|
|
import org.flywaydb.core.api.MigrationVersion;
|
|
|
|
import org.flywaydb.core.api.MigrationVersion;
|
|
|
|
|
|
|
|
import org.flywaydb.core.api.callback.FlywayCallback;
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.ObjectProvider;
|
|
|
|
import org.springframework.beans.factory.ObjectProvider;
|
|
|
|
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
|
|
|
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
|
|
@ -61,6 +62,7 @@ import org.springframework.util.ObjectUtils;
|
|
|
|
* @author Vedran Pavic
|
|
|
|
* @author Vedran Pavic
|
|
|
|
* @author Stephane Nicoll
|
|
|
|
* @author Stephane Nicoll
|
|
|
|
* @author Jacques-Etienne Beaudet
|
|
|
|
* @author Jacques-Etienne Beaudet
|
|
|
|
|
|
|
|
* @author Eddú Meléndez
|
|
|
|
* @since 1.1.0
|
|
|
|
* @since 1.1.0
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Configuration
|
|
|
|
@Configuration
|
|
|
@ -92,15 +94,19 @@ public class FlywayAutoConfiguration {
|
|
|
|
|
|
|
|
|
|
|
|
private final FlywayMigrationStrategy migrationStrategy;
|
|
|
|
private final FlywayMigrationStrategy migrationStrategy;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private FlywayCallback[] flywayCallbacks;
|
|
|
|
|
|
|
|
|
|
|
|
public FlywayConfiguration(FlywayProperties properties,
|
|
|
|
public FlywayConfiguration(FlywayProperties properties,
|
|
|
|
ResourceLoader resourceLoader, ObjectProvider<DataSource> dataSource,
|
|
|
|
ResourceLoader resourceLoader, ObjectProvider<DataSource> dataSource,
|
|
|
|
@FlywayDataSource ObjectProvider<DataSource> flywayDataSource,
|
|
|
|
@FlywayDataSource ObjectProvider<DataSource> flywayDataSource,
|
|
|
|
ObjectProvider<FlywayMigrationStrategy> migrationStrategy) {
|
|
|
|
ObjectProvider<FlywayMigrationStrategy> migrationStrategy,
|
|
|
|
|
|
|
|
ObjectProvider<FlywayCallback[]> flywayCallbacks) {
|
|
|
|
this.properties = properties;
|
|
|
|
this.properties = properties;
|
|
|
|
this.resourceLoader = resourceLoader;
|
|
|
|
this.resourceLoader = resourceLoader;
|
|
|
|
this.dataSource = dataSource.getIfUnique();
|
|
|
|
this.dataSource = dataSource.getIfUnique();
|
|
|
|
this.flywayDataSource = flywayDataSource.getIfAvailable();
|
|
|
|
this.flywayDataSource = flywayDataSource.getIfAvailable();
|
|
|
|
this.migrationStrategy = migrationStrategy.getIfAvailable();
|
|
|
|
this.migrationStrategy = migrationStrategy.getIfAvailable();
|
|
|
|
|
|
|
|
this.flywayCallbacks = flywayCallbacks.getIfAvailable();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@PostConstruct
|
|
|
|
@PostConstruct
|
|
|
@ -140,6 +146,9 @@ public class FlywayAutoConfiguration {
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
flyway.setDataSource(this.dataSource);
|
|
|
|
flyway.setDataSource(this.dataSource);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.flywayCallbacks != null && this.flywayCallbacks.length > 0) {
|
|
|
|
|
|
|
|
flyway.setCallbacks(this.flywayCallbacks);
|
|
|
|
|
|
|
|
}
|
|
|
|
flyway.setLocations(this.properties.getLocations().toArray(new String[0]));
|
|
|
|
flyway.setLocations(this.properties.getLocations().toArray(new String[0]));
|
|
|
|
return flyway;
|
|
|
|
return flyway;
|
|
|
|
}
|
|
|
|
}
|
|
|
|