Custom preconditions as an extension not working?

Hi,

I tried to implement a custom precondition following the instructions here: http://liquibase.jira.com/wiki/display/CONTRIB/Precondition

Either there is something missing, or I misunderstood the instructions.

Simply “using” the custom precondition in a changelog leads to

cvc-complex-type.2.4.a: Invalid content was found starting with element ‘columnIsNullable’. One of …

Is it enough to simply implement a Precondition in the right place (where PreconditionFactory will pick it up), or am I expected to declare these preconditions with a custom namespace an reference them as “<foo:columnIsNullable …”?

If I do this, AND if I extend the liquibase-2.0.xsd to contain “<xsd:any namespace=”##other" processContents=“lax” minOccurs=“0” maxOccurs=“unbounded” />" as an valid element for the group PreConditionChildren I get it to work as expected.

So… am I doing it wrong, or is there something missing in the Schema?

(Sorry for the slow response, been on vacation and your post got buried under a pile of other threads)

You do just need to put the custom class somewhere that PreconditionFactory will pick it up for the parser to be able to understand it, but you do need the XML parser to handle the unexpected tag.  You can create a custom XSD if you like, or there is an existing “ext” XSD that is a “whatever you want” schema.

For example:

    http://www.liquibase.org/xml/ns/dbchangelog"         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"         xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"         xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd         http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">

       
            <ext:modifyColumn tableName=“datatable”>
               
            </ext:modifyColumn>
       

Hi I’m Guest who commented above … just wanted to clarify that when I said "<span class=“Apple-style-span”

Has anyone managed to get a custom precondition working? I have created a precondition implementation, registered with PreconditionFactory, included the ext xsd schema as per Nathan’s reply above and I still receive 



You shouldn’t need to hack the .xsd, you just need to create an additional XSD (or use the extension xsd) and reference it from your changelog XML file as a separate namespace.


Nathan

Thanks for the quick reply. I can get custom tasks to pass xml validation using the extension xsd, but not custom preconditions.


I’ve attached two cases. The first (custom-task.xml) passes xml validation; the second (custom-precondition.xml) fails xml validation with “cvc-complex-type.2.4.a: Invalid content was found starting with element ‘ext:myPrecondition’.”


I’m running liquibase 2.0. Any help much is appreciated.

Custom task attachment

Thanks for the examples. I created http://liquibase.jira.com/browse/CORE-898 to track it.


Nathan