INSERT INTO `systemsettings` (`type`, `value`, `description`, `active`, `created`, `createdById`, `updated`, `updatedById`) VALUES
    ('hire_notification_receiving_emails', '', 'Email address used to receive hire notifications, use ";" to separate if more than one email address', 1, NOW(), 10, NOW(), 10);

INSERT INTO `hirestatus` (`name`, `active`, `created`, `createdById`, `updated`, `updatedById`) VALUES
('Partially On Hire', '1', '0001-01-01 00:00:00.000000', '10', CURRENT_TIMESTAMP, '10'),
('Partially Returned', '1', '0001-01-01 00:00:00.000000', '10', CURRENT_TIMESTAMP, '10'),
('Closed', '1', '0001-01-01 00:00:00.000000', '10', CURRENT_TIMESTAMP, '10');
UPDATE `hirestatus` SET `name` = 'All On Hire' WHERE `hirestatus`.`id` = 2;
UPDATE `hirestatus` SET `name` = 'All Returned' WHERE `hirestatus`.`id` = 3;

ALTER TABLE `partinstance`
ADD `hireId` INT(10) NULL DEFAULT NULL AFTER `hiringStatusId`;
ALTER TABLE `partinstance`
ADD INDEX(`hireId`);

ALTER TABLE `hireiteminstance`
ADD `shippedDate` DATETIME NULL DEFAULT NULL AFTER `isReturned`,
ADD `returnedDate` DATETIME NULL DEFAULT NULL AFTER `shippedDate`;
ALTER TABLE `hireiteminstance`
ADD INDEX( `shippedDate`),
ADD INDEX( `returnedDate`);

ALTER TABLE `hire`
ADD `instruction` VARCHAR(500) NULL DEFAULT NULL AFTER `shippmentId`,
ADD `isCheckListConfirmed` TINYINT(1) NOT NULL DEFAULT '0' AFTER `instruction`;
ALTER TABLE `hire`
ADD INDEX( `instruction`),
ADD INDEX( `isCheckListConfirmed`);

ALTER TABLE `hireiteminstance` CHANGE `unitPrice` `unitPrice` DOUBLE(10,4) NOT NULL DEFAULT '0';

ALTER TABLE `hireitem` DROP `unitPrice`, DROP `qtyOrdered`, DROP `totalPrice`;

ALTER TABLE `hireiteminstance` ADD `shippmentId` INT(10) NULL DEFAULT NULL AFTER `productId`;
ALTER TABLE `hireiteminstance` ADD INDEX(`shippmentId`);


ALTER TABLE `hire` DROP `hireStart`;
ALTER TABLE `hire` DROP `hireEnd`;
ALTER TABLE `hire` ADD `hireStart` DATE NOT NULL DEFAULT '0001-01-01'  AFTER `hireNo`;
ALTER TABLE `hire` ADD `hireEnd` DATE NOT NULL DEFAULT '0001-01-01'  AFTER `hireStart`;

