--liquibase formatted sql

--changeset enson:update_truck_and_do_pick_order

ALTER TABLE jo_pick_order 
CHANGE COLUMN second_qr_scan_status match_status enum('pending','scanned','completed'),
CHANGE COLUMN second_qr_scan_by match_by int,
CHANGE COLUMN second_qr_scan_qty match_qty int;

-- 2. Drop hide column
ALTER TABLE jo_pick_order 
DROP COLUMN hide;

-- 3. Add new columns
ALTER TABLE jo_pick_order
ADD COLUMN jobOrderId int,
ADD COLUMN jobOrderCode varchar(255),
ADD COLUMN targetDate datetime,
ADD COLUMN itemCode varchar(255),
ADD COLUMN ticketReleaseTime datetime,
ADD COLUMN ticketCompleteTime datetime,
ADD COLUMN pickOrderCode varchar(255);

-- Modify jo_pick_order_record table
-- 1. Rename columns from second_qr_scan_ to match_
ALTER TABLE jo_pick_order_record 
CHANGE COLUMN second_qr_scan_status match_status enum('pending','scanned','completed'),
CHANGE COLUMN second_qr_scan_by match_by int,
CHANGE COLUMN second_qr_scan_qty match_qty int;

-- 2. Drop hide column
ALTER TABLE jo_pick_order_record 
DROP COLUMN hide;

-- 3. Add new columns
ALTER TABLE jo_pick_order_record
ADD COLUMN jobOrderId int,
ADD COLUMN jobOrderCode varchar(255),
ADD COLUMN targetDate datetime,
ADD COLUMN itemCode varchar(255),
ADD COLUMN ticketReleaseTime datetime,
ADD COLUMN ticketCompleteTime datetime,
ADD COLUMN pickOrderCode varchar(255);