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的更多相关文章

  1. 快速掌握Flyway

    什么是Flyway? Flyway is an open-source database migration tool. It strongly favors simplicity and conve ...

  2. 数据库版本管理工具Flyway(4.0.3)---工作机制(译文)

    How Flyway works The easiest scenario is when you point Flyway to an empty database. 最容易的方案是Flyway指向 ...

  3. 快速掌握和使用Flyway

    什么是Flyway? 转载:https://blog.waterstrong.me/flyway-in-practice/ Flyway is an open-source database migr ...

  4. Concepts-->Migrations

    https://flywaydb.org/documentation/migrations Overview With Flyway all changes to the database are c ...

  5. flywaydb and sql server

    https://flywaydb.org/documentation/database/sqlserver How Flyway works https://flywaydb.org/getstart ...

  6. Flyway Overview and Installation

    https://flywaydb.org/documentation/ Flyway is an open-source database migration tool. It strongly fa ...

  7. springboot web项目创建及自动配置分析(thymeleaf+flyway)

    @ 目录 源码分析 webjars thymeleaf thymeleaf语法 springmvc 启动配置原理 集成flyway插件 springboot 创建web项目只需要引入对应的web-st ...

  8. spring注解源码分析--how does autowired works?

    1. 背景 注解可以减少代码的开发量,spring提供了丰富的注解功能.我们可能会被问到,spring的注解到底是什么触发的呢?今天以spring最常使用的一个注解autowired来跟踪代码,进行d ...

  9. 生产环境中,数据库升级维护的最佳解决方案flyway

    官网:https://flywaydb.org/ 转载:http://casheen.iteye.com/blog/1749916 1.  引言 想到要管理数据库的版本,是在实际产品中遇到问题后想到的 ...

随机推荐

  1. [9]Windows内核情景分析 --- DPC

    DPC不同APC,DPC的全名是'延迟过程调用'. DPC最初作用是设计为中断服务程序的一部分.因为每次触发中断,都会关中断,然后执行中断服务例程.由于关中断了,所以中断服务例程必须短小精悍,不能消耗 ...

  2. JavaScript-----截取字符串的常用方法

       1.substring(start,stop) 用于提取字符串中介于两个指定下标之间的字符 start 必需,一个非负的整数,规定要提取的子串的第一个字符在 stringObject 中的位置 ...

  3. webStorm 2018 激活

    原文地址 https://blog.csdn.net/jiangxinyu50/article/details/79104016 webStorm 2018 激活 今天早上一更新webStorm,之前 ...

  4. 关于Ajax无法下载文件到浏览器本地的问题

    最近在做网站的时候遇到这样一个功能,在如图所示的页面中,需要用户点击链接的时候,能够以异步Ajax的方式判断服务器中是否存储有相应的Excel文件,如果没有的话就提示用户没有找到,如果有的话就下载到用 ...

  5. Shell变量相关

    li@ubuntu:~/test$ vi test.sh li@ubuntu:~/test$ cat test.sh #!/bin/bash #shell变量不加引号;加单引号;加双引号都行 url= ...

  6. Kali linux vim使用命令笔记

    Kali Linux系统的vi编辑器/vim编辑器的使用和CentOS有很多不同.基本使用方法如下 1.vi的基本概念 基本上vi可以分为三种状态,分别是命令模式(command mode).插入模式 ...

  7. 基于STM32F4移植W5500官方驱动库ioLibrary_Driver(转)

    源: 基于STM32F4移植W5500官方驱动库ioLibrary_Driver 参考: 基于STM32+W5500 的Ethernet和Internet移植 Upgrade W5500 Throug ...

  8. Golang匿名函数

    概念所谓匿名函数,就是没有名字的函数匿名函数的两种使用方式一.在定义匿名函数的时候就可以直接使用(这种方式只使用一次) package main import ( "fmt" ) ...

  9. nginx动静态分离以及配置https(安全组强行切换以及导致的问题解决)

    公司原来的网络采用http/https同时支持的方式,http并不会强制自动跳转到https,最近要求强制切换,导致了一系列问题.趁今天测试完成了,整理如下: 1.要求HTTP自动跳转到HTTPS: ...

  10. C#.Net环境下的缓存技术

    转载:https://www.cnblogs.com/lvjy-net/p/8297679.html 一.缓存技术本节将介绍以下技术: 使用Asp.Net缓存: 使用Remoting Singleto ...