-- =============================================
-- SEAL_CONTRACT_LAUNCH_LOG 建表脚本 (Oracle)
-- 自动整理生成，已合并历史patch字段
-- 执行方式: sqlplus developer/dev123@localhost/XEPDB1 @SEAL_CONTRACT_LAUNCH_LOG.sql
-- =============================================

WHENEVER SQLERROR EXIT SQL.SQLCODE;

BEGIN
    EXECUTE IMMEDIATE 'DROP SEQUENCE SEQ_SEAL_CONTRACT_LAUNCH_LOG';
EXCEPTION
    WHEN OTHERS THEN
        IF SQLCODE != -2289 THEN RAISE; END IF;
END;
/

BEGIN
    EXECUTE IMMEDIATE 'DROP TABLE SEAL_CONTRACT_LAUNCH_LOG CASCADE CONSTRAINTS';
EXCEPTION
    WHEN OTHERS THEN
        IF SQLCODE != -942 THEN RAISE; END IF;
END;
/

CREATE TABLE SEAL_CONTRACT_LAUNCH_LOG (
    ID NUMBER(19) NOT NULL,
    CONTRACT_ID NUMBER(19) NOT NULL,
    ACTION_TYPE VARCHAR2(50 CHAR) NOT NULL,
    ACTION_NAME VARCHAR2(100 CHAR) NOT NULL,
    ACTION_STATUS VARCHAR2(20 CHAR) NOT NULL,
    OPERATOR_NAME VARCHAR2(64 CHAR),
    OPERATOR_PHONE VARCHAR2(32 CHAR),
    ACTION_TIME DATE DEFAULT SYSDATE,
    ACTION_CONTENT VARCHAR2(2000 CHAR),
    CALLBACK_PAYLOAD CLOB,
    REMARK VARCHAR2(1000 CHAR),
    CONSTRAINT PK_SEAL_CONTRACT_LAUNCH_LOG PRIMARY KEY (ID)
);

COMMENT ON TABLE SEAL_CONTRACT_LAUNCH_LOG IS '合同操作日志表';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_LOG.ID IS '主键ID';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_LOG.CONTRACT_ID IS '合同主表ID';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_LOG.ACTION_TYPE IS '动作类型';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_LOG.ACTION_NAME IS '动作名称';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_LOG.ACTION_STATUS IS '动作状态';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_LOG.OPERATOR_NAME IS '操作人';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_LOG.OPERATOR_PHONE IS '操作人手机号';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_LOG.ACTION_TIME IS '操作时间';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_LOG.ACTION_CONTENT IS '操作说明';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_LOG.CALLBACK_PAYLOAD IS '回调或接口报文';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_LOG.REMARK IS '备注';

CREATE INDEX IDX_SC_LOG_CTID ON SEAL_CONTRACT_LAUNCH_LOG (CONTRACT_ID);

CREATE SEQUENCE SEQ_SEAL_CONTRACT_LAUNCH_LOG
    INCREMENT BY 1
    MINVALUE 1
    MAXVALUE 9999999999999999999999999999
    NOCYCLE
    CACHE 20
    NOORDER;

COMMIT;
