如何读取liquibase变更日志中的环境变量

问题描述 投票:0回答:1
kubernetes openshift liquibase
1个回答
0
投票

property-substitution 中所写,您可以使用

-D
前缀将属性传递给 liquibase 命令 CLI(或者您可以使用其他方法),因此类似
-Dproperty-name=somevalue
的内容,然后在您的 changeSet/sql 中将其用作
${property-name} 
.

cmd:

liquibase update -Dpguser=myuser

<changeSet author="xxxxx" id="1682329977552-1" context="unittest">
<preConditions onFail="CONTINUE">
 <sqlCheck expectedResult="1"> SELECT COUNT(*) FROM pg_roles WHERE rolname='${pguser}';</sqlCheck>
</preConditions>
    <sqlFile dbms="!h2, oracle, mysql, postgresql"
             encoding="UTF-8"
             endDelimiter="\nGO"
             path="db_grants.sql"
             relativeToChangelogFile="true"
             splitStatements="true"
             stripComments="true"/>
</changeSet>
grant select on all tables in schema public to ${pguser};
grant insert on all tables in schema public to ${pguser};
grant delete on all tables in schema public to ${pguser};
grant update on all tables in schema public to ${pguser};
© www.soinside.com 2019 - 2024. All rights reserved.