Flyway version management database common errors and solutions

12-06-2022

Flyway is a database version of management tool that realizes the automation upgrade of DB Migration through SQL scripts. It supports independent operation. It can also integrate with the construction tool or Spring development environment.

Summarize common errors in the actual development process, share solutions and suggestions:

l migrate failed, prompting the SQL script error

Solution: Run the Flyway command to repair to repair the upgrade information in the database, correct the SQL error and then migrate again

Suggestion: Before running Migrate, make sure that SQL is correct first.

l migrate does not run the additional SQL script

Solution: SQL script naming follows rules, such as v1.0.0_init.sql

L Migrate failed to run, and the prompt was not enough.

Solution: Account needs to have the right to correspond to the SQL script, such as Create Table

l migrate failed, prompting the database is not empty, "Found Non-Empty Schema (s)"

Solution: Run the Flyway command baseline initialization according to the prompts.

Suggestion: Clear the database and initialize from the empty database.

l Prompt that you can't find the database, "UNKOWN DATABASE 'XXX'"

Solution: You need to create an empty database first.

After l spring, after integrated Flyway, clear the data and start failure

Solution: Confirm whether ValidationQuery is Select 1 from Dual or a specified data table. You need to use Dual when you database

l spring After integrated Flyway, start running an error

Solution: Bean that depends on the database needs to be specified after Flyway to complete the Migrate

l SQL script v1.0__xxx.sql is not running

Solution: Flyway via the version number unique script. If you first run Baseline, Flyway will automatically create version 1.0

Suggestion: 1, start starting from the empty database, do not run Baseline

Suggestion: 2, initialize the SQL script version number starting from V1.0.1, using three digits.

 

 

Copyright Description:No reproduction without permission。

Knowledge sharing community for developers。

Let more developers benefit from it。

Help developers share knowledge through the Internet。

Follow us

high perspicacity