I need to perform two update operations:
- update change data from string to bool in first case
- recreate tag with new name and data based on other tag
sample data in jsonb column:
[
{ "tax": "yes", "tax_percent": 20, "used_when": "after" },
{ "tax": "no", "tax_percent": 20 },
{ "tax_percent": 20, "used_when": "before" }
]
and now:
"tax" value needs to be updated from yes -> true, no OR null (not exists) means -> false
"used_when" needs to be updated to "using" and if after -> true, if before OR null (not exists) means -> false
so it will look like:
[
{ "tax": true, "tax_percent": 20, "using": true },
{ "tax": false, "tax_percent": 20, "using": false },
{ "tax": false, "tax_percent": 20, "using": false }
]
The values are optional so not all entries will have it, also this is single row in database column so this data in column needs to be updated for each row.