0%

Liquibase创建索引

创建索引

liquibase preconditions

创建索引前先判断索引是否存在

1
2
3
4
5
6
7
8
9
10
<changeSet id="228-039" author="jlin">
<preConditions onFail="MARK_RAN">
<not>
<indexExists tableName="t_health_abnormal" indexName="idx_create_time" columnNames="create_time"/>
</not>
</preConditions>
<createIndex tableName="t_health_abnormal" indexName="idx_create_time">
<column name="create_time" />
</createIndex>
</changeSet>

Available attributes

Attribute Description
onFail What to do when preconditions fail (see below).
onError What to do when preconditions error (see below).
onUpdateSQL What to do in updateSQL mode (see below).Since 1.9.5
onFailMessage Custom message to output when preconditions fail.Since 2.0
onErrorMessage Custom message to output when preconditions fail.Since 2.0

Possible onFail/onError values

Value Description
HALT Immediately halt the execution of the entire change log.[DEFAULT]
CONTINUE Skip over the change set. Execution of the change set will be attempted again on the next update. Continue with the change log.
MARK_RAN Skip over the change set, but mark it as executed. Continue with the change log.
WARN Output a warning and continue executing the change set/change log as normal.

Possible onUpdateSQL values

Value Description
RUN Run the changeSet in updateSQL mode.
FAIL Fail the preCondition in updateSQL mode.
IGNORE Ignore the preCondition in updateSQL mode.