|
3 | 3 | import io.sqlman.SqlDialectSupport; |
4 | 4 | import io.sqlman.SqlScriptResolver; |
5 | 5 | import io.sqlman.SqlSourceProvider; |
| 6 | +import io.sqlman.SqlVersionManager; |
6 | 7 | import io.sqlman.manager.JdbcIsolation; |
7 | 8 | import io.sqlman.manager.JdbcVersionManager; |
8 | 9 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; |
@@ -42,21 +43,19 @@ public class JdbcManagerConfiguration { |
42 | 43 | private SqlDialectSupport dialectSupport; |
43 | 44 |
|
44 | 45 | @Bean |
45 | | - @ConditionalOnMissingBean |
| 46 | + @ConditionalOnMissingBean(SqlVersionManager.class) |
46 | 47 | @ConditionalOnProperty(prefix = "sqlman", name = "enabled", havingValue = "true", matchIfMissing = true) |
47 | | - public JdbcVersionManager sqlmanBasicVersionManager(ApplicationContext applicationContext) throws Exception { |
48 | | - Map<String, DataSource> dataSources = applicationContext.getBeansOfType(DataSource.class); |
49 | | - if (dataSources.isEmpty()) { |
| 48 | + public JdbcVersionManager sqlmanBasicVersionManager(ApplicationContext applicationContext) { |
| 49 | + Map<String, DataSource> map = applicationContext.getBeansOfType(DataSource.class); |
| 50 | + if (map.isEmpty()) { |
50 | 51 | throw new IllegalStateException("no dataSource found in application context"); |
51 | 52 | } |
52 | | - DataSource dataSource = dataSources.size() == 1 ? dataSources.values().iterator().next() : dataSources.get(properties.getDataSource()); |
| 53 | + DataSource dataSource = map.size() == 1 ? map.values().iterator().next() : map.get(properties.getDataSource()); |
53 | 54 | if (dataSource == null) { |
54 | 55 | throw new IllegalStateException("no dataSource found in application context named: " + properties.getDataSource()); |
55 | 56 | } |
56 | 57 | JdbcIsolation jdbcIsolation = properties.getJdbcIsolation(); |
57 | | - JdbcVersionManager jdbcVersionManager = new JdbcVersionManager(dataSource, jdbcIsolation, scriptProvider, scriptResolver, dialectSupport); |
58 | | - jdbcVersionManager.upgrade(); |
59 | | - return jdbcVersionManager; |
| 58 | + return new JdbcVersionManager(dataSource, jdbcIsolation, scriptProvider, scriptResolver, dialectSupport); |
60 | 59 | } |
61 | 60 |
|
62 | 61 | } |
0 commit comments