Is there a way to run Flyway Java-based callbacks with Spring boot? I'm converting an existing project that after each migration updates some view definitions, and this is done by Java as it needs some extra logic. I know it could be done in pl/pgsql (we are using Postgres) but it is already done and tested in Java.
Spring boot docs says it is possible, but it is listed that the callback scripts should live in same dir as migrations, maybe this works just for SQL based callbacks.
This code works without Spring Boot:
Flyway flyway = new Flyway();
flyway.setDataSource(this.getDataSource());
flyway.setLocations("/db/migration");
flyway.setCallbacks(new LogMaintenanceFlywayCallback());
flyway.migrate();
I have several migrations in /db/migration and after each one I need to execute my callback. It works in my current project and I need to do the same (or another way to get the same behavior) in Spring Boot.
db.migrationspackage. - Wim DeblauweSomeMaintenanceFlywayCallback, implementing interfaceFlywayCallbackand methodafterEachMigratedoes not get called. I have tried to rename the class toAfterEachMigrate, but no success too. It is indb.migrationspackage, side by side with a Java migration that is executed, so the build path is ok. - Fernando M. Pinheirosrc/main/resources/db/migration. Java migrations should be insrc/main/java/db/migration. Each file normally starts withVxxx__some-text-here.sqlor Vxxx__MyJavaClass.java`. - Wim Deblauwedb.migrations, butdb.migration. See docs.spring.io/spring-boot/docs/current/reference/html/… - Wim Deblauwedb.migration. As I said, my migrations are being executed, what I need is the callback, after each migration run some code. I have updated my question to include the manual way to use Flyway. - Fernando M. Pinheiro