Reputation: 5236
What I want to do is;If there is an index(non-unique) named "message_id" then drop it and create an unique index with same name.
Below code doesn't checks for uniqueness. Is there a way to do this?
By the way I can write an "sqlcheck" statement but I need to find a way to get "message_id" index's uniqueness with mysql query.
<changeSet author="mark" id="201589895236">
<preConditions onFail="MARK_RAN">
<indexExists schemaName="${database.name}" indexName="message_id"/>
</preConditions>
<comment>comment for message_id index</comment>
<createIndex indexName="message_id" tableName="user_info" unique="true">
<column name="message_id"/>
<column name="message_prefix"/>
</createIndex>
</changeSet>
Upvotes: 0
Views: 1185
Reputation: 6499
Looks like it is not possible, nothing related to unique is here: https://github.com/liquibase/liquibase/blob/master/liquibase-core/src/main/java/liquibase/precondition/core/IndexExistsPrecondition.java So you should use SQL check or implement your own custom precondition.
Upvotes: 2