如何更新蚂蚁(版本)数据库? [英] How to update database by ant (versioning)?

查看:128
本文介绍了如何更新蚂蚁(版本)数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Java的Web应用程序,这正与数据库。我需要一个蚂蚁的脚本,将部署或更新我的应用程序至最新版本。没有与应用部分没有问题,但我不知道该怎么做数据库更新。

I have a web application on java, which is working with database. I need an ant’s script that will deploy or update my application to latest version. There is no problem with application part, but I don't know how to do database update.

我有一个想法来构建,一些元信息(版本号),以SQL脚本的名称。

I have an idea to build-in some meta-information (number of version) to the names of sql scripts.

例如:


  • DB_1.0.0.sql

  • DB_1.0.1.sql

  • DB_1.2.0.sql

  • DB_2.0.0.sql

  • DB_2.1.0.sql

我的脚本检测,目前的版本是1.0.1,所以我需要通过SQL任务来执行DB_1.2.0.sql,DB_2.0.0.sql,DB_2.1.0.sql文件。问题是:如何找到文件,蚂蚁,我需要执行

My script detected, that current version was 1.0.1, so I need to execute DB_1.2.0.sql, DB_2.0.0.sql, DB_2.1.0.sql files by SQL task. Problem is: how to find files with ant, that I need to execute.

也许是不更新数据库的最佳方式。你有什么其他的想法?

Maybe it is not the best way to update database. Do you have any other idea?

推荐答案

迁飞正如你工作描述。它使已经应用到数据库的SQL文件的记录,使自动升级。简单和直接的使用。

Flyway works as you've described. It keeps a record of the SQL files already applied to the database, enabling an automatic upgrade. Simple and straight forward to use.

一个更强大的解决方案,恕我直言,是 liquibase 。它有一个XML语法来记录数据库的变化,可实现跨平台的SQL的产生。它也有一些强大的功能,如回滚的变化和数据库之间进行差异的能力。

A more powerful solution, IMHO, is liquibase. It has an XML syntax to record database changes, enabling the generation of cross-platform SQL. It also has some powerful features such as the ability to roll-back changes and perform diff's between databases.

这篇关于如何更新蚂蚁(版本)数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