Oracle VARCHAR2 definition

Hi

We are migrating from an existing Oracle database to Liquibase. We would like to support multiple databases, at least PostgreSQL. We’ve got couple of varchar definitions like this: VARCHAR2(255 CHAR) . We use UTF8 database so defining length in chars is crucial.

generateSQL command generated the same XML definition as in Oracle, but this is not portable, PostgreSQL is not able to understand CHAR modifier.

I managed to solve this problem with dbms attribute in every table definiton, although this makes the script very redundant, I have to create seperate definitions for Oracle and PostgreSQL.

What is the proper way to define VARCHAR2 length in CHARs?

Thanks,

Hubi

You can create your own extension of the VarcharType class and override the toDatabaseType() method to change the behavior of what is generated.

Without adding a new class, the easiest approach may be to use changeset parameters to define a “charUnit” variable.

In your changelog you can define:

then you can just use and liquibase will substitue in CHAR or not depending on the target database.

Nathan