First Steps: Command-line
This brief tutorial will teach how to get up and running with the Flyway Command-line tool. It will take you through the steps on how to configure it and how to write and execute your first few database migrations.
This tutorial should take you about 5 minutes to complete.
Downloading and extracting Flyway
Start by downloading the Flyway Command-line Tool for your platform and extract it.
Let’s jump into our new directory:
cd flyway-5.2.4
Configuring Flyway
Once that is done, configure Flyway by editing /conf/flyway.conf
like this:
flyway.url=jdbc:h2:file:./foobardb
flyway.user=SA
flyway.password=
Creating the first migration
Now create a first migration in the /sql
directory called V1__Create_person_table.sql
:
create table PERSON (
ID int not null,
NAME varchar(100) not null
);
Migrating the database
It’s now time to execute Flyway to migrate your database:
flyway-5.2.4> flyway migrate
If all went well, you should see the following output:
Database: jdbc:h2:file:./foobardb (H2 1.4)
Successfully validated 1 migration (execution time 00:00.008s)
Creating Schema History table: "PUBLIC"."flyway_schema_history"
Current version of schema "PUBLIC": << Empty Schema >>
Migrating schema "PUBLIC" to version 1 - Create person table
Successfully applied 1 migration to schema "PUBLIC" (execution time 00:00.033s)
Adding a second migration
If you now add a second migration to the /sql
directory called V2__Add_people.sql
:
insert into PERSON (ID, NAME) values (1, 'Axel');
insert into PERSON (ID, NAME) values (2, 'Mr. Foo');
insert into PERSON (ID, NAME) values (3, 'Ms. Bar');
and execute it by issuing:
flyway-5.2.4> flyway migrate
You now get:
Database: jdbc:h2:file:./foobardb (H2 1.4)
Successfully validated 2 migrations (execution time 00:00.018s)
Current version of schema "PUBLIC": 1
Migrating schema "PUBLIC" to version 2 - Add people
Successfully applied 1 migration to schema "PUBLIC" (execution time 00:00.016s)
Summary
In this brief tutorial we saw how to:
- install the Flyway Command-line tool
- configure it so it can talk to our database
- write our first couple of migrations
These migrations were then successfully found and executed.
First Steps: Command-line的更多相关文章
- How to build .apk file from command line(转)
How to build .apk file from command line Created on Wednesday, 29 June 2011 14:32 If you don’t want ...
- Building Xcode iOS projects and creating *.ipa file from the command line
For our development process of iOS applications, we are using Jenkins set up on the Mac Mini Server, ...
- [笔记]The Linux command line
Notes on The Linux Command Line (by W. E. Shotts Jr.) edited by Gopher 感觉博客园是不是搞了什么CSS在里头--在博客园显示效果挺 ...
- 命令行command line 使用 http proxy的设置方法 Setting Up HTTP Proxy in Terminal
Step 1: Install Shadowsocks Client Shadowsocks is an open-source proxy project to help people visit ...
- Can't use Subversion command line client: svn Probably the path to Subversion executable is wrong. Fix it.
1.最近使用SVN工具时,Checkout出项目到本地后后,然后将其导入到Intellij idea中开发,在提交svn代码的时候,出现这样的错误:Can't use Subversion comma ...
- How to Use Android ADB Command Line Tool
Android Debug Bridge (adb) is a tool that lets you manage the state of an emulator instance or Andro ...
- Chrome-Console( Command Line API Reference)
来源于:https://developers.google.com/web/tools/chrome-devtools/console/command-line-reference The Comma ...
- logoff remote desktop sessions via command line tools
This trick I learned from my one of ex-college. In Windows servers, only two remote desktop session ...
- 使用intellij的svn时提示出错: Can't use Subversion command line client: svn.Errors found while svn working copies detection.
使用Intellij的svn时提示出错:Can't use Subversion command line client: svn. Errors found while svn working co ...
- ubuntu16.04安装virtualbox5.1失败 gcc:error:unrecognized command line option ‘-fstack-protector-strong’
系统:ubuntu16.04.1 软件:Virtualbox-5.1 编译器:GCC 4.7.4 在如上环境下安装Vbx5.1提示我在终端执行/sbin/vboxconfig命令 照做 出现如下err ...
随机推荐
- [ English ] Ping sb.
What does "Ping Me" mean? Recently, when I asked a colleague to ping me, he responded wi ...
- ModuleNotFoundError: No module named '_pydevd_bundle.pydevd_cython' error on debug
现象:pycharm调试代码出现错误:ModuleNotFoundError: No module named '_pydevd_bundle.pydevd_cython' error on debu ...
- Vue系列之 => 组件中的data和methods
使用data <!DOCTYPE html> <html lang="en"> <head> <meta charset="UT ...
- Real Time Credit Card Fraud Detection with Apache Spark and Event Streaming
https://mapr.com/blog/real-time-credit-card-fraud-detection-apache-spark-and-event-streaming/ Editor ...
- Fantasia (点强连通分量建图 + 树形DP)
简化一下题意,我们先看成一副强连通的图,这时候应该是最简单了,去点任意点都是其他的乘积.那再加强一点难度,改为两个强连通图连接的非强连通图呢?那应该就是找出关键的那个点,并求出两边的乘积.但是一个一个 ...
- uvalive 3276 The Great Wall Game
题意: 一个n * n的棋盘上放着n个棋子,现在要求把这n个棋子用最少的步数移到同一条直线上,即同一列同一行或者同一对角线(两条).输出最少的步数(只能往四个方向移动,即正东,正西,正南,正北). 思 ...
- 20155228 2016-2017-2 《Java程序设计》第3周学习总结
20155228 2016-2017-2 <Java程序设计>第3周学习总结 教材学习内容总结 认识对象 类与对象 类和对象的关系:类是对象的设计图,对象是类的实例 参考:将"名 ...
- 20165305 实验四:Android程序设计
实验内容 基于Android Studio开发简单的Android应用并部署测试; 了解Android.组件.布局管理器的使用: 掌握Android中事件处理机制. Android Studio安装 ...
- 20165215 2017-2018-2 《Java程序设计》第5周学习总结
20165215 2017-2018-2 <Java程序设计>第5周学习总结 教材学习内容总结 chapter7 Java支持在一个类中声明另外一个类,这样的类称作内部类,而包含内部类的类 ...
- elsearch
1. ElasticSearch是性能优化的分布式全文搜索引擎,存储数据的载体是文档(Document),它的优势在于搜索速度快和支持聚合操作,在更新文档时,基本上能够达到实时搜索.ElasticSe ...