基于 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/