-- iWork 用印回调日志（DM8）
-- 表：system_iwork_seal_log
-- 序列：system_iwork_seal_log_seq

-- 清理旧对象（若存在）
DROP TABLE IF EXISTS system_iwork_seal_log;

CREATE TABLE system_iwork_seal_log (
    id                 BIGINT      NOT NULL,
    request_id         VARCHAR(128) NOT NULL,
    business_code      VARCHAR(128),
    biz_callback_key   VARCHAR(255),
    status             INTEGER,
    retry_count        INTEGER      DEFAULT 0,
    max_retry          INTEGER,
    last_error_message VARCHAR(512),
    raw_callback       VARCHAR(2000),
    last_callback_time DATETIME,
    creator            VARCHAR(64),
    create_time        DATETIME DEFAULT SYSDATE,
    updater            VARCHAR(64),
    update_time        DATETIME DEFAULT SYSDATE,
    deleted            SMALLINT DEFAULT 0 NOT NULL,
    PRIMARY KEY (id),
    UNIQUE (request_id)
);

COMMENT ON TABLE system_iwork_seal_log IS 'iWork 用印回调日志';
COMMENT ON COLUMN system_iwork_seal_log.id IS '主键';
COMMENT ON COLUMN system_iwork_seal_log.request_id IS 'iWork requestId 唯一标识';
COMMENT ON COLUMN system_iwork_seal_log.business_code IS '业务单号';
COMMENT ON COLUMN system_iwork_seal_log.biz_callback_key IS '业务回调标识';
COMMENT ON COLUMN system_iwork_seal_log.status IS '状态枚举';
COMMENT ON COLUMN system_iwork_seal_log.retry_count IS '已重试次数';
COMMENT ON COLUMN system_iwork_seal_log.max_retry IS '最大重试次数快照';
COMMENT ON COLUMN system_iwork_seal_log.last_error_message IS '最后错误信息';
COMMENT ON COLUMN system_iwork_seal_log.raw_callback IS '回调原文截断';
COMMENT ON COLUMN system_iwork_seal_log.last_callback_time IS '最近回调时间';
COMMENT ON COLUMN system_iwork_seal_log.creator IS '创建者';
COMMENT ON COLUMN system_iwork_seal_log.create_time IS '创建时间';
COMMENT ON COLUMN system_iwork_seal_log.updater IS '更新者';
COMMENT ON COLUMN system_iwork_seal_log.update_time IS '最后更新时间';
COMMENT ON COLUMN system_iwork_seal_log.deleted IS '是否删除';
