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

相关推荐
达梦产品与服务5 小时前
SQLark V4.4 更新 | 新增 SQL Server 数据库支持、自定义格式复制、Agent 辅助建表等 20+ 项功能已上线!
数据库
小Ti客栈6 小时前
MySQL 常用函数速查(完整篇)
数据库·mysql·adb
隔窗听雨眠7 小时前
高可用不止于数据库的全栈工程实践
数据库·架构设计·高可用
码事漫谈8 小时前
以后人人都可以成为导演
后端
Resean02238 小时前
Spring 源码分析(二)配置类的解析与扫描
java·后端·spring
一只爱撸猫的程序猿8 小时前
五周、两个开源仓库、九次拦截之后:AI 时代程序员缺的到底是什么
人工智能·后端·开源
北城笑笑10 小时前
Vue 110 ,若依SSE流式接口限次空500排查与解决
前端·javascript·vue.js·后端·vue
nice_lcj52010 小时前
MySQL 主从复制与读写分离:从库怎么跟着主库走
数据库·mysql·面试·binlog·读写分离·主从复制
ServBay10 小时前
Local harness 将退役,VS Code 本地开发要不要搬到云端?
后端·ai编程·visual studio code