[BUG] manager cannot start again after V181 migration fails (flyway records failed migration)
Is there an existing issue for this?
- [x] I have searched the existing issues
Current Behavior
On a fresh MySQL/PostgreSQL database, Hibernate ddl-auto creates the hzb_sop_schedule table from the entity before Flyway runs (Flyway is deliberately delayed until after entityManagerFactory). V181__update_column.sql then executes a bare CREATE TABLE hzb_sop_schedule, which fails with "Table 'hzb_sop_schedule' already exists". Flyway records this failure in flyway_schema_history, and from then on every restart aborts during validation:
FlywayValidateException: Validate failed: Migrations have failed validation
Detected failed migration to version 181 (update column)
The instance can never start again until someone manually deletes the failed row from flyway_schema_history.
Expected Behavior
The V181 migration should tolerate objects already created by Hibernate (CREATE TABLE IF NOT EXISTS / CREATE INDEX IF NOT EXISTS), and a previously recorded failed migration should not permanently prevent startup — Flyway history can be repaired automatically and the (now idempotent) migration retried.
Steps To Reproduce
- Point the manager at an empty MySQL (or PostgreSQL) database with
spring.flyway.enabled=true(default startup config) - First boot: Hibernate creates
hzb_sop_schedule; Flyway's V181CREATE TABLEcollides and the failure is recorded inflyway_schema_history - Restart the manager
- Startup aborts with
Validate failed ... Detected failed migration to version 181— and keeps failing on every restart
Environment
HertzBeat version(s): master (also reproduced against 1.8.0 schema with MySQL 8 and PostgreSQL 15)
Debug logs
No response
Anything else?
No response