ScAlAn

Liquibase: Index.exists exception fix

Task: Fix index exists precondition exception

Solution:

Instead of using index exists liquibase tag use sql to check index exists. Problem is in: liqubase library uses SYS.INDEXES but mssql has sys.indexes table.

Example:

<preConditions onFail="MARK_RAN">
  <sqlCheck expectedResult="0">SELECT count(*) FROM sys.indexes WHERE name='I_APP_ID'</sqlCheck>
</preConditions>
<comment>Create Index I_APP_ID</comment>
<createIndex indexName="I_APP_ID" tableName="APPS" >
  <column name="APP_ID"/>
  <column name="TOPIC_ID"/>
</createIndex>

Done.

Leave a Reply

Your email address will not be published. Required fields are marked *

66  +    =  69