I learnt flywaydb migration with java works with JDBC connection and also spring support through SpringTemplate, but flyway doesn’t work with DAOs.
for tables/entities with more relationships,it makes life much easier to do migration with DAO’s rather than sql.
is there a solution or work-around to deal with this ?
Advertisement
Answer
First, Flyway has its own transaction managing system and does not use Spring transaction handling.
If your DAOs extend JdbcDaoSupport
, you could instantiate manually the your DAO and then manually inject the provided JdbcTemplate
in the DAO:
public class MyJdbcMigration implements SpringJdbcMigration { public void migrate(JdbcTemplate jdbcTemplate) { MyJdbcDao dao = new MyJdbcDao(); dao.setJdbcTemplate(jdbcTemplate); dao.updateDate(); } }