Created
March 17, 2015 09:44
-
-
Save hikoma/c4a339d0b7c893f5450b to your computer and use it in GitHub Desktop.
Force clean detabase before flyway migration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.flywaydb.core.Flyway; | |
import org.springframework.boot.autoconfigure.AutoConfigureBefore; | |
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | |
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; | |
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | |
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | |
import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
import javax.sql.DataSource; | |
/** | |
* {@link EnableAutoConfiguration Auto-configuration} for Flyway database cleanup. | |
*/ | |
@Configuration | |
@ConditionalOnClass(Flyway.class) | |
@ConditionalOnBean(DataSource.class) | |
@ConditionalOnProperty(prefix = "flyway", name = "enabled", matchIfMissing = true) | |
@AutoConfigureBefore(FlywayAutoConfiguration.class) | |
public class FlywayCleanAutoConfiguration { | |
@Configuration | |
public static class FlywayCleanConfiguration extends FlywayAutoConfiguration.FlywayConfiguration { | |
@Bean(name = "flywayClean", initMethod = "clean") | |
@Override | |
public Flyway flyway() { | |
return super.flyway(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use
flyway.cleanOnValidationError=true
instead