数据库的Schema发生改变时是多么痛苦的事情

整天跟数据库打交道的程序员都知道,当数据库的Schema发生改变时是多么痛苦的事情。尤其是一个在不断开发完善的项目,随着需求变化,数据库的schema也会跟着变化,而追踪记录这些变化一向都是费时费力。如果你拥有多个测试环境,那么保证这些环境下的数据库的一致性的难度会成倍增加。

Flyway,一款小工具,应用它能够大大简化这方面的工作。

它的优点:

  1. convention over configuration,配置简单,使用方便;支持Sql及Java配置;
  2. 支持当前几乎所有的主流数据库;
  3. 拥有命令行工具、Maven、Gradle插件….应用场景广泛。

使用它之前先要了解一些概念:

  • 版本:对数据库的每一次变更可称为一个版本。
  • 迁移:Flyway把数据库结构从一个版本更新到另一个版本叫做迁移。
  • 可用的迁移:Flyway的文件系统识别出来的迁移版本。
  • 已经应用的迁移:Flyway已经对数据库执行过的迁移。

http://www.italki.com/user/2299987
http://www.italki.com/user/2299989
http://www.italki.com/user/2299991
http://www.italki.com/user/2300283
http://www.italki.com/user/2300287
http://www.italki.com/user/2300296
http://www.italki.com/user/2300491
http://www.italki.com/user/2300486
http://www.italki.com/user/2300493
http://www.italki.com/user/2300531
http://www.italki.com/user/2300536
http://www.italki.com/user/2300685
http://www.italki.com/user/2300689
http://www.italki.com/user/2300694
http://www.italki.com/user/2300961
http://www.italki.com/user/2301097
http://www.italki.com/user/2301113
http://www.italki.com/user/2301114
http://www.italki.com/user/2301230
http://www.italki.com/user/2301242
http://www.italki.com/user/2301247
http://www.italki.com/user/2302220
http://www.italki.com/user/2302221
http://www.italki.com/user/2302259
http://www.italki.com/user/2302270
http://www.italki.com/user/2302271
http://www.italki.com/user/2302317
http://www.italki.com/user/2302331
http://www.italki.com/user/2302327
http://www.italki.com/user/2302388
http://www.italki.com/user/2302389
http://www.italki.com/user/2302494
http://www.italki.com/user/2302495
http://www.italki.com/user/2302511
http://www.italki.com/user/2302766
http://www.italki.com/user/2302759
http://www.italki.com/user/2302769
http://www.italki.com/user/2302873
http://www.italki.com/user/2302912
http://www.italki.com/user/2302976
http://www.italki.com/user/2302990
http://www.italki.com/user/2302999
http://www.italki.com/user/2303341
http://www.italki.com/user/2303362
http://www.italki.com/user/2303378
http://www.italki.com/user/2303481
http://www.italki.com/user/2303513
http://www.italki.com/user/2303507
http://www.italki.com/user/2303703
http://www.italki.com/user/2303718
http://www.italki.com/user/2303716
http://www.italki.com/user/2303968
http://www.italki.com/user/2303973
http://www.italki.com/user/2303977
http://www.italki.com/user/2304008
http://www.italki.com/user/2304040
http://www.italki.com/user/2304033
http://www.italki.com/user/2304099
http://www.italki.com/user/2304109
http://www.italki.com/user/2304111
http://www.italki.com/user/2304681
http://www.italki.com/user/2304680
http://www.italki.com/user/2304691
http://www.italki.com/user/2304748
http://www.italki.com/user/2304755
http://www.italki.com/user/2304759
http://www.italki.com/user/2304901
http://www.italki.com/user/2304910
http://www.italki.com/user/2304914
http://www.italki.com/user/2305208
http://www.italki.com/user/2305222
http://www.italki.com/user/2305228
http://www.italki.com/user/2305297
http://www.italki.com/user/2305310
http://www.italki.com/user/2305311
http://www.italki.com/user/2305687
http://www.italki.com/user/2305702
http://www.italki.com/user/2305723
http://www.italki.com/user/2306125
http://www.italki.com/user/2306135
http://www.italki.com/user/2306133
http://www.italki.com/user/2306372
http://www.italki.com/user/2306417
http://www.italki.com/user/2306423
http://www.italki.com/user/2306486
http://www.italki.com/user/2306503
http://www.italki.com/user/2306505
http://www.italki.com/user/2306624
http://www.italki.com/user/2306635
http://www.italki.com/user/2306653
http://www.italki.com/user/2306711
http://www.italki.com/user/2306717
http://www.italki.com/user/2306724
http://www.italki.com/user/2306800
http://www.italki.com/user/2306791
http://www.italki.com/user/2306824
http://www.italki.com/user/2307620
http://www.italki.com/user/2307648
http://www.italki.com/user/2307655
http://www.italki.com/user/2307982
http://www.italki.com/user/2308058
http://www.italki.com/user/2308125
http://www.italki.com/user/2308152
http://www.italki.com/user/2308156
http://www.italki.com/user/2308231
http://www.italki.com/user/2308273
http://www.italki.com/user/2308306
http://www.italki.com/user/2309031
http://www.italki.com/user/2309061
http://www.italki.com/user/2309063
http://www.italki.com/user/2309212
http://www.italki.com/user/2309245
http://www.italki.com/user/2309227
http://www.italki.com/user/2309353
http://www.italki.com/user/2309409
http://www.italki.com/user/2309425
http://www.italki.com/user/2309422
http://www.italki.com/user/2309521
http://www.italki.com/user/2309509
http://www.italki.com/user/2309554
http://www.italki.com/user/2309696
http://www.italki.com/user/2309710
http://www.italki.com/user/2309700
http://www.italki.com/user/2309808
http://www.italki.com/user/2309848
http://www.italki.com/user/2309875
http://www.italki.com/user/2309947
http://www.italki.com/user/2310008
http://www.italki.com/user/2310016
http://www.italki.com/user/2310139
http://www.italki.com/user/2310120
http://www.italki.com/user/2310152
http://www.italki.com/user/2310791
http://www.italki.com/user/2310784
http://www.italki.com/user/2310804
http://www.italki.com/user/2310952
http://www.italki.com/user/2310906
http://www.italki.com/user/2311456
http://www.italki.com/user/2311470
http://www.italki.com/user/2311467
http://www.italki.com/user/2311560
http://www.italki.com/user/2311573
http://www.italki.com/user/2311582
http://www.italki.com/user/2311901
http://www.italki.com/user/2311918
http://www.italki.com/user/2311914
http://www.italki.com/user/2312122
http://www.italki.com/user/2312149
http://www.italki.com/user/2312140
http://www.italki.com/user/2312255
http://www.italki.com/user/2312272
http://www.italki.com/user/2312287
http://www.italki.com/user/2312346
http://www.italki.com/user/2312371
http://www.italki.com/user/2312378
http://www.italki.com/user/2312493
http://www.italki.com/user/2312526
http://www.italki.com/user/2312527
http://www.italki.com/user/2312752
http://www.italki.com/user/2312771
http://www.italki.com/user/2312789
http://www.italki.com/user/2312893
http://www.italki.com/user/2312930
http://www.italki.com/user/2312933
http://www.italki.com/user/2313029
http://www.italki.com/user/2313047
http://www.italki.com/user/2313078
http://www.italki.com/user/2313562
http://www.italki.com/user/2313566
http://www.italki.com/user/2313578
http://www.italki.com/user/2313643
http://www.italki.com/user/2313668
http://www.italki.com/user/2313657
http://www.italki.com/user/2313947
http://www.italki.com/user/2313967
http://www.italki.com/user/2313957
http://www.italki.com/user/2314070
http://www.italki.com/user/2314096
http://www.italki.com/user/2314079
http://www.italki.com/user/2314728
http://www.italki.com/user/2314726
http://www.italki.com/user/2314740
http://www.italki.com/user/2315007
http://www.italki.com/user/2315027
http://www.italki.com/user/2314991
http://www.italki.com/user/2315235
http://www.italki.com/user/2315278
http://www.italki.com/user/2315297
http://www.italki.com/user/2318220
http://www.italki.com/user/2318331
http://www.italki.com/user/2318320
http://www.italki.com/user/2330987
http://www.italki.com/user/2331024
http://www.italki.com/user/2331071
http://www.italki.com/user/2331303
http://www.italki.com/user/2331380
http://www.italki.com/user/2331463
http://www.italki.com/user/2331555
http://www.italki.com/user/2331834
http://www.italki.com/user/2332008
http://www.italki.com/user/2277118
http://www.italki.com/user/2279224
http://www.italki.com/user/2279756
http://www.italki.com/user/2285635
http://www.italki.com/user/2288304
http://www.italki.com/user/2288521

