Best practice: How to modify flyway migration script after it has been used
I completely agree with the fact you shouldn't do it.
But if you really need to, you can change the flyway configuration and set the validateOnMigrate boolean as false.
Here's the link: https://flywaydb.org/documentation/commandline/migrate#validateOnMigrate
The first rule is don't.
The second one is do it very carefully and use Flyway.repair() to realign the checksums in the DB with the ones on disk.