Specifying mapping for a database ?

Hi,

I am using type=“clob” in my changesets.

For mySQL, liquibase use a “text” sql type.

The problem is that the JPA annotation @Lob used with Hibernate and Mysql5InnodbDialect expects a “longtext”.

I know this has been asked several time and the answer seems to be “use the changelog parameter”.

I would like to know if someone already has done this via the block of the DatabaseChangeLog file itself, and if yes how ?

Just a little sidenote : I ask this question because when I write :

    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">

     
     

it doesnot work :

    Caused by: liquibase.exception.ChangeLogParseException: Error parsing line 7 column 17 of classpath:net/decalog/gabi/db/gabi-liquibase-changelog.xml: cvc-complex-type.2.4.a: Invalid content was found starting with element 'parameters'. One of '{"http://www.liquibase.org/xml/ns/dbchangelog/1.9":preConditions, "http://www.liquibase.org/xml/ns/dbchangelog/1.9":property, "http://www.liquibase.org/xml/ns/dbchangelog/1.9":changeSet, "http://www.liquibase.org/xml/ns/dbchangelog/1.9":include, "http://www.liquibase.org/xml/ns/dbchangelog/1.9":includeAll}' is expected. at liquibase.parser.xml.XMLChangeLogParser.parse(XMLChangeLogParser.java:78) at liquibase.parser.ChangeLogParser.parse(ChangeLogParser.java:28) at liquibase.Liquibase.update(Liquibase.java:105) at liquibase.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:214) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1469) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1409) ... 34 more Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'parameters'. One of '{"http://www.liquibase.org/xml/ns/dbchangelog/1.9":preConditions, "http://www.liquibase.org/xml/ns/dbchangelog/1.9":property, "http://www.liquibase.org/xml/ns/dbchangelog/1.9":changeSet, "http://www.liquibase.org/xml/ns/dbchangelog/1.9":include, "http://www.liquibase.org/xml/ns/dbchangelog/1.9":includeAll}' is expected.

Making progress on this : the tag to use is property (instead of parameters).

=> PLEASE, update the documentation at http://www.liquibase.org/manual/changelog_parameters

Then, how do I specify different value for different dbms ? Said otherwise, how do I write things such as :

       

At the moment, I am doing the following (which is quite annoying) : add another changeset specific to mysql just after the “generic” changeset :

                                                                                                                                                                                                                             

Note : all that stuff could be avoided if liquibase had a configurable liquibase-mapping.xml file…

I added an example to the page you referenced.  Basically, you add nodes on their own in the changeset and can specify a dbms and/or context attribute if you need.

Another option with 2.0 now is the ability to specify your own extensions (http://liquibase.org/extensions) so you could easily create a subclass of MysqlDatabase that overrides the getClobType method and returns “longtext” instead.  It’s not quite as easy as a  liquibase-mappings.xml file, but it is more flexible.

Nathan