Liquibase offers the update function which updates the whole value in the column. Is there also a way to just replace a part of the value? Or do I have to use plain sql statements for it?
The value in the column looks like this:
downtime = maintenanceTime + rampUpTime + repairTime;
when calling
<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>
it translates it to
UPDATE parameter set VALUE = 'setupTime' where VALUE like '%rampUpTime%'
I'm searching for something similar which will be translated into
UPDATE parameter
SET VALUE = REPLACE(VALUE, 'rampUpTime', 'setupTime')
WHERE VALUE LIKE '%rampUpTime%';
Liquibase doesn't offer REPLACE
, but it offers valueComputed
attribute for an <update>
tag.
I think the following should do the trick:
<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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With