PostgreSQL update table then insert on another table
You can use a data modifying CTE to do this in a single statement:
with changed_user as (
  UPDATE users 
    SET free_shipping_until = spu.created_at::date + interval '1 year'
  FROM shipping_priority_users AS spu
  WHERE spu.role_id = #{role.id} 
    and users.id = spu.user_id 
    and spu.created_at is not null
  returning *
) 
insert into log (user_id, created_at, data)
select id, 
       current_timestamp, 
       jsonb_build_object('free_shipping_until', array[null, free_shipping_until::text])
from changed_user;

from changed_user