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.