Flyway is used in actual development. Let’s briefly introduce flyway
1. Flyway introduction
Flyway is an open source database version management tool. It can be easily used in the command line or introduced in Java applications to manage our database version.
In a project or product, it is difficult to clarify the business at the beginning and design the database table well, so the data table will also iterate continuously in the iteration cycle. Using flyway in Java applications can be used to iterate the database table structure quickly and effectively, and ensure that the data tables are consistent when deployed to the test environment or production environment.
Please refer to flyway’s official documents for details
2. Flyway dependency package
<dependency> <groupId>org.flywaydb</groupId> <artifactId>flyway-core</artifactId> <version>7.9.2</version> </dependency>
3. Benefits of using flyway
In multi person development projects, we are used to using SVN or git to version control the code. The main purpose is to solve the problems of code conflict and version fallback in multi person development.
II Problem analysis
1. Flyway reports an error: detected applied migration not resolved locally:2
When using flyway for system management, my program reported such errors
1.1 problem analysis:
Reported error: Application migration not detected locally resolved
The reason for this problem is:
1. because the imported database contains flyway_schema_history table, so the local runtime version inconsistent error,
2. I migrated a version 2 sql, then I deleted it, and when I ran it again for the second time, I couldn’t find the V2__orange_cms file that I migrated before.
Special Note: Must be in test environment and local environment
1. mvn flyway:clean, this step will clear the existing data.
2. Ensure that the configuration file is open for flyway.
3. Start the project, complete the initialization of the flyway_schema_history table, backup the flyway_schema_history table after the startup is complete
4. Import the data, at this time the flyway_schema_history table will be updated to the version of the imported data
5. After the successful import, delete the flyway_schema_history table and replace it with the backup flyway_schema_history table
6. Start the application again, Success!
2. Script execution error
2.1 problem analysis
The general meaning of the error message: when flyway is opened in my project configuration file, it will explode: the execution of SQL is abnormal, and the “XXX” table cannot be found
This is a problem that has bothered me for a long time. I don’t know where my program and configuration are wrong
Error reason: because our flyway is based on the version of database mysql5.7, but my local database version is mysql5.5, the error “cannot find XXX table” is always reported when starting flyway configuration for database initialization
2.2 problem solving
Upgrade our database version, which is greater than or equal to our development database version. Due to the twists and turns in the road of upgrading the database, we suggest that you learn from it: more detailed
Open our flyway configuration after the database upgrade
Start the program to see if our project can start successfully
- Java error prompt….. cannot be resolved
- [Solved] Annotation Customize Error: ElementType cannot be resolved to a variable
- Mac project startup error: logback configuration error detected
- [Solved] android Execution failed for task ‘:app:processDebugManifest‘
- Three ways of thread sequence alternate execution in Java lock free programming
- [Solved] Execution failed for task ‘:app:uploadCrashlyticsMappingFileRelease‘
- [Solved] Jenkins error: Asynchronous execution failure
- Error resolving template [index], template might not exist
- Java uses single thread pool to realize multi thread sequential execution (non alternating, non synchronous)
- [ERROR] Failed to execute goal on project simple-project: Could not resolve dependencies for project
- [Solved] Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource could
- RSA Decryption Error: java.security.InvalidKeyException: IOException : algid parse error, not a sequence
- [Solved] Tomcat Do not Start Error: Error: Application Server not specified
- [Solved] Error resolving template [x] template might not exist or might not be accessible by any of the con
- [Solved] The war package Error: The reason why the XSD file could not be found
- [Solved] canal-adpter Startup Error: Could not resolve placeholder
- IDEA-Error java error release version 5 not supported (How To Fix)
- [Solved] itextpdf Read PDF File Error: Rebuild failed: trailer not found.
- [Solved] Could not find resource COM / atguigu / Dao / studentdao.xm, the mapper file for storing SQL statements could not be found and an error occurred
- org.hibernate.exception.SQLGrammarException: could not extract ResultSet, Resolve MySQL 5.7.5 or above GROUP_BY is not supported