--liquibase formatted sql

--changeset cyril:inventory
ALTER TABLE `inventory`
    ADD COLUMN `price` DECIMAL(14, 2) NULL AFTER `qty`,
    ADD COLUMN `priceUnit` VARCHAR(5) NULL AFTER `price`,
    ADD COLUMN `warehouseId` INT NOT NULL AFTER `stockInLineId`,
    ADD CONSTRAINT FK_INVENTORY_STOCKINLINEID FOREIGN KEY (stockInLineId) REFERENCES stock_in_line (id),
    ADD CONSTRAINT FK_INVENTORY_WAREHOUSEID FOREIGN KEY (warehouseId) REFERENCES warehouse (id);

CREATE TABLE `inventory_lot_no`
(
    `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',
    `inventoryId` INT      NOT NULL,
    `lotNo`       VARCHAR(30) NULL,
    `qrCodeJson`  JSON NULL,
    CONSTRAINT pk_inventory_lot_no PRIMARY KEY (id),
    CONSTRAINT FK_INVENTORY_LOT_NO_INVENTORYID FOREIGN KEY (inventoryId) REFERENCES inventory (id)
);