Skip to content

tms_drivers UPDATE driver details

Update phone number inside of the details JSON row:

UPDATE driver
SET details = pgp_sym_encrypt(
    jsonb_set(
        COALESCE(pgp_sym_decrypt(details, '<DRIVER_DETAILS_ENCRYPTION_KEY>')::jsonb, '{}'::jsonb),
        '{phone_number}',
        '"+35812345678"'
    )::text,
    '<DRIVER_DETAILS_ENCRYPTION_KEY>'
)
WHERE uuid = 'da3742cf-707a-4365-bcac-7a675efe7784'
RETURNING
    index,
    uuid,
    org_uuid,
    company_uuid,
    phone_number,
    deleted_state,
    pgp_sym_decrypt(driver.details, '<DRIVER_DETAILS_ENCRYPTION_KEY>')::jsonb AS details;