Liquibase前提条件被忽略

时间:2016-06-01 09:08:48

标签: liquibase sybase-ase

我想在开发数据库中添加一些数据用于测试目的。 为此,我创建了一个使用

包含的 test_data.sql
<include file="./test_data.sql" relativeToChangelogFile="true"/>

test_data.sql的格式如下:

--liquibase formatted sql

--changeset whiad-16453:testdata runOnChange:true failOnError:true endDelimiter:go stripComments:false
--preconditions onFail:HALT onError:HALT
--precondition-sql-check expectedResult:1 select case when db_name()='devdb' then 1 else 0 end
insert into...

我希望只在select返回1时执行插入(它是Sybase SQL方言,我使用Sybase Central在Dev和Prod环境中执行查询,并按预期返回0或1)。 然而,Liquibase创建了一个包含插入的脚本(使用updateSQL命令行参数)。

我或者尝试在更改日志中的include文件之前使用前置条件:

<preConditions>
    <sqlCheck expectedResult="1">select case when db_name()='devdb' then 1 else 0 end</sqlCheck>
</preConditions>
<include file="./test_data.sql" relativeToChangelogFile="true"/>

但也是在这种情况下插入的地方。 我还试图使用我在条件中使用的属性:

<changeLogPropertyDefined property="deploy_test_data" value="true"/>

但这也没有任何效果。

我做错了什么?

1 个答案:

答案 0 :(得分:0)

我现在使用上下文作为我的目的,将“contexts ==!testdata”作为prod上的参数传递。