Grails and LiquiBase - How to use (Jakob Kuelzer)
Grails, Jakob Kuelzer September 19th, 2008
Jakob Kuelzer wrote a quick guide about getting LiquiBase working on your Grails project. He starts by describing what is LiquiBase and why it may be a good idea to add it to your project. He then points you to the LiquiBase plugin for Grails download and manual page. From there the story is very similar as to every other Grails plugin. He finishes by giving some useful advice depending on the current state of you project and when to add LiquiBase to it.
LiquiBase is a tool that helps developers to track and apply changes to database schemas. Basically what it does is storing all changes that are made to a database in a special XML file, called a database changelog file. This changelog file can be used to determine if there are any changes between the schema in the changelog file and the schema found in a database. The nice thing about LiquiBase is that it is database neutral so you can use with any database Java is able to connect to, and that are a lot…
But there is more to LiquiBase that just tracking changes. The outstanding feature of LiquiBase is that it is able to migrate data using the information stored in the database changelog file. This doesn’t sound like very much when you are starting a project from scratch, but as soon as you start entering data in your evolving application, you’ll understand. And as every application evolves, this is a feature handy for every developer, especially for Grails developers as Hibernate as ORM basically supports only two modes of operation to handle the database schema (configured via the hibernate.hbm2ddl.auto option): wiping out the database and applying a new schema (called create or create-drop) or attempting to update the schema (simply called update). The update option looks like a good way to go at first but as it turns out it has its drawbacks, especially if there is data in the database.
Tags: Grails, Jakob Kuelzer
About