diff --git a/persist/src/main/java/lcsb/mapviewer/persist/CustomDatabasePopulator.java b/persist/src/main/java/lcsb/mapviewer/persist/CustomDatabasePopulator.java index 27f980d87404b7da3e86812e51997e6f5d5371fd..7b1c033ddb46448b95422d708d718038e6a8da93 100644 --- a/persist/src/main/java/lcsb/mapviewer/persist/CustomDatabasePopulator.java +++ b/persist/src/main/java/lcsb/mapviewer/persist/CustomDatabasePopulator.java @@ -1,47 +1,41 @@ -package lcsb.mapviewer.persist; - -import java.sql.Connection; -import java.sql.SQLException; - -import javax.sql.DataSource; - -import org.apache.log4j.Logger; -import org.flywaydb.core.Flyway; -import org.springframework.jdbc.datasource.init.DatabasePopulator; -import org.springframework.jdbc.datasource.init.ScriptException; - -import com.mchange.v2.c3p0.ComboPooledDataSource; - -public class CustomDatabasePopulator implements DatabasePopulator { - Logger logger = Logger.getLogger(CustomDatabasePopulator.class); - - private DataSource dataSource; - - // public CustomDatabasePopulator(DataSource source) { - // logger.debug("Constructor"); - // logger.debug(source); - // } - - @Override - public void populate(Connection connection) throws SQLException, ScriptException { - logger.debug(dataSource); - - ComboPooledDataSource source = (ComboPooledDataSource) dataSource; - String url = source.getJdbcUrl(); - String user = source.getUser(); - String password = source.getPassword(); - Flyway flyway = new Flyway(); - flyway.setDataSource(url, user, password); - flyway.baseline(); - flyway.migrate(); - - } - - public DataSource getDataSource() { - return dataSource; - } - - public void setDataSource(DataSource dataSource) { - this.dataSource = dataSource; - } -} +package lcsb.mapviewer.persist; + +import java.sql.Connection; +import java.sql.SQLException; + +import javax.sql.DataSource; + +import org.apache.log4j.Logger; +import org.flywaydb.core.Flyway; +import org.springframework.jdbc.datasource.init.DatabasePopulator; +import org.springframework.jdbc.datasource.init.ScriptException; + +import com.mchange.v2.c3p0.ComboPooledDataSource; + +public class CustomDatabasePopulator implements DatabasePopulator { + Logger logger = Logger.getLogger(CustomDatabasePopulator.class); + + private DataSource dataSource; + + @Override + public void populate(Connection connection) throws SQLException, ScriptException { + ComboPooledDataSource source = (ComboPooledDataSource) dataSource; + String url = source.getJdbcUrl(); + String user = source.getUser(); + String password = source.getPassword(); + Flyway flyway = new Flyway(); + flyway.setDataSource(url, user, password); + flyway.setBaselineVersionAsString("12.1.0"); + flyway.setBaselineOnMigrate(true); + flyway.migrate(); + + } + + public DataSource getDataSource() { + return dataSource; + } + + public void setDataSource(DataSource dataSource) { + this.dataSource = dataSource; + } +}