liquibase中有替换功能吗?
Is there a replace function in liquibase?
Liquibase 提供了更新列中整个值的更新功能。还有一种方法可以只替换一部分值吗?或者我必须使用普通的 sql 语句吗?
列中的值如下所示:
downtime = maintenanceTime + rampUpTime + repairTime;
打电话时
<changeSet author="faf" id="29.10.19-16:34-001">
<update tableName="PARAMETER">
<column name="VALUE" type="varchar(64)" value="setupTime" />
<where>VALUE LIKE '%rampUpTime%'</where>
</update>
</changeSet>
它把它翻译成
UPDATE parameter set VALUE = 'setupTime' where VALUE like '%rampUpTime%'
我正在搜索将被翻译成的类似内容
UPDATE parameter
SET VALUE = REPLACE(VALUE, 'rampUpTime', 'setupTime')
WHERE VALUE LIKE '%rampUpTime%';
Liquibase 不提供 REPLACE
,但它为 <update>
标签提供 valueComputed
属性。
我认为以下应该可以解决问题:
<changeSet author="faf" id="29.10.19-16:34-001">
<update tableName="PARAMETER">
<column name="VALUE" type="varchar(64)" valueComputed="REPLACE(VALUE, 'rampUpTime', 'setupTime')" />
<where>VALUE LIKE '%rampUpTime%'</where>
</update>
</changeSet>
Liquibase 提供了更新列中整个值的更新功能。还有一种方法可以只替换一部分值吗?或者我必须使用普通的 sql 语句吗?
列中的值如下所示:
downtime = maintenanceTime + rampUpTime + repairTime;
打电话时
<changeSet author="faf" id="29.10.19-16:34-001">
<update tableName="PARAMETER">
<column name="VALUE" type="varchar(64)" value="setupTime" />
<where>VALUE LIKE '%rampUpTime%'</where>
</update>
</changeSet>
它把它翻译成
UPDATE parameter set VALUE = 'setupTime' where VALUE like '%rampUpTime%'
我正在搜索将被翻译成的类似内容
UPDATE parameter
SET VALUE = REPLACE(VALUE, 'rampUpTime', 'setupTime')
WHERE VALUE LIKE '%rampUpTime%';
Liquibase 不提供 REPLACE
,但它为 <update>
标签提供 valueComputed
属性。
我认为以下应该可以解决问题:
<changeSet author="faf" id="29.10.19-16:34-001">
<update tableName="PARAMETER">
<column name="VALUE" type="varchar(64)" valueComputed="REPLACE(VALUE, 'rampUpTime', 'setupTime')" />
<where>VALUE LIKE '%rampUpTime%'</where>
</update>
</changeSet>