Reputation: 11
We knew there were some callbacks in flyway: beforeMigrate,beforeEachMigrate,afterEachUndo...
Our project need to fix a problem in an indicated version sql such as V1.0.0 without modify V1.0.0.sql.
Is there any way to help us? Should we support new an Event BEFORE_INDICATED_VERSION_MIGRATE to work with new callback file like beforeMigrate_V1.0.0.sql?
Take for an example: we missed
SET FOREIGN_KEY_CHECKS = 0;
in V1.1.0.sql so we want to callback it while migrating only before V1.1.0.sql. So we add the below sql in beforeEachMigrate.sql:
SELECT version INTO @max_ver FROM `schema_version` ORDER BY version_rank DESC LIMIT 1;
SET FOREIGN_KEY_CHECKS = IF(@max_ver = "1.0.9", 0, @@FOREIGN_KEY_CHECKS);
SET FOREIGN_KEY_CHECKS = IF(@max_ver = "1.1.0", 1, @@FOREIGN_KEY_CHECKS);
In general condition it works. But if we add V1.0.9.1 one day, it won't work. Is there any ideas?
Upvotes: 1
Views: 185
Reputation: 35169
While you can't do this like you suggested, you can easily add a V1.0.0.1__my_additional_change.sql
file which will then automatically be applied after 1.0.0
and before 1.0.1
when migrating the database.
Upvotes: 1