Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grails database migration plugins

There are at least two Grails plugins that emulate the database migration functionality of Rails:

  • Autobase
  • Liquibase

Is there a consensus about which of these is best, or is there another plugin that does database migration better than either of the above?

like image 286
Dónal Avatar asked Jan 20 '10 17:01

Dónal


4 Answers

There is now a standard Grails database migration plugin available. According to this blog post at least the liquibase plugin will therefore not be maintained past the liquibase 1.9 release anymore.

The new database migration plugin has built-in functionality to execute changelogs on startup and supports the definition of changes in Groovy DSL, so it's probably what you are looking for.

like image 183
Christian Hang-Hicks Avatar answered Oct 21 '22 19:10

Christian Hang-Hicks


I use Autobase (which is built on top of Liquibase) as it (last time I checked) allows you to automatically check/apply your migrations when the app starts. With the Liquibase plugin I have to do this myself in servlet init code. This allows you to set your datasource to dbCreate = none and let Autobase handle getting the DB into shape.

It does mean you need to write a migration each time you add a property to a domain class, but I think this is a good thing as it makes you think about what the underlying field should actually be instead of just letting Hibernate take a guess at it.

I think some of the Autobase plugin (e.g. the groovy dsl) is being migrated back to the Liquibase plugin, but you'd need to check up on that.

The only downside to Autobase is the lack of good documentation. There is some but it's not complete. Luckily, the dsl is the same as the xml Liquibase tags so you can work most of it out.

like image 27
leebutts Avatar answered Oct 21 '22 18:10

leebutts


I use liquibase, I'm not sure that Robert is still actively maintaining Autobase and the xml that liquibase provides is actually pretty DSL-like. I think it also gives a little bit of separation to your database commands and doesn't make it ingrained into the start-up process (some people might prefer the reverse).

like image 21
Ted Naleid Avatar answered Oct 21 '22 17:10

Ted Naleid


At least as of Grails2.0, the database migration plugin is the defacto way to handle non-trivial database changes. The plugin is built on Liquibase, and is authored by the Springsource folks - always a mark of quality. I wrote an introduction to the database migration plugin which might be of use to someone reading this.

like image 32
34m0 Avatar answered Oct 21 '22 17:10

34m0