时间: 2024-12-15 23:21:11

数据库的Schema发生改变时是多么痛苦的事情的相关文章

EF CodeFirst 如何通过配置自动创建数据库<当模型改变时>

最近悟出来一个道理,在这儿分享给大家:学历代表你的过去,能力代表你的现在,学习代表你的将来. 十年河东十年河西,莫欺少年穷 学无止境,精益求精    本篇为进阶篇,也是弥补自己之前没搞明白的地方,惭愧惭愧. 如有不明白,请参考:EF CodeFirst 创建数据库 及 EF CodeFirst增删改查之'CRUD' 话不多说,直接上代码: using System; using System.Collections.Generic; using System.Linq; using System

树形结构的数据库表Schema设计-基于左右值编码

树形结构的数据库表Schema设计 程序设计过程中,我们常常用树形结构来表征某些数据的关联关系,如企业上下级部门.栏目结构.商品分类等等,通常而言,这些树状结构需要借助于数据库完 成持久化.然而目前的各种基于关系的数据库,都是以二维表的形式记录存储数据信息,因此是不能直接将Tree存入DBMS,设计合适的Schema及其对 应的CRUD算法是实现关系型数据库中存储树形结构的关键. 理想中树形结构应该具备如下特征:数据存储冗余度小.直观性强:检索遍历过程简单高效:节点增删改查CRUD操作高效.无意

