Liquibase:检查是否设置了属性

标签 liquibase

如果设置了自定义属性,我找不到检查前置条件元素的方法。

到目前为止,我发现的有关此问题的信息是 here . 正如票证注释所示,扩展 CustomPrecondition不修改 API 将无济于事。还有其他方法吗?

最佳答案

documentation描述 changeLogPropertyDefined 前置条件。

以下示例对我来说效果很好:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd">

    <changeSet author="mark (generated)" id="mark-1">
        <preConditions onFail="HALT">
            <changeLogPropertyDefined property="testing" value="1"/>
        </preConditions>

        <createTable tableName="TEST001">
            <column name="ID" type="VARCHAR(10)">
                <constraints nullable="false"/>
            </column>
            <column name="X" type="VARCHAR(9)">
                <constraints nullable="false"/>
            </column>
            <column name="Y" type="DECIMAL(7,2)"/>
            <column name="Z" type="DECIMAL(7,2)"/>
        </createTable>
    </changeSet>

</databaseChangeLog>

我从 Maven 运行 liquibase。可以从命令行设置 testing 属性,如下所示:

mvn -Dtesting=1 compile

关于Liquibase:检查是否设置了属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10297583/

相关文章:

java - Hibernate 期望序列而不是 postgres 的表

mysql - Liquibase 使用垃圾值更新 mysql 数据库

postgresql - liquibase 命令行错误 org.yaml.snakeyaml.Yaml

mysql - 在 Ubuntu 中运行 liquibase 脚本后出现错误,但在 Windows 中工作正常

java - Dropwizard Migrations Liquibase 中代码优先的方法

java - 从 1.9 到 2.0.3 缺少 Liquibase 类

java - 在 Tomcat 8.5 上找不到 liquibase.logging.Logger 的实现

液碱 : checksum changed and I don't know why

grails - “Unexpected error running Liquibase: Unknown Reason” liquibase 3.3.5和grails war文件

java - Postgresql 的 Liquibase addAutoIncrement 错误