Callbacks are added and executed multiple times #1625
What version of Flyway are you using?
Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin, SBT plugin, ANT tasks)
What database are you using (type & version)?
Oracle 12c (188.8.131.52.0 / 64 Bit)
What operating system are you using?
Windows 7 (64 Bit) / JDK 1.8.0_131
What did you do?
What did you expect to see?
The beforeBaseline.sql script should be executed only once.
What did you see instead?
The beforeBaseline.sql script has been executed twice:
It seems that this bug has been introduced in commit 0baf57e, which changed the execute method in Flyway.java:
Whenever the execute method is invoked (and skipDefaultCallbacks is not set), an additional SqlScriptFlywayCallback instance is added to the callbacks property.
The text was updated successfully, but these errors were encountered:
This appears to affect default SQL callbacks on the command line as well (certainly the beforeMigrate and afterMigrate ones). I'm using V4.2.0 and have placed beforeMigrate.sql and afterMigrate.sql in the flyway location and am seeing duplicate 'Executing SQL callback;' messages.
It appears that what I was seeing is that the beforeMigrate.sql and afterMigrate.sql scripts are run for the clean and the migrate command when running 'flyway clean migrate'. But, the additional executions are not before or after the clean phase, they are around the migrate phase.
I realised this when I ran a migrate on a fully up-to-date schema (I wanted to check whether the callbacks are executed when there are no migrations that are required to be run). In this situation there is a single execution of the relevant script rather than two. Adding an (unnecessary) repair to the command line (flyway repair clean migrate) results in three executions of each of the beforeMigrate and afterMigrate callback scripts.