195. Spring Boot 2.0数据库迁移:Flyway
【视频&交流平台】
àSpringBoot视频:http://t.cn/R3QepWG
à SpringCloud视频:http://t.cn/R3QeRZc
à Spring Boot源码:https://gitee.com/happyangellxq520/spring-boot
à Spring Boot交流平台:http://412887952-qq-com.iteye.com/blog/2321532
à Spring Boot Shiro视频:http://t.cn/R3QDMbh
à Spring Boot 2.0 之Spring Data 和JPA:http://t.cn/R1pSojf
历史相关章节:
说明:
(1)Spring Boot 版本:2.0.0.RELEASE
(2)Flyway版本:5.0.7
前言:
在上一节中spring boot使用了1.5.12.RELEASE,这里我们要看看2.0.0.RELEASE的一个使用情况。大体的思路和上一篇是使用的,这里我们在上一篇文章的基础上进行调整。
一、版本说明
这里的Spring Boot版本使用的是2.0.0.RELEASE,那么对于Flyway的版本是5.0.7,这里从3.2.1到5.0.7版本的跨度还是很大的,至于多做了什么改变,这里就不详细展开说明,有兴趣的可以去了解下Flyway版本的升级情况。
二、准备工作
在上一篇的基础上,我们需要将数据库中的所有表结构全部删掉,为什么要全部删除掉呢?在上面我们说到了Flyway的版本跨度是比较大的,这里Flyway的管理版本的表名称调整为了flyway_schema_history(3.2.1的是schema_version)。
三、测试
到这里就可以运行测试了,顺利的话,会在数据库中看到之前的表和数据,另外就是Flyway管理版本信息的表:flyway_schema_history。
四、存放路径说明
由于我们使用了默认的路径,如果你要修改默认的路径的话,在2.0.0版本之后,使用的是如下的配置了:
- spring.flyway.locations=classpath:/db/migration
5.1.12的版本的是:
- flyway.locations=classpath:/db/migration
五、配置说明
对于2.x的版本,Flyway的配置加上了spring的前缀,如下配置:
# FLYWAY (FlywayProperties)
spring.flyway.baseline-description= #
spring.flyway.baseline-on-migrate= #
spring.flyway.baseline-version=1 # Version to start migration
spring.flyway.check-location=true # Whether to check that migration scripts location exists.
spring.flyway.clean-disabled= #
spring.flyway.clean-on-validation-error= #
spring.flyway.dry-run-output= #
spring.flyway.enabled=true # Whether to enable flyway.
spring.flyway.encoding= #
spring.flyway.error-handlers= #
spring.flyway.group= #
spring.flyway.ignore-future-migrations= #
spring.flyway.ignore-missing-migrations= #
spring.flyway.init-sqls= # SQL statements to execute to initialize a connection immediately after obtaining it.
spring.flyway.installed-by= #
spring.flyway.locations=classpath:db/migration # The locations of migrations scripts.
spring.flyway.mixed= #
spring.flyway.out-of-order= #
spring.flyway.password= # JDBC password to use if you want Flyway to create its own DataSource.
spring.flyway.placeholder-prefix= #
spring.flyway.placeholder-replacement= #
spring.flyway.placeholder-suffix= #
spring.flyway.placeholders.*= #
spring.flyway.repeatable-sql-migration-prefix= #
spring.flyway.schemas= # schemas to update
spring.flyway.skip-default-callbacks= #
spring.flyway.skip-default-resolvers= #
spring.flyway.sql-migration-prefix=V #
spring.flyway.sql-migration-separator= #
spring.flyway.sql-migration-suffix=.sql #
spring.flyway.sql-migration-suffixes= #
spring.flyway.table= #
spring.flyway.target= #
spring.flyway.undo-sql-migration-prefix= #
spring.flyway.url= # JDBC url of the database to migrate. If not set, the primary configured data source is used.
spring.flyway.user= # Login user of the database to migrate.
spring.flyway.validate-on-migrate= #
Spring Boot 1.x的版本如下配置:
# FLYWAY (FlywayProperties)
flyway.baseline-description= #
flyway.baseline-version=1 # version to start migration
flyway.baseline-on-migrate= #
flyway.check-location=false # Check that migration scripts location exists.
flyway.clean-on-validation-error= #
flyway.enabled=true # Enable flyway.
flyway.encoding= #
flyway.ignore-failed-future-migration= #
flyway.init-sqls= # SQL statements to execute to initialize a connection immediately after obtaining it.
flyway.locations=classpath:db/migration # locations of migrations scripts
flyway.out-of-order= #
flyway.password= # JDBC password if you want Flyway to create its own DataSource
flyway.placeholder-prefix= #
flyway.placeholder-replacement= #
flyway.placeholder-suffix= #
flyway.placeholders.*= #
flyway.schemas= # schemas to update
flyway.sql-migration-prefix=V #
flyway.sql-migration-separator= #
flyway.sql-migration-suffix=.sql #
flyway.table= #
flyway.url= # JDBC url of the database to migrate. If not set, the primary configured data source is used.
flyway.user= # Login user of the database to migrate.
flyway.validate-on-migrate= #
点赞、转发、评论,伸出你的双手666…召唤你的小蚂蚁:
你就是你,不一样的小蚂蚁!
微信公众号「SpringBoot」最近更新:
206. Spring Boot 2.0 Swagger2:使用
205. Spring Boot 2.0 Swagger2:初识Swagger
当要离开的时候,我却动情了
205. jetcache:你需要知道的小技巧
204. jetcache:在Spring Boot中怎么玩?
遇见阿里,遇见自己
203. 阿里jetcache
202. 阿里Pandora Boot
微信公众号赞赏功能升级了,真的假的?
《喜剧之王》「我养你啊」之人生选择
201. Spring Boot JNDI:Spring Boot中怎么玩JNDI
510阿里日,马老师献上最走心、最科技范儿证婚词~
200. Spring Boot JNDI:在Tomcat中怎么玩JNDI?
199. Spring Boot JNDI:这是虾米?
Spring Boot 数据库迁移系列
Spring Boot葵花宝典:初露锋芒:MyBatis insert异常 Parameter 'name' not found
198. Spring Boot Flyway工作原理
21天习惯养成法则
197. Spring Boot 2.0数据库迁移:Liquibase
196. Spring Boot 数据库迁移:Liquibase
195. Spring Boot 2.0数据库迁移:Flyway
194. Spring Boot 数据库迁移:Flyway
193. Spring Boot 数据库迁移:概述
搜索「springboot」或者扫描以下二维码即可关注:
195. Spring Boot 2.0数据库迁移:Flyway的更多相关文章
- Spring Boot 2.0正式发布,新特性解读
作者|翟永超 Spring Boot 2.0 来啦,有哪些新特性?升级吗? 写在前面 北京时间 3 月 1 日,经过漫长的等待之后,Spring Boot 2.0 正式发布.作为 Spring 生态中 ...
- Spring 官宣发布 Spring Boot 3.0 第一个里程碑 M1,从 Java 8 提升到 Java 17!
Spring官方于2022年1月20日发布Spring Boot 3.0.0-M1版本,预示开启了Spring Boot 3.0的里程碑,相信这是通往下一代Spring框架的激动人心的旅程. 接下来一 ...
- Spring Boot 2.0 迁移指南

