Bug/inconvenience in preConditions

When a preConditions is attached to a changeSet in will not be evaluated until the migrator gets to that particular changeset,
but if the same preConditions is attached to a changelog it will be evaluated before any migration.
That is a problem because the changelog can be executed from an include, but still it is evaluated before any prior includes are executed.

All_Refactorings.xml

    <?xml version="1.0" encoding="UTF-8"?> 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">

       
       
       

Refactoring_1.xml

    <?xml version="1.0" encoding="UTF-8"?> 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">                    

Example 1: preConditions attached to a changeSet
Refactoring_2.xml

    <?xml version="1.0" encoding="UTF-8"?> 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">

       
           
               
       
           
       

       
           
               
       
           
       

Executing All_Refactorings will be succesfull both if Refactoring_1 is already executed before and if Refactoring_1 is not executed before and should therefore be executed in this migration.

Example 2: preConditions attached to a changelog
Refactoring_2.xml

    <?xml version="1.0" encoding="UTF-8"?> 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">

       
           
       

       
           
       

       
           
               
       
           
       

Executing All_Refactorings will be succesfull if Refactoring_1 is already executed before, but will fail if Refactoring_1 is not executed before and should therefore be executed in this migration.

This makes preConditions attached to changelogs pritty unusable at the moment.

That behavior is by design.  The goal of changeLog wide preconditions is to make checks that should be ran before anything is attempted.  A good example is a “running under mysql” precondition.  You may specify that in an included changelog to document/test that the assumption you made when creating the changelog is correct.  The tests that make the most sense in changeLog preconditions are more static tests like runningAs or dbms. 

The changeSet preconditions, on the other hand, are designed to be ran as part of the execution stream.

What you probably want to do is convert your changeLog wide precondition in refactoring_2 to be a changeSet precondition:

    <?xml version="1.0" encoding="UTF-8"?> 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">

       
           
               
           
       

       
           
       

       
           
               
       
           
       

Nathan

Ok, that makes sense. Your solution will work fine for me.
Perhaps the documentation should be a little more specific about this.