SET @data_group_name = 'pbi_reports';

INSERT INTO `ohrm_data_group` (`id`, `name`, `description`, `can_read`, `can_create`, `can_update`, `can_delete`) VALUES (NULL, @data_group_name, 'Power BI - Advanced Reports', '1', '0', '0', '0'); 

SET @bi_reports_data_group_id = (SELECT `id` FROM `ohrm_data_group` WHERE `name` =  @data_group_name);

SET @admin_user_role_id = (SELECT `id` FROM `ohrm_user_role` WHERE `name`='Admin');
SET @ess_user_role_id = (SELECT `id` FROM `ohrm_user_role` WHERE `name`='ESS');
SET @supervisor_user_role_id = (SELECT `id` FROM `ohrm_user_role` WHERE `name`='Supervisor');

INSERT INTO `ohrm_user_role_data_group` (`id`, `user_role_id`, `data_group_id`, `can_read`, `can_create`, `can_update`, `can_delete`, `self`, `restriction_id`) VALUES 
(NULL, @admin_user_role_id, @bi_reports_data_group_id, '1', '0', '0', '0', '0', NULL),
(NULL, @ess_user_role_id, @bi_reports_data_group_id, '0', '0', '0', '0', '0', NULL),
(NULL, @supervisor_user_role_id, @bi_reports_data_group_id, '0', '0', '0', '0', '0', NULL);
