当前位置: 首页 > news >正文

195. Spring Boot 2.0数据库迁移:Flyway

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 和JPAhttp://t.cn/R1pSojf

 历史相关章节:

193. Spring Boot 数据库迁移:概述

194. Spring Boot 数据库迁移:Flyway

 

 

说明:

(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或者扫描以下二维码即可关注:

posted on 2018-07-28 17:36 悟纤 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/springboot-wuqian/p/9382749.html

相关文章:

  • opencv python Meanshift 和 Camshift
  • Scala基础
  • mysql进阶(七)数据库锁
  • caffe问题
  • HDU 6330--Visual Cube(构造,计算)
  • mysql 数据库修改名字
  • 设计模式-简单工厂、工厂方法模式、抽象工厂模式详解
  • 9种数据分析方法
  • 人群估值一般性算法
  • oracle获取过去两年的今天时间
  • SOFATracer 中 Disruptor 实践
  • C#抽象类与接口的区别【转】
  • 区块链时代的拜占庭容错:Tendermint(一)
  • 一致性算法Hash(Consistent Hashing)
  • Java 多线程
  • 「前端早读君006」移动开发必备:那些玩转H5的小技巧
  • crontab执行失败的多种原因
  • CSS 提示工具(Tooltip)
  • django开发-定时任务的使用
  • docker-consul
  • interface和setter,getter
  • Java 11 发布计划来了,已确定 3个 新特性!!
  • js正则,这点儿就够用了
  • leetcode46 Permutation 排列组合
  • maven工程打包jar以及java jar命令的classpath使用
  • Spring Boot快速入门(一):Hello Spring Boot
  • v-if和v-for连用出现的问题
  • 动态魔术使用DBMS_SQL
  • 分享一份非常强势的Android面试题
  • 如何实现 font-size 的响应式
  • 学习笔记TF060:图像语音结合,看图说话
  • 一道面试题引发的“血案”
  • 一文看透浏览器架构
  • 大数据全解:定义、价值及挑战
  • $(document).ready(function(){}), $().ready(function(){})和$(function(){})三者区别
  • (2/2) 为了理解 UWP 的启动流程,我从零开始创建了一个 UWP 程序
  • (Redis使用系列) SpringBoot 中对应2.0.x版本的Redis配置 一
  • (windows2012共享文件夹和防火墙设置
  • (附源码)计算机毕业设计SSM基于java的云顶博客系统
  • (七)理解angular中的module和injector,即依赖注入
  • (全部习题答案)研究生英语读写教程基础级教师用书PDF|| 研究生英语读写教程提高级教师用书PDF
  • (四)【Jmeter】 JMeter的界面布局与组件概述
  • (四)图像的%2线性拉伸
  • (已更新)关于Visual Studio 2019安装时VS installer无法下载文件,进度条为0,显示网络有问题的解决办法
  • .NET Core 2.1路线图
  • .net core 6 redis操作类
  • .NET Core SkiaSharp 替代 System.Drawing.Common 的一些用法
  • .net core 微服务_.NET Core 3.0中用 Code-First 方式创建 gRPC 服务与客户端
  • .NET Framework与.NET Framework SDK有什么不同?
  • .net打印*三角形
  • /bin/bash^M: bad interpreter: No such file ordirectory
  • [100天算法】-目标和(day 79)
  • [Android] Upload package to device fails #2720
  • [BZOJ1060][ZJOI2007]时态同步 树形dp
  • [Codeforces] combinatorics (R1600) Part.2