Measurables: add unique composite index on category + external id
</update>
</changeSet>
+
+ <!-- Measurables: unique composite index on category and external id -->
+ <changeSet id="20190102-3687-1"
+ author="kamransaleem"
+ dbms="mysql,postgresql">
+ <comment>Measurables: unique composite index on category and external id</comment>
+ <createIndex tableName="measurable"
+ indexName="idx_category_ext_id_not_null"
+ unique="true">
+ <column name="measurable_category_id"
+ type="${id.type}" />
+ <column name="external_id"
+ type="${external-id.type}">
+ <constraints nullable="true" />
+ </column>
+ </createIndex>
+ </changeSet>
+
+ <changeSet id="20190102-3687-1"
+ author="kamransaleem"
+ dbms="mssql">
+ <comment>Measurables: unique composite index on category and external id</comment>
+ <sql>
+ CREATE UNIQUE NONCLUSTERED INDEX idx_category_ext_id_not_null
+ ON [measurable]([measurable_category_id], [external_id])
+ WHERE [external_id] IS NOT NULL;
+ </sql>
+ </changeSet>
+
</databaseChangeLog>
