ebi
ebi

Reputation: 335

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

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)

Upvotes: 16

Views: 27908

Answers (1)

Mark O&#39;Connor
Mark O&#39;Connor

Reputation: 77971

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?

Upvotes: 13

Related Questions