java.sql.date与java.util.date区别以及数据库中插入带时分秒的时间

java.sql.Date,java.sql.Time和java.sql.Timestamp三个都是java.util.Date的子类(包装类). java.sql.Date是java.util.Date的子类,是一个包装了毫秒值的瘦包装器,允许 JDBC 将毫秒值标识为 SQL DATE 值.毫秒值表示自 1970 年 1 月 1 日 00:00:00 GMT 以来经过的毫秒数. 为了与 SQL DATE 的定义一致,由 java.sql.Date 实例包装的毫秒值必须通过将时间.分钟.秒和毫

把数据保存到数据库附加表 `dede_addonarticle` 时出错,请把相关信息提交给DedeCms

把数据保存到数据库附加表 `dede_addonarticle` 时出错,请把相关信息提交给DedeCms官方.Duplicate entry '2′ for key 'PRIMARY' 你的主键是不可重复的,现在重复插入值为3的主键了.可以去掉主键唯一,或是设成自增加.就不会出现这种情况了. 具体操作: 进入后台,"系统" - "系统设置" - "SQL命令行工具" 运行SQL命令行: alter table dede_addonarticle

关于数据库与Hibernate匹配时的小问题

今天做了一个小程序,jsp输入一些字段,action中将这些字段放到list中,然后从数据库get到那列数据,同样放到另一个list中,然后进行值相等的判断,就是这么简单的一个程序.但因为很久没碰Hibernate了,所以执行起来有些坎坷.列出如下问题: 空指针异常频发,这是因为在vo类中,没有指定与数据库列的映射: 关键字问题:我之前设定的列名有叫values的,但一直不通过,最后发现问题所在. 关于list的空指针问题,这个是发生比较多的.一个是没有实例化,这是基础知识的问题.第二个我觉得也

数据库资源消耗高时两条简单管用、快速找出可能问题原因的SQL语句

1.  查看正在执行的SQL语句 (1)SQL语句: selectdistinct s.sid,s.sql_id,s.event,s.program,s.MACHINE,q.sql_textfrom v$session s,v$sql q where s.sql_id=q.sql_idand s.status='ACTIVE'order by sql_text: (2)用途说明: 当数据库服务器负载高时,资源绝大部分的可能是被正在运行的SQL所消耗,查询到正在执行的SQL语句,是打开高消耗原因盒

hibernate创建导出数据库DDL schema

SchemaExport se=new SchemaExport(cfg).setOutputFile("xby.sql"); se.execute(true,true,false,false); 第一个true指导出sql文件,第二个true指执行数据库DDL. public class HibernateUtils { public static final Logger log=LoggerFactory.getLogger(HibernateUtils.class); priv

mysql数据库导入sql文件时提示“Error Code: 1153 - Got a packet bigger than 'max_allowed_packet' bytes”解决办法

向mysql数据库中导入sql文件时,如果文件过大(几百M),会提示"Error Code: 1153 - Got a packet bigger than 'max_allowed_packet' bytes" 1.查看目前数据库配置 show VARIABLES like '%max_allowed_packet%'; 显示如下结果 +--------------------+---------+ | Variable_name      | Value   | +--------

winform datagridview 不显示默认第一列 不显示未绑定列 数据源发生改变时自动更新 (转)

不显示带星号的第一列: datagridview属性框中将 RowHeadersVisiber 设置为  false 不显示未绑定列: datagridview有一个属性是 AutoGenerateColumns.但是让人不理解的是这个属性不在属性框中,因此你在那里找不到它.只能在后台代码中进行设置. this.datagridview1.AutoGenerateColumns  = false; 数据源发生改变时自动更新: datagridview的数据源在页面操作的过程中经常会发生变化.我们