/* create dummy product with sku: HireJobCharge */


ALTER TABLE `hire` ADD `pONo` VARCHAR(100) NULL DEFAULT NULL AFTER `hireStatusId`,
ADD INDEX(`pONo`);

ALTER TABLE `hireiteminstance` ADD `period` DOUBLE(3,1) NOT NULL DEFAULT '0' AFTER `returnedDate`,
ADD INDEX(`period`);

ALTER TABLE `order` CHANGE `period` `period` DOUBLE(3,1) NOT NULL DEFAULT '0';


ALTER TABLE `partinstance` ADD `hourUsage` VARCHAR(255) NULL DEFAULT NULL AFTER `hireId`,
ADD INDEX(`hourUsage`);

ALTER TABLE `hireiteminstance` ADD `hourOut` VARCHAR(255) NULL DEFAULT NULL AFTER `unitPrice`,
ADD `hourIn` VARCHAR(255) NULL DEFAULT NULL AFTER `hourOut`;
ALTER TABLE `hireiteminstance` ADD INDEX(`hourOut`);
ALTER TABLE `hireiteminstance` ADD INDEX(`hourIn`);


INSERT INTO product (`sku`, `name`, `active`, `created`, `createdById`, `updated`, `updatedById`)
VALUES ('HireJob', 'Hire Job', 1, NOW(), 10, NOW(), 10);

ALTER TABLE `taskitem` CHANGE `partInstanceId` `hireItemInstanceId` INT(10) NOT NULL;
ALTER TABLE `taskitem` ADD `conditionReport` VARCHAR(255) NULL DEFAULT NULL AFTER `hireItemInstanceId`;
ALTER TABLE `taskitem` ADD INDEX(`conditionReport`);

ALTER TABLE `order` ADD `isForHirePartsItem` TINYINT(1) NOT NULL DEFAULT '0' AFTER `hireId`;
ALTER TABLE `order` ADD INDEX(`isForHirePartsItem`);

DROP TABLE IF EXISTS `hirepartsitem`;
CREATE TABLE `hirepartsitem` ( `id` INT(10) NOT NULL AUTO_INCREMENT ,  `productId` INT(10) NULL DEFAULT NULL ,  `orderItemId` INT(10) NULL DEFAULT NULL ,  `partInstanceId` INT(10) NULL DEFAULT NULL ,  `unitPrice` DOUBLE(10,4) NULL DEFAULT NULL ,  `totalPrice` DOUBLE(10,4) NULL DEFAULT NULL ,  `qty` DOUBLE(10,4) NULL DEFAULT NULL ,  `active` TINYINT(1) NOT NULL DEFAULT '1' ,  `created` DATETIME NOT NULL DEFAULT '0001-01-01' ,  `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 `hirepartsitem` ADD `hireId` INT(10) NULL DEFAULT NULL AFTER `id`;
ALTER TABLE `hirepartsitem`
ADD INDEX(`hireId`),
ADD INDEX( `productId`),
ADD INDEX( `orderItemId`),
ADD INDEX( `partInstanceId`),
ADD INDEX( `unitPrice`),
ADD INDEX( `totalPrice`),
ADD INDEX( `qty`),
ADD INDEX( `createdById`),
ADD INDEX( `updatedById`);

ALTER TABLE `hirepartsitem` ADD `itemDescription` VARCHAR(100) NULL DEFAULT NULL AFTER `partInstanceId`;
ALTER TABLE `hirepartsitem` ADD INDEX(`itemDescription`);
