--liquibase formatted sql

--changeset derek:qc check
CREATE TABLE `qc_check` (
    `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',
    `qcItemId` INT(1) NOT NULL,
    `isRange` TINYINT(1) NOT NULL DEFAULT '0',
    `description` VARCHAR(100) NULL,
    `systemInput` TINYINT(1) NOT NULL DEFAULT '0',
    `lowerLimit` DECIMAL(16,2) NULL,
    `upperLimit` DECIMAL(16,2) NULL,
    `itemId` INT NOT NULL,
    PRIMARY KEY (`id`),
    CONSTRAINT fk_check_qc_items FOREIGN KEY (`qcItemId`) REFERENCES `qc_item` (`id`),
    CONSTRAINT fk_check_items FOREIGN KEY (`itemId`) REFERENCES `items` (`id`)
);

CREATE TABLE `qc_result` (
    `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',
    itemId INT NOT NULL,
    qcCheckId INT NOT NULL,
    `recordDate` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `result_value` DECIMAL(16,2) NULL,
    `result_bool` TINYINT(1) NULL,
    `inspectorId` INT NOT NULL,
    PRIMARY KEY (`id`),
    CONSTRAINT fk_qc_check FOREIGN KEY (`qcCheckId`) REFERENCES `qc_check` (`id`)
);