Run Flyway in repair mode
Flyway migration error
Reason: Sometimes developers need to change old SQL scripts. These can scripts were pushed in repository days/months/years ago. Flyway detects scripts that were already applied in databases of OpenIAM but after were changed in repository. Good news! Flyway can fix itself; you just need to give it proper command to start. Highly possible situation when you are using "dev" or "qa" tags.
Example of error in flyway container:
ERROR: Validate failed: Migrations have failed validationMigration checksum mismatch for migration version 4.2.1.2.001-> Applied to database : 938263552-> Resolved locally : 726554884. Either revert the changes to the migration, or run repair to update the schema history.
To fix it follow instruction:
- Remove flyway from docker stack by command: docker stack rm flyway
- Open compose file 3.2/utilities/flyway/docker-compose.yaml
- Add in environment section: FLYWAY_COMMAND: "repair"
- Run ./startup.sh
- When script completed check Flyway container log. use flag -a to see finished containers: docker ps -a | grep flyway
- Error in Flyway container should be gone now
- Comment line FLYWAY_COMMAND: "repair" in3.2/utilities/flyway/docker-compose.yaml
- Remove flyway from docker stack by command: docker stack rm flyway
- Run ./startup.sh again
- If the same error appears again in next updates, repeat these steps.