-- liquibase formatted sql
-- changeset cyril:update_stock_in

ALTER TABLE `stock_in`
    ADD COLUMN `stockTakeId` INT NULL DEFAULT NULL AFTER `stockOutId`,
    ADD INDEX `FK_STOCK_IN_ON_STOCKTAKEID` (`stockTakeId` ASC) VISIBLE;
;
ALTER TABLE `stock_in`
    ADD CONSTRAINT `FK_STOCK_IN_ON_STOCKTAKEID`
        FOREIGN KEY (`stockTakeId`)
            REFERENCES `stock_take` (`id`)
            ON DELETE RESTRICT
            ON UPDATE RESTRICT;

ALTER TABLE `stock_in_line`
    ADD COLUMN `stockTakeLineId` INT NULL DEFAULT NULL AFTER `purchaseOrderLineId`,
    ADD INDEX `FK_STOCK_IN_LINE_ON_STOCKTAKELINEID` (`stockTakeLineId` ASC) VISIBLE;
;
ALTER TABLE `stock_in_line`
    ADD CONSTRAINT `FK_STOCK_IN_LINE_ON_STOCKTAKELINEID`
        FOREIGN KEY (`stockTakeLineId`)
            REFERENCES `stock_take_line` (`id`)
            ON DELETE RESTRICT
            ON UPDATE RESTRICT;
