ALTER TABLE `ohrm_request` CHANGE `description` `description` VARCHAR( 6000 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ;
ALTER TABLE `ohrm_request` CHANGE `resolution` `resolution` VARCHAR( 6000 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ;
ALTER TABLE `ohrm_request_comment` CHANGE `comment` `comment` VARCHAR( 6000 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ;
ALTER TABLE `ohrm_request` ADD `archived` TINYINT( 1 ) NOT NULL DEFAULT '0';

SET @data_group_id := (SELECT id from ohrm_data_group WHERE name = 'employee_requests');
SET @request_owner_id := (SELECT id FROM ohrm_user_role where name = 'RequestOwner');
SET @admin_id := (SELECT id FROM ohrm_user_role where name = 'Admin');

UPDATE ohrm_user_role_data_group SET can_delete = 1 WHERE data_group_id =  @data_group_id AND user_role_id IN (@request_owner_id, @admin_id);

SET @data_group_id := (SELECT id from ohrm_data_group WHERE name = 'my_requests');  
UPDATE ohrm_user_role_data_group SET can_delete = 0 WHERE data_group_id =  @data_group_id;

SET @workflow_id := (SELECT id FROM `ohrm_workflow` WHERE name = 'requestTracker');
INSERT INTO `ohrm_workflow_state_machine`(`workflow`, `state`, `role`, `action`, `resulting_state`) VALUES 
(@workflow_id,'Completed','RequestOwner','Save','Completed'),
(@workflow_id,'Withdrawn','RequestOwner','Save','Withdrawn'),
(@workflow_id,'Completed','Admin','Save','Completed'),
(@workflow_id,'Withdrawn','Admin','Save','Withdrawn'),
(@workflow_id,'Request Info Required','RequestOwner','Submit','In Progress');

UPDATE ohrm_workflow_state_machine SET action = 'SAVE_REMOVED' WHERE workflow = @workflow_id AND state = 'Initial' AND role = 'Admin' AND action = 'Save';
update `ohrm_workflow_state_machine` set action = 'Save' WHERE `workflow` = 'REQUEST' AND `action` = 'SAVE_REMOVED' and `role` = 'RequestOwner';
UPDATE `ohrm_workflow_state_machine` set action = 'Save' WHERE `workflow` = 'REQUEST' AND `action` = 'SAVE_REMOVED' and `role` = 'Requester' and `state` = 'Request Info Required';