Liquibase changeSet with failOnError="false" are always ran?

ebi picture ebi · Jun 6, 2012 · Viewed 15.5k times · Source

I'm trying to execute the following changeSet in liquibase which should create an index. If the index doesn't exist, it should silently fail:

<changeSet failOnError="false" author="sys" id="1">
    <createIndex unique="true"  indexName="key1" tableName="Table1">
        <column name="name" />
    </createIndex>
</changeSet>

So far, so good. The Problem is, that this changeSet doesn't get logged into DATABASECHANGELOG table and is therefor executed every time liquibase runs. According to the liquibase documentation and e.g. this answer from Nathen Voxland i thought that the changeset should be marked as ran in the DATABASECHANGELOG table. Instead it isn't logged at all and as i said before executed every time liquibase runs (and fails everytime again).

Am i missing something?

(I'm using MySQL as DBMS)

Answer

Mark O&#39;Connor picture Mark O'Connor · Jun 7, 2012

In the answer given by Nathen Voxland, he recommended the more correct approach of using a precondition to check the state of the database, before running the changeset.

It seems to me that ignoring a failure is a bad idea.... Means you don't fully control the database configuration.... The "failOnError" parameter allows liquibase to continue. Wouldn't it be a bad idea for a build to record a changset as executed, if in fact it didn't because an error occurred?