# Custom preconditions as an extension not working?

**URL:** <https://forum.liquibase.org/t/custom-preconditions-as-an-extension-not-working/1428>\
**Category:** Liquibase Development\
**Created:** [August 28, 2010, 12:34pm UTC](https://forum.liquibase.org/t/custom-preconditions-as-an-extension-not-working/1428 "2010-08-28T12:34:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![nseessle](https://avatars.discourse-cdn.com/v4/letter/n/7bcc69/32.png) [@nseessle](https://forum.liquibase.org/u/nseessle)\
**Post date:** [August 28, 2010, 12:34pm UTC](https://forum.liquibase.org/t/custom-preconditions-as-an-extension-not-working/1428/1 "2010-08-28T12:34:00Z")

</div>

Hi,

I tried to implement a custom precondition following the instructions here: [http://liquibase.jira.com/wiki/display/CONTRIB/Precondition](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?

---

<div class="post-metadata">

**Author:** ![nvoxland](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@nvoxland](https://forum.liquibase.org/u/nvoxland)\
**Post date:** [August 28, 2010, 12:34pm UTC](https://forum.liquibase.org/t/custom-preconditions-as-an-extension-not-working/1428/2 "2010-08-28T12:34:00Z")

</div>

(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.&nbsp; 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" &nbsp; &nbsp; &nbsp; &nbsp; xmlns:xsi="[http://www.w3.org/2001/XMLSchema-instance"](http://www.w3.org/2001/XMLSchema-instance%22) &nbsp; &nbsp; &nbsp; &nbsp; xmlns:ext="[http://www.liquibase.org/xml/ns/dbchangelog-ext"](http://www.liquibase.org/xml/ns/dbchangelog-ext%22) &nbsp; &nbsp; &nbsp; &nbsp; xsi:schemaLocation="[http://www.liquibase.org/xml/ns/dbchangelog](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/dbchangelog-2.0.xsd) &nbsp; &nbsp; &nbsp; &nbsp; [http://www.liquibase.org/xml/ns/dbchangelog-ext](http://www.liquibase.org/xml/ns/dbchangelog-ext)[http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd"\>](http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd%22>)

&nbsp; &nbsp;   
&nbsp; &nbsp; &nbsp; &nbsp; \<ext:modifyColumn tableName=“datatable”\>  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;   
&nbsp; &nbsp; &nbsp; &nbsp; \</ext:modifyColumn\>  
&nbsp; &nbsp;

---

<div class="post-metadata">

**Author:** ![jcreenaune](https://avatars.discourse-cdn.com/v4/letter/j/ba9def/32.png) [@jcreenaune](https://forum.liquibase.org/u/jcreenaune)\
**Post date:** [August 28, 2010, 12:34pm UTC](https://forum.liquibase.org/t/custom-preconditions-as-an-extension-not-working/1428/3 "2010-08-28T12:34:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Guest](https://avatars.discourse-cdn.com/v4/letter/g/8dc957/32.png) [@Guest](https://forum.liquibase.org/u/Guest)\
**Post date:** [August 28, 2010, 12:34pm UTC](https://forum.liquibase.org/t/custom-preconditions-as-an-extension-not-working/1428/4 "2010-08-28T12:34:00Z")

</div>

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&nbsp;

---

<div class="post-metadata">

**Author:** ![nvoxland](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@nvoxland](https://forum.liquibase.org/u/nvoxland)\
**Post date:** [August 28, 2010, 12:34pm UTC](https://forum.liquibase.org/t/custom-preconditions-as-an-extension-not-working/1428/5 "2010-08-28T12:34:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jcreenaune](https://avatars.discourse-cdn.com/v4/letter/j/ba9def/32.png) [@jcreenaune](https://forum.liquibase.org/u/jcreenaune)\
**Post date:** [August 28, 2010, 12:34pm UTC](https://forum.liquibase.org/t/custom-preconditions-as-an-extension-not-working/1428/6 "2010-08-28T12:34:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jcreenaune](https://avatars.discourse-cdn.com/v4/letter/j/ba9def/32.png) [@jcreenaune](https://forum.liquibase.org/u/jcreenaune)\
**Post date:** [August 28, 2010, 12:34pm UTC](https://forum.liquibase.org/t/custom-preconditions-as-an-extension-not-working/1428/7 "2010-08-28T12:34:00Z")

</div>

Custom task attachment

---

<div class="post-metadata">

**Author:** ![nvoxland](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@nvoxland](https://forum.liquibase.org/u/nvoxland)\
**Post date:** [August 28, 2010, 12:34pm UTC](https://forum.liquibase.org/t/custom-preconditions-as-an-extension-not-working/1428/8 "2010-08-28T12:34:00Z")

</div>

Thanks for the examples. I created&nbsp;[http://liquibase.jira.com/browse/CORE-898](http://liquibase.jira.com/browse/CORE-898)&nbsp;to track it.

Nathan
