Commit 2cc5bdfa authored by Dave Syer's avatar Dave Syer

Hack to force Flyway to initialize early

parent 341ca38d
...@@ -20,7 +20,9 @@ import javax.annotation.PostConstruct; ...@@ -20,7 +20,9 @@ import javax.annotation.PostConstruct;
import javax.sql.DataSource; import javax.sql.DataSource;
import org.flywaydb.core.Flyway; import org.flywaydb.core.Flyway;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
...@@ -31,6 +33,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; ...@@ -31,6 +33,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.core.io.DefaultResourceLoader; import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader; import org.springframework.core.io.ResourceLoader;
...@@ -52,7 +55,7 @@ public class FlywayAutoConfiguration { ...@@ -52,7 +55,7 @@ public class FlywayAutoConfiguration {
@Configuration @Configuration
@ConditionalOnMissingBean(Flyway.class) @ConditionalOnMissingBean(Flyway.class)
@EnableConfigurationProperties(FlywayProperties.class) @EnableConfigurationProperties(FlywayProperties.class)
public static class LiquibaseConfiguration { public static class FlywayConfiguration {
@Autowired @Autowired
private FlywayProperties properties = new FlywayProperties(); private FlywayProperties properties = new FlywayProperties();
...@@ -93,6 +96,26 @@ public class FlywayAutoConfiguration { ...@@ -93,6 +96,26 @@ public class FlywayAutoConfiguration {
return flyway; return flyway;
} }
@Bean
@DependsOn("flyway")
protected BeanPostProcessor forceFlywayToInitialize() {
return new BeanPostProcessor() {
@Override
public Object postProcessAfterInitialization(Object bean, String beanName)
throws BeansException {
return bean;
}
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName)
throws BeansException {
return bean;
}
};
}
} }
} }
spring.jpa.generate-ddl: false spring.jpa.generate-ddl: false
spring.jpa.hibernate.ddl-auto: none spring.jpa.hibernate.ddl-auto: validate
\ No newline at end of file \ No newline at end of file
CREATE TABLE PERSON ( CREATE TABLE PERSON (
id INTEGER GENERATED BY DEFAULT AS IDENTITY, id BIGINT GENERATED BY DEFAULT AS IDENTITY,
first_name varchar(255) not null, first_name varchar(255) not null,
last_name varchar(255) not null last_name varchar(255) not null
); );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment