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

相关推荐
hsg774 小时前
简述:Rust、GeoRust、自主研发GIS平台
开发语言·后端·rust
卓怡学长11 小时前
w255基于springboot仓库管理系统
java·数据库·spring boot·spring·intellij-idea
谭光志12 小时前
Vibe Coding 时代,程序员该何去何从
前端·后端·ai编程
GoGeekBaird12 小时前
我用 BeeWeave 跑完了一次完整写作闭环
后端·github
J-Tony1113 小时前
【Redis】 Redis 是单线程还是多线程
服务器·数据库·mysql
这个DBA有点耶13 小时前
SQL调优进阶:从“优化一条SQL”到“优化一个系统”的思维升级
java·大数据·数据库·sql·程序人生·dba·改行学it
IvorySQL13 小时前
PG 日报|SQL/PGQ 图查询基于联接重写机制实现
数据库·人工智能·sql·postgresql·区块链·ivorysql
仿生狮子14 小时前
别再说“全栈”了,AI 时代团队只认这 5 种人
前端·人工智能·后端
csdn2015_14 小时前
springboot读取配置的方法
java·spring boot·spring
Reart16 小时前
Leetcode 213.打家劫舍2(内含闲谈,打劫真是技术活,好题,716)
后端·算法