--liquibase formatted sql

--changeset fpsms:create qc_result_measurement
CREATE TABLE `qc_result_measurement`
(
    `id`             INT            NOT NULL AUTO_INCREMENT,
    `created`        DATETIME       NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `createdBy`      VARCHAR(30)    NULL,
    `version`        INT            NOT NULL DEFAULT 0,
    `modified`       DATETIME       NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `modifiedBy`     VARCHAR(30)    NULL,
    `deleted`        TINYINT(1)     NOT NULL DEFAULT 0,
    `qcResultId`     INT            NOT NULL,
    `stockInLineId`  INT            NULL,
    `qcType`         VARCHAR(45)    NOT NULL,
    `orderRefCode`   VARCHAR(100)   NULL,
    `measureType`    VARCHAR(45)    NOT NULL,
    `value`          DECIMAL(14, 2) NULL,
    `unit`           VARCHAR(20)    NULL,
    CONSTRAINT PK_QC_RESULT_MEASUREMENT PRIMARY KEY (`id`),
    CONSTRAINT FK_QCRM_TO_QC_RESULT_ON_QC_RESULT_ID
        FOREIGN KEY (`qcResultId`) REFERENCES `qc_result` (`id`),
    CONSTRAINT FK_QCRM_TO_STOCK_IN_LINE_ON_STOCK_IN_LINE_ID
        FOREIGN KEY (`stockInLineId`) REFERENCES `stock_in_line` (`id`)
);
