The trouble with using the preconditions to check for rollback is that
the precondition result may be modified by the changet.  Suppose you had
this changeset:

<changeSet author="me" id="2009-03-09-3345-2">
        <preConditions onFail="MARK_RAN">
            <not><sequenceExists name="TEST_ID_SEQ"/></not>
        </preConditions>
        <comment>Create a sequence/trigger oracle</comment>
        <createSequence sequenceName="TEST_ID_SEQ"/>
        <sql splitStatements="false"> create or replace trigger
test_bef_trg
before insert on test
            ...</sql>
        <rollback>drop trigger test_bef_trg</rollback>
</changeSet>

The precondition would make the changeset only run if the sequence
doesn't exist, but when the rollback happens then the precondition
result will the opposite of execution time.

What we probably need to do is have a separate precondition block to
control rollback, but that is not in yet. 

If you change onFail to "CONTINUE" it will not mark it as ran which will
keep it from rolling back (like I think you meant to say) but that means
it will check that precondition on every update which makes updates take
longer and (like you said) it makes for a different number of entries in
the databasechangelog table.

In your case, it may make more sense to use the dbms attribute:
<changeSet author="me" id="2009-03-09-3345-2" dbms="oracle">.  That will
make it only update on oracle, and it only attempt rollback on oracle as
well.

Nathan

-----Original Message-----
From: kkrikor [mailto:[email protected]] 
Sent: Thursday, March 26, 2009 8:34 AM
To: [email protected]
Subject: [Liquibase-user] Rolling back a changeSet which has a
preCondition set to MARK_RAN


Hey guys , 

I have a change set like the following 

<changeSet author="me" id="2009-03-09-3345-2">
        <preConditions onFail="MARK_RAN">
            <dbms type="oracle"/>
        </preConditions>
        <comment>Create a sequence/trigger oracle</comment>
        <createSequence sequenceName="TEST_ID_SEQ"/>
        <sql splitStatements="false"> create or replace trigger
test_bef_trg
before insert on test
            ...</sql>
        <rollback>drop trigger test_bef_trg</rollback>
</changeSet>

Now if we run an update on a Postgres DB this changeset will not run yet
a
row will be added to changeLogDatabase. Now the problem happens when we
do a
rollback, The rollback actually runs in Postgres and causing an error as
expected. Shouldn't the rollback not run ? It does not seem to be
looking at
the preCondition. 

One solution would be to change onFail to Mark ran, but I do want a
consistent number of rown in the changeLogDatabase in both dbs. 

Thank you 
-- 
View this message in context:
http://www.nabble.com/Rolling-back-a-changeSet-which-has-a-preCondition-
set-to-MARK_RAN-tp22722117p22722117.html
Sent from the LiquiBase - User mailing list archive at Nabble.com.


------------------------------------------------------------------------
------
_______________________________________________
Liquibase-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/liquibase-user

------------------------------------------------------------------------------
_______________________________________________
Liquibase-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/liquibase-user

Reply via email to