--liquibase formatted sql
--changeset fai:create_m18_goods_receipt_note_log

CREATE TABLE IF NOT EXISTS `m18_goods_receipt_note_log` (
    `id`                      BIGINT        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',

    `m18_record_id`           BIGINT        NOT NULL COMMENT 'M18 Goods Receipt Note record id',
    `stock_in_line_id`        BIGINT        NOT NULL COMMENT 'Stock-in line this GRN line was created from',
    `purchase_order_line_id`  BIGINT        NOT NULL COMMENT 'Purchase order line id',
    `purchase_order_id`      BIGINT        NOT NULL COMMENT 'Purchase order id',
    `po_code`                 VARCHAR(60)   NULL     DEFAULT NULL COMMENT 'Purchase order code',
    `status`                  TINYINT(1)    NOT NULL COMMENT 'Whether M18 API returned success',
    `message`                 VARCHAR(1000) NULL     DEFAULT NULL COMMENT 'Optional message from M18',

    CONSTRAINT pk_m18_goods_receipt_note_log PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
