Liquibase前提条件失败自定义错误消息 [英] Liquibase preconditions failure custom error message

查看:15
本文介绍了Liquibase前提条件失败自定义错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个变更集

<changeSet id="ABC123" author="davnicwil">
  <preConditions onFail="HALT">
    <sqlCheck expectedResult="3">SELECT count(*) FROM little_pigs</sqlCheck>
  </preConditions>
  <sql>DROP TABLE wolf</sql>
</changeSet>

little_pigs中只有2行时,失败,并显示以下错误消息

liquibase.exception.MigrationFailedException: 
  Migration failed for change set migrations.xml::ABC123::davnicwil:
    Reason: 
      migrations.xml : SQL Precondition failed.  Expected '3' got '2'

我希望看到更有意义的错误消息,例如

liquibase.exception.MigrationFailedException: 
  Migration failed for change set migrations.xml::ABC123::davnicwil:
    Reason: 
      3 little pigs are required to defeat the wolf

有没有办法为前提条件配置这样的自定义错误消息?

静态消息就可以了。如果可以发送动态消息,那就更好了。

推荐答案

我认为

onFailMessage   Custom message to output when preconditions fail. Since 2.0

(http://www.liquibase.org/documentation/preconditions.html)是静态消息所需要的。我不知道您希望"动态消息"有什么功能,但您可以使用<customPrecondition>

实现您自己的逻辑

这篇关于Liquibase前提条件失败自定义错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