Skip to content

fix: require explicit opt-in for Flyway history repair - #657

Merged
mateaix merged 1 commit into
mateaix:devfrom
RobinZhiBin:codex/fix-flyway-validation
Oct 9, 2026
Merged

mateaix merged 1 commit into
mateaix:devfrom
RobinZhiBin:codex/fix-flyway-validation

Conversation

@RobinZhiBin

Copy link
Copy Markdown
Contributor

Problem

Startup currently calls Flyway.repair() before every migration. If an already-applied SQL file changes, startup replaces its recorded checksum before validation can reject the change, even though the database has not executed the changed SQL. PostgreSQL and Kingbase profiles additionally disable validation.

Change

  • Run normal migration with validation by default; require mateclaw.flyway.auto-repair=true for history repair and log a warning when enabled.
  • Let PostgreSQL and Kingbase inherit the shared strict validation default. Explicit external validation overrides remain available.
  • Update English/Chinese configuration and architecture docs with recovery steps and Desktop upgrade implications. Repair is metadata correction, not schema/data recovery; no existing migration SQL is changed.

Compatibility

An existing installation, including Desktop, with a changed applied migration may now fail startup. Operators should back up and compare the applied scripts and actual schema before any one-time repair. Keeping auto-repair enabled or disabling validation is not the default upgrade strategy.

Validation

  • Before the change: 12 tests, 5 expected failures, 0 errors.
  • After the change: 12 tests passed, 0 failures/errors/skips (Java 21, Maven offline).
  • Coverage: fresh/repeated startup, checksum drift preserving history and blocking pending SQL, explicit property/environment opt-in, all four profile validation defaults, explicit validation overrides.
  • Command: mvn -B -o -pl mateclaw-server -am -Dtest=FlywayRepairConfigTest -Dsurefire.failIfNoSpecifiedTests=false test.

Tests use real isolated H2 migration fixtures and load all four shipped database profile configurations; they do not connect to PostgreSQL, MySQL or Kingbase servers. No production database was accessed.

@mateaix
mateaix merged commit 0394ba2 into mateaix:dev Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants