<preConditions onFail="CONTINUE" onSqlOutput="TEST"> - broken?

hi,

currently I can’t see a difference in using onFail=“WARN” or onFail=“CONTINUE”

using the following changeset

                                            select 1 from dual                                

results in

    INFO: Continuing past: db.changelog.xml::1::test::(Checksum: 2:7395ee8a3585194a1da70a88b613b6d4) despite precondition failure:       1 preconditions failed     db.changelog.xml : SQL Precondition failed.  Expected '0' got '1'

    – *********************************************************************
    – Update Database Script
    […]
    – Changeset db.changelog.xml::1::test::(Checksum: 2:7395ee8a3585194a1da70a88b613b6d4)
    DROP TABLE DUAL;

    INFO: Error executing SQL DROP TABLE DUAL
    liquibase.exception.MigrationFailedException: Migration failed for change set db.changelog.xml::1::test:
        Reason: liquibase.exception.DatabaseException: Error executing SQL DROP TABLE DUAL:

(not all at the same time, using updateSql for the first part, and update for the last exception)

if I change it to warning the only change is the log-entry “Continuing past…” is changing from INFO to WARNING.

I thought (but maybe I misunderstood that), that CONTINUE should skip the “guarded” changeset and continue with the next one (if any) in the changelog - causing a “try again next time”. WARN works the way I expected it to work - print a warning, but try to apply the change anyway.

If it’s not working as expected, I think the problem may be that in liquibase.precondition.core.PreconditionContainer.check(Database, DatabaseChangeLog, ChangeSet) the exception is caught and not rethrown. At least it works more to my expectations if I comment out the last else in the catch-block (make the throw always “rethrow” the exception, or throw a new one).

(using 2.0-rc6-SNAPSHOT)

Sorry for the slow reply.  Your message got lost in my queue.

Warn and continue functionally work the same, with the only difference being the output you get.  Continue is for when you expect a precondition to fail at times, but that is OK.  Warn is for when you expect a precondition to fail at times but you want to generate a warning.  Neither mark the changeSet as ran and so will be evaluated on all future updates.  There is an onFail=“MARK_RAN” that will mark the change set as ran and so will not be re-checked in the future.

Nathan

Hi, I’d tried the MARK_RAN but no changelog is inserted to database. Liquibase still runs my changeset and throws validation fails:

       
 
   
     
   
   
 

INFO: Validation Failed:
    1 changes have validation failures
          createSequence is not supported on derby …

I expect the changeset is skipped and a changelog is inserted to database. Right?

my liquibase: 2.0-rc2.
Same problem when I run it by maven plugin. Any idea?

Probably I just posted the same issue, http://liquibase.org/forum/index.php?topic=750.0.

When you are not upgrading from an older version (I try to upgrade from 1.9.5) then maybe the dbms attribute on the changeSet might help you.

Regards,
Chris

Originally posted by: Nathan
Warn and continue functionally work the same, with the only difference being the output you get.  Continue is for when you expect a precondition to fail at times, but that is OK.  Warn is for when you expect a precondition to fail at times but you want to generate a warning.  Neither mark the changeSet as ran and so will be evaluated on all future updates.  There is an onFail="MARK_RAN" that will mark the change set as ran and so will not be re-checked in the future.
The thing is that the changeSet gets executed when using CONTINUE (even if the pre-condition fails). This is not according to the documentation (and not desired behaviour).

[Edit: Added clarification about pre-condition failing]

I did find and fix the bug with CONTINUE yesterday, so there is a fix in trunk that will be in the next release. 

Nathan

Great. Thanks for the support!

Hi Nathan, 


can you tell me when it is planned to be fixed. I need to use this CONTINUE functionality in my project…


Problem is that even if the precondition failed than the changeset is executed…


Thanks