-- liquibase formatted sql

-- changeset cyril:update bom
ALTER TABLE `bom`
    CHANGE COLUMN `name` `name` VARCHAR(100) NOT NULL ;


ALTER TABLE `bom_material`
    ADD COLUMN `itemName` VARCHAR(100) NULL AFTER `itemId`,
    ADD COLUMN `uomName`  VARCHAR(100) NULL AFTER `uomId`,
    ADD COLUMN `remarks`  VARCHAR(1000) NULL AFTER `bomId`
;

ALTER TABLE `bom_material`
    DROP FOREIGN KEY `FK_BOM_MATERIAL_ON_ITEMID`,
    DROP FOREIGN KEY `FK_BOM_MATERIAL_ON_UOMID`;
ALTER TABLE `bom_material`
    CHANGE COLUMN `itemId` `itemId` INT NULL,
    CHANGE COLUMN `uomId` `uomId` INT NULL;
ALTER TABLE `bom_material`
    ADD CONSTRAINT `FK_BOM_MATERIAL_ON_ITEMID`
        FOREIGN KEY (`itemId`)
            REFERENCES `items` (`id`),
    ADD CONSTRAINT `FK_BOM_MATERIAL_ON_UOMID`
        FOREIGN KEY (`uomId`)
            REFERENCES `uom_conversion` (`id`);
