Reputation: 297
I use flyway command-line in a docker container to apply my migration scripts. I now have to add a Java callback in my implementation. The callback can successfully be detected and launch through the flyway-maven-plugin, with a <callback>
definition in the pom.xml
. I generate a JAR of this project.
I now want to run it with the command line. The following command works, my SQL migrations are applied
flyway repair migrate
-locations=path/to/sql/migration
-url=...
If I add my callback, in this way, it tells me the following error
flyway repair migrate
-locations=path/to/sql/migration
-callbacks=com.company.MyCallback
-url=...
Unable to instantiate class "com.company.MyCallback"
I also tried the jarDirs option, but same error
flyway repair migrate
-locations=path/to/sql/migration
-jarDirs=/folder/containing/the/jar/i/generated
-callbacks=com.company.MyCallback
-url=...
But no result. Any help or hint will be appreciated!
Upvotes: 2
Views: 1248
Reputation: 779
As per the documentation, -jarDirs
switch is supported for both repair and migrate commands that you are trying for and the documentation states
jarDirs Default:{install-dir}/jars Comma-separated list of directories containing JDBC drivers and Java-based migrations
But this did not work in loading Custom Callbacks. Custom Callbacks seems to be loaded from ${FLYWAY_HOME}/jars
only.
I did some testing with a simple callback that extends from org.flywaydb.core.api.callback.BaseFlywayCallback
and it seemed to work fine.
Hope this will solve your issue.
Upvotes: 1