CREATE TABLE `partinstanceforhirestatus` (
`id` INT(10) NOT NULL AUTO_INCREMENT ,
`name` varchar(100) NOT NULL DEFAULT '',
`isReady` TINYINT(1) NOT NULL DEFAULT '0' ,
`isPreHireCheckRequired` TINYINT(1) NOT NULL DEFAULT '0' ,
`isReserved` TINYINT(1) NOT NULL DEFAULT '0' ,
`isOnHire` TINYINT(1) NOT NULL DEFAULT '0' ,
`isPostHireCheckRequired` TINYINT(1) NOT NULL DEFAULT '0' ,
`isLost` TINYINT(1) NOT NULL DEFAULT '0' ,
`isDamaged` TINYINT(1) NOT NULL DEFAULT '0' ,
`actionHelper` varchar(100) NULL DEFAULT NULL,
`active` TINYINT(1) NOT NULL DEFAULT '1' ,
`created` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' ,
`createdById` INT(10) NOT NULL DEFAULT '10' ,
`updated` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
`updatedById` INT(10) NOT NULL DEFAULT '10' ,
PRIMARY KEY  (`id`)) ENGINE = InnoDB;

ALTER TABLE `partinstanceforhirestatus`
ADD INDEX( `name`),
ADD INDEX( `isReady`),
ADD INDEX( `isReserved`),
ADD INDEX( `isPreHireCheckRequired`),
ADD INDEX( `isOnHire`),
ADD INDEX( `isPostHireCheckRequired`),
ADD INDEX( `isLost`),
ADD INDEX( `isDamaged`),
ADD INDEX( `active`);
INSERT INTO `partinstanceforhirestatus` (
`id`, `name`,           `isReady`, `isPreHireCheckRequired`, `isReserved`,  `isOnHire`, `isPostHireCheckRequired`, `isLost`, `isDamaged`,`active`, `created`, `createdById`, `updated`, `updatedById`) VALUES
(1, 'Ready',               '1', '0', '0', '0', '0', '0', '0', '1', NOW(), '10', CURRENT_TIMESTAMP, '10'),
(2, 'Pre Hire Check',      '0', '1', '0', '0', '0', '0', '0', '1', NOW(), '10', CURRENT_TIMESTAMP, '10'),
(3, 'Reserved',            '0', '0', '1', '0', '0', '0', '0', '1', NOW(), '10', CURRENT_TIMESTAMP, '10'),
(4, 'On Hire',             '0', '0', '0', '1', '0', '0', '0', '1', NOW(), '10', CURRENT_TIMESTAMP, '10'),
(5, 'Post Hire Check',     '0', '0', '0', '0', '1', '0', '0', '1', NOW(), '10', CURRENT_TIMESTAMP, '10'),
(6, 'Lost',                '0', '0', '0', '0', '0', '1', '0', '1', NOW(), '10', CURRENT_TIMESTAMP, '10'),
(7, 'Damaged',             '0', '0', '0', '0', '0', '0', '1', '1', NOW(), '10', CURRENT_TIMESTAMP, '10'),
(8, 'Sold',                '0', '0', '0', '0', '0', '0', '0', '1', NOW(), '10', CURRENT_TIMESTAMP, '10');

CREATE TABLE `actionhelper` (
`id` INT(10) NOT NULL AUTO_INCREMENT ,
`actionHelper` varchar(100) NULL DEFAULT NULL,
`entityName` varchar(100) NULL DEFAULT NULL,
`entityId` INT(10) NULL DEFAULT NULL ,
`active` TINYINT(1) NOT NULL DEFAULT '1' ,
`created` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' ,
`createdById` INT(10) NOT NULL DEFAULT '10' ,
`updated` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
`updatedById` INT(10) NOT NULL DEFAULT '10' ,
PRIMARY KEY  (`id`)) ENGINE = InnoDB;

ALTER TABLE `actionhelper`
ADD INDEX( `actionHelper`),
ADD INDEX( `entityName`),
ADD INDEX( `entityId`),
ADD INDEX( `active`);

INSERT INTO `actionhelper` (
`id`, `actionHelper`,         `entityName`,            `entityId`,  `active`, `created`, `createdById`, `updated`, `updatedById`) VALUES
(1, 'TaskHelper',             'PartInstanceForHireStatus', '2','1', NOW(), '10', CURRENT_TIMESTAMP, '10'),
(2, 'TaskHelper',             'PartInstanceForHireStatus', '5','1', NOW(), '10', CURRENT_TIMESTAMP, '10'),
(3, 'StockAdjustmentHelper', 'PartInstanceForHireStatus', '6','1', NOW(), '10', CURRENT_TIMESTAMP, '10'),
(4, 'StockAdjustmentHelper', 'PartInstanceForHireStatus', '8','1', NOW(), '10', CURRENT_TIMESTAMP, '10'),
(5, 'EmailHelper',            'PartInstanceForHireStatus', '6','1', NOW(), '10', CURRENT_TIMESTAMP, '10'),
(6, 'EmailHelper',            'PartInstanceForHireStatus', '7','1', NOW(), '10', CURRENT_TIMESTAMP, '10');


ALTER TABLE `taskitem` ADD `hourOut` VARCHAR(255) NULL DEFAULT NULL AFTER `hireItemInstanceId`;
ALTER TABLE `taskitem` ADD `hourIn` VARCHAR(255) NULL DEFAULT NULL AFTER `hourOut`;
ALTER TABLE `taskitem` ADD INDEX( `hourOut`);
ALTER TABLE `taskitem` ADD INDEX( `hourIn`);


CREATE TABLE `taskitemassets` ( `id` INT(10) NOT NULL AUTO_INCREMENT ,  `taskItemId` INT(10) NOT NULL ,  `fileName` VARCHAR(100) NOT NULL ,  `fileAssetId` VARCHAR(100) NOT NULL ,  `active` TINYINT(1) NOT NULL DEFAULT '1' ,  `created` DATETIME NOT NULL DEFAULT '0001-01-01 00:00:00' ,  `createdById` INT(10) NOT NULL DEFAULT '10' ,  `updated` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,  `updatedById` INT(10) NOT NULL DEFAULT '10' ,    PRIMARY KEY  (`id`)) ENGINE = InnoDB;
ALTER TABLE `taskitemassets`
ADD INDEX( `taskItemId`),
ADD INDEX( `fileName`),
ADD INDEX( `fileAssetId`),
ADD INDEX( `createdById`),
ADD INDEX( `updatedById`);

UPDATE `hirestatus` SET `name` = 'Completed' WHERE `hirestatus`.`id` = 7;