Repair的作用:

  • Remove failed migration entries (only for databases that do NOT support DDL transactions)
  • Realign the checksums, descriptions, and types of the applied migrations with the ones of the available migrations
  • Mark all missing migrations as deleted
  1. Maven依赖

    1
    2
    3
    4
    
    <dependency>
    	<groupId>org.flywaydb</groupId>
    	<artifactId>flyway-core</artifactId>
    </dependency> 
    
  2. Java配置

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    
    @Component
    public class FlywayConfig implements FlywayMigrationStrategy{
    
        @Override
        public void migrate(Flyway flyway) {
            flyway.repair();
            flyway.migrate();
        }
    
    }