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 ...
随机推荐
- 11.match
(我对部分段落进行翻译) A match statement is used to branch execution of a program. It’s the equivalent of the ...
- sql2008升级到r2提示:检查当前是否正确配置了报表服务器、数据库服务器是否正在运行以及您是否有权访问
sql2008升级到r2提示:检查当前是否正确配置了报表服务器.数据库服务器是否正在运行以及您是否有权访问 解决方法:把服务开启ok
- asp.net web form 的缺点
与mvc相比,web form 的缺点: 代码架构麻烦. 以页面或控件为单位,把逻辑放在了一起,代码架构简单.平铺直叙,修改.维护比较麻烦. 不方便单元测试. 功能堆加在了一起,不方便对单个的功能进 ...
- redis和mongodb的比较
>>RedisRedis的优点:支持多种数据结构,如 string(字符串). list(双向链表).dict(hash表).set(集合).zset(排序set).hyperloglog ...
- python实现堆栈和队列
利用python列表实现堆栈和队列 堆栈: 堆栈是一个后进先出的数据结构,其工作方式就像生活中常见到的直梯,先进去的人肯定是最后出. 我们可以设置一个类,用列表来存放栈中的元素的信息,利用列表的app ...
- restful的特点
1. 资源(Resources) REST的名称”表现层状态转化”中,省略了主语.”表现层”其实指的是”资源”(Resources)的”表现层”. 所谓”资源”,就是网络 ...
- jquery遍历获取每一行数据进行对比
$("#dtlTable tr:gt(0)").each(function(i){ var orderQtyBy = $("input[name='orderQtyBys ...
- Java学习技术分享:Java中的原子操作
学习java需要有一套完整的学习线路,需要有条理性,当下学习java已经有一段时间了,由当初的懵逼状态逐渐好转,也逐渐养成了写技术学习笔记的习惯,今天总结了一下java中的原子操作. 1.Java中的 ...
- easyui dialog 和 dategrid相关设置与应用
1 dialog一些参数 可以进行文件上传等操作closed:true:定义初始状态为关闭:modal:true:对话框被打开时,会有一个modal-mask,使得对话框底部的内容被一个层覆盖,不 ...
- MySQL日志详细说明
这片博文我们会详细说明MySQL本身的日志,不包含重做日志和undo日志(这两个日志是innodb存储引擎的日志). MySQL本身的日志有以下几种(MySQL5.7版本): 错误日志 慢查询日志 通 ...