Flyway Overview and Installation
https://flywaydb.org/documentation/
Flyway is an open-source database migration tool. It strongly favors simplicity and convention over configuration.
It is based around just 7 basic commands: Migrate, Clean, Info, Validate, Undo, Baseline and Repair.
Migrations can be written in SQL (database-specific syntax (such as PL/SQL, T-SQL, ...) is supported) or Java (for advanced data transformations or dealing with LOBs).
It has a Command-line client. If you are on the JVM, we recommend using the Java API (also works on Android) for migrating the database on application startup. Alternatively, you can also use the Maven plugin or Gradle plugin.
And if that not enough, there are plugins available for Spring Boot, Dropwizard, Grails, Play, SBT, Ant, Griffon, Grunt, Ninja and more!
Supported databases are Oracle, SQL Server (including Amazon RDS and Azure SQL Database, DB2, MySQL (including Amazon RDS, Azure Database & Google Cloud SQL), Aurora MySQL, MariaDB, Percona XtraDB Cluster, PostgreSQL (including Amazon RDS, Azure Database, Google Cloud SQL & Heroku), Aurora PostgreSQL, Redshift, CockroachDB, SAP HANA, Sybase ASE, Informix, H2, HSQLDB, Derby and SQLite.
https://flywaydb.org/documentation/commandline/#download-and-installation
类似于Powershell的发布,Flyway也提供了stable和preview两种版本
Command-line tool
The Flyway command-line tool is a standalone Flyway distribution. It runs on Windows, macOS and Linux and it is primarily meant for users who wish to migrate their database from the command-line without having to integrate Flyway into their applications nor having to install a build tool.
Download and installation
Select the platform that you need.
Each download contains all editions (community, pro, enterprise) of Flyway.

Directory structure
The Flyway download, once extracted, now becomes a directory with the following structure:
flyway-5.2.4
conf
flyway.conf configuration file
drivers JDBC drivers
jars Java-based migrations (as jars)
jre
lib
licenses
sql SQL migrations
flyway macOS/Linux executable
flyway.cmd Windows executable
Usage
> flyway [options] command
Flyway editions
The Flyway Command-line tool distribution ships with all editions of Flyway.
It defaults to Flyway Community Edition.
It can however easily be configured to run the Flyway Pro or Enterprise Edition instead.
Environment variable
One way to switch between the various Flyway editions is to set the FLYWAY_EDITION environment variable prior to executing Flyway to any of the following values:
community |
Select the Flyway Community Edition (default) |
pro |
Select the Flyway Pro Edition |
enterprise |
Select the Flyway Enterprise Edition |
Edition-selecting flags
Alternatively Flyway also comes with edition-selecting flags.
By default the flyway command will launch whatever edition has been selected with the FLYWAY_EDITION environment variable (defaulting to community).
You can however also use edition-selecting flags to force the selection of the edition of your choice and avoid the need to set any environment variable at all:
-community |
Select the Flyway Community Edition |
-pro |
Select the Flyway Pro Edition |
-enterprise |
Select the Flyway Enterprise Edition |
Commands
| Name | Description |
|---|---|
| migrate | Migrates the database |
| clean | Drops all objects in the configured schemas |
| info | Prints the details and status information about all the migrations |
| validate | Validates the applied migrations against the ones available on the classpath |
| baseline | Baselines an existing database, excluding all migrations up to and including baselineVersion |
| repair | Repairs the schema history table |
JDBC drivers
In order to connect with your database, Flyway needs the appropriate JDBC driver to be available in its drivers directory.
Flyway ships with JDBC drivers for the following databases by default:
- Aurora MySQL
- Aurora PostgreSQL
- CockroachDB
- Derby
- H2
- HSQLDB
- MariaDB
- MySQL
- Percona XtraDB
- PostgreSQL
- SQLite
- SQL Server
- Sybase ASE
If your database is not listed here, you need to download its JDBC driver and place it in the drivers directory yourself.
Instructions on where to download the drivers from are provided on the respective documentation pages for each database.
Configuration
The Flyway Command-line tool can be configured in a wide variety of ways.
You can use config files, environment variables and command-line parameters.
These different means of configuration can be combined at will.
Config files
Config files are supported by the Flyway command-line tool.
If you are not familiar with them, check out the Flyway config file structure and settings reference first.
Flyway will search for and automatically load the following config files if present:
<install-dir>/conf/flyway.conf<user-home>/flyway.conf<current-dir>/flyway.conf
It is also possible to point Flyway at one or more additional config files.
This is achieved by supplying the command line parameter -configFiles= as follows:
flyway -configFiles=path/to/myAlternativeConfig.conf migrate
To pass in multiple files, separate their names with commas:
flyway -configFiles=path/to/myAlternativeConfig.conf,other.conf migrate
Relative paths are relative to the current working directory.
Alternatively you can also use the FLYWAY_CONFIG_FILES environment variable for this. When set it will take preference over the command-line parameter.
> export FLYWAY_CONFIG_FILES=path/to/myAlternativeConfig.conf,other.conf
> flyway migrate
By default Flyway loads configuration files using UTF-8. To use an alternative encoding, use the command line parameter -configFileEncoding= as follows:
> flyway -configFileEncoding=ISO-8859-1 migrate
Alternatively you can also use the FLYWAY_CONFIG_FILE_ENCODING environment variable for this. When set it will take preference over the command-line parameter.
> export FLYWAY_CONFIG_FILE_ENCODING=ISO-8859-1
Environment Variables
To make it easier to work with cloud and containerized environments, Flyway also supports configuration via environment variables.
Check out the Flyway environment variable reference for details.
Command-line Arguments
Finally, Flyway can also be configured by passing arguments directly from the command-line:
> flyway -user=myuser -schemas=schema1,schema2 -placeholders.keyABC=valueXYZ migrate
Overriding order
The Flyway command-line tool has been carefully designed to load and override configuration in a sensible order.
Settings are loaded in the following order (higher items in the list take precedence over lower ones):
- Command-line arguments
- Environment variables
- Custom config files
<current-dir>/flyway.conf<user-home>/flyway.conf<install-dir>/conf/flyway.conf- Flyway command-line defaults
The means that if for example flyway.url is both present in a config file and passed as -url= from the command-line, the command-line argument will take precedence and be used.
Credentials
If you do not supply a database user or password via any of the means above, you will be prompted to enter them:
Database user: myuser
Database password:
If you want Flyway to connect to your database without a user or password, you can suppress prompting by adding the -n flag.
Java Arguments
If you need to to pass custom arguments to Flyway’s JVM, you can do so by setting the JAVA_ARGS environment variable.
They will then automatically be taken into account when launching Flyway.
This is particularly useful when needing to set JVM system properties.
Output
All debug, info and warning output is sent to stdout. All errors are sent to stderr.
Debug output
Add -X to the argument list to also print debug output.
Quiet mode
Add -q to the argument list to suppress all output, except for errors and warnings.
Flyway Overview and Installation的更多相关文章
- Spring Boot Reference Guide
Spring Boot Reference Guide Authors Phillip Webb, Dave Syer, Josh Long, Stéphane Nicoll, Rob Winch, ...
- Docker on CentOS for beginners
Introduction The article will introduce Docker on CentOS. Key concepts Docker Docker is the world's ...
- leptonica 学习笔记1
Updated: April 26, 2015 Leptonica is a pedagogically-oriented open source site containing software t ...
- Guzzle php resetful webservice farmework
Guzzle is a PHP HTTP client that makes it easy to work with HTTP/1.1 and takes the pain out of consu ...
- phantompy — phantompy 0.10 documentation
phantompy - phantompy 0.10 documentation phantompy¶ Release v0.10. phantompy is a BSD Li ...
- ROS常用三維機器人仿真工具Gazebo教程匯總
參考網址: 1. http://gazebosim.org/tutorials 2. http://gazebosim.org/tutorials/browse Gazebo Tutorials Ga ...
- Troubleshooting Autoinvoice Import
metalink :1089172.1 In this Document Purpose Troubleshooting Steps AutoInvoice Execution Repor ...
- mcelog用法详解
手动启动mcelog方法: # mcelog --daemon Run mcelog in daemon mode, waiting for errors from the kernel. 后台服务启 ...
- ZipArchive扩展的使用和Guzzle依赖的安装使用
在项目开发的过程中,需要去远程下载录音文件 然后保存到自己的项目中,然后再把录音文件压缩打包,最后再下载给用户 1.Guzzle依赖的安装 guzzle官方文档:http://guzzle-cn.re ...
随机推荐
- python base64加密文本内容(2)
上面一篇简单进行了base64加密 但安全系数非常低,只需要用网上的在线base64解码就能破解 这里我们可以自己修改一下base64加密后的字符串,在解码的时候只需要先提前将修改的内容还原就可以了 ...
- Rpgmakermv(31)MOG插件与YEP的结合
问题简述: 因为我在开发时使用了gamequestsystem(任务插件),所以必须使用YEP_mainmenumanager; 此时,我又想加个MOG_Picture插件(图片收集插件): 当他们在 ...
- 城市里的间谍B901
城市里的间谍 城市里的间谍 难度级别:C: 运行时间限制:1000ms: 运行空间限制:51200KB: 代码长度限制:2000000B 试题描述 某城市的地铁是线性的,有 n(2 <= n ...
- 使用IntelljIDEA生成接口的类继承图及装饰器模式
类图生成方法 以一个装饰器模式实现数学运算的例子为例. 安装 Intellj Ultimate , lience server: http://xdouble.cn:8888/ 在类上右键点击 cla ...
- document.createDocumentFragment 以及创建节点速度比较
document.createDocumentFragment document.createDocumentFragment()方法创建一个新空白的DocumentFragment对象. Docum ...
- nfs共享文件搭建
Linux NFS服务器的安装与配置详解 一.NFS服务简介 NFS是Network File System(网络文件系统).主要功能是通过网络让不同的服务器之间可以共享文件或者目录.NFS客户端 ...
- Python进阶【第二篇】编写Python代码
一.第一句Python代码——Hello Word 在 /home/dev/ 目录下创建 hello.py 文件,内容如下: print "hello,world" 执行 hell ...
- 在Eclipse中创建Dynamic Web Project具有和MyEclipse中Web Project一样的目录结构
1.在Eclipse中新建Dynamic Web Project 1.1.修改default output folder build\classes修改为:WebRoot\WEB-INF\classe ...
- \r\n回车换行\r回车\n换行的区别
在计算机还没有出现之前,有一种叫做电传打字机(Teletype Model 33,Linux/Unix下的tty概念也来自于此)的玩意,每秒钟可以打10个字符.但是它有一个问题,就是打完一行换行的时候 ...
- linux下启动多个php,分别监听不同的端口。
在工作中,我们可能会遇到,服务器集群的搭建. 这个时候,我们不可能,每一台服务器都是lnmp的环境,我们会把nmp分别放在不同的服务器上,不同的服务器负责不同的功能.比如我们下面要说的php 加入ng ...