Mysql Liquibase使用变量设置变更集作者
是否可以使用某种变量或属性在liquibase格式的sql文件中设置变更集作者 我尝试在chnagelog.xml中设置一个属性,并为作者使用该属性,如下所示 changelog.xmlMysql Liquibase使用变量设置变更集作者,mysql,liquibase,Mysql,Liquibase,是否可以使用某种变量或属性在liquibase格式的sql文件中设置变更集作者 我尝试在chnagelog.xml中设置一个属性,并为作者使用该属性,如下所示 changelog.xml <?xml version="1.0" encoding="UTF-8"?> <databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
<?xml version="1.0" encoding="UTF-8"?>
<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-3.8.xsd">
<property name="author" value="my-author"/>
<include file="sql/test_schema.sql"/>
</databaseChangeLog>
但是,作者未设置为作者属性“我的作者”
我认为这也可以通过terraform模板来实现,但是有没有一种方法可以只使用liquibase功能来实现呢?在变更日志中使用属性替换 Liquibase允许您使用不同的方法来设置属性值。Liquibase按以下指定的顺序指定这些值: 作为传递给你的Liquibase跑步者的属性
选中此项Liquibase允许动态替换changelog文件中的属性。我们可以在一个文件中配置多个属性,然后在需要时使用它们。在您的情况下,我们可以只使用一些值配置属性“authorName”,然后在changelog文件中使用${authorName}语法 无论乔治在回答中提到什么都是正确的。Liquibase按以下顺序为配置的属性分配值或设置其优先级:
<?xml version="1.0" encoding="UTF-8"?>
<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-3.8.xsd">
<changeSet author="${authorName}" id="some-unique-id" dbms="${dbType}" context="some-context">
**My SQL query/ transactional logic goes here**
</changeSet>
</databaseChangeLog>
注意:上面的示例使用了2个属性(authorName和dbType)。您只能使用authorName,甚至更多
如果您需要有关创建“liquibase.properties”文件的帮助,请访问
干杯 这对于xml变更集很好,但它不允许我将“authorName”传递给liquibase格式的sql文件。是的,liquibase属性替换仅适用于xml、JSON和YAML变更集。它还不能用于SQL变更集。您可以在此处检查此项:。另一个选项是在XML变更集文件中使用标记,在该文件中,您可以使用属性替换以及运行SQL语句。
<?xml version="1.0" encoding="UTF-8"?>
<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-3.8.xsd">
<changeSet author="${authorName}" id="some-unique-id" dbms="${dbType}" context="some-context">
**My SQL query/ transactional logic goes here**
</changeSet>
</databaseChangeLog>
authorName=Rakhi
dbType=PostgreSQL