-- liquibase formatted sql
-- changeset enson:altertable_warehouse


ALTER TABLE do_pick_order_record
  ADD COLUMN pick_order_code      VARCHAR(50)   NULL AFTER pick_order_id,
  ADD COLUMN delivery_order_code  VARCHAR(50)   NULL AFTER do_order_id,
  ADD COLUMN handler_name         VARCHAR(100)  NULL AFTER handled_by,
  ADD COLUMN loading_sequence     INT           NULL AFTER ShopName;


ALTER TABLE do_pick_order
  ADD COLUMN pick_order_code      VARCHAR(50)   NULL AFTER pick_order_id,
  ADD COLUMN delivery_order_code  VARCHAR(50)   NULL AFTER do_order_id,
  ADD COLUMN handler_name         VARCHAR(100)  NULL AFTER handled_by,
  ADD COLUMN loading_sequence     INT           NULL AFTER ShopName;

ALTER TABLE do_pick_order_record
  MODIFY COLUMN id                       INT           NOT NULL AUTO_INCREMENT FIRST,
  MODIFY COLUMN pick_order_id            INT           NULL  AFTER id,
  MODIFY COLUMN do_order_id              INT           NULL  AFTER pick_order_id,
  MODIFY COLUMN truck_id                 INT           NULL  AFTER do_order_id,
  MODIFY COLUMN shop_id                  INT           NULL  AFTER truck_id,
  MODIFY COLUMN store_id                 VARCHAR(10)   NULL  AFTER shop_id,
  MODIFY COLUMN RequiredDeliveryDate     DATE          NULL  AFTER store_id,
  MODIFY COLUMN truck_departure_time     TIME          NULL  AFTER RequiredDeliveryDate,
  MODIFY COLUMN TruckLanceCode           VARCHAR(50)   NULL  AFTER truck_departure_time,
  MODIFY COLUMN ShopCode                 VARCHAR(50)   NULL  AFTER TruckLanceCode,
  MODIFY COLUMN ShopName                 VARCHAR(255)  NULL  AFTER ShopCode,
  MODIFY COLUMN loading_sequence         INT           NULL  AFTER ShopName,
  MODIFY COLUMN delivery_order_code      VARCHAR(50)   NULL  AFTER loading_sequence,
  MODIFY COLUMN pick_order_code          VARCHAR(50)   NULL  AFTER delivery_order_code,
  MODIFY COLUMN ticket_no                VARCHAR(50)   NULL  AFTER pick_order_code,
  MODIFY COLUMN ticket_release_time      DATETIME      NULL  AFTER ticket_no,
  MODIFY COLUMN ticketCompleteDateTime   DATETIME      NULL  AFTER ticket_release_time,
  MODIFY COLUMN ticket_status            ENUM('pending','released','completed') NULL AFTER ticketCompleteDateTime,
  MODIFY COLUMN handled_by               INT           NULL  AFTER ticket_status,
  MODIFY COLUMN handler_name             VARCHAR(100)  NULL  AFTER handled_by,
  MODIFY COLUMN created                  DATETIME      NULL  AFTER handler_name,
  MODIFY COLUMN createdBy                VARCHAR(30)   NULL  AFTER created,
  MODIFY COLUMN version                  INT           NULL  AFTER createdBy,
  MODIFY COLUMN modified                 DATETIME      NULL  AFTER version,
  MODIFY COLUMN modifiedBy               VARCHAR(30)   NULL  AFTER modified,
  MODIFY COLUMN deleted                  TINYINT(1)    NULL  AFTER modifiedBy;

ALTER TABLE do_pick_order
  MODIFY COLUMN id                       INT           NOT NULL AUTO_INCREMENT FIRST,
  MODIFY COLUMN pick_order_id            INT           NULL  AFTER id,
  MODIFY COLUMN do_order_id              INT           NULL  AFTER pick_order_id,
  MODIFY COLUMN truck_id                 INT           NULL  AFTER do_order_id,
  MODIFY COLUMN shop_id                  INT           NULL  AFTER truck_id,
  MODIFY COLUMN store_id                 VARCHAR(10)   NULL  AFTER shop_id,
  MODIFY COLUMN RequiredDeliveryDate     DATE          NULL  AFTER store_id,
  MODIFY COLUMN truck_departure_time     TIME          NULL  AFTER RequiredDeliveryDate,
  MODIFY COLUMN TruckLanceCode           VARCHAR(50)   NULL  AFTER truck_departure_time,
  MODIFY COLUMN ShopCode                 VARCHAR(50)   NULL  AFTER TruckLanceCode,
  MODIFY COLUMN ShopName                 VARCHAR(255)  NULL  AFTER ShopCode,
  MODIFY COLUMN loading_sequence         INT           NULL  AFTER ShopName,
  MODIFY COLUMN delivery_order_code      VARCHAR(50)   NULL  AFTER loading_sequence,
  MODIFY COLUMN pick_order_code          VARCHAR(50)   NULL  AFTER delivery_order_code,
  MODIFY COLUMN ticket_no                VARCHAR(50)   NULL  AFTER pick_order_code,
  MODIFY COLUMN ticket_release_time      DATETIME      NULL  AFTER ticket_no,
  MODIFY COLUMN ticketCompleteDateTime   DATETIME      NULL  AFTER ticket_release_time,
  MODIFY COLUMN ticket_status            ENUM('pending','released','completed') NULL AFTER ticketCompleteDateTime,
  MODIFY COLUMN handled_by               INT           NULL  AFTER ticket_status,
  MODIFY COLUMN handler_name             VARCHAR(100)  NULL  AFTER handled_by,
  MODIFY COLUMN created                  DATETIME      NULL  AFTER handler_name,
  MODIFY COLUMN createdBy                VARCHAR(30)   NULL  AFTER created,
  MODIFY COLUMN version                  INT           NULL  AFTER createdBy,
  MODIFY COLUMN modified                 DATETIME      NULL  AFTER version,
  MODIFY COLUMN modifiedBy               VARCHAR(30)   NULL  AFTER modified,
  MODIFY COLUMN deleted                  TINYINT(1)    NULL  AFTER modifiedBy;