Is there a way in liquibase to create java code change set (i.e. provide a java class, which will receive a JDBC connection and will perform some changes in the database) ?
(I know that flyway has such feature)
Yes, there is such feature. You can create a customChange
:
<customChange class="my.java.Class">
<param name="id" value="2" />
</customChange>
The class must implements the liquibase.change.custom.CustomTaskChange
interface.
@Override
public void execute(final Database arg0) throws CustomChangeException {
JdbcConnection dbConn = (JdbcConnection) arg0.getConnection();
try {
... do funny stuff ...
} catch (Exception e) {
// swallow the exception !
}
}