ALTER TABLE `package` 
	ADD `notifyBefore` int(10) unsigned NULL;

ALTER TABLE `product`
	ADD `stockable` tinyint(1) unsigned NOT NULL DEFAULT '0',
	ADD `type` tinyint(2) unsigned NOT NULL DEFAULT '0' AFTER `stockable`,
	ADD `color` varchar(20) NULL AFTER `type`;

UPDATE product SET type = isCategory;

CREATE TABLE `stockFill` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `utFill` int(10) unsigned NOT NULL,
  `note` text NOT NULL,
  `userId` int(10) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `userId` (`userId`),
  CONSTRAINT `stockFill_ibfk_1` FOREIGN KEY (`userId`) REFERENCES `user` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `stockChange` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `currentAmount` decimal(10,0) NOT NULL,
  `changeAmount` decimal(10,0) NOT NULL,
  `productId` int(10) unsigned NOT NULL,
  `productSellId` int(10) unsigned DEFAULT NULL,
  `stockFillId` int(11) DEFAULT NULL,
  `utChange` int(10) unsigned NOT NULL,
  `isActual` tinyint(1) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `productSellId` (`productSellId`),
  KEY `productId` (`productId`),
  KEY `stockFillId` (`stockFillId`),
  CONSTRAINT `stockChange_ibfk_1` FOREIGN KEY (`productSellId`) REFERENCES `productSell` (`id`),
  CONSTRAINT `stockChange_ibfk_2` FOREIGN KEY (`productId`) REFERENCES `product` (`id`),
  CONSTRAINT `stockChange_ibfk_3` FOREIGN KEY (`stockFillId`) REFERENCES `stockFill` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE `user` CHANGE `passwordHash` `passwordHash` varchar(60) COLLATE 'utf8_czech_ci' NULL AFTER `username`;
-- $2y$10$i17.g6y.dVYivItd3MM8ruBQ8UIJ4BsLiA9gr.HS6TpHmfZ9dwinO

UPDATE `user` SET `passwordHash` = '$2y$10$i17.g6y.dVYivItd3MM8ruBQ8UIJ4BsLiA9gr.HS6TpHmfZ9dwinO' WHERE `username` = 'imp';
