ALTER TABLE `ohrm_data_list` ADD COLUMN `meta_data` TEXT;

ALTER TABLE `ohrm_data_list_settings` ADD COLUMN `meta_data` TEXT;

INSERT INTO ohrm_data_group (name, description, can_read,can_create,can_update,can_delete) VALUES
  ('list_configuration', 'System Configuration - List Configuration', 1, 0, 1, 0);

SELECT id INTO @list_configuration_datagroup_id FROM `ohrm_data_group` WHERE `name` = 'list_configuration';

SET @admin_user_role := (SELECT id FROM ohrm_user_role WHERE `name` = 'Admin');
SET @ess_user_role := (SELECT id FROM ohrm_user_role WHERE `name` = 'ESS');

INSERT INTO ohrm_user_role_data_group (`id`, `user_role_id`, `data_group_id`, `can_read`, `can_create`, `can_update`, `can_delete`, `self`)
VALUES (NULL, @admin_user_role , @list_configuration_datagroup_id, '1', NULL, '1', NULL, '0'),
       (NULL, @admin_user_role , @list_configuration_datagroup_id, '1', NULL, '1', NULL, '1'),
       (NULL, @ess_user_role , @list_configuration_datagroup_id, '1', NULL, '1', NULL, '1');

INSERT INTO ohrm_user_role_type_data_group (`user_role_type_id`, `data_group_id`, `can_read`, `can_create`, `can_update`, `can_delete`) VALUES
  (@ess_user_role, @list_configuration_datagroup_id, 1, 0, 1, 0);


INSERT INTO ohrm_user_role_data_group (`user_role_id`, `data_group_id`, `can_read`, `can_create`, `can_update`, `can_delete`, `self`)
SELECT id, @list_configuration_datagroup_id, 1, NULL, 1, NULL, 1 FROM ohrm_user_role WHERE `type_id` = @ess_user_role AND `is_predefined` = 0;