In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces how to write the SQL script of Springboot+Flyway management project, the content is very detailed, interested friends can use it for reference, hope to be helpful to you.
The test package is in the front.
Download the test package it is recommended to use the GitZip for github plug-in to download the stand-alone directory
Modify the application.yaml database address.
Access http://localhost:8080/user/info/1 after startup
How Flyway works
Flyway needs to create a metdata table in DB (the default table is flyway_schema_history), which stores a record of each migration, including the version number of the migration script and the checksum value of the SQL script. When a new SQL script is scanned, Flyway parses the version number of the SQL script and compares it with the apply migration of the metadata table. If the SQL script version is updated, the SQL file will be executed on the specified DB, otherwise the SQL file will be skipped.
Version number size description
For the comparison of the two flyway version numbers, the left alignment principle is adopted and the vacancy is replaced by 0. Examples are as follows:
1.2.9.4 is higher than 1.2.9
1.2.10 is higher than version 1.2.9.4
The 1.2.10 version number is the same as the 1.2.010 version number, and the leading 0 of each version number is ignored.
Script classification
Flyway SQL files can be divided into two categories:
Versioned
Repeatable
Versioned
Versioned migration is used for version upgrade. Each version has a unique version number and can only be apply once.
Repeatable
Repeatable migration refers to the migration that can be loaded repeatedly. Once the checksum of the SQL script changes, flyway reapplies the script. It is not used for version updates, and this type of migration is always executed after versioned migration execution.
Naming rule diagram of Migration SQL
The file name consists of the following sections, which can customize rules in addition to the default configuration.
Prefix: configurable, prefix identified, default value V for Versioned, R for Repeatable
Version: identifies the version number, consisting of one or more digits, and the point at which separators are available. Or underscore _
Separator: configurable to separate version identification and description information. Default is two underscores'_ _'.
Description: description information. Text can be separated by underscores or spaces.
Suffix: configurable, followed by identification. Default is .sql
About the development | production environment version notes
The development environment SQL file recommends that the timestamp be used as the version number.
Multi-person development will not cause contention for the version number, and the version number of the production environment will be added at the same time. In this case, it will be more convenient to manually merge into a production environment migration script in the future. SQL file example:
V20200317.1059__V1.0_Unique_User_Names.sqlV20180317.1459__V1.0_Add_SomeTables.sql
The SQL file for the production environment should be a manual SQL script for the merge development environment, with the version number according to the normal version, such as V2.1.5_001__Release.sql
On the Springboot+Flyway management project SQL script how to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.