Liquibase – A Smart Database-Migration Tool

I just want to make some publicity for liquibase, which is a tool (the only one?) for database migrations in Java and licensed under LGPL.So you can deploy it to your server if you want very hot database changes.

Liquibase is sth. like the rails db migrations but for Java😉.

One note: if you want to use liquibase from maven – use the following configuration so that you can call

mvn liquibase:updateSQL
<build>
 <plugins>
   <plugin>
      <groupId>org.liquibase</groupId>
      <artifactId>liquibase-plugin</artifactId>
      <version>1.9.0.0</version>
      <configuration>
        <propertyFile>src/main/resources/liquibase.properties</propertyFile>
        <verbose>true</verbose>
      </configuration> 
   </plugin>
   ...
 </plugins>
 ...
<build>

Then you don’t bind the sql-update process to a build step like proposed in the docs.

Other useful infos are:

  • liquibase-plugin is 1.9.0.0, but core is only 1.9.0
  • use the hibernate config file to generate the diff. (Is this even possible if I use annotations?)
  • keep in mind that you have to specify the rollback tags if you call ‘mvn liquibase:rollback -Dliquibase.rollbackCount=1’:
      <changeSet id="1" author="pk">
            <createTable tableName="test">
                <column name="id" type="int">
                    <constraints primaryKey="true" nullable="false"/>
                </column>           
            </createTable>
            <rollback>
                <dropTable tableName="test"/>
            </rollback>
        </changeSet>
  • docs, video docs
  • the project blog

One thought on “Liquibase – A Smart Database-Migration Tool

  1. Pingback: Migrate to Liquibase « Java and more …

Comments are closed.