Java – repairing flight path with spring boot

When the migration failed in the spring boot project, I didn't quite understand what I should do

I passed in my POM Flyway dependency is added to XML to activate flyway Everything is fine When I start the spring boot application, my database scripts will be migrated

But there was an error in one of my scripts, and my last migration failed Now, when I try to migrate, there is a "migration checksum mismatch" Usually, I will run MVN flyway: fix, but since I use spring boot, I should not use flyway Maven plug-in What should I do?

Solution

There are several ways to perform a repair on a database I personally prefer simple SQL statements

SQL statement:

Just delete the rows that failed the migration After that, you can run the migration again

Direct operation flight

You can install flyway local in the console and run flight maintenance

Using the flyway Maven plug-in

Add flyway Maven plugin to your POM and run MVN flyway: repair I don't think this contradicts the concept of spring boot

Extended spring start

In flyway migration strategy, you can call migration or repair methods from the flight path More information can be found in the spring boot reference guide

I don't think the flyway migration strategy in the application is the right place to repair the database Migration failure is an exception and should be handled outside the application

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>