Adding new datatype via the ServiceLocator


I wonder what the best way is to add a new data type to Liquibase. Lets say that in the changelog XML I have columns of type DECIMAL, for Oracle these must be converted to NUMBER. I created a new class extending OracleTypeConverter overriding the getDataType(String, Boolean) method. In case I need to change a datatype for one of the supported types I override the getXXXType() method.

The class is pushed into Liquibase using the ServiceLocator.addPackageToScan(String) method. When the changelog is parsed and processed Liquibase uses my class instead of the original OracleTypeConvertor.

Is this the intended approach to extend datatypes?


Sorry for the slow reply.

Yes, that is the intended approach.  I haven’t gotten it documented yet as it has been in flux until the last week or so.  Let me know if you have any troubles getting it to work, or have any suggestions.


At the moment I was just wondering if I got it correct (also because I could not find any docs and had to go with ‘the code is the documentation’). No problems at this time.

I have a small suggestion for the AbstractTypeConverter, split the getDataType(String, Boolean) into two functions. This makes override the getDataType() method easier because the first code part (determination of data type name and precision) is a common issue. See the attached patch. When I create a new descendant for a type converter I just override the new protected method and prevent code copy for the first part.


That looks like a good change.  I applied it to trunk.  Thanks!