执行器(Actuator)的定义 执行器是一个制造业术语,指的是用于移动或控制东西的一个机械装置,一个很小的改变就能让执行器产生大量的运动. An actuator is a manufacturin ...
- Spring Boot实践——Spring Boot 2.0 新特性和发展方向
出自:https://mp.weixin.qq.com/s/EWmuzsgHueHcSB0WH-3AQw 以Java 8 为基准 Spring Boot 2.0 要求Java 版本必须8以上, Jav ...
随机推荐
- Qml和C++开发的学生信息管理软件一
一个月前接触到了Qml,也做过一些练习,但只能实现动画和简单的布局功能,逻辑部分和数据处理很难上手,看到许多人将C++和结合起来,Qml负责界面设计,C++实现逻辑处理,但将C++注册到 Qml中一直 ...
- Alpha冲刺5
前言 队名:拖鞋旅游队 组长博客:https://www.cnblogs.com/Sulumer/p/9989898.html 作业博客:https://edu.cnblogs.com/campus/ ...
- GitHub入门与实践 读书笔记一:欢迎来到GitHubde世界
1.什么是GitHub GitHubshi为开发者提供Git仓库的托管服务.除此之外,还为开发者提供能帮助提高代码效率和品质的功能. GitHub和Git的区别? Git是源码仓库而GitHub是在网 ...
- [Java复习] 复习知识点
将线程转换为守护线程可以通过调用Thread对象的setDaemon(true)方法来实现. String 被设计成不可变(immutable)类, 所以它的所有对象都是不可变对象. 要被序列化的实例 ...
- Java通过URL 从web服务端获取数据
1.Java 通过HttpURLConnection Post方式提交json,并从服务端返回json数据 package Demo.Test; import java.io.ByteArrayOut ...
- JAVA将汉字转换为全拼以及返回中文的首字母,将字符串转移为ASCII码
import net.sourceforge.pinyin4j.PinyinHelper;import net.sourceforge.pinyin4j.format.HanyuPinyinCaseT ...
- 下载安装ngnix
在这个网站上进行下载,http://nginx.org/en/download.html,由于我的是windows系统 我下载解压后,打开文件夹里面看到ngix.exe,我去双击它,发现它就是一闪,后 ...
- emmet简单记录
一.引式符号 html:5 or ! . class # id []标签内属性 pycharm不支持 {}标签的内容 pycharm不支持 ()分组标签 pycharm不支持 二.关系符号 1 ...
- 学习笔记TF036:实现Bidirectional LSTM Classifier
双向循环神经网络(Bidirectional Recurrent Neural Networks,Bi-RNN),Schuster.Paliwal,1997年首次提出,和LSTM同年.Bi-RNN,增 ...
- [Java] 例外處裡 try/catch & throws
public class CheckException { public static void main(String[] args) { File file = new File("xx ...