0

I'm exporting a Oracle schema, and I want to have a script that I can use for in-memory tests with H2.

I export the schema with maven, mvn liquibase:generateChangeLog.

I have noticed that when I specify an outputChangeLogFile of type sql, the Oracle and H2 formats produce different output (e.g. generatedChangelog.h2.sql vs generatedChangelog.oracle.sql).

With type xml they produce the same ( generatedChangelog.h2.xml vs generatedChangelog.oracle.xml).

In particular, with the sql type I get

  • NAME VARCHAR(255) NOT NULL for H2
  • NAME VARCHAR2(255 BYTE) NOT NULL for Oracle

with the xml format I get

  • <column name="NAME" type="VARCHAR2(255 BYTE)"> for both H2 and Oracle

this particular syntax is not valid with H2, so this seems a bug to me. Liquibase can clearly understands this as you can see from the sql example, but it doesn't produce a valid changeSet for the xml format.

Is there anything I can do to produce the correct output in xml format?

Thanks

user103716
  • 190
  • 12

1 Answers1

0

There is quite a lot of differences between different databases. What you can do (manually or by some regex) is to create changeLog variables and do following:

  • change column definition
<column name="NAME" type="VARCHAR2(255${byteType})">
  • add variable for different db vendors
<property name="byteType" dbms="oracle" value="BYTE"/>
<property name="byteType" dbms="h2" value=""/>

with changes above you'll be able to run changeSets against both (or almost any) databases.

bilak
  • 4,526
  • 3
  • 35
  • 75