ALTER TABLE `ohrm_project` ADD `status` TINYINT DEFAULT '1';

DROP TABLE IF EXISTS `ohrm_audittrail_time_project_trail`;

CREATE TABLE `ohrm_audittrail_time_project_trail` (
  `action_time` DATETIME,
  `action_owner_id` VARCHAR(6),
  `action_owner_name` TEXT,
  `version_id` BIGINT,
  `affected_entity_id` VARCHAR(20),
  `affected_entity_name` TEXT,
  `action` VARCHAR(255),
  `action_description` TEXT,
  PRIMARY KEY(`action_time`, `action_owner_id`, `version_id`, `affected_entity_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;

INSERT INTO `ohrm_audittrail_module` (`name`) VALUES ('Time');
SET @time_module_id := (SELECT `id` FROM `ohrm_audittrail_module` WHERE `name`='Time');

INSERT INTO `ohrm_audittrail_section` (`name`, `description`, `affected_entity`, `module_id`) VALUES
('TimeProject', 'Project', 'Project', @time_module_id);

SET @time_project_section_id := (SELECT `id` FROM `ohrm_audittrail_section` WHERE `name`='TimeProject' AND `module_id` = @time_module_id);

INSERT INTO `ohrm_audittrail_section_actions` (`section_id`, `action`, `description`) VALUES
(@time_project_section_id, 'ADD PROJECT', 'Add Project'),
(@time_project_section_id, 'UPDATE PROJECT', 'Update Project'),
(@time_project_section_id, 'DELETE PROJECT', 'Delete Project');

INSERT INTO `ohrm_event_listener` (`id`, `event`, `listener_class`, `enabled`, `position`) VALUES (NULL, 'time.project_audit', 'TimeProjectAuditListener', '1', '72');
