-- Parche: permisos de Módulos, Páginas y Logs para el rol Administrador
-- Ejecutar si esas opciones no aparecen en el menú lateral.

INSERT INTO auth.profile (role_id, page_id, can_view, can_create, can_edit, can_delete)
SELECT r.id, p.id, TRUE, TRUE, TRUE, TRUE
FROM auth.roles r
CROSS JOIN auth.page p
WHERE r.name_en IN ('Administrator', 'ADMINISTRADOR', 'ADMIN')
  AND p.path IN ('/security/modules', '/security/pages', '/security/logs', '/organization/companies')
ON CONFLICT (role_id, page_id) DO UPDATE
SET can_view = EXCLUDED.can_view,
    can_create = EXCLUDED.can_create,
    can_edit = EXCLUDED.can_edit,
    can_delete = EXCLUDED.can_delete;
