【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文件首次启动后不要再修改此文件。

相关推荐
高频因子挖掘机4 小时前
300 只股票 × 两年日 K:为什么逐只循环会变成维护灾难?
后端·github·api
苏三说技术5 小时前
Spring AI Alibaba已停更了,Java还有希望吗?
后端
ShineWinsu5 小时前
对于Redis:主从复制的解析
linux·数据库·c++·redis·缓存·面试·主从复制
许彰午5 小时前
03-Linux环境准备依赖包内核参数与用户组
linux·运维·服务器·数据库
松就是我902986 小时前
如何搭建一个 Agent 系统:方法论、理想形态与一次真实落地
后端
Layer6 小时前
即时通讯系统的关键设计
后端·架构
阳光九叶草LXGZXJ6 小时前
达梦数据库-报错-16-MERGE INTO提示:无效的列名[XX]
linux·运维·数据库·sql·学习
墨天梦6 小时前
B10_文件SharedPreferences与SQLite
jvm·数据库·sqlite
鲲极6 小时前
居间业务数据统计看板 三条取数口径怎么归一才对得上
数据库·鲲极·鲲极系统
ao-weilai6 小时前
MySQL数据库:基本查询
android·数据库·mysql