Liquibase Extensions

This page is outdated and no longer receives updates!

Since Liquibase 2.0, to improve flexibility, a new extensions framework was created. These extensions allow liquibase to behave in a way that is not core to the way in which Liquibase works. Liquibase 2.0 introduced the ability to create custom java classes that will replace or augment virtually all areas of Liquibase’s execution including changelog parsing, database support, available refactorings, generated SQL, logging and more.

OpenMRS Extensions

The source code for Liquibase Extensions for OpenMRS are available at: http://svn.openmrs.org/repo/openmrs-contrib/liquibase-ext/

Modify Column

In OpenMRS, liquibase-update-to-latest.xml we use a lot of <modifyColumn> tag. This has been deprecated in Liquibase v2.0 due to complexity of modifyColumn's operations. Although we cannot change this tag instantly due to backward compatibility, we've implemented the modifyColumn through an extension. This extension is a modified version of the ModifyColumn Change extension that is available through the Liquibase Extensions Portal. The extension available through liquibase does not implement the defaultValue attribute that is part of the modifyColumn tag. This tag has been widely used in the OpenMRS changesets and thus, we have modified the code and made the necessary changes that are required to set the defaultValue attribute.

Maven code for Modify Column:

<dependency> <groupId>org.openmrs.liquibase.ext</groupId> <artifactId>modify-column</artifactId> <version>2.0.2-SNAPSHOT</version> </dependency>

Identity Insert

In OpenMRS, we use IDENTITY columns (auto-increment) for primary key columns. This is useful so that the id is automatically incremented. But during the installation, we insert data directly into our database with ids into these IDENTITY columns. This is fine for MySQL and Postgres, but SQL Server does not allow to add values to an IDENTITY column and throws error. Thus, we need to wrap insert statements in "SET IDENTITY <tableName> OFF" and "SET IDENTITY <tableName> ON". The Identity-Insert Liquibase extension allows wrapping an insert statement, when the database is found to SQL Server.

Maven code for identity insert:

<dependency> <groupId>org.openmrs.liquibase.ext</groupId> <artifactId>identity-insert</artifactId> <version>1.2.1-SNAPSHOT</version> </dependency>

Type Converter

In liquibase version 2.0.3, all changesets of column data type TEXT are mapped to LONGTEXT in MySQL. The effect of this is that MySQL users end up with excessively long text fields. The Type-Converter Liquibase extension allows mapping them to TEXT, when the database is found to be MySQL. We are currently using version 2.0.1 of liquibase and hence this mapping has no value at the moment but will be useful when we eventually upgrade. The second use of this extension is mapping CLOB data types to LONGTEXT, for MySQL, instead of TEXT as incorrectly done by liquibase version 2.0.1 which we currently use.

Maven code for type converter:

<dependency> <groupId>org.openmrs.liquibase.ext</groupId> <artifactId>type-converter</artifactId> <version>1.0.1</version> </dependency>

Â