Does Liquibase do this?

We would like to use Liquibase in our project to build schemas in MULTIPLE dialect databases; and use Liquibase as a generic schema description and migration tool.  We have excellent success with it so far with H2, but now want to use the same changelogs to build oracle and mssql instances (among others). 

  1. Does liquibase support this?
  2. Does it internally support a dialect concept similar to Hibernate?
  3. If not, is there some other way to achieve this?

Presently we are pointing it to oracle with our changesets and are getting IDENTITY creation failure error messages; obviously oracle does not support IDENTITY.

Thanks

Sean

Liquibase does do it.  Sometimes automatically, sometimes not.  All the built-in changes will modify the generated SQL to match your target database (correct create table syntax, for example) and will also modify some specified data types to database-speicifc types (clob->text for example).

If you run into cases where the built-in independence is not enough, there are some options:

  • The changeSet tag can use a “dbms” attribute where you can specify which database types the changeset is applicable to. 
  • Each changeSet can use preconditions to control when they run
  • You can use changelog parameters so you can pass along values that are substituted in at run time.

Let us know if you run into any troubles.

Nathan

Hi Nathan. I’m working with the person who posted this question. Thanks for getting back to us so quickly.

I’m finding that for IDENTITY, Liquibase is not automatically substituting some generic numeric type if the database is Oracle. I’m a bit of newbie here, and I may be doing something wrong.

I have put together a programmatic interface to Liquibase, like this:

final Liquibase liquibase = new Liquibase(relativeLogFile, fileSystemFileOpener, db);
final String parms = "driver=" + driverName + ", url=" + url + ", defaultSchemaName=" + dbName + ", username=" + user + ", password=" + pswd + ", diffTypes=data, generateChangeLog";
final File file = new File("MyOutput.xml");
final FileWriter txt = new FileWriter(file);
final PrintWriter out = new PrintWriter(txt);
liquibase.update(parms, out);

When I plug in an Oracle url and driver, with a ChangeSet originally build from H2 (which supports IDENTITY), the resulting Update Database Script still tries to make fields IDENTITY.

Also, in your forum from a couple years ago, you seemed to say you were intentionally NOT handling this particular issue:

http://liquibase.jira.com/browse/CORE-137

(Frankly, I wouldn’t want to handle this issue either!)

We can work with the other solutions you suggested, but I wanted to confirm that I’m not missing something here, and we’ll need to handle IDENTITY in a special way. Is that right?

Thanks again for your help.

BrianMcNamara,

could http://liquibase.org/forum/index.php?topic=690.0 help you?

It looks like it might. But I’m getting this message:

Caused by: org.xml.sax.SAXParseException: cvc-complex-type.3.2.2: Attribute ‘dbms’ is not allowed to appear in element ‘property’.

From this test case:

<databaseChangeLog xmlns=“http://www.liquibase.org/xml/ns/dbchangelog/1.9”
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=“http://www.liquibase.org/xml/ns/dbchangelog/1.9 http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd”>













Does it matter that we’re still on 1.9? The Liquibase docs say “property” is from 1.7.

To answer my own question, I have found I needed the 2.0 xsd. Still working on this in general. Thx.

This is all working now. Thanks very much for your help!

Glad you got it working, thanks for updating us.

Nathan