create or replace view v_users as
select
	users.id,
    coalesce(roles.id,'') as role_id, 
	coalesce(roles.name,'') as role_name,
    users.formation_level_id,
    formation_levels.name as formation_level_name,
    users.place_id,
    places.name as place_name,
    users.name,
    users.email,
    users.phone,
    users.image,
    users.document_number,
    users.notifications,
    users.status,
    users.username,
    users.language
from users
left join formation_levels on formation_levels.id = users.formation_level_id
left join places on places.id = users.place_id
left join model_has_roles on model_has_roles.model_id = users.id
left join roles on roles.id = model_has_roles.role_id;