1、flyway
flyway官方文档地址:https://documentation.red-gate.com/fd
对于不怎么看文档的我来说:
1)flyway是个管理数据库版本的工具,可以对不同环境的sql进行迁移操作。
2)优点:初始化、后期数据的管理、变更等,个人认为锦上添花的是一件执行数据脚本,方便快捷
对于数据库每当发布时会出现手动执行sql脚本进行升级数据库,中间经常出现一些漏写、错写情况,对数据库的版本与代码的版本不匹配,
2、文件命名规则
前缀:
V 代表版本变迁(Versioned Migrations),
U 代表撤销变迁(Undo Migrations),
R 代表可重复变迁(Repeatable Migrations),一般为可重复执行的sql语句。没有版本号
版本号: 唯一的版本号,比如V1.0.1
分隔符: __ (两个下划线)
描述信息: 描述信息
后缀: .sql
== 其中,V开头的SQL执行优先级要比R开头的SQL优先级高==
命名eg:
V1__insert.sql
R__insert.sql
3、版本号
- 0.0.1.1 比 0.0.1 高
- 0.0.10 和 0.0.010 一样高
4、Springboot集成Flyway
4.1 pom
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!--引入 Spring Boot Starter 父工程: -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.flyway</groupId>
<artifactId>flyway</artifactId>
<version>