--liquibase formatted sql

--changeset enson:update pick_order_group

CREATE TABLE `pick_execution_issue` (
   `id` int NOT NULL AUTO_INCREMENT,
   `pick_order_id` int NOT NULL,
   `pick_order_code` varchar(50) NOT NULL,
   `pick_order_create_date` date DEFAULT NULL,
   `pick_execution_date` date DEFAULT NULL,
   `pick_order_line_id` int NOT NULL,
   `item_id` int NOT NULL,
   `item_code` varchar(50) DEFAULT NULL,
   `item_description` varchar(255) DEFAULT NULL,
   `lot_id` int DEFAULT NULL,
   `lot_no` varchar(50) DEFAULT NULL,
   `store_location` varchar(100) DEFAULT NULL,
   `required_qty` decimal(10,2) DEFAULT NULL,
   `actual_pick_qty` decimal(10,2) DEFAULT NULL,
   `miss_qty` decimal(10,2) DEFAULT '0.00',
   `bad_item_qty` decimal(10,2) DEFAULT '0.00',
   `issue_remark` text,
   `picker_name` varchar(100) DEFAULT NULL,
   `handle_status` enum('pending','handled','resolved') DEFAULT 'pending',
   `handle_date` date DEFAULT NULL,
   `handled_by` int DEFAULT NULL,
   `created` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
   `createdBy` varchar(30) DEFAULT NULL,
   `version` int NOT NULL DEFAULT '0',
   `modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
   `modifiedBy` varchar(30) DEFAULT NULL,
   `deleted` tinyint(1) NOT NULL DEFAULT '0',
   PRIMARY KEY (`id`),
   KEY `FK_PICK_EXECUTION_ISSUE_ON_PICK_ORDER` (`pick_order_id`),
   KEY `FK_PICK_EXECUTION_ISSUE_ON_PICK_ORDER_LINE` (`pick_order_line_id`),
   KEY `FK_PICK_EXECUTION_ISSUE_ON_ITEM` (`item_id`),
   KEY `FK_PICK_EXECUTION_ISSUE_ON_LOT` (`lot_id`),
   KEY `FK_PICK_EXECUTION_ISSUE_ON_HANDLED_BY` (`handled_by`),
   CONSTRAINT `FK_PICK_EXECUTION_ISSUE_ON_HANDLED_BY` FOREIGN KEY (`handled_by`) REFERENCES `user` (`id`),
   CONSTRAINT `FK_PICK_EXECUTION_ISSUE_ON_ITEM` FOREIGN KEY (`item_id`) REFERENCES `items` (`id`),
   CONSTRAINT `FK_PICK_EXECUTION_ISSUE_ON_LOT` FOREIGN KEY (`lot_id`) REFERENCES `inventory_lot` (`id`),
   CONSTRAINT `FK_PICK_EXECUTION_ISSUE_ON_PICK_ORDER` FOREIGN KEY (`pick_order_id`) REFERENCES `pick_order` (`id`),
   CONSTRAINT `FK_PICK_EXECUTION_ISSUE_ON_PICK_ORDER_LINE` FOREIGN KEY (`pick_order_line_id`) REFERENCES `pick_order_line` (`id`)
 ) ENGINE=InnoDB AUTO_INCREMENT=39 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci