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

相关推荐
岁岁种桃花儿3 分钟前
AI超级智能开发系列从入门到上天第十篇:SpringAI+云知识库服务
linux·运维·数据库·人工智能·oracle·llm
CHQIUU10 分钟前
PostgreSQL vs MySQL:选型指南与深度对比
数据库·mysql·postgresql
qq_4160187222 分钟前
Python多线程与多进程:如何选择?(GIL全局解释器锁详解)
jvm·数据库·python
m0_6625779727 分钟前
用Python生成艺术:分形与算法绘图
jvm·数据库·python
苍何34 分钟前
你的Agent🦞也能做电影了!
后端
yymboss34 分钟前
【JavaEE】Spring Boot 项目创建
java·spring boot·java-ee
Soofjan40 分钟前
GMP 源码(下):调度循环、抢占与 syscall
后端
苍何42 分钟前
一人公司,我雇了 6 个 AI 龙虾总监
后端
娇娇yyyyyy43 分钟前
QT编程(19) : Qt 实现自定义delegate
开发语言·数据库·qt
颜酱1 小时前
回溯算法专项突破练习(1)
javascript·后端·算法