gpt4 book ai didi

mysql - Liquibase格式化的sql前提条件tableExists

转载 作者:行者123 更新时间:2023-11-29 06:41:46 28 4
gpt4 key购买 nike

基于 Liquibase xml 的变更集 block :

<preConditions>
<not>
<tableExists tableName="alarm" schemaName="public"/>
</not>
</preConditions>

它在“liquibase formatted sql”中应该是怎样的?Liquibase的官方文档仅给出基于xml的

最佳答案

使用这个:

--preconditions onFail:HALT onError:HALT
--precondition-sql-check expectedResult:0 SELECT count(*) FROM information_schema.tables where table_name = 'alarm';

expectedResult 是 liquibase 中的一个字符串,评估将进行字符串比较。因此,无论您的 sql 返回什么,都需要完全匹配(包括区分大小写)。

您还可以查看单元测试类FormattedSqlChangeLogParserTest获取更多示例。

关于mysql - Liquibase格式化的sql前提条件tableExists,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51277777/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com