How Flyway works
The easiest scenario is when you point Flyway to an empty database.

It will try to locate its schema history table. As the database is empty, Flyway won't find it and will create it instead.
You now have a database with a single empty table called flyway_schema_history by default:

This table will be used to track the state of the database.
Immediately afterwards Flyway will begin scanning the filesystem or the classpath of the application for migrations. They can be written in either Sql or Java.
The migrations are then sorted based on their version number and applied in order:

As each migration gets applied, the schema history table is updated accordingly:
flyway_schema_history
| installed_rank | version | description | type | script | checksum | installed_by | installed_on | execution_time | success |
|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | Initial Setup | SQL | V1__Initial_Setup.sql | 1996767037 | axel | 2016-02-04 22:23:00.0 | 546 | true |
| 2 | 2 | First Changes | SQL | V2__First_Changes.sql | 1279644856 | axel | 2016-02-06 09:18:00.0 | 127 | true |
With the metadata and the initial state in place, we can now talk about migrating to newer versions.
Flyway will once again scan the filesystem or the classpath of the application for migrations. The migrations are checked against the schema history table. If their version number is lower or equal to the one of the version marked as current, they are ignored.
The remaining migrations are the pending migrations: available, but not applied.

They are then sorted by version number and executed in order:

The schema history table is updated accordingly:
flyway_schema_history
| installed_rank | version | description | type | script | checksum | installed_by | installed_on | execution_time | success |
|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | Initial Setup | SQL | V1__Initial_Setup.sql | 1996767037 | axel | 2016-02-04 22:23:00.0 | 546 | true |
| 2 | 2 | First Changes | SQL | V2__First_Changes.sql | 1279644856 | axel | 2016-02-06 09:18:00.0 | 127 | true |
| 3 | 2.1 | Refactoring | JDBC | V2_1__Refactoring | axel | 2016-02-10 17:45:05.4 | 251 | true |
And that's it! Every time the need to evolve the database arises, whether structure (DDL) or reference data (DML), simply create a new migration with a version number higher than the current one. The next time Flyway starts, it will find it and upgrade the database accordingly.
How Flyway works的更多相关文章
- 快速掌握Flyway
什么是Flyway? Flyway is an open-source database migration tool. It strongly favors simplicity and conve ...
- 数据库版本管理工具Flyway(4.0.3)---工作机制(译文)
How Flyway works The easiest scenario is when you point Flyway to an empty database. 最容易的方案是Flyway指向 ...
- 快速掌握和使用Flyway
什么是Flyway? 转载:https://blog.waterstrong.me/flyway-in-practice/ Flyway is an open-source database migr ...
- Concepts-->Migrations
https://flywaydb.org/documentation/migrations Overview With Flyway all changes to the database are c ...
- flywaydb and sql server
https://flywaydb.org/documentation/database/sqlserver How Flyway works https://flywaydb.org/getstart ...
- Flyway Overview and Installation
https://flywaydb.org/documentation/ Flyway is an open-source database migration tool. It strongly fa ...
- springboot web项目创建及自动配置分析(thymeleaf+flyway)
@ 目录 源码分析 webjars thymeleaf thymeleaf语法 springmvc 启动配置原理 集成flyway插件 springboot 创建web项目只需要引入对应的web-st ...
- spring注解源码分析--how does autowired works?
1. 背景 注解可以减少代码的开发量,spring提供了丰富的注解功能.我们可能会被问到,spring的注解到底是什么触发的呢?今天以spring最常使用的一个注解autowired来跟踪代码,进行d ...
- 生产环境中,数据库升级维护的最佳解决方案flyway
官网:https://flywaydb.org/ 转载:http://casheen.iteye.com/blog/1749916 1. 引言 想到要管理数据库的版本,是在实际产品中遇到问题后想到的 ...
随机推荐
- html5-css的引入
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8&qu ...
- Toolkit tool 获取屏幕、显示在屏幕中心
2018-11-11 15:30:05开始写 Toolkit tool = Toolkit.getDefaultToolkit(); Dimension d = tool.getScreenSize ...
- jQuery筛选--find(expr|obj|ele)和siblings([expr])
find(expr|obj|ele) 概述 搜索所有与指定表达式匹配的元素.这个函数是找出正在处理的元素的后代元素的好方法 参数 expr 用于查找的表达式 jQuery object 一个用于 ...
- Block 循环引用(中)
不会造成循环引用的block 大部分GCD方法 dispatch_async(dispatch_get_main_queue(), ^{ [self doSomething]; }); 因为self并 ...
- OpenCV学习笔记(一) - 边界填充、Rect函数
边界填充: c++实现,测试在mac pro里,输入720p时间0.4ms: cv::copyMakeBorder(image, dst, , , , , cv::BORDER_REPLICATE); ...
- java.security.NoSuchAlgorithmException: AES KeyGenerator not available
异常信息 Caused by: Java.lang.IllegalStateException: Unable to acquire AES algorithm. This is required t ...
- python 某个目录下的所有文件列表
使用os.listdir() 函数来获取某个目录中的文件列表 import os names = os.listdir('somedir') 结果会返回目录中所有文件列表,包括所有文件,子目录,符号链 ...
- Redis 的 5 个常见应用场景
前言Redis 是一个强大的内存型存储,具有丰富的数据结构,使其可以应用于很多方面,包括作为数据库.缓存.消息队列等等. 如果你的印象中Redis只是一个 key-value 存储,那就错过了Redi ...
- 20165215 学习基础和c语言基础调查
学习基础和c语言基础调查 <做中学>读后感与技能学习心得 读后感 Don't watch the clock. Do what it does. Keep going. 不要只看时钟,要效 ...
- 谷歌重磅开源强化学习框架Dopamine吊打OpenAI
谷歌重磅开源强化学习框架Dopamine吊打OpenAI 近日OpenAI在Dota 2上的表现,让强化学习又火了一把,但是 OpenAI 的强化学习训练环境 OpenAI Gym 却屡遭抱怨,比如不 ...