--liquibase formatted sql
--changeset derek:update suggested pick lot

ALTER TABLE `job_order_bom_material`
DROP CONSTRAINT `FK_JOBM_TO_SUGGESTED_PICK_LOT_ON_SUGGESTED_PICK_LOT_ID`;

DROP TABLE `suggested_pick_lot`;
CREATE TABLE `suggested_pick_lot`
(
    `id`             INT          NOT NULL AUTO_INCREMENT,
    `created`        DATETIME     NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `createdBy`      VARCHAR(30)  NULL     DEFAULT NULL,
    `version`        INT          NOT NULL DEFAULT '0',
    `modified`       DATETIME     NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `modifiedBy`     VARCHAR(30)  NULL     DEFAULT NULL,
    `deleted`        TINYINT(1)   NOT NULL DEFAULT '0',
    `type`           VARCHAR(100) NOT NULL,
    `stockOutLineId` INT          NULL,
    `suggestedLotLineId` INT          NOT NULL,
    CONSTRAINT pk_suggested_pick_lot PRIMARY KEY (id),
    CONSTRAINT `FK_SUGGESTED_PICK_LOT_ON_STOCKOUTLINEID` FOREIGN KEY (`stockOutLineId`) REFERENCES `stock_out_line` (`id`),
    CONSTRAINT `FK_SUGGESTED_PICK_LOT_ON_SUGGESTEDLOTLINEID` FOREIGN KEY (`suggestedLotLineId`) REFERENCES `inventory_lot_line` (`id`)
);

ALTER TABLE `job_order_bom_material`
ADD CONSTRAINT FK_JOBM_TO_SUGGESTED_PICK_LOT_ON_SUGGESTED_PICK_LOT_ID FOREIGN KEY (`suggestedPickLotId`) REFERENCES `suggested_pick_lot` (`id`);