【springboot】【flyway】数据库版本控制

这里写目录标题

pom.xml

本项目 spring-boot版本2.3.0

注意根据后面实际路径配置<include>**/**/*.sql</include>

xml 复制代码
......
<dependency>
    <groupId>org.flywaydb</groupId>
    <artifactId>flyway-core</artifactId>
    <version>5.2.1</version>
</dependency>
......
<resource>
   <directory>src/main/resources</directory>
    <includes>
        <include>**/*.yml</include>
        <include>**/*.properties</include>
        <include>**/*.xml</include>
        <include>**/**/*.sql</include>
    </includes>
    <filtering>false</filtering>
</resource>
......

application.yml

locations: classpath:db/migration可改为自定义路径

yaml 复制代码
spring:
  flyway:
    enabled: true
    table: flyway_schema_history
    encoding: UTF-8
    baseline-on-migrate: true
    locations: classpath:db/migration
    sql-migration-prefix: V
    sql-migration-suffixes: .sql
    validate-on-migrate: true
    check-location: true
    clean-disabled: true

sql文件

相关sql文件放置在resources目录下,根据spring.flyway.locations新建文件夹db和子文件夹migration,创建相关VXXX__XXXX.sql

启动

如果数据库没有flyway_schema_history会自动创建,.sql文件首次启动后不要再修改此文件。

相关推荐
FYKJ_20102 小时前
springboot高校实验室综合管理系统86531-计算机毕业设计、课程设计
java·vue.js·spring boot·后端·python·spring·课程设计
parade岁月3 小时前
没有称手工具了怎么办?搓一个!AI 时代顺手造了个单文件 Mermaid ER 查看器
数据库·后端
金銀銅鐵9 小时前
类实例里还有什么——putfield、getfield 与对象传递
java·jvm·后端
织码weavecodes9 小时前
Spring Boot 接入 AI 图像生成:模型适配、图片转存与 Redis 清理
人工智能·spring boot·redis
hryou09229 小时前
向量库选型别踩坑:10个候选、6个暗坑,一次说清
数据库·架构
emoji1111119 小时前
python总结
数据库
皮皮林5519 小时前
你还在使用 WebSocket 实现实时消息推送吗?
后端
码事漫谈10 小时前
token账单到底要怎么看
后端
zxcvb15311 小时前
运维实践里把备份mysql数据库做稳的一些思路
运维·数据库·mysql
Cosolar11 小时前
当 Harness 标准化后,工程师还剩什么?
人工智能·后端·agent