I have a jsonb field in a PostgreSQL table and I want to change only the key name, keeping the same value for it.
Currently, I'm doing this in Rails like this:
Event.each do |event|
event.metadata['new_key'] = metadata['old_key']
event.metadata.delete('old_key')
event.save
end
Is there a way to achieve the same result using a single update_all query?