I want to use flywaydb in order to to version control my database and manage Database schema and data migrations. I want to use the java migrations and java api because I think it's easier to integrate it inside my app. The problem is that when I applied my migrations although I had a syntax error on my sql prepared statment and raised an SQLException the metadata table of flywaydb (schema_version) contained the record that my migrations was applied. Is there a way to change this behavour? My java migration class implements JdbcMigration
public class V1_2__Change_commnets_to_int implements JdbcMigration {
@Override
public void migrate(Connection con){
PreparedStatement stm = con.prepareStatement("Query with syntax error");
try{
stm.execute();
}catch(SQLException e){
e.printStackTrace();
}finally{
stm.close();
}
}
}
Could you also please provide with an example of how to use checksums with java migrations in flywaydb?
Your code caught the exception and carried on, so Flyway didn't know there was anything wrong.
Better to rethrow it