首页 > 解决方案 > 有没有办法在变更集中定义局部变量?(不是变更日志级别属性)

问题描述

我有一个Liquibase变更集,它执行PostGIS可执行命令,以便将shapefile(GIS 文件)转换为表格。

<!-- Will execute :
export PGPASSWORD=postgres

shp2pgsql 
   -s 4326 -I /data/comptes-france/territoire/2016/communes.shp
   public.communes_2016 | psql -d comptesfrance -U postgres -h localhost 
-->
<changeSet id="shp2pgsql_communes_2016" author="mlebihan" failOnError="false">
    <comment>Importation des shapefiles des contours des communes 2016</comment>
    
    <executeCommand executable="export">
        <arg value="PGPASSWORD=postgres"/>
    </executeCommand>
    
    <executeCommand executable="shp2pgsql">
        <arg value="-s"/>
        <arg value="4326"/>
        
        <arg value="-I"/>  
        <arg value="/data/comptes-france/territoire/2016/communes.shp 
             public.communes_2016"/>  

        <arg value="|"/>
        <arg value="psql"/>  

        <arg value="-d"/>  
        <arg value="comptesfrance"/>  

        <arg value="-U"/>  
        <arg value="postgres"/>  

        <arg value="-h"/>  
        <arg value="localhost"/>  
    </executeCommand>
 </changeSet>

正如你所读的,它提到了很多2016年。

有没有办法在变更集中声明一个局部变量,以便我可以使用 a$year或其他东西,以避免2016到处重复?

这个变量必须只对那个变更集是本地的,因为下一个变更集会愿意做同样的事情,但是 for2017等等,(也许,在后面的问题中,我会问你执行for循环的能力,如果这个问题得到肯定的回答)。

标签: liquibase

解决方案


推荐阅读