BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Creating Ruby Style Migrations In Java

Creating Ruby Style Migrations In Java

Database migrations are a critical piece of any project upgrade. The most common Java database migration tool is writing scripts and executing them by hand. Most projects that have a tool end up rolling their own but there are several open-source tools out there which tackle the problem in different ways. Available tools include Migrator (a set of Ant tasks for doing database migration in the style of ActiveRecord, a part of the Ruby on Rails platform), Scriptella (mainly an ETL tool but schema migrations are possible), and DdlUtils (database independent migrations).

Migrator is currently out in beta, and has no documentation, but Obie Fernandez just wrote an overview. Migrator is easy-to-use, but is undocumented and relies on SQL and therefore your migrations are not portable to other databases. It is an attempt to bring the functionality of ActiveRecord migrations to Java.

Scriptella, which has gone from a 0.1 release to version 0.4 in the last two months, is primarily a Extract-Transform-Load (ETL) tool. However, it does provide the capability to do schema migrations. In their examples, they provide a demonstration of how to do migrations, with documentation. Scriptella is primarily used from Ant and uses straight SQL in the query and script sections of its XML configuration file, thus it is not cross-database (although it nicely supports moving data from one database to another, you have to write both sets of SQL yourself).

DdlUtils is an Apache project that first and foremost handles straight DDL changes to your database in a cross-platform way. Guy Davis blogged how to use DdlUtils in a cross-database way including dumping and loading data. One limitation of DdlUtils is that it currently does not have the ability to capture or create triggers, constraints, or stored procedures.

Of the above projects, DdlUtils has been around the longest, although Sciptella was developed in-house and then open-sourced so it is also fairly stable. Migrator shows good promise, but it is too soon to say how it will develop.

InfoQ covered some similar ideas back in August when talking about the broader idea of project updates.

Rate this Article

Adoption
Style

BT