Liquibase Type Mapping MySQL & SQL Server

305 views Asked by At

From command line I let liquibase run in the version 4.19.0.

liquibase --changeLogFile=update.xml update

where update.xml is a bundle of changelogs:

<databaseChangeLog ...
    <include file="changelog_1.xml" relativeToChangelogFile="true"/>
    <include file="changelog_2.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

The first run ends with an error:

Unexpected error running Liquibase: Data type definition contains unparseable embedded information: ${dbtype.varchar}(20)

So far as I understand the ${dbtype.varchar} comes from my company and in Java code I see a replacement.

My question is for MySQL ${dbtype.varchar} should be replaced with VARCHAR and for SQL Server with nvarchar.

Is there an easy way to tell liquibase to replace this placeholder with MySQL values?

In the liquibase.properties I tell liquibase that it should be done for MySQL.

driver: com.mysql.jdbc.Driver 
url: jdbc:mysql://localhost:3306/test
classpath: /home/markus/drivers/mysql-connector-java-5.1.49.jar

EDIT: I found inside the Liquibase documentation how I can do it with properties from outside.

liquibase --changeLogFile=batch_changelogs.xml update -Ddbtype.bigint=BIGINT -Ddbtype.ubigint='BIGINT UNSIGNED'

It's not exaclty what I'm looking for but at the momement is comfortable to use.

Thanks, Markus

1

There are 1 answers

0
Clueless On

Finally I found it inside the documentation

In liquibase.properties I can add with the parameter.

parameter.dbtype.bigint=BIGINT 
parameter.dbtype.ubigint='BIGINT UNSIGNED' 

Solved for MySql. For MSSQL I will generate a new property file and change by exeuction.