Flyway for DB
1. Command Tool
1.1 Command Tool with H2 DB demo
Find and download the flyway-commandline-2.3.zip, unzip and put it in the working directory.
>cd /opt/flyway
>cd jars
>wget http://repo1.maven.org/maven2/com/h2database/h2/1.3.170/h2-1.3.170.jar
Just download the driver and place them in the jars directory
Just use H2 for demo, set up the configuration file like this
>vi conf/flyway.properties
flyway.url=jdbc:h2:file:./foobardb
flyway.user=SA
Put the first SQL migration under sql
>vi sql/V1__Create_person_table.sql
create table PERSON ( ID int not null, NAME varchar(100) not null );
The first letter should be V, can not be v.
>./flyway migrate
/opt/local/bin/tput Flyway (Command-line Tool) v.2.3 Current version of schema "PUBLIC": << Empty Schema >> Migrating schema "PUBLIC" to version 1 Successfully applied 1 migration to schema "PUBLIC" (execution time 00:00.104s).
Adding a second migration
sparkworker1:flyway carl$ cat sql/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');
1.2 Let us play with MySql
Download the jar from the official website
>wget http://cdn.mysql.com/Downloads/Connector-J/mysql-connector-java-5.1.29.tar.gz
Find and place the jar mysql-connector-java-5.1.29-bin.jar under the jars directory.
Edit the configuration file
>vi conf/flyway.properties
flyway.url=jdbc:mysql://localhost:3306/test
flyway.user=root
flyway.password=
>flyway migrate
There are a lot of other command parameters I can use. For example, clean, migrate, validate, info, repair
2. Flyway DB for SBT
First of all, if I want to use flyway plugin, I need to update my sbt version to 1.13.0 to support the latest version.
Check this file
>cat project/build.properties sbt.version=0.13.0
And update the version of my other plugins to support the sbt 0.13
>cat project/plugins.sbt addSbtPlugin("com.googlecode.flyway" % "flyway-sbt" % "2.3") resolvers += "Flyway" at "http://flywaydb.org/repo" addSbtPlugin("io.spray" % "sbt-revolver" % "0.7.1") addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.10.2") addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.3.0") addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.2.0") resolvers += "Sonatype snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/" addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.5.0-SNAPSHOT")
Check the build.sbt to make sure the flyway configuration
import com.googlecode.flyway.sbt.FlywayPlugin._
//flyway start
seq(flywaySettings: _*)
flywayUrl := "jdbc:h2:~/demo_test;DB_CLOSE_DELAY=-1"
flywayUser := "sa"
flywayPassword := "password"
//flyway end
And place the migration files in the directory like these>
src/main/resources/db/migration/V1__Create_person_table.sql
src/main/resources/db/migration/V2__Add_people.sql
create table PERSON (
ID int not null,
NAME varchar(100) not null
);
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');
Run the command to migrate the DB
>sbt flywayMigrate
There are also other commands flywayClean, flywayInit, flywayMigrate, flywayValidate, flywayInfo, flywayRepair
References:
http://flywaydb.org/getstarted/firststeps/commandline.html
http://flywaydb.org/getstarted/firststeps/sbt.html
http://flywaydb.org/documentation/sbt/
- 浏览: 2543128 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
发表评论
-
Update Site will come soon
2021-06-02 04:10 1672I am still keep notes my tech n ... -
Hadoop Docker 2019 Version 3.2.1
2019-12-10 07:39 289Hadoop Docker 2019 Version 3.2. ... -
Nginx and Proxy 2019(1)Nginx Enable Lua and Parse JSON
2019-12-03 04:17 441Nginx and Proxy 2019(1)Nginx En ... -
Data Solution 2019(13)Docker Zeppelin Notebook and Memory Configuration
2019-11-09 07:15 284Data Solution 2019(13)Docker Ze ... -
Data Solution 2019(10)Spark Cluster Solution with Zeppelin
2019-10-29 08:37 245Data Solution 2019(10)Spark Clu ... -
AMAZON Kinesis Firehose 2019(1)Firehose Buffer to S3
2019-10-01 10:15 315AMAZON Kinesis Firehose 2019(1) ... -
Rancher and k8s 2019(3)Clean Installation on CentOS7
2019-09-19 23:25 308Rancher and k8s 2019(3)Clean In ... -
Pacemaker 2019(1)Introduction and Installation on CentOS7
2019-09-11 05:48 336Pacemaker 2019(1)Introduction a ... -
Crontab-UI installation and Introduction
2019-08-30 05:54 447Crontab-UI installation and Int ... -
Spiderkeeper 2019(1)Installation and Introduction
2019-08-29 06:49 495Spiderkeeper 2019(1)Installatio ... -
Supervisor 2019(2)Ubuntu and Multiple Services
2019-08-19 10:53 366Supervisor 2019(2)Ubuntu and Mu ... -
Supervisor 2019(1)CentOS 7
2019-08-19 09:33 325Supervisor 2019(1)CentOS 7 Ins ... -
Redis Cluster 2019(3)Redis Cluster on CentOS
2019-08-17 04:07 367Redis Cluster 2019(3)Redis Clus ... -
MySQL HA Solution 2019(4)MaxScale
2019-08-03 21:19 788MySQL HA Solution 2019(4)MaxSca ... -
Amazon Lambda and Version Limit
2019-08-02 01:42 433Amazon Lambda and Version Limit ... -
MySQL HA Solution 2019(3)MyCat
2019-07-30 11:45 369MySQL HA Solution 2019(3)MyCat ... -
MySQL HA Solution 2019(2)ProxySQL
2019-07-29 09:39 485MySQL HA Solution 2019(2)ProxyS ... -
MySQL HA Solution 2019(1)Master Slave on MySQL 5.7
2019-07-27 22:26 516MySQL HA Solution 2019(1)Master ... -
RabbitMQ Cluster 2019(2)Cluster HA and Proxy
2019-07-11 12:41 456RabbitMQ Cluster 2019(2)Cluster ... -
Zeppelin and Spark Library Dependency
2019-07-09 03:20 457Zeppelin and Spark Library Depe ...
相关推荐
这里,`locations`属性指定了存放SQL脚本的目录,通常在`src/main/resources/db/migration`下,文件命名遵循Flyway的约定,如`V1__Initial_schema.sql`,其中`V1`表示版本号,`__`后是描述。 集成完成后,启动...
SpringBoot整合Flyway实现数据库版本控制 在软件开发中,数据库的版本控制是非常重要的一步骤。Flyway是一个流行的数据库版本控制工具,它可以与SpringBoot框架集成,以实现自动化的数据库版本控制。在本文中,我们...
Flyway是一款强大的数据库版本管理工具,它以Java为基础,旨在帮助开发者和运维人员有效地管理和维护数据库的演变。在软件开发过程中,随着项目的发展,数据库结构也会随之改变,这些变化需要被系统地记录和管理,...
【Flyway:数据库版本管理利器】 Flyway是一款强大的开源数据库版本管理工具,它使得数据库的迁移变得简单且有序。在“flyway简单测试工程”中,我们可以通过实践来理解其核心概念和工作流程,这对于数据库的开发...
spring.flyway.locations=classpath:/db/migration ``` 一旦配置完成,SpringBoot启动时,Flyway会自动检测并执行未运行的SQL脚本,从而更新数据库。在这个例子中,`by_testLog`可能是一个日志相关的数据库表或者...
* 增加sql脚本:在resource下的db/migration文件夹中增加sql脚本文件 使用Flyway需要注意以下几点: * 开发人员必须要确保代码和数据库版本相统一 * 需要同步提交新代码和相应的sql脚本 * 对数据库表的变更要通过...
kingbase 数据库 flyway 插件,导入此jar在依赖 flyway-8.5.13.jar 版本即可,人大金仓 数据库 国产数据库
2. **指定迁移脚本位置**:Flyway默认查找`src/main/resources/db/migration`目录下的脚本,但可以自定义这个路径。 3. **其他配置**:例如,是否自动迁移、是否忽略未知迁移、错误处理策略等。 ### 使用...
### Flyway数据库版本管理 #### 一、Flyway介绍 Flyway是一款强大的开源数据库版本管理工具,它采用了“规约优于配置”的设计理念。这一理念强调的是通过预设的行为模式简化配置,减少错误的可能性,使开发者能够...
spring.flyway.locations=classpath:/db/migration ``` `locations`属性指定了存放迁移脚本的目录。 **2.3 自动迁移** SpringBoot启动时,Flyway会自动执行所有未应用的迁移。你可以通过设置`spring.flyway....
Flyway 是一个开源的数据库版本控制工具,专为管理数据库迁移而设计。它允许开发者以结构化和自动化的方式处理数据库的版本升级和降级,从而确保数据库与应用程序代码的同步。在本例中,我们讨论的是Flyway 5.1.1 的...
Flyway是一款开源的数据库版本控制工具,用于管理数据库版本,帮助开发者进行数据库迁移。在数据库应用开发中,随着项目的迭代,数据库结构的变化是不可避免的,Flyway提供了一种规范化的、自动化的方式来跟踪、管理...
基于flyway的6.5.7版本修改flway-core ,支持国产数据库,暂时处于自测阶段,使用连接kingbase进行管理正常。
1、解压flyway-commandline-6.4.2-linux-x64.tar.gz或flyway-commandline-6.4.2-windows-x64.zip包; 2、把path目录里的lib目录拷贝到解压目录里进行覆盖; 覆盖lib/community/flyway-core-6.4.2.jar包是去除不...
Flyway 是一款开源的数据库版本管理工具,它更倾向于规约优于配置的方式。Flyway 可以独立于应用实现管理并跟踪数据库变更,支持数据库版本自动升级,并且有一套默认的规约,不需要复杂的配置,Migrations 可以写成 ...
用法跑步: docker run --rm -v /path/to/your/migrations:/sql -e FLYWAY_CMD=migrate -e DB_USER=postgres -e DB_PASSWORD=postgres -e DB_URL=jdbc:postgresql://db_host/db_name iterators/flyway-docker -e DB_...
Flyway 是一款开源的数据库版本管理工具,它更倾向于规约优于配置的方式。Flyway 可以独立于应用实现管理并跟踪数据库变更,支持数据库版本自动升级,并且有一套默认的规约,不需要复杂的配置,Migrations 可以写成 ...
flyway-maven-plugin flyway maven plugin 是基于flyway的的数据库脚本升级插件 使用方式 1. 在resources下创建application.propeties,存放数据库相关配置 #default表示数据源的名字 db.default.url=jdbc:mysql://...
springboot集成flyway实现数据库版本自动升级及冲突问题解决,灵活实现升级语句的自主执行
在Maven或Gradle的配置文件中添加相应的依赖项,然后在项目的资源目录下创建一个特定的目录(通常是`db/migration`),用于存放各个版本的DDL脚本。每个脚本的文件名应遵循Flyway的命名规则,例如`V1__Initial_...