ALTER TABLE settings_data
ADD COLUMN contacts jsonb NOT NULL DEFAULT '{}';

UPDATE settings_data
SET 
    contacts = jsonb_set(contacts, '{emails}'::text[], to_jsonb(emails))
WHERE 
    array_length(emails, 1) > 0;

UPDATE settings_data
SET 
    contacts = jsonb_set(contacts, '{phones}'::text[], jsonb_build_array(phone))
WHERE 
    phone IS NOT NULL;
