CREATE TABLE BPM_AGENT_CONDITION (
   ID_                  VARCHAR(64)          NOT NULL,
   SETTING_ID_          VARCHAR(64)          NULL DEFAULT NULL,
   CONDITION_DESC_      VARCHAR(128)         NULL DEFAULT NULL,
   CONDITION_           VARCHAR(4000)        NULL DEFAULT NULL,
   AGENT_ID_            VARCHAR(64)          NULL DEFAULT NULL,
   AGENT_NAME_          VARCHAR(128)         NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_AGENT_CONDITION PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_AGENT_CONDITION IS
'流程代理条件';

COMMENT ON COLUMN BPM_AGENT_CONDITION.SETTING_ID_ IS
'设定ID';

COMMENT ON COLUMN BPM_AGENT_CONDITION.CONDITION_DESC_ IS
'条件描述';

COMMENT ON COLUMN BPM_AGENT_CONDITION.CONDITION_ IS
'条件';

COMMENT ON COLUMN BPM_AGENT_CONDITION.AGENT_ID_ IS
'代理人ID';

COMMENT ON COLUMN BPM_AGENT_CONDITION.AGENT_NAME_ IS
'代理人';

CREATE TABLE BPM_AGENT_DEF (
   ID_                  VARCHAR(64)          NOT NULL,
   SETTING_ID_          VARCHAR(64)          NOT NULL,
   FLOW_KEY_            VARCHAR(64)          NULL DEFAULT NULL,
   FLOW_NAME_           VARCHAR(255)         NULL DEFAULT NULL,
   NODE_ID_             VARCHAR(512)         NULL DEFAULT NULL,
   NODE_NAME_           VARCHAR(128)         NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_AGENT_DEF PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_AGENT_DEF IS
'代理指定流程';

COMMENT ON COLUMN BPM_AGENT_DEF.SETTING_ID_ IS
'设定ID';

COMMENT ON COLUMN BPM_AGENT_DEF.FLOW_KEY_ IS
'流程定义KEY';

COMMENT ON COLUMN BPM_AGENT_DEF.FLOW_NAME_ IS
'流程定义名称';

COMMENT ON COLUMN BPM_AGENT_DEF.NODE_ID_ IS
'节点定义ID(为空的情况,如果指定ID,那么代理只在这些ID的任务生效)';

COMMENT ON COLUMN BPM_AGENT_DEF.NODE_NAME_ IS
'节点名称';

CREATE TABLE BPM_AGENT_SETTING (
   ID_                  VARCHAR(64)          NOT NULL,
   SUBJECT_             VARCHAR(64)          NOT NULL,
   AUTH_ID_             VARCHAR(64)          NOT NULL,
   AUTH_NAME_           VARCHAR(64)          NOT NULL,
   START_DATE_          TIMESTAMP                 NULL,
   END_DATE_            TIMESTAMP                 NULL,
   IS_ENABLED_          CHAR(1)              NOT NULL,
   AGENT_ID_            VARCHAR(64)          NULL DEFAULT NULL,
   AGENT_               VARCHAR(128)         NULL DEFAULT NULL,
   FLOW_KEY_            VARCHAR(64)          NULL DEFAULT NULL,
   TYPE_                INT2                 NULL DEFAULT NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_AGENT_SETTING PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_AGENT_SETTING IS
'流程代理设置';

COMMENT ON COLUMN BPM_AGENT_SETTING.SUBJECT_ IS
'标题';

COMMENT ON COLUMN BPM_AGENT_SETTING.AUTH_ID_ IS
'授权人ID';

COMMENT ON COLUMN BPM_AGENT_SETTING.AUTH_NAME_ IS
'授权人姓名';

COMMENT ON COLUMN BPM_AGENT_SETTING.IS_ENABLED_ IS
'是否有效';

COMMENT ON COLUMN BPM_AGENT_SETTING.AGENT_ID_ IS
'代理人ID';

COMMENT ON COLUMN BPM_AGENT_SETTING.AGENT_ IS
'代理人';

COMMENT ON COLUMN BPM_AGENT_SETTING.FLOW_KEY_ IS
'流程定义KEY';

COMMENT ON COLUMN BPM_AGENT_SETTING.TYPE_ IS
'代理类型(1,全权代理,2,部分代理,3.条件代理)';

COMMENT ON COLUMN BPM_AGENT_SETTING.CREATE_BY_ IS
'创建人ID';

COMMENT ON COLUMN BPM_AGENT_SETTING.CREATE_ORG_ID_ IS
'创建者所属组织ID';

COMMENT ON COLUMN BPM_AGENT_SETTING.UPDATE_BY_ IS
'更新人ID';

COMMENT ON COLUMN BPM_AGENT_SETTING.TENANT_ID_ IS
'租户id';

CREATE TABLE BPM_APPROVAL_ITEM (
   ID_                  VARCHAR(64)          NOT NULL,
   USER_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   DEF_KEY_             VARCHAR(128)         NULL DEFAULT NULL,
   DEF_NAME_            CHAR(10)             NULL DEFAULT NULL,
   TYPE_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   TYPE_                INT2                 NULL DEFAULT NULL,
   EXPRESSION_          VARCHAR(4000)        NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_APPROVAL_ITEM PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_APPROVAL_ITEM IS
'常用语管理';

COMMENT ON COLUMN BPM_APPROVAL_ITEM.USER_ID_ IS
'用户ID';

COMMENT ON COLUMN BPM_APPROVAL_ITEM.DEF_KEY_ IS
'流程定义KEY';

COMMENT ON COLUMN BPM_APPROVAL_ITEM.DEF_NAME_ IS
'流程定义名称';

COMMENT ON COLUMN BPM_APPROVAL_ITEM.TYPE_ID_ IS
'流程分类ID';

COMMENT ON COLUMN BPM_APPROVAL_ITEM.TYPE_ IS
'常用语类型\r\n默认为1=全局\r\n2=流程分类\r\n3=流程\r\n4=个人的常用语';

COMMENT ON COLUMN BPM_APPROVAL_ITEM.EXPRESSION_ IS
'常用语        多个项用回车分开';

COMMENT ON COLUMN BPM_APPROVAL_ITEM.CREATE_BY_ IS
'创建人ID';

COMMENT ON COLUMN BPM_APPROVAL_ITEM.CREATE_ORG_ID_ IS
'创建人所属组织ID';

COMMENT ON COLUMN BPM_APPROVAL_ITEM.UPDATE_BY_ IS
'更新人ID';

CREATE TABLE BPM_APPROVAL_ORG (
   ID_                  VARCHAR(64)          NOT NULL,
   APPROVAL_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   POST_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   ROLE_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   DEPARTMENT_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   CREATE_BY_           VARCHAR(255)         NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_APPROVAL_ORG PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_APPROVAL_ORG IS
'常用语组织';

COMMENT ON COLUMN BPM_APPROVAL_ORG.APPROVAL_ID_ IS
'常用语';

COMMENT ON COLUMN BPM_APPROVAL_ORG.POST_ID_ IS
'岗位';

COMMENT ON COLUMN BPM_APPROVAL_ORG.ROLE_ID_ IS
'角色';

COMMENT ON COLUMN BPM_APPROVAL_ORG.DEPARTMENT_ID_ IS
'部门';

CREATE TABLE BPM_BUS_LINK (
   ID_                  VARCHAR(64)          NOT NULL,
   DEF_ID_              VARCHAR(64)          NULL DEFAULT NULL,
   PROC_INST_ID_        VARCHAR(64)          NULL DEFAULT NULL,
   BUSINESSKEY_         INT8                 NULL DEFAULT NULL,
   BUSINESSKEY_STR_     VARCHAR(64)          NULL DEFAULT NULL,
   SYS_CODE_            VARCHAR(64)          NULL DEFAULT NULL,
   FORM_IDENTIFY_       VARCHAR(64)          NOT NULL,
   START_ID_            VARCHAR(64)          NULL DEFAULT NULL,
   STARTOR_             VARCHAR(128)         NULL DEFAULT NULL,
   CREATE_DATE_         TIMESTAMP                 NULL,
   START_GROUP_ID_      VARCHAR(64)          NULL DEFAULT NULL,
   START_GROUP_         VARCHAR(128)         NULL DEFAULT NULL,
   IS_MAIN_             INT2                 NULL DEFAULT NULL,
   BO_DEF_CODE_         VARCHAR(64)          NULL DEFAULT NULL,
   SAVE_MODE_           VARCHAR(50)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_BUS_LINK PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_BUS_LINK IS
'流程实例与业务数据关系表，每一条记录对应业务的物理表，属于物理表的额外属性';

COMMENT ON COLUMN BPM_BUS_LINK.DEF_ID_ IS
'流程定义ID';

COMMENT ON COLUMN BPM_BUS_LINK.PROC_INST_ID_ IS
'流程实例ID';

COMMENT ON COLUMN BPM_BUS_LINK.BUSINESSKEY_ IS
'业务键';

COMMENT ON COLUMN BPM_BUS_LINK.BUSINESSKEY_STR_ IS
'业务键字符型';

COMMENT ON COLUMN BPM_BUS_LINK.SYS_CODE_ IS
'业务系统编码';

COMMENT ON COLUMN BPM_BUS_LINK.FORM_IDENTIFY_ IS
'表单标识';

COMMENT ON COLUMN BPM_BUS_LINK.START_ID_ IS
'发起人';

COMMENT ON COLUMN BPM_BUS_LINK.STARTOR_ IS
'发起人';

COMMENT ON COLUMN BPM_BUS_LINK.START_GROUP_ID_ IS
'发起组织ID';

COMMENT ON COLUMN BPM_BUS_LINK.START_GROUP_ IS
'发起组织';

COMMENT ON COLUMN BPM_BUS_LINK.IS_MAIN_ IS
'主记录';

COMMENT ON COLUMN BPM_BUS_LINK.BO_DEF_CODE_ IS
'bodefcode数据';

COMMENT ON COLUMN BPM_BUS_LINK.SAVE_MODE_ IS
'保存模式 (boObject,database)';

CREATE TABLE BPM_CALL_LOG (
   ID_                  VARCHAR(64)          NOT NULL,
   SUBJECT_             VARCHAR(600)         NULL DEFAULT NULL,
   PROC_DEF_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   PROC_DEF_KEY_        VARCHAR(128)         NULL DEFAULT NULL,
   TASK_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   SUP_INST_ID_         VARCHAR(64)          NULL DEFAULT '0',
   PROC_INST_ID_        VARCHAR(64)          NULL DEFAULT NULL,
   TASK_KEY_            VARCHAR(64)          NULL DEFAULT NULL,
   TASK_NAME_           VARCHAR(255)         NULL DEFAULT NULL,
   USER_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   EVENT_TYPE_          VARCHAR(64)          NULL DEFAULT NULL,
   URL_                 VARCHAR(255)         NULL DEFAULT NULL,
   DESC_                VARCHAR(255)         NULL DEFAULT NULL,
   INVOKE_MODE_         INT4                 NULL DEFAULT NULL,
   IS_SUCCESS_          INT2                 NULL DEFAULT 0,
   RESPONSE_            VARCHAR(2000)        NULL DEFAULT NULL,
   CALL_TIME_           TIMESTAMP                 NULL,
   PARAMS_              TEXT                 NULL,
   HEADER_              VARCHAR(512)         NULL DEFAULT NULL,
   RETRY_COUNT_         INT4                 NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_CALL_LOG PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_CALL_LOG IS
'restful接口调用日志';

COMMENT ON COLUMN BPM_CALL_LOG.SUBJECT_ IS
' 流程标题';

COMMENT ON COLUMN BPM_CALL_LOG.PROC_DEF_ID_ IS
' 流程定义ID';

COMMENT ON COLUMN BPM_CALL_LOG.PROC_DEF_KEY_ IS
'流程定义Key';

COMMENT ON COLUMN BPM_CALL_LOG.TASK_ID_ IS
'任务ID';

COMMENT ON COLUMN BPM_CALL_LOG.SUP_INST_ID_ IS
'父流程实例ID';

COMMENT ON COLUMN BPM_CALL_LOG.PROC_INST_ID_ IS
'流程实例ID';

COMMENT ON COLUMN BPM_CALL_LOG.TASK_KEY_ IS
'任务定义Key';

COMMENT ON COLUMN BPM_CALL_LOG.TASK_NAME_ IS
'任务名称';

COMMENT ON COLUMN BPM_CALL_LOG.USER_ID_ IS
'调用人员ID';

COMMENT ON COLUMN BPM_CALL_LOG.EVENT_TYPE_ IS
'事件类型';

COMMENT ON COLUMN BPM_CALL_LOG.URL_ IS
'调用地址';

COMMENT ON COLUMN BPM_CALL_LOG.DESC_ IS
'接口描述';

COMMENT ON COLUMN BPM_CALL_LOG.INVOKE_MODE_ IS
'接口调用模式:0:同步，1:异步';

COMMENT ON COLUMN BPM_CALL_LOG.IS_SUCCESS_ IS
'是否调用成功';

COMMENT ON COLUMN BPM_CALL_LOG.RESPONSE_ IS
'调用结果';

COMMENT ON COLUMN BPM_CALL_LOG.PARAMS_ IS
'请求参数';

COMMENT ON COLUMN BPM_CALL_LOG.HEADER_ IS
'请求头';

COMMENT ON COLUMN BPM_CALL_LOG.RETRY_COUNT_ IS
'重试次数';

CREATE TABLE BPM_CHECK_OPINION (
   ID_                  VARCHAR(64)          NOT NULL,
   PROC_DEF_ID_         VARCHAR(64)          NOT NULL,
   SUP_INST_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   PROC_INST_ID_        VARCHAR(64)          NOT NULL,
   TASK_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   TASK_KEY_            VARCHAR(64)          NULL DEFAULT NULL,
   TASK_NAME_           VARCHAR(255)         NULL DEFAULT NULL,
   TOKEN_               VARCHAR(64)          NULL DEFAULT NULL,
   QUALFIEDS_           TEXT                 NULL DEFAULT NULL,
   QUALFIED_NAMES_      TEXT                 NULL DEFAULT NULL,
   AUDITOR_             VARCHAR(64)          NULL DEFAULT NULL,
   AUDITOR_NAME_        VARCHAR(64)          NULL DEFAULT NULL,
   ORG_ID_              VARCHAR(64)          NULL DEFAULT NULL,
   ORG_PATH_            VARCHAR(600)         NULL DEFAULT NULL,
   OPINION_             VARCHAR(4000)        NULL DEFAULT NULL,
   STATUS_              VARCHAR(40)          NOT NULL,
   FORM_DEF_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   FORM_NAME_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   ASSIGN_TIME_         TIMESTAMP                 NULL,
   COMPLETE_TIME_       TIMESTAMP                 NULL,
   DUR_MS_              INT8                 NULL DEFAULT NULL,
   FILES_               VARCHAR(4000)        NULL DEFAULT NULL,
   INTERPOSE_           INT2                 NULL DEFAULT NULL,
   IS_DELE_             INT4                 NOT NULL DEFAULT 0,
   IS_READ_             INT4                 NOT NULL DEFAULT 0,
   AGENT_LEADER_ID_     VARCHAR(64)          NULL DEFAULT NULL,
   PROP1_               VARCHAR(200)         NULL DEFAULT NULL,
   PROP2_               VARCHAR(200)         NULL DEFAULT NULL,
   PROP3_               VARCHAR(200)         NULL DEFAULT NULL,
   PROP4_               VARCHAR(200)         NULL DEFAULT NULL,
   PROP5_               VARCHAR(200)         NULL DEFAULT NULL,
   PROP6_               TEXT                 NULL,
   Z_FILES_             VARCHAR(1000)        NULL DEFAULT NULL,
   FORM_DATA_           TEXT                 NULL,
   PARENT_TASK_ID_      VARCHAR(64)          NULL DEFAULT NULL,
   SIGN_TYPE_           VARCHAR(64)          NULL DEFAULT NULL,
   SKIP_TYPE_           VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_CHECK_OPINION PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_CHECK_OPINION IS
'流程审批意见';

COMMENT ON COLUMN BPM_CHECK_OPINION.PROC_DEF_ID_ IS
'流程定义ID';

COMMENT ON COLUMN BPM_CHECK_OPINION.SUP_INST_ID_ IS
'父流程实例ID';

COMMENT ON COLUMN BPM_CHECK_OPINION.PROC_INST_ID_ IS
'流程实例ID';

COMMENT ON COLUMN BPM_CHECK_OPINION.TASK_ID_ IS
'任务ID';

COMMENT ON COLUMN BPM_CHECK_OPINION.TASK_KEY_ IS
'任务定义Key';

COMMENT ON COLUMN BPM_CHECK_OPINION.TASK_NAME_ IS
'任务名称';

COMMENT ON COLUMN BPM_CHECK_OPINION.TOKEN_ IS
'任务令牌';

COMMENT ON COLUMN BPM_CHECK_OPINION.QUALFIEDS_ IS
'有审批资格用户ID串';

COMMENT ON COLUMN BPM_CHECK_OPINION.QUALFIED_NAMES_ IS
'有审批资格用户名称串';

COMMENT ON COLUMN BPM_CHECK_OPINION.AUDITOR_ IS
'执行人ID';

COMMENT ON COLUMN BPM_CHECK_OPINION.AUDITOR_NAME_ IS
'执行人名';

COMMENT ON COLUMN BPM_CHECK_OPINION.ORG_ID_ IS
'组织ID';

COMMENT ON COLUMN BPM_CHECK_OPINION.ORG_PATH_ IS
'组织全路径';

COMMENT ON COLUMN BPM_CHECK_OPINION.OPINION_ IS
'审批意见';

COMMENT ON COLUMN BPM_CHECK_OPINION.STATUS_ IS
'审批状态。start=发起流程；awaiting_check=待审批；agree=同意；against=反对；return=驳回；abandon=弃权；retrieve=追回';

COMMENT ON COLUMN BPM_CHECK_OPINION.FORM_DEF_ID_ IS
'表单定义ID';

COMMENT ON COLUMN BPM_CHECK_OPINION.FORM_NAME_ IS
'表单名';

COMMENT ON COLUMN BPM_CHECK_OPINION.FILES_ IS
'附件';

COMMENT ON COLUMN BPM_CHECK_OPINION.INTERPOSE_ IS
'是否干预';

COMMENT ON COLUMN BPM_CHECK_OPINION.IS_DELE_ IS
'是否已删，1已删除，0未删除';

COMMENT ON COLUMN BPM_CHECK_OPINION.IS_READ_ IS
'0：待阅，1：已阅';

COMMENT ON COLUMN BPM_CHECK_OPINION.AGENT_LEADER_ID_ IS
'被代理的领导人id';

COMMENT ON COLUMN BPM_CHECK_OPINION.PROP1_ IS
'扩展属性1';

COMMENT ON COLUMN BPM_CHECK_OPINION.PROP2_ IS
'扩展属性2';

COMMENT ON COLUMN BPM_CHECK_OPINION.PROP3_ IS
'扩展属性3';

COMMENT ON COLUMN BPM_CHECK_OPINION.PROP4_ IS
'扩展属性4';

COMMENT ON COLUMN BPM_CHECK_OPINION.PROP5_ IS
'扩展属性5';

COMMENT ON COLUMN BPM_CHECK_OPINION.PROP6_ IS
'扩展属性6';

COMMENT ON COLUMN BPM_CHECK_OPINION.Z_FILES_ IS
'正文附件';

COMMENT ON COLUMN BPM_CHECK_OPINION.PARENT_TASK_ID_ IS
'父任务id';

COMMENT ON COLUMN BPM_CHECK_OPINION.SIGN_TYPE_ IS
'任务类型';

COMMENT ON COLUMN BPM_CHECK_OPINION.SKIP_TYPE_ IS
'跳过类型 启动跳过 审批跳过 执行人为空跳过 相同执行人跳过';

CREATE TABLE BPM_CHECK_OPINION_HI (
   ID_                  VARCHAR(64)          NOT NULL,
   PROC_DEF_ID_         VARCHAR(64)          NOT NULL,
   SUP_INST_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   PROC_INST_ID_        VARCHAR(64)          NOT NULL,
   TASK_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   TASK_KEY_            VARCHAR(64)          NULL DEFAULT NULL,
   TASK_NAME_           VARCHAR(255)         NULL DEFAULT NULL,
   TOKEN_               VARCHAR(64)          NULL DEFAULT NULL,
   QUALFIEDS_           TEXT                 NULL DEFAULT NULL,
   QUALFIED_NAMES_      TEXT                 NULL DEFAULT NULL,
   AUDITOR_             VARCHAR(64)          NULL DEFAULT NULL,
   AUDITOR_NAME_        VARCHAR(64)          NULL DEFAULT NULL,
   ORG_ID_              VARCHAR(64)          NULL DEFAULT NULL,
   ORG_PATH_            VARCHAR(600)         NULL DEFAULT NULL,
   OPINION_             VARCHAR(4000)        NULL DEFAULT NULL,
   STATUS_              VARCHAR(40)          NOT NULL,
   FORM_DEF_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   FORM_NAME_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   ASSIGN_TIME_         TIMESTAMP                 NULL,
   COMPLETE_TIME_       TIMESTAMP                 NULL,
   DUR_MS_              INT8                 NULL DEFAULT NULL,
   FILES_               VARCHAR(4000)        NULL DEFAULT NULL,
   INTERPOSE_           INT2                 NULL DEFAULT NULL,
   PROP1_               VARCHAR(200)         NULL DEFAULT NULL,
   PROP2_               VARCHAR(200)         NULL DEFAULT NULL,
   PROP3_               VARCHAR(200)         NULL DEFAULT NULL,
   PROP4_               VARCHAR(200)         NULL DEFAULT NULL,
   PROP5_               VARCHAR(200)         NULL DEFAULT NULL,
   PROP6_               TEXT                 NULL,
   Z_FILES_             VARCHAR(1000)        NULL DEFAULT NULL,
   FORM_DATA_           TEXT                 NULL,
   PARENT_TASK_ID_      VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_CHECK_OPINION_HI PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_CHECK_OPINION_HI IS
'流程审批意见历史';

COMMENT ON COLUMN BPM_CHECK_OPINION_HI.PROC_DEF_ID_ IS
'流程定义ID';

COMMENT ON COLUMN BPM_CHECK_OPINION_HI.SUP_INST_ID_ IS
'父流程实例ID';

COMMENT ON COLUMN BPM_CHECK_OPINION_HI.TASK_ID_ IS
'任务ID';

COMMENT ON COLUMN BPM_CHECK_OPINION_HI.TASK_KEY_ IS
'任务定义Key';

COMMENT ON COLUMN BPM_CHECK_OPINION_HI.TASK_NAME_ IS
'任务名称';

COMMENT ON COLUMN BPM_CHECK_OPINION_HI.TOKEN_ IS
'任务令牌';

COMMENT ON COLUMN BPM_CHECK_OPINION_HI.QUALFIEDS_ IS
'有审批资格用户ID串';

COMMENT ON COLUMN BPM_CHECK_OPINION_HI.QUALFIED_NAMES_ IS
'有审批资格用户名称串';

COMMENT ON COLUMN BPM_CHECK_OPINION_HI.AUDITOR_ IS
'执行人ID';

COMMENT ON COLUMN BPM_CHECK_OPINION_HI.AUDITOR_NAME_ IS
'执行人名';

COMMENT ON COLUMN BPM_CHECK_OPINION_HI.ORG_ID_ IS
'组织ID';

COMMENT ON COLUMN BPM_CHECK_OPINION_HI.ORG_PATH_ IS
'组织全路径';

COMMENT ON COLUMN BPM_CHECK_OPINION_HI.OPINION_ IS
'审批意见';

COMMENT ON COLUMN BPM_CHECK_OPINION_HI.STATUS_ IS
'审批状态。start=发起流程；create=任务创建；agree=同意；against=反对；return=驳回；abandon=弃权；retrieve=追回';

COMMENT ON COLUMN BPM_CHECK_OPINION_HI.FORM_DEF_ID_ IS
'表单定义ID';

COMMENT ON COLUMN BPM_CHECK_OPINION_HI.FORM_NAME_ IS
'表单名';

COMMENT ON COLUMN BPM_CHECK_OPINION_HI.DUR_MS_ IS
'持续时间(ms)';

COMMENT ON COLUMN BPM_CHECK_OPINION_HI.PROP1_ IS
'扩展属性1';

COMMENT ON COLUMN BPM_CHECK_OPINION_HI.PROP2_ IS
'扩展属性2';

COMMENT ON COLUMN BPM_CHECK_OPINION_HI.PROP3_ IS
'扩展属性3';

COMMENT ON COLUMN BPM_CHECK_OPINION_HI.PROP4_ IS
'扩展属性4';

COMMENT ON COLUMN BPM_CHECK_OPINION_HI.PROP5_ IS
'扩展属性5';

COMMENT ON COLUMN BPM_CHECK_OPINION_HI.PROP6_ IS
'扩展属性6';

COMMENT ON COLUMN BPM_CHECK_OPINION_HI.Z_FILES_ IS
'正文附件';

COMMENT ON COLUMN BPM_CHECK_OPINION_HI.PARENT_TASK_ID_ IS
'父任务id';

CREATE TABLE BPM_COMMU_RECEIVER (
   ID_                  VARCHAR(64)          NOT NULL,
   COMMU_ID_            VARCHAR(64)          NULL DEFAULT NULL,
   RECEIVER_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   RECEIVER             VARCHAR(128)         NULL DEFAULT NULL,
   STATUS_              VARCHAR(20)          NULL DEFAULT NULL,
   OPINION_             VARCHAR(512)         NULL DEFAULT NULL,
   RECEIVE_TIME_        TIMESTAMP                 NULL,
   FEEDBACK_TIME_       TIMESTAMP                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_COMMU_RECEIVER PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_COMMU_RECEIVER IS
'任务通知接收人';

COMMENT ON COLUMN BPM_COMMU_RECEIVER.COMMU_ID_ IS
'通知ID';

COMMENT ON COLUMN BPM_COMMU_RECEIVER.RECEIVER_ID_ IS
'接收人ID';

COMMENT ON COLUMN BPM_COMMU_RECEIVER.RECEIVER IS
'接收人';

COMMENT ON COLUMN BPM_COMMU_RECEIVER.STATUS_ IS
'状态';

COMMENT ON COLUMN BPM_COMMU_RECEIVER.OPINION_ IS
'反馈意见';

CREATE TABLE BPM_CPTO_RECEIVER (
   ID_                  VARCHAR(64)          NOT NULL,
   CPTO_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   RECEIVER_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   RECEIVER_            VARCHAR(64)          NULL DEFAULT NULL,
   IS_READ_             INT2                 NULL DEFAULT NULL,
   READ_TIME_           TIMESTAMP                 NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_CPTO_RECEIVER PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_CPTO_RECEIVER IS
'抄送接收人';

COMMENT ON COLUMN BPM_CPTO_RECEIVER.CPTO_ID_ IS
'关联ID';

COMMENT ON COLUMN BPM_CPTO_RECEIVER.RECEIVER_ID_ IS
'接收人ID';

COMMENT ON COLUMN BPM_CPTO_RECEIVER.RECEIVER_ IS
'接收人';

COMMENT ON COLUMN BPM_CPTO_RECEIVER.IS_READ_ IS
'已读';

CREATE TABLE BPM_CUSTOM_SIGNDATA (
   ID_                  VARCHAR(64)          NOT NULL,
   TYPE_                VARCHAR(64)          NULL DEFAULT NULL,
   STATUS_              VARCHAR(64)          NULL DEFAULT NULL,
   PARENT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   PATH_                VARCHAR(3000)        NULL DEFAULT NULL,
   INST_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   NODE_ID_             VARCHAR(128)         NULL DEFAULT NULL,
   TASK_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_CUSTOM_SIGNDATA PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_CUSTOM_SIGNDATA IS
'并行签署';

COMMENT ON COLUMN BPM_CUSTOM_SIGNDATA.TYPE_ IS
'任务类型（并签，顺签，并批）';

COMMENT ON COLUMN BPM_CUSTOM_SIGNDATA.STATUS_ IS
'审批中，完成，二次并签，被撤回，撤回审批中，撤回无待办';

COMMENT ON COLUMN BPM_CUSTOM_SIGNDATA.PARENT_ID_ IS
'父id';

COMMENT ON COLUMN BPM_CUSTOM_SIGNDATA.PATH_ IS
'路径';

COMMENT ON COLUMN BPM_CUSTOM_SIGNDATA.INST_ID_ IS
'实例id';

COMMENT ON COLUMN BPM_CUSTOM_SIGNDATA.NODE_ID_ IS
'节点id';

COMMENT ON COLUMN BPM_CUSTOM_SIGNDATA.TASK_ID_ IS
'任务id';

CREATE TABLE BPM_DEFINITION (
   DEF_ID_              VARCHAR(64)          NOT NULL,
   NAME_                VARCHAR(64)          NOT NULL,
   DEF_KEY_             VARCHAR(64)          NOT NULL,
   DESC_                VARCHAR(1024)        NULL DEFAULT NULL,
   TYPE_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   STATUS_              VARCHAR(40)          NOT NULL,
   TEST_STATUS_         VARCHAR(40)          NOT NULL,
   BPMN_DEF_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   BPMN_DEPLOY_ID_      VARCHAR(64)          NULL DEFAULT NULL,
   VERSION_             INT4                 NULL DEFAULT NULL,
   MAIN_DEF_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   IS_MAIN_             CHAR(1)              NOT NULL,
   REASON_              VARCHAR(1024)        NULL DEFAULT NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   DESIGNER_            VARCHAR(20)          NULL DEFAULT NULL,
   SUPPORT_MOBILE_      INT4                 NULL DEFAULT 0,
   REV_                 INT4                 NOT NULL DEFAULT 1,
   SHOW_URGENT_STATE_   INT4                 NULL DEFAULT NULL,
   IS_READ_REVOKE       VARCHAR(64)          NULL DEFAULT NULL,
   URGENT_MAIL_TEL      TEXT                 NULL,
   URGENT_SMS_TEL       TEXT                 NULL,
   TYPE_NAME_           VARCHAR(64)          NULL DEFAULT NULL,
   SHOW_MODIFY_RECORD_  INT4                 NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_DEFINITION PRIMARY KEY (DEF_ID_)
);

COMMENT ON TABLE BPM_DEFINITION IS
'流程定义';

COMMENT ON COLUMN BPM_DEFINITION.DEF_ID_ IS
'流程定义ID';

COMMENT ON COLUMN BPM_DEFINITION.NAME_ IS
'流程名称';

COMMENT ON COLUMN BPM_DEFINITION.DEF_KEY_ IS
'流程定义KEY';

COMMENT ON COLUMN BPM_DEFINITION.DESC_ IS
'流程描述';

COMMENT ON COLUMN BPM_DEFINITION.TYPE_ID_ IS
'所属分类ID';

COMMENT ON COLUMN BPM_DEFINITION.STATUS_ IS
'状态。草稿、发布、禁用';

COMMENT ON COLUMN BPM_DEFINITION.TEST_STATUS_ IS
'测试状态';

COMMENT ON COLUMN BPM_DEFINITION.BPMN_DEF_ID_ IS
'BPMN - 流程定义ID';

COMMENT ON COLUMN BPM_DEFINITION.BPMN_DEPLOY_ID_ IS
'BPMN - 流程发布ID';

COMMENT ON COLUMN BPM_DEFINITION.VERSION_ IS
'版本 - 当前版本号';

COMMENT ON COLUMN BPM_DEFINITION.MAIN_DEF_ID_ IS
'版本 - 主版本流程ID';

COMMENT ON COLUMN BPM_DEFINITION.IS_MAIN_ IS
'版本 - 是否主版本';

COMMENT ON COLUMN BPM_DEFINITION.REASON_ IS
'版本 - 变更理由';

COMMENT ON COLUMN BPM_DEFINITION.CREATE_BY_ IS
'创建人ID';

COMMENT ON COLUMN BPM_DEFINITION.CREATE_ORG_ID_ IS
'创建者所属组织ID';

COMMENT ON COLUMN BPM_DEFINITION.UPDATE_BY_ IS
'更新人ID';

COMMENT ON COLUMN BPM_DEFINITION.DESIGNER_ IS
'设计器类型';

COMMENT ON COLUMN BPM_DEFINITION.SUPPORT_MOBILE_ IS
'支持手机表单';

COMMENT ON COLUMN BPM_DEFINITION.REV_ IS
'关联锁';

COMMENT ON COLUMN BPM_DEFINITION.SHOW_URGENT_STATE_ IS
'是否显示紧急状态';

COMMENT ON COLUMN BPM_DEFINITION.IS_READ_REVOKE IS
'传阅已阅是否允许撤回';

COMMENT ON COLUMN BPM_DEFINITION.URGENT_MAIL_TEL IS
'人工催办内容邮件模板';

COMMENT ON COLUMN BPM_DEFINITION.URGENT_SMS_TEL IS
'人工催办内容短信模板';

COMMENT ON COLUMN BPM_DEFINITION.SHOW_MODIFY_RECORD_ IS
'是否显示表单留痕';

CREATE TABLE BPM_DEF_ACT (
   ID_                  VARCHAR(64)          NOT NULL,
   AUTHORIZE_ID_        VARCHAR(64)          NULL DEFAULT NULL,
   DEF_KEY_             VARCHAR(64)          NULL DEFAULT NULL,
   DEF_NAME_            VARCHAR(128)         NULL DEFAULT NULL,
   RIGHT_CONTENT_       VARCHAR(128)         NULL DEFAULT NULL,
   TYPE_                VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_DEF_ACT PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_DEF_ACT IS
'流程授权流程定义';

COMMENT ON COLUMN BPM_DEF_ACT.AUTHORIZE_ID_ IS
'流程授权主表ID';

COMMENT ON COLUMN BPM_DEF_ACT.DEF_KEY_ IS
'授权流程KEY';

COMMENT ON COLUMN BPM_DEF_ACT.DEF_NAME_ IS
'授权流程名称';

COMMENT ON COLUMN BPM_DEF_ACT.RIGHT_CONTENT_ IS
'授权内容';

CREATE TABLE BPM_DEF_AUTHORIZE (
   ID_                  VARCHAR(64)          NOT NULL,
   AUTHORIZE_DESC_      VARCHAR(255)         NULL DEFAULT NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATOR_             VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   MULTI_PLE            VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_DEF_AUTHORIZE PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_DEF_AUTHORIZE IS
'流程授权主表';

COMMENT ON COLUMN BPM_DEF_AUTHORIZE.AUTHORIZE_DESC_ IS
'流程授权说明';

COMMENT ON COLUMN BPM_DEF_AUTHORIZE.CREATE_BY_ IS
'创建人ID';

COMMENT ON COLUMN BPM_DEF_AUTHORIZE.CREATOR_ IS
'创建人';

CREATE TABLE BPM_DEF_AUTH_TYPE (
   ID_                  VARCHAR(64)          NOT NULL,
   AUTHORIZE_ID_        VARCHAR(64)          NULL DEFAULT NULL,
   AUTHORIZE_TYPE_      VARCHAR(20)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_DEF_AUTH_TYPE PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_DEF_AUTH_TYPE IS
'流程授权类型';

COMMENT ON COLUMN BPM_DEF_AUTH_TYPE.AUTHORIZE_ID_ IS
'流程授权主表ID';

COMMENT ON COLUMN BPM_DEF_AUTH_TYPE.AUTHORIZE_TYPE_ IS
'流程授权类型定义（management）、启动（start）、实例（instance）和任务（task）';

CREATE TABLE BPM_DEF_DATA (
   ID_                  VARCHAR(64)          NOT NULL,
   DEF_XML_             TEXT                 NULL,
   BPMN_XML_            TEXT                 NULL,
   DEF_JSON_            TEXT                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_DEF_DATA PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_DEF_DATA IS
'流程定义XML数据';

COMMENT ON COLUMN BPM_DEF_DATA.BPMN_XML_ IS
'流程定义XML';

CREATE TABLE BPM_DEF_USER (
   ID_                  VARCHAR(64)          NOT NULL,
   AUTHORIZE_ID_        VARCHAR(64)          NULL DEFAULT NULL,
   OWNER_ID_            VARCHAR(64)          NULL DEFAULT NULL,
   OWNER_NAME_          VARCHAR(128)         NULL DEFAULT NULL,
   RIGHT_TYPE_          VARCHAR(20)          NULL DEFAULT NULL,
   OBJ_TYPE_            VARCHAR(64)          NULL DEFAULT NULL,
   AUTH_ORG_            VARCHAR(255)         NULL DEFAULT NULL,
   AUTH_ORG_NAME_       VARCHAR(255)         NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_DEF_USER PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_DEF_USER IS
'流程授权中用户';

COMMENT ON COLUMN BPM_DEF_USER.AUTHORIZE_ID_ IS
'流程授权主表ID';

COMMENT ON COLUMN BPM_DEF_USER.OWNER_ID_ IS
'授权对象ID';

COMMENT ON COLUMN BPM_DEF_USER.OWNER_NAME_ IS
'授权对象名称';

COMMENT ON COLUMN BPM_DEF_USER.RIGHT_TYPE_ IS
'授权对象类型(角色,用户,岗位等)';

CREATE TABLE BPM_DEPUTY (
   ID_                  VARCHAR(64)          NOT NULL,
   USER_ID_             VARCHAR(64)          NOT NULL,
   USER_NAME_           VARCHAR(64)          NULL DEFAULT NULL,
   AGENT_ID_            VARCHAR(64)          NOT NULL,
   AGENT_NAME_          VARCHAR(64)          NULL DEFAULT NULL,
   IS_MAIL_             INT4                 NULL DEFAULT 1,
   IS_USABLE_           INT4                 NULL DEFAULT 1,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_DEPUTY PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_DEPUTY IS
'流程代理表';

COMMENT ON COLUMN BPM_DEPUTY.USER_ID_ IS
'被代理人id';

COMMENT ON COLUMN BPM_DEPUTY.USER_NAME_ IS
'被代理人姓名';

COMMENT ON COLUMN BPM_DEPUTY.AGENT_ID_ IS
'代理人id';

COMMENT ON COLUMN BPM_DEPUTY.AGENT_NAME_ IS
'代理人姓名';

COMMENT ON COLUMN BPM_DEPUTY.IS_MAIL_ IS
'是否接收邮件(1:接收，0：不接收)';

COMMENT ON COLUMN BPM_DEPUTY.IS_USABLE_ IS
'是否可用（1：启用，0：禁用）';

CREATE TABLE BPM_EXE_STACK (
   ID_                  VARCHAR(64)          NOT NULL,
   PRCO_DEF_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   NODE_ID_             VARCHAR(64)          NOT NULL,
   NODE_NAME_           VARCHAR(128)         NULL DEFAULT NULL,
   START_TIME_          TIMESTAMP                 NULL,
   END_TIME             TIMESTAMP                 NULL,
   IS_MULITI_TASK_      INT2                 NOT NULL,
   PARENT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   PROC_INST_ID_        VARCHAR(64)          NULL DEFAULT NULL,
   NODE_PATH_           VARCHAR(1024)        NULL DEFAULT NULL,
   DEPTH_               INT2                 NULL DEFAULT NULL,
   TASK_TOKEN_          VARCHAR(255)         NULL DEFAULT NULL,
   NODE_TYPE_           VARCHAR(255)         NULL DEFAULT NULL,
   TARGET_NODE_         VARCHAR(20)          NULL DEFAULT NULL,
   TARGET_TOKEN_        VARCHAR(255)         NULL DEFAULT NULL,
   INTERPOSE_           INT2                 NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_EXE_STACK PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_EXE_STACK IS
'流程执行堆栈树';

COMMENT ON COLUMN BPM_EXE_STACK.PRCO_DEF_ID_ IS
'流程定义ID';

COMMENT ON COLUMN BPM_EXE_STACK.NODE_ID_ IS
'节点ID';

COMMENT ON COLUMN BPM_EXE_STACK.NODE_NAME_ IS
'节点名';

COMMENT ON COLUMN BPM_EXE_STACK.IS_MULITI_TASK_ IS
'多实例任务\r\n1=是\r\n0=否';

COMMENT ON COLUMN BPM_EXE_STACK.PARENT_ID_ IS
'父ID';

COMMENT ON COLUMN BPM_EXE_STACK.PROC_INST_ID_ IS
'流程实例ID';

COMMENT ON COLUMN BPM_EXE_STACK.NODE_PATH_ IS
'节点路径\r\n格式如：\r\n0.1.2.\r\n其中2则为本行记录的主键值';

COMMENT ON COLUMN BPM_EXE_STACK.DEPTH_ IS
'节点层';

COMMENT ON COLUMN BPM_EXE_STACK.TASK_TOKEN_ IS
'是针对分发任务时，携带的令牌，方便查找其父任务堆栈';

COMMENT ON COLUMN BPM_EXE_STACK.NODE_TYPE_ IS
'节点类型';

COMMENT ON COLUMN BPM_EXE_STACK.TARGET_NODE_ IS
'驳回时返回节点';

COMMENT ON COLUMN BPM_EXE_STACK.INTERPOSE_ IS
'是否干预执行';

CREATE TABLE BPM_EXE_STACK_EXECUTOR (
   ID_                  VARCHAR(64)          NOT NULL,
   STACK_ID_            VARCHAR(64)          NULL DEFAULT NULL,
   TASK_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   ASSIGNEE_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   END_TIME_            TIMESTAMP                 NULL,
   STATUS_              INT2                 NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_EXE_STACK_EXECUTOR PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_EXE_STACK_EXECUTOR IS
'堆栈执行人';

COMMENT ON COLUMN BPM_EXE_STACK_EXECUTOR.STACK_ID_ IS
'堆栈ID';

COMMENT ON COLUMN BPM_EXE_STACK_EXECUTOR.TASK_ID_ IS
'任务ID';

COMMENT ON COLUMN BPM_EXE_STACK_EXECUTOR.ASSIGNEE_ID_ IS
'执行人';

COMMENT ON COLUMN BPM_EXE_STACK_EXECUTOR.STATUS_ IS
'状态(0,初始,1,完成,2,取消)';

CREATE TABLE BPM_EXE_STACK_HIS (
   ID_                  VARCHAR(64)          NOT NULL,
   PRCO_DEF_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   NODE_ID_             VARCHAR(64)          NOT NULL,
   NODE_NAME_           VARCHAR(128)         NULL DEFAULT NULL,
   START_TIME_          TIMESTAMP                 NULL,
   END_TIME             TIMESTAMP                 NULL,
   IS_MULITI_TASK_      INT2                 NOT NULL,
   PARENT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   PROC_INST_ID_        VARCHAR(64)          NULL DEFAULT NULL,
   NODE_PATH_           VARCHAR(1024)        NULL DEFAULT NULL,
   DEPTH_               INT2                 NULL DEFAULT NULL,
   TASK_TOKEN_          VARCHAR(255)         NULL DEFAULT NULL,
   NODE_TYPE_           VARCHAR(255)         NULL DEFAULT NULL,
   TARGET_NODE_         VARCHAR(20)          NULL DEFAULT NULL,
   TARGET_TOKEN_        VARCHAR(255)         NULL DEFAULT NULL,
   INTERPOSE_           INT2                 NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_EXE_STACK_HIS PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_EXE_STACK_HIS IS
'流程执行堆栈树';

COMMENT ON COLUMN BPM_EXE_STACK_HIS.PRCO_DEF_ID_ IS
'流程定义ID';

COMMENT ON COLUMN BPM_EXE_STACK_HIS.NODE_ID_ IS
'节点ID';

COMMENT ON COLUMN BPM_EXE_STACK_HIS.NODE_NAME_ IS
'节点名';

COMMENT ON COLUMN BPM_EXE_STACK_HIS.IS_MULITI_TASK_ IS
'多实例任务\r\n1=是\r\n0=否';

COMMENT ON COLUMN BPM_EXE_STACK_HIS.PARENT_ID_ IS
'父ID';

COMMENT ON COLUMN BPM_EXE_STACK_HIS.PROC_INST_ID_ IS
'流程实例ID';

COMMENT ON COLUMN BPM_EXE_STACK_HIS.NODE_PATH_ IS
'节点路径\r\n格式如：\r\n0.1.2.\r\n其中2则为本行记录的主键值';

COMMENT ON COLUMN BPM_EXE_STACK_HIS.DEPTH_ IS
'节点层';

COMMENT ON COLUMN BPM_EXE_STACK_HIS.TASK_TOKEN_ IS
'是针对分发任务时，携带的令牌，方便查找其父任务堆栈';

COMMENT ON COLUMN BPM_EXE_STACK_HIS.NODE_TYPE_ IS
'节点类型';

COMMENT ON COLUMN BPM_EXE_STACK_HIS.TARGET_NODE_ IS
'驳回时返回节点';

COMMENT ON COLUMN BPM_EXE_STACK_HIS.INTERPOSE_ IS
'是否干预执行';

CREATE TABLE BPM_EXE_STACK_RELATION (
   RELATION_ID_         VARCHAR(64)          NOT NULL,
   PROC_INST_ID_        VARCHAR(64)          NOT NULL,
   FROM_STACK_ID_       VARCHAR(64)          NOT NULL,
   TO_STACK_ID_         VARCHAR(64)          NOT NULL,
   FROM_NODE_ID_        VARCHAR(64)          NOT NULL,
   TO_NODE_ID_          VARCHAR(64)          NOT NULL,
   RELATION_STATE_      INT2                 NOT NULL DEFAULT 1,
   FROM_NODE_TYPE_      VARCHAR(64)          NOT NULL,
   TO_NODE_TYPE_        VARCHAR(64)          NOT NULL,
   CREATED_TIME_        TIMESTAMP                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_EXE_STACK_RELATION PRIMARY KEY (RELATION_ID_)
);

COMMENT ON TABLE BPM_EXE_STACK_RELATION IS
'堆栈关系表';

COMMENT ON COLUMN BPM_EXE_STACK_RELATION.RELATION_ID_ IS
'关系ID';

COMMENT ON COLUMN BPM_EXE_STACK_RELATION.PROC_INST_ID_ IS
'流程实例ID';

COMMENT ON COLUMN BPM_EXE_STACK_RELATION.FROM_STACK_ID_ IS
'来自堆栈ID';

COMMENT ON COLUMN BPM_EXE_STACK_RELATION.TO_STACK_ID_ IS
'到达堆栈ID';

COMMENT ON COLUMN BPM_EXE_STACK_RELATION.FROM_NODE_ID_ IS
'来自节点';

COMMENT ON COLUMN BPM_EXE_STACK_RELATION.TO_NODE_ID_ IS
'到达节点';

COMMENT ON COLUMN BPM_EXE_STACK_RELATION.RELATION_STATE_ IS
'关系状态：1正常，0回收作废';

COMMENT ON COLUMN BPM_EXE_STACK_RELATION.FROM_NODE_TYPE_ IS
'来自的节点类型';

COMMENT ON COLUMN BPM_EXE_STACK_RELATION.TO_NODE_TYPE_ IS
'到达的节点类型';

CREATE TABLE BPM_EXE_STACK_RELATION_HIS (
   RELATION_ID_         VARCHAR(64)          NOT NULL,
   PROC_INST_ID_        VARCHAR(64)          NOT NULL,
   FROM_STACK_ID_       VARCHAR(64)          NOT NULL,
   TO_STACK_ID_         VARCHAR(64)          NOT NULL,
   FROM_NODE_ID_        VARCHAR(64)          NOT NULL,
   TO_NODE_ID_          VARCHAR(64)          NOT NULL,
   RELATION_STATE_      INT2                 NOT NULL DEFAULT 1,
   FROM_NODE_TYPE_      VARCHAR(64)          NOT NULL,
   TO_NODE_TYPE_        VARCHAR(64)          NOT NULL,
   CREATED_TIME_        TIMESTAMP                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_EXE_STACK_RELATION_HIS PRIMARY KEY (RELATION_ID_)
);

COMMENT ON TABLE BPM_EXE_STACK_RELATION_HIS IS
'堆栈关系历史表';

COMMENT ON COLUMN BPM_EXE_STACK_RELATION_HIS.RELATION_ID_ IS
'关系ID';

COMMENT ON COLUMN BPM_EXE_STACK_RELATION_HIS.PROC_INST_ID_ IS
'流程实例ID';

COMMENT ON COLUMN BPM_EXE_STACK_RELATION_HIS.FROM_STACK_ID_ IS
'来自堆栈ID';

COMMENT ON COLUMN BPM_EXE_STACK_RELATION_HIS.TO_STACK_ID_ IS
'到达堆栈ID';

COMMENT ON COLUMN BPM_EXE_STACK_RELATION_HIS.FROM_NODE_ID_ IS
'来自节点';

COMMENT ON COLUMN BPM_EXE_STACK_RELATION_HIS.TO_NODE_ID_ IS
'到达节点';

COMMENT ON COLUMN BPM_EXE_STACK_RELATION_HIS.RELATION_STATE_ IS
'关系状态：1正常，0回收作废';

COMMENT ON COLUMN BPM_EXE_STACK_RELATION_HIS.FROM_NODE_TYPE_ IS
'来自的节点类型';

COMMENT ON COLUMN BPM_EXE_STACK_RELATION_HIS.TO_NODE_TYPE_ IS
'到达的节点类型';

CREATE TABLE BPM_FORM_MODIFY_RECORD (
   ID_                  VARCHAR(64)          NOT NULL,
   USER_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   USER_NAME_           VARCHAR(128)         NULL DEFAULT NULL,
   INST_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   TASK_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   TASK_NAME_           VARCHAR(128)         NULL DEFAULT NULL,
   NODE_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   MODIFY_TIME_         TIMESTAMP                 NULL,
   IP_                  VARCHAR(64)          NULL DEFAULT NULL,
   DETAIL_              TEXT                 NULL,
   REASON_              TEXT                 NULL DEFAULT NULL,
   REF_ID_              VARCHAR(64)          NULL DEFAULT NULL,
   DATA_                TEXT                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_FORM_MODIFY_RECORD PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_FORM_MODIFY_RECORD IS
'表单修改记录表';

COMMENT ON COLUMN BPM_FORM_MODIFY_RECORD.REF_ID_ IS
'外键（表单记录主键）';

COMMENT ON COLUMN BPM_FORM_MODIFY_RECORD.DATA_ IS
'表单数据';

CREATE TABLE BPM_HR_SCRIPT (
   ID_                  VARCHAR(64)          NOT NULL,
   ALIAS_NAME_          VARCHAR(128)         NULL DEFAULT NULL,
   ALIAS_DESC_          VARCHAR(512)         NULL DEFAULT NULL,
   CLASS_NAME_          VARCHAR(128)         NULL DEFAULT NULL,
   CLASS_INS_NAME_      VARCHAR(128)         NULL DEFAULT NULL,
   METHOD_NAME_         VARCHAR(40)          NULL DEFAULT NULL,
   METHOD_DESC_         VARCHAR(255)         NULL DEFAULT NULL,
   RETURN_TYPE_         VARCHAR(40)          NULL DEFAULT NULL,
   ARGUMENT_            VARCHAR(4000)        NULL DEFAULT NULL,
   ENABLE_              INT2                 NOT NULL,
   TYPE_                INT2                 NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_HR_SCRIPT PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_HR_SCRIPT IS
'系统脚本';

COMMENT ON COLUMN BPM_HR_SCRIPT.ALIAS_NAME_ IS
'脚本的别名';

COMMENT ON COLUMN BPM_HR_SCRIPT.ALIAS_DESC_ IS
'脚本的描叙';

COMMENT ON COLUMN BPM_HR_SCRIPT.CLASS_NAME_ IS
'调用类的路径';

COMMENT ON COLUMN BPM_HR_SCRIPT.CLASS_INS_NAME_ IS
'调用类的对象名';

COMMENT ON COLUMN BPM_HR_SCRIPT.METHOD_NAME_ IS
'调用的方法名';

COMMENT ON COLUMN BPM_HR_SCRIPT.METHOD_DESC_ IS
'调用的方法的描叙';

COMMENT ON COLUMN BPM_HR_SCRIPT.RETURN_TYPE_ IS
'方法返回类型';

COMMENT ON COLUMN BPM_HR_SCRIPT.ARGUMENT_ IS
'方法相关设置';

COMMENT ON COLUMN BPM_HR_SCRIPT.ENABLE_ IS
'是否有效，有效 1，无效 0';

COMMENT ON COLUMN BPM_HR_SCRIPT.TYPE_ IS
'脚本类型，条件脚本 1，别名脚本 2，人员脚本 3';

CREATE TABLE BPM_INST_FORM (
   ID_                  VARCHAR(64)          NOT NULL,
   DEF_ID_              VARCHAR(64)          NULL DEFAULT NULL,
   INST_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   FORM_VALUE_          VARCHAR(255)         NULL DEFAULT NULL,
   NODE_ID_             VARCHAR(255)         NULL DEFAULT NULL,
   FORM_TYPE_           VARCHAR(64)          NULL DEFAULT NULL,
   FORM_CATEGORY_       VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_INST_FORM PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_INST_FORM IS
'记录流程启动时，节点使用的表单';

COMMENT ON COLUMN BPM_INST_FORM.DEF_ID_ IS
'流程定义id';

COMMENT ON COLUMN BPM_INST_FORM.INST_ID_ IS
'流程实例id';

COMMENT ON COLUMN BPM_INST_FORM.FORM_VALUE_ IS
'表单 inner 记录id  frame 记录formValue';

COMMENT ON COLUMN BPM_INST_FORM.NODE_ID_ IS
'节点id';

COMMENT ON COLUMN BPM_INST_FORM.FORM_TYPE_ IS
'表单类型 pc mobile';

COMMENT ON COLUMN BPM_INST_FORM.FORM_CATEGORY_ IS
'url表单 frame  在线表单 inner';

CREATE TABLE BPM_INTERPOSE_RECORED (
   ID_                  VARCHAR(64)          NOT NULL,
   PROC_DEF_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   PROC_INST_ID_        VARCHAR(64)          NOT NULL,
   TASK_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   TASK_NAME_           VARCHAR(255)         NULL DEFAULT NULL,
   AUDITOR_             VARCHAR(64)          NULL DEFAULT NULL,
   AUDITOR_NAME_        VARCHAR(64)          NULL DEFAULT NULL,
   OPINION_             VARCHAR(2000)        NULL DEFAULT NULL,
   STATUS_              VARCHAR(40)          NOT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   COMPLETE_TIME_       TIMESTAMP                 NULL,
   DUR_MS_              INT4                 NULL DEFAULT NULL,
   FILES_               VARCHAR(2000)        NULL DEFAULT NULL,
   IS_DONE_             VARCHAR(4000)        NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_INTERPOSE_RECORED PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_INTERPOSE_RECORED IS
'流程干预记录表';

COMMENT ON COLUMN BPM_INTERPOSE_RECORED.PROC_DEF_ID_ IS
'流程定义ID';

COMMENT ON COLUMN BPM_INTERPOSE_RECORED.PROC_INST_ID_ IS
'流程实例ID';

COMMENT ON COLUMN BPM_INTERPOSE_RECORED.TASK_ID_ IS
'任务ID';

COMMENT ON COLUMN BPM_INTERPOSE_RECORED.TASK_NAME_ IS
'任务名称';

COMMENT ON COLUMN BPM_INTERPOSE_RECORED.AUDITOR_ IS
'执行人ID';

COMMENT ON COLUMN BPM_INTERPOSE_RECORED.AUDITOR_NAME_ IS
'执行人名';

COMMENT ON COLUMN BPM_INTERPOSE_RECORED.STATUS_ IS
'干预动作';

COMMENT ON COLUMN BPM_INTERPOSE_RECORED.DUR_MS_ IS
'持续时间(ms)';

CREATE TABLE BPM_MEETINGROOM (
   ID_                  VARCHAR(64)          NOT NULL,
   NAME_                VARCHAR(100)         NULL DEFAULT NULL,
   NEED_PENDING_        INT2                 NULL DEFAULT NULL,
   PENDING_USER_ID_     VARCHAR(64)          NULL DEFAULT NULL,
   PENDING_USER_NAME_   VARCHAR(100)         NULL DEFAULT NULL,
   SUPPORT_SERVICE_     VARCHAR(500)         NULL DEFAULT NULL,
   LOCATION_            VARCHAR(300)         NULL DEFAULT NULL,
   CAPACITY_            INT4                 NULL DEFAULT NULL,
   MEMO_                VARCHAR(600)         NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_MEETINGROOM PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_MEETINGROOM IS
'会议室';

COMMENT ON COLUMN BPM_MEETINGROOM.NAME_ IS
'会议室名称';

COMMENT ON COLUMN BPM_MEETINGROOM.NEED_PENDING_ IS
'是否需要审批';

COMMENT ON COLUMN BPM_MEETINGROOM.PENDING_USER_ID_ IS
'审批人ID';

COMMENT ON COLUMN BPM_MEETINGROOM.PENDING_USER_NAME_ IS
'审批人';

COMMENT ON COLUMN BPM_MEETINGROOM.SUPPORT_SERVICE_ IS
'支持的服务';

COMMENT ON COLUMN BPM_MEETINGROOM.LOCATION_ IS
'会议室地址';

COMMENT ON COLUMN BPM_MEETINGROOM.CAPACITY_ IS
'会议室容量';

COMMENT ON COLUMN BPM_MEETINGROOM.MEMO_ IS
'会议室备注';

CREATE TABLE BPM_MEETINGROOM_APPOINTMENT (
   ID_                  VARCHAR(64)          NOT NULL,
   MEETINGROOM_ID_      VARCHAR(64)          NULL DEFAULT NULL,
   MEETING_ID_          VARCHAR(64)          NULL DEFAULT NULL,
   MEETING_NAME_        VARCHAR(64)          NULL DEFAULT NULL,
   HOSTESS_NAME_        VARCHAR(64)          NULL DEFAULT NULL,
   APPOINTMENT_BEG_TIME_ TIMESTAMP                 NULL,
   APPOINTMENT_END_TIME_ TIMESTAMP                 NULL,
   APPOINTMENT_STATUS_  INT4                 NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_MEETINGROOM_APPOINTMENT PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_MEETINGROOM_APPOINTMENT IS
'会议室预约';

COMMENT ON COLUMN BPM_MEETINGROOM_APPOINTMENT.MEETING_ID_ IS
'会议id';

COMMENT ON COLUMN BPM_MEETINGROOM_APPOINTMENT.MEETING_NAME_ IS
'会议名称';

COMMENT ON COLUMN BPM_MEETINGROOM_APPOINTMENT.HOSTESS_NAME_ IS
'主持人姓名';

COMMENT ON COLUMN BPM_MEETINGROOM_APPOINTMENT.APPOINTMENT_STATUS_ IS
'预约状态';

CREATE TABLE BPM_MESSAGE_TYPE (
   ID_                  VARCHAR(64)          NOT NULL,
   CLASSIFICATION_CODE_ VARCHAR(100)         NULL DEFAULT NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   IS_PENDING_          INT2                 NULL DEFAULT NULL,
   PENDING_USER_ID_     VARCHAR(100)         NULL DEFAULT NULL,
   PENDING_USER_NAME_   VARCHAR(200)         NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_MESSAGE_TYPE PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_MESSAGE_TYPE IS
'分类管理';

COMMENT ON COLUMN BPM_MESSAGE_TYPE.CLASSIFICATION_CODE_ IS
'分类名称';

COMMENT ON COLUMN BPM_MESSAGE_TYPE.CREATE_BY_ IS
'创建人';

COMMENT ON COLUMN BPM_MESSAGE_TYPE.IS_PENDING_ IS
'是否需要审批';

COMMENT ON COLUMN BPM_MESSAGE_TYPE.PENDING_USER_ID_ IS
'审批人id';

COMMENT ON COLUMN BPM_MESSAGE_TYPE.PENDING_USER_NAME_ IS
'审批人姓名';

CREATE TABLE BPM_MULTI_SCRIPT (
   ID_                  VARCHAR(64)          NOT NULL,
   ALIAS_NAME_          VARCHAR(128)         NULL DEFAULT NULL,
   ALIAS_DESC_          VARCHAR(512)         NULL DEFAULT NULL,
   CLASS_NAME_          VARCHAR(128)         NULL DEFAULT NULL,
   CLASS_INS_NAME_      VARCHAR(128)         NULL DEFAULT NULL,
   METHOD_NAME_         VARCHAR(40)          NULL DEFAULT NULL,
   METHOD_DESC_         VARCHAR(255)         NULL DEFAULT NULL,
   RETURN_TYPE_         VARCHAR(40)          NULL DEFAULT NULL,
   ARGUMENT_            VARCHAR(4000)        NULL DEFAULT NULL,
   ENABLE_              INT2                 NOT NULL,
   TYPE_                INT2                 NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_MULTI_SCRIPT PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_MULTI_SCRIPT IS
'系统脚本';

COMMENT ON COLUMN BPM_MULTI_SCRIPT.ALIAS_NAME_ IS
'脚本的别名';

COMMENT ON COLUMN BPM_MULTI_SCRIPT.ALIAS_DESC_ IS
'脚本的描叙';

COMMENT ON COLUMN BPM_MULTI_SCRIPT.CLASS_NAME_ IS
'调用类的路径';

COMMENT ON COLUMN BPM_MULTI_SCRIPT.CLASS_INS_NAME_ IS
'调用类的对象名';

COMMENT ON COLUMN BPM_MULTI_SCRIPT.METHOD_NAME_ IS
'调用的方法名';

COMMENT ON COLUMN BPM_MULTI_SCRIPT.METHOD_DESC_ IS
'调用的方法的描叙';

COMMENT ON COLUMN BPM_MULTI_SCRIPT.RETURN_TYPE_ IS
'方法返回类型';

COMMENT ON COLUMN BPM_MULTI_SCRIPT.ARGUMENT_ IS
'方法相关设置';

COMMENT ON COLUMN BPM_MULTI_SCRIPT.ENABLE_ IS
'是否有效，有效 1，无效 0';

COMMENT ON COLUMN BPM_MULTI_SCRIPT.TYPE_ IS
'脚本类型，条件脚本 1，别名脚本 2，人员脚本 3';

CREATE TABLE BPM_OFTEN_FLOW (
   ID_                  VARCHAR(64)          NOT NULL,
   DEF_KEY_             VARCHAR(64)          NOT NULL,
   USER_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   USER_NAME_           VARCHAR(128)         NULL DEFAULT NULL,
   ORDER_               INT2                 NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_OFTEN_FLOW PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_OFTEN_FLOW IS
'通用流程';

COMMENT ON COLUMN BPM_OFTEN_FLOW.DEF_KEY_ IS
'流程定义KEY';

COMMENT ON COLUMN BPM_OFTEN_FLOW.USER_ID_ IS
'所属人id。-1为所有人都有权限';

COMMENT ON COLUMN BPM_OFTEN_FLOW.ORDER_ IS
'排序号';

CREATE TABLE BPM_OFTEN_FLOW_USER (
   ID_                  VARCHAR(64)          NOT NULL,
   OFTEN_FLOW_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   OWNER_ID_            VARCHAR(64)          NULL DEFAULT NULL,
   OWNER_NAME_          VARCHAR(128)         NULL DEFAULT NULL,
   RIGHT_TYPE_          VARCHAR(20)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_OFTEN_FLOW_USER PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_OFTEN_FLOW_USER IS
'常用流程授权对象表';

COMMENT ON COLUMN BPM_OFTEN_FLOW_USER.ID_ IS
'主键';

COMMENT ON COLUMN BPM_OFTEN_FLOW_USER.OFTEN_FLOW_ID_ IS
'常用流程表主键ID';

COMMENT ON COLUMN BPM_OFTEN_FLOW_USER.OWNER_ID_ IS
'授权对象ID';

COMMENT ON COLUMN BPM_OFTEN_FLOW_USER.OWNER_NAME_ IS
'授权对象名称';

COMMENT ON COLUMN BPM_OFTEN_FLOW_USER.RIGHT_TYPE_ IS
'授权对象类型(角色,用户,岗位等)';

COMMENT ON COLUMN BPM_OFTEN_FLOW_USER.TENANT_ID_ IS
'租户ID';

CREATE TABLE BPM_PRINT_RECORD (
   ID_                  VARCHAR(64)          NOT NULL,
   PROC_DEF_KEY_        VARCHAR(64)          NULL DEFAULT NULL,
   PROC_DEF_NAME_       VARCHAR(64)          NULL DEFAULT NULL,
   PROC_DEF_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   PROC_INST_ID_        VARCHAR(64)          NULL DEFAULT NULL,
   NODE_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   FORM_KEY_            VARCHAR(64)          NULL DEFAULT NULL,
   TEMPLATE_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   TEMPLATE_NAME_       VARCHAR(64)          NULL DEFAULT NULL,
   FILE_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   LAST_VERSION_        INT4                 NULL DEFAULT 0,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_PRINT_RECORD PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_PRINT_RECORD IS
'流程打印文件管理表';

COMMENT ON COLUMN BPM_PRINT_RECORD.ID_ IS
'主键';

COMMENT ON COLUMN BPM_PRINT_RECORD.PROC_DEF_KEY_ IS
'流程定义KEY';

COMMENT ON COLUMN BPM_PRINT_RECORD.PROC_DEF_NAME_ IS
'流程定义名称';

COMMENT ON COLUMN BPM_PRINT_RECORD.PROC_DEF_ID_ IS
'流程定义ID';

COMMENT ON COLUMN BPM_PRINT_RECORD.PROC_INST_ID_ IS
'流程实例ID';

COMMENT ON COLUMN BPM_PRINT_RECORD.NODE_ID_ IS
'流程节点ID';

COMMENT ON COLUMN BPM_PRINT_RECORD.FORM_KEY_ IS
'表单key';

COMMENT ON COLUMN BPM_PRINT_RECORD.TEMPLATE_ID_ IS
'打印模板ID';

COMMENT ON COLUMN BPM_PRINT_RECORD.TEMPLATE_NAME_ IS
'打印模板名称';

COMMENT ON COLUMN BPM_PRINT_RECORD.FILE_ID_ IS
'打印文件id';

COMMENT ON COLUMN BPM_PRINT_RECORD.LAST_VERSION_ IS
'是否最后的版本（1：是，0：否）';

COMMENT ON COLUMN BPM_PRINT_RECORD.TENANT_ID_ IS
'租户ID';

CREATE TABLE BPM_PRO_BO (
   ID_                  VARCHAR(64)          NOT NULL,
   PROCESS_ID_          VARCHAR(64)          NULL DEFAULT NULL,
   PROCESS_KEY_         VARCHAR(128)         NULL DEFAULT NULL,
   BO_CODE_             VARCHAR(128)         NULL DEFAULT NULL,
   BO_NAME_             VARCHAR(128)         NULL DEFAULT NULL,
   CREATOR_ID_          VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_PRO_BO PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_PRO_BO IS
'流程业务对象设置表';

COMMENT ON COLUMN BPM_PRO_BO.PROCESS_ID_ IS
'流程ID';

COMMENT ON COLUMN BPM_PRO_BO.PROCESS_KEY_ IS
'流程KEY';

COMMENT ON COLUMN BPM_PRO_BO.BO_CODE_ IS
'业务对象CODE';

COMMENT ON COLUMN BPM_PRO_BO.BO_NAME_ IS
'业务对象名称';

COMMENT ON COLUMN BPM_PRO_BO.CREATOR_ID_ IS
'创建人';

CREATE TABLE BPM_PRO_CPTO (
   ID_                  VARCHAR(64)          NOT NULL,
   INST_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   BPMN_INST_ID_        VARCHAR(64)          NULL DEFAULT NULL,
   NODE_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   OPINION_             VARCHAR(512)         NULL DEFAULT NULL,
   SUBJECT_             VARCHAR(128)         NULL DEFAULT NULL,
   TYPE_                VARCHAR(20)          NULL DEFAULT NULL,
   STARTOR_ID_          VARCHAR(64)          NULL DEFAULT NULL,
   TYPE_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   STARTOR_             VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_PRO_CPTO PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_PRO_CPTO IS
'流程实例抄送';

COMMENT ON COLUMN BPM_PRO_CPTO.INST_ID_ IS
'流程实例ID';

COMMENT ON COLUMN BPM_PRO_CPTO.BPMN_INST_ID_ IS
'ACT实例ID';

COMMENT ON COLUMN BPM_PRO_CPTO.NODE_ID_ IS
'节点ID';

COMMENT ON COLUMN BPM_PRO_CPTO.OPINION_ IS
'意见';

COMMENT ON COLUMN BPM_PRO_CPTO.SUBJECT_ IS
'流程实例标题';

COMMENT ON COLUMN BPM_PRO_CPTO.TYPE_ IS
'抄送类型(copyto抄送,trans转发)';

COMMENT ON COLUMN BPM_PRO_CPTO.STARTOR_ID_ IS
'流程发起人';

COMMENT ON COLUMN BPM_PRO_CPTO.TYPE_ID_ IS
'流程分类';

COMMENT ON COLUMN BPM_PRO_CPTO.STARTOR_ IS
'创建人';

CREATE TABLE BPM_PRO_INST (
   ID_                  VARCHAR(64)          NOT NULL,
   SUBJECT_             VARCHAR(128)         NOT NULL,
   PROC_DEF_ID_         VARCHAR(64)          NOT NULL,
   BPMN_DEF_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   PROC_DEF_KEY_        VARCHAR(128)         NULL DEFAULT NULL,
   PROC_DEF_NAME_       VARCHAR(128)         NOT NULL,
   BIZ_KEY_             VARCHAR(64)          NULL DEFAULT NULL,
   SYS_CODE_            VARCHAR(64)          NULL DEFAULT NULL,
   FORM_KEY_            VARCHAR(64)          NULL DEFAULT NULL,
   STATUS_              VARCHAR(40)          NULL DEFAULT NULL,
   END_TIME_            TIMESTAMP                 NULL,
   DURATION_            INT8                 NULL DEFAULT NULL,
   TYPE_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   RESULT_TYPE_         VARCHAR(40)          NULL DEFAULT NULL,
   BPMN_INST_ID_        VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   IS_FORMMAL_          CHAR(1)              NOT NULL,
   PARENT_INST_ID_      VARCHAR(64)          NULL DEFAULT NULL,
   IS_FORBIDDEN_        INT2                 NULL DEFAULT NULL,
   DATA_MODE_           VARCHAR(20)          NULL DEFAULT NULL,
   CREATOR_             VARCHAR(64)          NULL DEFAULT NULL,
   SUPPORT_MOBILE_      INT4                 NULL DEFAULT 0,
   SUPER_NODE_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   IS_DELE_             INT4                 NOT NULL DEFAULT 0,
   URGENT_STATE_        VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_ORG_PATH_     TEXT                 NULL,
   CONSTRAINT PK_BPM_PRO_INST PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_PRO_INST IS
'流程实例';

COMMENT ON COLUMN BPM_PRO_INST.SUBJECT_ IS
'流程实例标题';

COMMENT ON COLUMN BPM_PRO_INST.PROC_DEF_ID_ IS
'流程定义ID';

COMMENT ON COLUMN BPM_PRO_INST.BPMN_DEF_ID_ IS
'BPMN流程定义ID';

COMMENT ON COLUMN BPM_PRO_INST.PROC_DEF_KEY_ IS
'流程定义Key';

COMMENT ON COLUMN BPM_PRO_INST.PROC_DEF_NAME_ IS
'流程名称';

COMMENT ON COLUMN BPM_PRO_INST.BIZ_KEY_ IS
'业务主键';

COMMENT ON COLUMN BPM_PRO_INST.SYS_CODE_ IS
'业务系统编码';

COMMENT ON COLUMN BPM_PRO_INST.FORM_KEY_ IS
'绑定的表单主键';

COMMENT ON COLUMN BPM_PRO_INST.STATUS_ IS
'实例状态';

COMMENT ON COLUMN BPM_PRO_INST.DURATION_ IS
'持续时间(ms)';

COMMENT ON COLUMN BPM_PRO_INST.TYPE_ID_ IS
'所属分类ID';

COMMENT ON COLUMN BPM_PRO_INST.RESULT_TYPE_ IS
'流程结束后的最终审批结果，agree=同意；refuse=拒绝';

COMMENT ON COLUMN BPM_PRO_INST.BPMN_INST_ID_ IS
'BPMN流程实例ID';

COMMENT ON COLUMN BPM_PRO_INST.CREATE_BY_ IS
'创建人ID';

COMMENT ON COLUMN BPM_PRO_INST.CREATE_ORG_ID_ IS
'创建者所属组织ID';

COMMENT ON COLUMN BPM_PRO_INST.UPDATE_BY_ IS
'更新人ID';

COMMENT ON COLUMN BPM_PRO_INST.IS_FORMMAL_ IS
'是否正式数据';

COMMENT ON COLUMN BPM_PRO_INST.PARENT_INST_ID_ IS
'父实例Id';

COMMENT ON COLUMN BPM_PRO_INST.IS_FORBIDDEN_ IS
'禁止';

COMMENT ON COLUMN BPM_PRO_INST.DATA_MODE_ IS
'业务数据存储模式。\r\npk:主键\r\nbo:业务对象';

COMMENT ON COLUMN BPM_PRO_INST.CREATOR_ IS
'创建人';

COMMENT ON COLUMN BPM_PRO_INST.SUPPORT_MOBILE_ IS
'支持手机端';

COMMENT ON COLUMN BPM_PRO_INST.SUPER_NODE_ID_ IS
'子流程节点的ID';

COMMENT ON COLUMN BPM_PRO_INST.IS_DELE_ IS
'是否已删，1已删除，0未删除';

COMMENT ON COLUMN BPM_PRO_INST.URGENT_STATE_ IS
'紧急状态';

CREATE TABLE BPM_PRO_INST_HI (
   ID_                  VARCHAR(64)          NOT NULL,
   SUBJECT_             VARCHAR(128)         NOT NULL,
   PROC_DEF_ID_         VARCHAR(64)          NOT NULL,
   BPMN_DEF_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   PROC_DEF_KEY_        VARCHAR(128)         NULL DEFAULT NULL,
   PROC_DEF_NAME_       VARCHAR(128)         NOT NULL,
   BIZ_KEY_             VARCHAR(64)          NULL DEFAULT NULL,
   SYS_CODE_            VARCHAR(64)          NULL DEFAULT NULL,
   FORM_KEY_            VARCHAR(64)          NULL DEFAULT NULL,
   STATUS_              VARCHAR(40)          NULL DEFAULT NULL,
   END_TIME_            TIMESTAMP                 NULL,
   DURATION_            INT8                 NULL DEFAULT NULL,
   TYPE_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   RESULT_TYPE_         VARCHAR(40)          NULL DEFAULT NULL,
   BPMN_INST_ID_        VARCHAR(64)          NOT NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   IS_FORMMAL_          CHAR(1)              NOT NULL,
   PARENT_INST_ID_      VARCHAR(64)          NULL DEFAULT NULL,
   IS_FORBIDDEN_        INT2                 NULL DEFAULT NULL,
   DATA_MODE_           VARCHAR(20)          NULL DEFAULT NULL,
   CREATOR_             VARCHAR(64)          NULL DEFAULT NULL,
   SUPPORT_MOBILE_      INT4                 NULL DEFAULT 0,
   SUPER_NODE_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_PRO_INST_HI PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_PRO_INST_HI IS
'流程实例历史';

COMMENT ON COLUMN BPM_PRO_INST_HI.SUBJECT_ IS
'流程实例标题';

COMMENT ON COLUMN BPM_PRO_INST_HI.PROC_DEF_ID_ IS
'流程定义ID';

COMMENT ON COLUMN BPM_PRO_INST_HI.BPMN_DEF_ID_ IS
'BPMN流程定义ID';

COMMENT ON COLUMN BPM_PRO_INST_HI.PROC_DEF_KEY_ IS
'流程定义Key';

COMMENT ON COLUMN BPM_PRO_INST_HI.PROC_DEF_NAME_ IS
'流程名称';

COMMENT ON COLUMN BPM_PRO_INST_HI.BIZ_KEY_ IS
'关联数据业务主键';

COMMENT ON COLUMN BPM_PRO_INST_HI.SYS_CODE_ IS
'业务系统编码';

COMMENT ON COLUMN BPM_PRO_INST_HI.FORM_KEY_ IS
'绑定的表单主键';

COMMENT ON COLUMN BPM_PRO_INST_HI.STATUS_ IS
'实例状态';

COMMENT ON COLUMN BPM_PRO_INST_HI.DURATION_ IS
'持续时间';

COMMENT ON COLUMN BPM_PRO_INST_HI.TYPE_ID_ IS
'所属分类ID';

COMMENT ON COLUMN BPM_PRO_INST_HI.RESULT_TYPE_ IS
'流程结束后的最终审批结果，agree=同意；refuse=拒绝';

COMMENT ON COLUMN BPM_PRO_INST_HI.BPMN_INST_ID_ IS
'BPMN流程实例ID';

COMMENT ON COLUMN BPM_PRO_INST_HI.CREATE_BY_ IS
'创建人ID';

COMMENT ON COLUMN BPM_PRO_INST_HI.CREATE_ORG_ID_ IS
'创建者所属组织ID';

COMMENT ON COLUMN BPM_PRO_INST_HI.UPDATE_BY_ IS
'更新人ID';

COMMENT ON COLUMN BPM_PRO_INST_HI.IS_FORMMAL_ IS
'是否正式数据 0非正式,1正式';

COMMENT ON COLUMN BPM_PRO_INST_HI.PARENT_INST_ID_ IS
'父实例Id';

COMMENT ON COLUMN BPM_PRO_INST_HI.CREATOR_ IS
'创建人';

COMMENT ON COLUMN BPM_PRO_INST_HI.SUPPORT_MOBILE_ IS
'支持手机端';

COMMENT ON COLUMN BPM_PRO_INST_HI.SUPER_NODE_ID_ IS
'子流程节点ID';

CREATE TABLE BPM_PRO_INST_STATUS (
   ID_                  VARCHAR(64)          NOT NULL,
   KEY_                 VARCHAR(255)         NULL DEFAULT NULL,
   VALUE_               VARCHAR(255)         NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_PRO_INST_STATUS PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_PRO_INST_STATUS IS
'流程实例状态排序表';

COMMENT ON COLUMN BPM_PRO_INST_STATUS.KEY_ IS
'流程实例状态';

COMMENT ON COLUMN BPM_PRO_INST_STATUS.VALUE_ IS
'流程实例状态对应的排序号';

CREATE TABLE BPM_PRO_STATUS (
   ID_                  VARCHAR(64)          NOT NULL,
   PROC_INST_ID_        VARCHAR(64)          NOT NULL,
   PROC_DEF_ID_         VARCHAR(64)          NOT NULL,
   NODE_ID_             VARCHAR(255)         NOT NULL,
   NODE_NAME_           VARCHAR(255)         NULL DEFAULT NULL,
   STATUS_              VARCHAR(50)          NOT NULL,
   LAST_UPDATE_         TIMESTAMP                 NULL,
   LAST_USERID_         VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_PRO_STATUS PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_PRO_STATUS IS
'流程节点审批状态';

COMMENT ON COLUMN BPM_PRO_STATUS.PROC_INST_ID_ IS
'流程实例ID';

COMMENT ON COLUMN BPM_PRO_STATUS.PROC_DEF_ID_ IS
'ACT流程定义ID';

COMMENT ON COLUMN BPM_PRO_STATUS.NODE_ID_ IS
'节点ID';

COMMENT ON COLUMN BPM_PRO_STATUS.NODE_NAME_ IS
'节点名称';

COMMENT ON COLUMN BPM_PRO_STATUS.STATUS_ IS
'状态';

COMMENT ON COLUMN BPM_PRO_STATUS.LAST_USERID_ IS
'最后更新人';

CREATE TABLE BPM_PRO_STATUS_HI (
   ID_                  VARCHAR(64)          NOT NULL,
   PROC_INST_ID_        VARCHAR(64)          NOT NULL,
   PROC_DEF_ID_         VARCHAR(64)          NOT NULL,
   NODE_ID_             VARCHAR(255)         NOT NULL,
   NODE_NAME_           VARCHAR(255)         NULL DEFAULT NULL,
   STATUS_              VARCHAR(50)          NOT NULL,
   LAST_UPDATE_         TIMESTAMP                 NULL,
   LAST_USERID_         VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_PRO_STATUS_HI PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_PRO_STATUS_HI IS
'流程节点审批历史状态';

COMMENT ON COLUMN BPM_PRO_STATUS_HI.PROC_INST_ID_ IS
'流程实例ID';

COMMENT ON COLUMN BPM_PRO_STATUS_HI.PROC_DEF_ID_ IS
'ACT流程定义ID';

COMMENT ON COLUMN BPM_PRO_STATUS_HI.NODE_ID_ IS
'节点ID';

COMMENT ON COLUMN BPM_PRO_STATUS_HI.NODE_NAME_ IS
'节点名称';

COMMENT ON COLUMN BPM_PRO_STATUS_HI.STATUS_ IS
'状态';

COMMENT ON COLUMN BPM_PRO_STATUS_HI.LAST_USERID_ IS
'最后更新人';

CREATE TABLE BPM_READ_RECORD (
   ID_                  VARCHAR(255)         NOT NULL,
   PROC_DEF_ID_         VARCHAR(255)         NULL DEFAULT NULL,
   SUP_INST_ID_         VARCHAR(255)         NULL DEFAULT NULL,
   PROC_INST_ID_        VARCHAR(255)         NULL DEFAULT NULL,
   TASK_ID_             VARCHAR(255)         NULL DEFAULT NULL,
   TASK_KEY_            VARCHAR(255)         NULL DEFAULT NULL,
   TASK_NAME_           VARCHAR(255)         NULL DEFAULT NULL,
   READER_              VARCHAR(255)         NULL DEFAULT NULL,
   READER_NAME_         VARCHAR(255)         NULL DEFAULT NULL,
   READ_TIME_           TIMESTAMP                 NULL,
   ORG_ID_              VARCHAR(255)         NULL DEFAULT NULL,
   ORG_PATH_            VARCHAR(255)         NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_READ_RECORD PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_READ_RECORD IS
'任务阅读记录表';

COMMENT ON COLUMN BPM_READ_RECORD.PROC_DEF_ID_ IS
'流程定义ID';

COMMENT ON COLUMN BPM_READ_RECORD.SUP_INST_ID_ IS
'父流程实例ID';

COMMENT ON COLUMN BPM_READ_RECORD.PROC_INST_ID_ IS
'流程实例ID';

COMMENT ON COLUMN BPM_READ_RECORD.TASK_ID_ IS
'任务ID';

COMMENT ON COLUMN BPM_READ_RECORD.TASK_KEY_ IS
'任务定义Key';

COMMENT ON COLUMN BPM_READ_RECORD.TASK_NAME_ IS
'任务名称';

COMMENT ON COLUMN BPM_READ_RECORD.READER_ IS
'阅读人ID';

COMMENT ON COLUMN BPM_READ_RECORD.READER_NAME_ IS
'阅读人名';

COMMENT ON COLUMN BPM_READ_RECORD.ORG_ID_ IS
'组织id';

COMMENT ON COLUMN BPM_READ_RECORD.ORG_PATH_ IS
'组织名称';

CREATE TABLE BPM_REMINDER_HISTORY (
   ID_                  VARCHAR(64)          NOT NULL,
   INST_ID_             VARCHAR(255)         NULL DEFAULT NULL,
   ISNT_NAME_           VARCHAR(255)         NULL DEFAULT NULL,
   NODE_NAME_           VARCHAR(255)         NULL DEFAULT NULL,
   NODE_ID_             VARCHAR(255)         NULL DEFAULT NULL,
   EXECUTE_DATE_        TIMESTAMP                 NULL DEFAULT NULL,
   REMIND_TYPE_         VARCHAR(255)         NULL DEFAULT NULL,
   USER_ID_             VARCHAR(255)         NULL DEFAULT NULL,
   NOTE_                VARCHAR(255)         NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   TASK_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_REMINDER_HISTORY PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_REMINDER_HISTORY IS
'催办历史';

COMMENT ON COLUMN BPM_REMINDER_HISTORY.INST_ID_ IS
'流程实例ID';

COMMENT ON COLUMN BPM_REMINDER_HISTORY.ISNT_NAME_ IS
'流程实例标题';

COMMENT ON COLUMN BPM_REMINDER_HISTORY.NODE_NAME_ IS
'节点名称';

COMMENT ON COLUMN BPM_REMINDER_HISTORY.NODE_ID_ IS
'节点ID';

COMMENT ON COLUMN BPM_REMINDER_HISTORY.EXECUTE_DATE_ IS
'执行时间';

COMMENT ON COLUMN BPM_REMINDER_HISTORY.REMIND_TYPE_ IS
'执行类型';

COMMENT ON COLUMN BPM_REMINDER_HISTORY.USER_ID_ IS
'说明';

CREATE TABLE BPM_REPORT_ACT (
   ID_                  VARCHAR(64)          NOT NULL,
   REPORT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   BPM_DEF_ID_          VARCHAR(64)          NULL DEFAULT NULL,
   REPORT_NAME_         VARCHAR(255)         NULL DEFAULT NULL,
   DIMENSION_ID_        VARCHAR(255)         NULL DEFAULT NULL,
   GRADE_               VARCHAR(255)         NULL DEFAULT NULL,
   PARAMS_              VARCHAR(255)         NULL DEFAULT NULL,
   RIGHT_CONTENT_       VARCHAR(255)         NULL DEFAULT NULL,
   IS_DEFAULT_          VARCHAR(64)          NULL DEFAULT NULL,
   X_AXIS_              VARCHAR(255)         NULL DEFAULT NULL,
   Y_AXIS_              VARCHAR(255)         NULL DEFAULT NULL,
   PORP_                TEXT                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_REPORT_ACT PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_REPORT_ACT IS
'报表子表';

COMMENT ON COLUMN BPM_REPORT_ACT.REPORT_ID_ IS
'报表主表ID';

COMMENT ON COLUMN BPM_REPORT_ACT.BPM_DEF_ID_ IS
'流程定义ID';

COMMENT ON COLUMN BPM_REPORT_ACT.REPORT_NAME_ IS
'报表名称';

COMMENT ON COLUMN BPM_REPORT_ACT.DIMENSION_ID_ IS
'组织维度id';

COMMENT ON COLUMN BPM_REPORT_ACT.GRADE_ IS
'统计级别';

COMMENT ON COLUMN BPM_REPORT_ACT.PARAMS_ IS
'统计参数';

COMMENT ON COLUMN BPM_REPORT_ACT.RIGHT_CONTENT_ IS
'授权内容(报表类型显示)';

COMMENT ON COLUMN BPM_REPORT_ACT.IS_DEFAULT_ IS
'默认显示视图(1：柱状图，2：饼图)';

COMMENT ON COLUMN BPM_REPORT_ACT.X_AXIS_ IS
'x轴数据';

COMMENT ON COLUMN BPM_REPORT_ACT.Y_AXIS_ IS
'y轴数据';

COMMENT ON COLUMN BPM_REPORT_ACT.PORP_ IS
'统计参数';

CREATE TABLE BPM_REPORT_LIST (
   ID_                  VARCHAR(64)          NOT NULL,
   NAME_                VARCHAR(255)         NULL DEFAULT NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_NAME_         VARCHAR(255)         NULL DEFAULT NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_ORG_NAME_     VARCHAR(255)         NULL DEFAULT NULL,
   TYPE_                VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_REPORT_LIST PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_REPORT_LIST IS
'报表主表';

COMMENT ON COLUMN BPM_REPORT_LIST.NAME_ IS
'报表主表名称';

COMMENT ON COLUMN BPM_REPORT_LIST.CREATE_BY_ IS
'创建人ID';

COMMENT ON COLUMN BPM_REPORT_LIST.CREATE_NAME_ IS
'创建人名称';

COMMENT ON COLUMN BPM_REPORT_LIST.CREATE_ORG_ID_ IS
'创建者所属组织ID';

COMMENT ON COLUMN BPM_REPORT_LIST.CREATE_ORG_NAME_ IS
'组织名称';

COMMENT ON COLUMN BPM_REPORT_LIST.TYPE_ IS
'是否发布(1:是，2否)';

CREATE TABLE BPM_REPORT_USER (
   ID_                  VARCHAR(64)          NOT NULL,
   REPORT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   OWNER_ID_            VARCHAR(64)          NULL DEFAULT NULL,
   OWNER_NAME_          VARCHAR(255)         NULL DEFAULT NULL,
   RIGHT_TYPE_          VARCHAR(20)          NULL DEFAULT NULL,
   AUTH_ORG_            VARCHAR(255)         NULL DEFAULT NULL,
   AUTH_ORG_NAME_       VARCHAR(255)         NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_REPORT_USER PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_REPORT_USER IS
'报表授权表';

COMMENT ON COLUMN BPM_REPORT_USER.REPORT_ID_ IS
'报表授权主表ID';

COMMENT ON COLUMN BPM_REPORT_USER.OWNER_ID_ IS
'授权对象ID';

COMMENT ON COLUMN BPM_REPORT_USER.OWNER_NAME_ IS
'授权对象名称';

COMMENT ON COLUMN BPM_REPORT_USER.RIGHT_TYPE_ IS
'授权对象类型(角色,用户,岗位等)';

COMMENT ON COLUMN BPM_REPORT_USER.AUTH_ORG_ IS
'主组织ID';

COMMENT ON COLUMN BPM_REPORT_USER.AUTH_ORG_NAME_ IS
'主组织名称';

CREATE TABLE BPM_SAVE_OPINION (
   ID_                  VARCHAR(255)         NOT NULL,
   PROC_INST_ID_        VARCHAR(255)         NOT NULL,
   TASK_ID_             VARCHAR(255)         NOT NULL,
   OPINION_             VARCHAR(2000)        NOT NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_SAVE_OPINION PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_SAVE_OPINION IS
'审批意见暂存表';

COMMENT ON COLUMN BPM_SAVE_OPINION.ID_ IS
'主键ID';

COMMENT ON COLUMN BPM_SAVE_OPINION.PROC_INST_ID_ IS
'流程实例ID';

COMMENT ON COLUMN BPM_SAVE_OPINION.TASK_ID_ IS
'任务ID';

COMMENT ON COLUMN BPM_SAVE_OPINION.OPINION_ IS
'暂存的审批意见';

COMMENT ON COLUMN BPM_SAVE_OPINION.CREATE_BY_ IS
'创建人';

COMMENT ON COLUMN BPM_SAVE_OPINION.CREATE_TIME_ IS
'创建时间';

COMMENT ON COLUMN BPM_SAVE_OPINION.UPDATE_BY_ IS
'更新人';

COMMENT ON COLUMN BPM_SAVE_OPINION.UPDATE_TIME_ IS
'更新时间';

COMMENT ON COLUMN BPM_SAVE_OPINION.TENANT_ID_ IS
'租户ID';

CREATE TABLE BPM_SCRIPT (
   ID_                  VARCHAR(64)          NOT NULL,
   NAME_                VARCHAR(128)         NULL DEFAULT NULL,
   SCRIPT_              TEXT                 NULL,
   CATEGORY_            VARCHAR(128)         NULL DEFAULT NULL,
   MEMO_                VARCHAR(512)         NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_SCRIPT PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_SCRIPT IS
'常用脚本';

COMMENT ON COLUMN BPM_SCRIPT.NAME_ IS
'脚本名称';

COMMENT ON COLUMN BPM_SCRIPT.SCRIPT_ IS
'脚本';

COMMENT ON COLUMN BPM_SCRIPT.CATEGORY_ IS
'脚本分类';

COMMENT ON COLUMN BPM_SCRIPT.MEMO_ IS
'备注';

COMMENT ON COLUMN BPM_SCRIPT.CREATE_BY_ IS
'创建人ID';

COMMENT ON COLUMN BPM_SCRIPT.CREATE_ORG_ID_ IS
'创建人所属组织ID';

COMMENT ON COLUMN BPM_SCRIPT.UPDATE_BY_ IS
'更新人ID';

CREATE TABLE BPM_SECRETARY_MANAGE (
   ID_                  VARCHAR(64)          NOT NULL,
   LEADER_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   LEADER_NAME_         VARCHAR(255)         NULL DEFAULT NULL,
   SECRETARY_ID_        VARCHAR(255)         NULL DEFAULT NULL,
   SECRETARY_NAME_      VARCHAR(1024)        NULL DEFAULT NULL,
   SHARE_TYPE_          VARCHAR(2)           NULL DEFAULT NULL,
   SHARE_KEY_           VARCHAR(255)         NULL DEFAULT NULL,
   SHARE_NAME_          VARCHAR(1024)        NULL DEFAULT NULL,
   ENABLED_             VARCHAR(2)           NULL DEFAULT '1',
   SHARE_RIGHT_         VARCHAR(10)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_SECRETARY_MANAGE PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_SECRETARY_MANAGE IS
'秘书管理表';

COMMENT ON COLUMN BPM_SECRETARY_MANAGE.LEADER_ID_ IS
'领导id';

COMMENT ON COLUMN BPM_SECRETARY_MANAGE.LEADER_NAME_ IS
'领导姓名';

COMMENT ON COLUMN BPM_SECRETARY_MANAGE.SECRETARY_ID_ IS
'秘书id';

COMMENT ON COLUMN BPM_SECRETARY_MANAGE.SECRETARY_NAME_ IS
'秘书姓名';

COMMENT ON COLUMN BPM_SECRETARY_MANAGE.SHARE_TYPE_ IS
'共享类型，1流程分类。2，流程定义';

COMMENT ON COLUMN BPM_SECRETARY_MANAGE.SHARE_KEY_ IS
'共享的key';

COMMENT ON COLUMN BPM_SECRETARY_MANAGE.SHARE_NAME_ IS
'共享对象的名称';

COMMENT ON COLUMN BPM_SECRETARY_MANAGE.ENABLED_ IS
'是否有效';

COMMENT ON COLUMN BPM_SECRETARY_MANAGE.SHARE_RIGHT_ IS
'共享权限类型';

CREATE TABLE BPM_SELECTOR_DEF (
   ID_                  VARCHAR(64)          NOT NULL,
   NAME_                VARCHAR(40)          NULL DEFAULT NULL,
   ALIAS_               VARCHAR(64)          NULL DEFAULT NULL,
   GROUP_FIELD_         VARCHAR(512)         NULL DEFAULT NULL,
   BUTTONS_             VARCHAR(512)         NULL DEFAULT NULL,
   IS_CUSTOM_           INT2                 NULL DEFAULT NULL,
   FLAG_                INT2                 NULL DEFAULT 0,
   METHOD_              VARCHAR(64)          NULL DEFAULT NULL,
   CONF_KEY_            VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_SELECTOR_DEF PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_SELECTOR_DEF IS
'控件组合定义';

COMMENT ON COLUMN BPM_SELECTOR_DEF.NAME_ IS
'名称';

COMMENT ON COLUMN BPM_SELECTOR_DEF.ALIAS_ IS
'别名';

COMMENT ON COLUMN BPM_SELECTOR_DEF.GROUP_FIELD_ IS
'组合字段';

COMMENT ON COLUMN BPM_SELECTOR_DEF.BUTTONS_ IS
'按钮定义';

COMMENT ON COLUMN BPM_SELECTOR_DEF.IS_CUSTOM_ IS
'系统预定义';

COMMENT ON COLUMN BPM_SELECTOR_DEF.FLAG_ IS
'标记是否系统默认';

COMMENT ON COLUMN BPM_SELECTOR_DEF.METHOD_ IS
'选择器对应的js方法名称';

COMMENT ON COLUMN BPM_SELECTOR_DEF.CONF_KEY_ IS
'已选数据参数的传递key';

CREATE TABLE BPM_TASK (
   ID_                  VARCHAR(64)          NOT NULL,
   NAME_                VARCHAR(64)          NOT NULL,
   SUBJECT_             VARCHAR(128)         NOT NULL,
   PROC_INST_ID_        VARCHAR(64)          NOT NULL,
   TASK_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   EXEC_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   NODE_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   PROC_DEF_ID_         VARCHAR(64)          NOT NULL,
   PROC_DEF_KEY_        VARCHAR(64)          NULL DEFAULT NULL,
   PROC_DEF_NAME_       VARCHAR(64)          NULL DEFAULT NULL,
   OWNER_ID_            VARCHAR(64)          NULL DEFAULT NULL,
   OWNER_NAME_          VARCHAR(128)         NULL DEFAULT NULL,
   ASSIGNEE_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   ASSIGNEE_NAME_       VARCHAR(128)         NULL DEFAULT NULL,
   STATUS_              VARCHAR(40)          NOT NULL,
   PRIORITY_            INT4                 NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   DUE_TIME_            TIMESTAMP                 NULL,
   SUSPEND_STATE_       INT2                 NULL DEFAULT 0,
   PARENT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   BPMN_INST_ID_        VARCHAR(64)          NULL DEFAULT NULL,
   BPMN_DEF_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   TYPE_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   SUPPORT_MOBILE_      INT4                 NULL DEFAULT 0,
   IS_DELE_             INT4                 NOT NULL DEFAULT 0,
   IS_READ_             INT4                 NULL DEFAULT NULL,
   IS_REVOKE_           INT4                 NULL DEFAULT NULL,
   PROP1_               VARCHAR(200)         NULL DEFAULT NULL,
   PROP2_               VARCHAR(200)         NULL DEFAULT NULL,
   PROP3_               VARCHAR(200)         NULL DEFAULT NULL,
   PROP4_               VARCHAR(200)         NULL DEFAULT NULL,
   PROP5_               VARCHAR(200)         NULL DEFAULT NULL,
   PROP6_               TEXT                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_TASK PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_TASK IS
'流程任务';

COMMENT ON COLUMN BPM_TASK.NAME_ IS
'任务名称';

COMMENT ON COLUMN BPM_TASK.SUBJECT_ IS
'待办事项标题';

COMMENT ON COLUMN BPM_TASK.PROC_INST_ID_ IS
'关联 - 流程实例ID';

COMMENT ON COLUMN BPM_TASK.TASK_ID_ IS
'关联的任务ID';

COMMENT ON COLUMN BPM_TASK.EXEC_ID_ IS
'关联 - 节点执行ID';

COMMENT ON COLUMN BPM_TASK.NODE_ID_ IS
'关联 - 任务节点ID';

COMMENT ON COLUMN BPM_TASK.PROC_DEF_ID_ IS
'关联 - 流程定义ID';

COMMENT ON COLUMN BPM_TASK.PROC_DEF_KEY_ IS
'关联 - 流程业务主键';

COMMENT ON COLUMN BPM_TASK.PROC_DEF_NAME_ IS
'关联 - 流程名称';

COMMENT ON COLUMN BPM_TASK.OWNER_ID_ IS
'任务所属人ID';

COMMENT ON COLUMN BPM_TASK.ASSIGNEE_ID_ IS
'任务执行人ID';

COMMENT ON COLUMN BPM_TASK.STATUS_ IS
'任务状态';

COMMENT ON COLUMN BPM_TASK.PRIORITY_ IS
'任务优先级';

COMMENT ON COLUMN BPM_TASK.SUSPEND_STATE_ IS
'是否挂起(0正常,1挂起)';

COMMENT ON COLUMN BPM_TASK.PARENT_ID_ IS
'父任务ID';

COMMENT ON COLUMN BPM_TASK.BPMN_INST_ID_ IS
'bpmn实例ID';

COMMENT ON COLUMN BPM_TASK.BPMN_DEF_ID_ IS
'BPMN定义ID';

COMMENT ON COLUMN BPM_TASK.TYPE_ID_ IS
'分类ID';

COMMENT ON COLUMN BPM_TASK.SUPPORT_MOBILE_ IS
'支持手机';

COMMENT ON COLUMN BPM_TASK.IS_DELE_ IS
'是否已删，1已删除，0未删除';

COMMENT ON COLUMN BPM_TASK.PROP1_ IS
'扩展属性1';

COMMENT ON COLUMN BPM_TASK.PROP2_ IS
'扩展属性2';

COMMENT ON COLUMN BPM_TASK.PROP3_ IS
'扩展属性3';

COMMENT ON COLUMN BPM_TASK.PROP4_ IS
'扩展属性4';

COMMENT ON COLUMN BPM_TASK.PROP5_ IS
'扩展属性5';

COMMENT ON COLUMN BPM_TASK.PROP6_ IS
'扩展属性6';

CREATE TABLE BPM_TASK_CANDIDATE (
   ID_                  VARCHAR(64)          NOT NULL,
   TASK_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   TYPE_                VARCHAR(20)          NULL DEFAULT NULL,
   EXECUTOR_            VARCHAR(64)          NULL DEFAULT NULL,
   PROC_INST_ID_        VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_TASK_CANDIDATE PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_TASK_CANDIDATE IS
'任务候选人';

COMMENT ON COLUMN BPM_TASK_CANDIDATE.TASK_ID_ IS
'任务ID';

COMMENT ON COLUMN BPM_TASK_CANDIDATE.TYPE_ IS
'候选人类型';

COMMENT ON COLUMN BPM_TASK_CANDIDATE.EXECUTOR_ IS
'执行人ID';

COMMENT ON COLUMN BPM_TASK_CANDIDATE.PROC_INST_ID_ IS
'流程实例';

CREATE TABLE BPM_TASK_COMMU (
   ID_                  VARCHAR(64)          NOT NULL,
   INSTANCE_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   NODE_NAME_           VARCHAR(128)         NULL DEFAULT NULL,
   NODE_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   TASK_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   SENDER_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   SENDER               VARCHAR(128)         NULL DEFAULT NULL,
   CREATETIME_          TIMESTAMP                 NULL,
   OPINION_             VARCHAR(512)         NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_TASK_COMMU PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_TASK_COMMU IS
'任务通知';

COMMENT ON COLUMN BPM_TASK_COMMU.INSTANCE_ID_ IS
'流程实例ID';

COMMENT ON COLUMN BPM_TASK_COMMU.NODE_NAME_ IS
'节点名称';

COMMENT ON COLUMN BPM_TASK_COMMU.NODE_ID_ IS
'节点ID';

COMMENT ON COLUMN BPM_TASK_COMMU.TASK_ID_ IS
'任务ID';

COMMENT ON COLUMN BPM_TASK_COMMU.SENDER_ID_ IS
'发送沟通人ID';

COMMENT ON COLUMN BPM_TASK_COMMU.SENDER IS
'发送沟通人';

COMMENT ON COLUMN BPM_TASK_COMMU.OPINION_ IS
'意见';

CREATE TABLE BPM_TASK_DUE_TIME (
   ID_                  VARCHAR(64)          NOT NULL,
   PARENT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   INST_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   TASK_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   DATE_TYPE_           VARCHAR(32)          NULL DEFAULT NULL,
   DUE_TIME_            INT4                 NULL DEFAULT NULL,
   ADD_DUE_TIME_        INT4                 NULL DEFAULT NULL,
   START_TIME_          TIMESTAMP                 NULL,
   EXPIRATION_DATE_     TIMESTAMP                 NULL,
   REMAINING_TIME_      INT4                 NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   STATUS_              INT4                 NULL DEFAULT NULL,
   USER_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   USER_NAME_           VARCHAR(128)         NULL DEFAULT NULL,
   REMARK_              VARCHAR(512)         NULL DEFAULT NULL,
   FILE_ID_             VARCHAR(512)         NULL DEFAULT NULL,
   IS_NEW_              INT4                 NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_TASK_DUE_TIME PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_TASK_DUE_TIME IS
'任务期限记录表';

COMMENT ON COLUMN BPM_TASK_DUE_TIME.PARENT_ID_ IS
'父id';

COMMENT ON COLUMN BPM_TASK_DUE_TIME.INST_ID_ IS
'流程实例id';

COMMENT ON COLUMN BPM_TASK_DUE_TIME.TASK_ID_ IS
'任务id';

COMMENT ON COLUMN BPM_TASK_DUE_TIME.DATE_TYPE_ IS
'时间类型  工作日 worktime  日历日 caltime';

COMMENT ON COLUMN BPM_TASK_DUE_TIME.DUE_TIME_ IS
'任务时间 (分钟)';

COMMENT ON COLUMN BPM_TASK_DUE_TIME.ADD_DUE_TIME_ IS
'延迟时间';

COMMENT ON COLUMN BPM_TASK_DUE_TIME.REMAINING_TIME_ IS
'任务剩余时间（分钟）';

COMMENT ON COLUMN BPM_TASK_DUE_TIME.STATUS_ IS
'状态 是否延期申请过 1申请过  0没延迟过';

COMMENT ON COLUMN BPM_TASK_DUE_TIME.USER_ID_ IS
'审批人ID';

COMMENT ON COLUMN BPM_TASK_DUE_TIME.USER_NAME_ IS
'审批人姓名';

COMMENT ON COLUMN BPM_TASK_DUE_TIME.REMARK_ IS
'说明';

COMMENT ON COLUMN BPM_TASK_DUE_TIME.FILE_ID_ IS
'附件';

COMMENT ON COLUMN BPM_TASK_DUE_TIME.IS_NEW_ IS
'是否新的延迟 1 是  0 否 ';

CREATE TABLE BPM_TASK_FOLLOW (
   ID                   VARCHAR(255)         NOT NULL,
   TASK_ID              VARCHAR(255)         NULL DEFAULT NULL,
   CREATOR_ID_          VARCHAR(255)         NULL DEFAULT NULL,
   PRO_INST_            VARCHAR(255)         NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_TASK_FOLLOW PRIMARY KEY (ID)
);

COMMENT ON TABLE BPM_TASK_FOLLOW IS
'任务跟踪表';

COMMENT ON COLUMN BPM_TASK_FOLLOW.ID IS
'主键';

COMMENT ON COLUMN BPM_TASK_FOLLOW.TASK_ID IS
'任务id';

COMMENT ON COLUMN BPM_TASK_FOLLOW.CREATOR_ID_ IS
'创建者ID';

COMMENT ON COLUMN BPM_TASK_FOLLOW.PRO_INST_ IS
'流程实例id';

CREATE TABLE BPM_TASK_NOTICE (
   ID_                  VARCHAR(64)          NOT NULL,
   NAME_                VARCHAR(64)          NOT NULL,
   SUBJECT_             VARCHAR(128)         NOT NULL,
   PROC_INST_ID_        VARCHAR(64)          NOT NULL,
   TASK_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   EXEC_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   NODE_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   PROC_DEF_ID_         VARCHAR(64)          NOT NULL,
   PROC_DEF_KEY_        VARCHAR(64)          NULL DEFAULT NULL,
   PROC_DEF_NAME_       VARCHAR(64)          NULL DEFAULT NULL,
   OWNER_ID_            VARCHAR(64)          NULL DEFAULT NULL,
   OWNER_NAME_          VARCHAR(128)         NULL DEFAULT NULL,
   ASSIGNEE_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   ASSIGNEE_NAME_       VARCHAR(128)         NULL DEFAULT NULL,
   STATUS_              VARCHAR(40)          NOT NULL,
   PRIORITY_            INT4                 NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   DUE_TIME_            TIMESTAMP                 NULL,
   SUSPEND_STATE_       INT2                 NULL DEFAULT 0,
   PARENT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   BPMN_INST_ID_        VARCHAR(64)          NULL DEFAULT NULL,
   BPMN_DEF_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   TYPE_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   SUPPORT_MOBILE_      INT4                 NULL DEFAULT 0,
   IS_DELE_             INT4                 NOT NULL DEFAULT 0,
   IS_READ_             INT4                 NOT NULL DEFAULT 0,
   IS_REVOKE_           INT4                 NOT NULL DEFAULT 0,
   PROP1_               VARCHAR(200)         NULL DEFAULT NULL,
   PROP2_               VARCHAR(200)         NULL DEFAULT NULL,
   PROP3_               VARCHAR(200)         NULL DEFAULT NULL,
   PROP4_               VARCHAR(200)         NULL DEFAULT NULL,
   PROP5_               VARCHAR(200)         NULL DEFAULT NULL,
   PROP6_               TEXT                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_TASK_NOTICE PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_TASK_NOTICE IS
'知会任务表';

COMMENT ON COLUMN BPM_TASK_NOTICE.NAME_ IS
'任务名称';

COMMENT ON COLUMN BPM_TASK_NOTICE.SUBJECT_ IS
'待办事项标题';

COMMENT ON COLUMN BPM_TASK_NOTICE.PROC_INST_ID_ IS
'关联 - 流程实例ID';

COMMENT ON COLUMN BPM_TASK_NOTICE.TASK_ID_ IS
'关联的任务ID';

COMMENT ON COLUMN BPM_TASK_NOTICE.EXEC_ID_ IS
'关联 - 节点执行ID';

COMMENT ON COLUMN BPM_TASK_NOTICE.NODE_ID_ IS
'关联 - 任务节点ID';

COMMENT ON COLUMN BPM_TASK_NOTICE.PROC_DEF_ID_ IS
'关联 - 流程定义ID';

COMMENT ON COLUMN BPM_TASK_NOTICE.PROC_DEF_KEY_ IS
'关联 - 流程业务主键';

COMMENT ON COLUMN BPM_TASK_NOTICE.PROC_DEF_NAME_ IS
'关联 - 流程名称';

COMMENT ON COLUMN BPM_TASK_NOTICE.OWNER_ID_ IS
'任务所属人ID';

COMMENT ON COLUMN BPM_TASK_NOTICE.ASSIGNEE_ID_ IS
'任务执行人ID';

COMMENT ON COLUMN BPM_TASK_NOTICE.STATUS_ IS
'任务状态';

COMMENT ON COLUMN BPM_TASK_NOTICE.PRIORITY_ IS
'任务优先级';

COMMENT ON COLUMN BPM_TASK_NOTICE.SUSPEND_STATE_ IS
'是否挂起(0正常,1挂起)';

COMMENT ON COLUMN BPM_TASK_NOTICE.PARENT_ID_ IS
'父任务ID';

COMMENT ON COLUMN BPM_TASK_NOTICE.BPMN_INST_ID_ IS
'bpmn实例ID';

COMMENT ON COLUMN BPM_TASK_NOTICE.BPMN_DEF_ID_ IS
'BPMN定义ID';

COMMENT ON COLUMN BPM_TASK_NOTICE.TYPE_ID_ IS
'分类ID';

COMMENT ON COLUMN BPM_TASK_NOTICE.SUPPORT_MOBILE_ IS
'支持手机';

COMMENT ON COLUMN BPM_TASK_NOTICE.IS_DELE_ IS
'是否已删，1已删除，0未删除';

COMMENT ON COLUMN BPM_TASK_NOTICE.IS_READ_ IS
'传阅的任务是否已阅 0:待阅，1：已阅';

COMMENT ON COLUMN BPM_TASK_NOTICE.IS_REVOKE_ IS
'传阅的任务是否撤回 0:否，1：是';

COMMENT ON COLUMN BPM_TASK_NOTICE.PROP1_ IS
'扩展属性1';

COMMENT ON COLUMN BPM_TASK_NOTICE.PROP2_ IS
'扩展属性2';

COMMENT ON COLUMN BPM_TASK_NOTICE.PROP3_ IS
'扩展属性3';

COMMENT ON COLUMN BPM_TASK_NOTICE.PROP4_ IS
'扩展属性4';

COMMENT ON COLUMN BPM_TASK_NOTICE.PROP5_ IS
'扩展属性5';

COMMENT ON COLUMN BPM_TASK_NOTICE.PROP6_ IS
'扩展属性6';

CREATE TABLE BPM_TASK_NOTICE_DONE (
   ID_                  VARCHAR(64)          NOT NULL,
   PROC_DEF_ID_         VARCHAR(64)          NOT NULL,
   SUP_INST_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   PROC_INST_ID_        VARCHAR(64)          NOT NULL,
   TASK_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   TASK_KEY_            VARCHAR(64)          NULL DEFAULT NULL,
   TASK_NAME_           VARCHAR(255)         NULL DEFAULT NULL,
   TOKEN_               VARCHAR(64)          NULL DEFAULT NULL,
   QUALFIEDS_           TEXT                 NULL DEFAULT NULL,
   QUALFIED_NAMES_      TEXT                 NULL DEFAULT NULL,
   AUDITOR_             VARCHAR(64)          NULL DEFAULT NULL,
   AUDITOR_NAME_        VARCHAR(64)          NULL DEFAULT NULL,
   ORG_ID_              VARCHAR(64)          NULL DEFAULT NULL,
   ORG_PATH_            VARCHAR(600)         NULL DEFAULT NULL,
   OPINION_             VARCHAR(4000)        NULL DEFAULT NULL,
   STATUS_              VARCHAR(40)          NOT NULL,
   FORM_DEF_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   FORM_NAME_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   ASSIGN_TIME_         TIMESTAMP                 NULL,
   COMPLETE_TIME_       TIMESTAMP                 NULL,
   DUR_MS_              INT4                 NULL DEFAULT NULL,
   FILES_               VARCHAR(4000)        NULL DEFAULT NULL,
   INTERPOSE_           INT2                 NULL DEFAULT NULL,
   SUBJECT_             VARCHAR(255)         NULL DEFAULT NULL,
   PROC_DEF_NAME_       VARCHAR(255)         NULL DEFAULT NULL,
   BPM_TASK_NOTICE_ID_  VARCHAR(255)         NULL DEFAULT NULL,
   SUPPORT_MOBILE_      INT4                 NULL DEFAULT 0,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_TASK_NOTICE_DONE PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_TASK_NOTICE_DONE IS
'知会任务已办';

COMMENT ON COLUMN BPM_TASK_NOTICE_DONE.PROC_DEF_ID_ IS
'流程定义ID';

COMMENT ON COLUMN BPM_TASK_NOTICE_DONE.SUP_INST_ID_ IS
'父流程实例ID';

COMMENT ON COLUMN BPM_TASK_NOTICE_DONE.PROC_INST_ID_ IS
'流程实例ID';

COMMENT ON COLUMN BPM_TASK_NOTICE_DONE.TASK_ID_ IS
'任务ID';

COMMENT ON COLUMN BPM_TASK_NOTICE_DONE.TASK_KEY_ IS
'任务定义Key';

COMMENT ON COLUMN BPM_TASK_NOTICE_DONE.TASK_NAME_ IS
'任务名称';

COMMENT ON COLUMN BPM_TASK_NOTICE_DONE.TOKEN_ IS
'任务令牌';

COMMENT ON COLUMN BPM_TASK_NOTICE_DONE.QUALFIEDS_ IS
'有审批资格用户ID串';

COMMENT ON COLUMN BPM_TASK_NOTICE_DONE.QUALFIED_NAMES_ IS
'有审批资格用户名称串';

COMMENT ON COLUMN BPM_TASK_NOTICE_DONE.AUDITOR_ IS
'执行人ID';

COMMENT ON COLUMN BPM_TASK_NOTICE_DONE.AUDITOR_NAME_ IS
'执行人名';

COMMENT ON COLUMN BPM_TASK_NOTICE_DONE.ORG_ID_ IS
'组织ID';

COMMENT ON COLUMN BPM_TASK_NOTICE_DONE.ORG_PATH_ IS
'组织全路径';

COMMENT ON COLUMN BPM_TASK_NOTICE_DONE.OPINION_ IS
'审批意见';

COMMENT ON COLUMN BPM_TASK_NOTICE_DONE.STATUS_ IS
'知会任务已办状态';

COMMENT ON COLUMN BPM_TASK_NOTICE_DONE.FORM_DEF_ID_ IS
'表单定义ID';

COMMENT ON COLUMN BPM_TASK_NOTICE_DONE.FORM_NAME_ IS
'表单名';

COMMENT ON COLUMN BPM_TASK_NOTICE_DONE.DUR_MS_ IS
'持续时间(ms)';

COMMENT ON COLUMN BPM_TASK_NOTICE_DONE.FILES_ IS
'附件';

COMMENT ON COLUMN BPM_TASK_NOTICE_DONE.INTERPOSE_ IS
'是否干预';

COMMENT ON COLUMN BPM_TASK_NOTICE_DONE.SUBJECT_ IS
'流程标题';

COMMENT ON COLUMN BPM_TASK_NOTICE_DONE.PROC_DEF_NAME_ IS
'任务名称';

COMMENT ON COLUMN BPM_TASK_NOTICE_DONE.BPM_TASK_NOTICE_ID_ IS
'知会待办主键ID';

COMMENT ON COLUMN BPM_TASK_NOTICE_DONE.SUPPORT_MOBILE_ IS
'是否支持手机0：不支持，1：支持';

CREATE TABLE BPM_TASK_READ (
   READ_ID_             VARCHAR(64)          NOT NULL,
   PROC_DEF_ID          VARCHAR(64)          NULL DEFAULT NULL,
   PROC_INST_ID_        VARCHAR(64)          NULL DEFAULT NULL,
   TASK_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   NODE_ID_             VARCHAR(255)         NULL DEFAULT NULL,
   READ_TIME_           TIMESTAMP                 NULL,
   USER_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   USER_NAME_           VARCHAR(32)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_TASK_READ PRIMARY KEY (READ_ID_)
);

COMMENT ON TABLE BPM_TASK_READ IS
'流程任务查看';

COMMENT ON COLUMN BPM_TASK_READ.READ_ID_ IS
'主键';

COMMENT ON COLUMN BPM_TASK_READ.PROC_DEF_ID IS
'流程定义ID';

COMMENT ON COLUMN BPM_TASK_READ.PROC_INST_ID_ IS
'流程实例ID';

COMMENT ON COLUMN BPM_TASK_READ.TASK_ID_ IS
'任务ID';

COMMENT ON COLUMN BPM_TASK_READ.NODE_ID_ IS
'节点ID';

COMMENT ON COLUMN BPM_TASK_READ.USER_ID_ IS
'用户ID';

COMMENT ON COLUMN BPM_TASK_READ.USER_NAME_ IS
'用户名';

CREATE TABLE BPM_TASK_REMINDER (
   ID_                  VARCHAR(64)          NOT NULL,
   TASK_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   NAME_                VARCHAR(64)          NULL DEFAULT NULL,
   REL_DATE_            TIMESTAMP                 NULL,
   DUE_ACTION_          VARCHAR(64)          NULL DEFAULT NULL,
   DUE_SCRIPT_          VARCHAR(255)         NULL DEFAULT NULL,
   DUE_DATE_            TIMESTAMP                 NULL,
   IS_SEND_MSG_         INT4                 NULL DEFAULT NULL,
   MSG_SEND_DATE_       TIMESTAMP                 NULL,
   MSG_INTERVAL_        INT4                 NULL DEFAULT NULL,
   MSG_COUNT_           INT4                 NULL DEFAULT NULL,
   MSG_TYPE_            VARCHAR(64)          NULL DEFAULT NULL,
   HTML_MSG_            VARCHAR(255)         NULL DEFAULT NULL,
   PLAIN_MSG_           VARCHAR(255)         NULL DEFAULT NULL,
   WARNINGSET_          VARCHAR(255)         NULL DEFAULT NULL,
   TRIGGER_DATE_        TIMESTAMP                 NULL,
   SEND_PERSON_         VARCHAR(64)          NULL DEFAULT NULL,
   SEND_USER_ID_        VARCHAR(64)          NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   DURATION_SCRIPT_     TEXT                 NULL,
   DURATION_            INT4                 NULL,
   SEND_DURATION_       INT4                 NULL,
   DATE_TYPE_           VARCHAR(20)          NULL,
   TYPE_SCRIPT_         TEXT                 NULL,
   REL_TIME_SCRIPT_     TEXT                 NULL,
   CONSTRAINT PK_BPM_TASK_REMINDER PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_TASK_REMINDER IS
'任务催办';

COMMENT ON COLUMN BPM_TASK_REMINDER.TASK_ID_ IS
'催办任务ID';

COMMENT ON COLUMN BPM_TASK_REMINDER.NAME_ IS
'催办名称';

COMMENT ON COLUMN BPM_TASK_REMINDER.DUE_ACTION_ IS
'到期执行动作';

COMMENT ON COLUMN BPM_TASK_REMINDER.DUE_SCRIPT_ IS
'调用指定方法';

COMMENT ON COLUMN BPM_TASK_REMINDER.IS_SEND_MSG_ IS
'期间是否发送催办';

COMMENT ON COLUMN BPM_TASK_REMINDER.MSG_INTERVAL_ IS
'发送消息间隔';

COMMENT ON COLUMN BPM_TASK_REMINDER.MSG_COUNT_ IS
'发送次数';

COMMENT ON COLUMN BPM_TASK_REMINDER.MSG_TYPE_ IS
'消息类型  inner,msg,email 等';

COMMENT ON COLUMN BPM_TASK_REMINDER.HTML_MSG_ IS
'富文本';

COMMENT ON COLUMN BPM_TASK_REMINDER.PLAIN_MSG_ IS
'纯文本消息';

COMMENT ON COLUMN BPM_TASK_REMINDER.WARNINGSET_ IS
'预警配置（预警名称，triggerDate，change2level）';

COMMENT ON COLUMN BPM_TASK_REMINDER.SEND_USER_ID_ IS
'发送个人ID';

COMMENT ON COLUMN BPM_TASK_REMINDER.DURATION_SCRIPT_ IS
'时长脚本';

COMMENT ON COLUMN BPM_TASK_REMINDER.DURATION_ IS
'时长';

COMMENT ON COLUMN BPM_TASK_REMINDER.SEND_DURATION_ IS
'消息时长';

COMMENT ON COLUMN BPM_TASK_REMINDER.DATE_TYPE_ IS
'类型 caltime日历日 worktime工作日';

COMMENT ON COLUMN BPM_TASK_REMINDER.TYPE_SCRIPT_ IS
'类型脚本';

COMMENT ON COLUMN BPM_TASK_REMINDER.REL_TIME_SCRIPT_ IS
'相对时间脚本';

CREATE TABLE BPM_TASK_SIGNDATA (
   ID_                  VARCHAR(64)          NOT NULL,
   DEF_ID_              VARCHAR(64)          NULL DEFAULT NULL,
   INST_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   EXECUTE_ID_          VARCHAR(40)          NULL DEFAULT NULL,
   ACT_INST_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   NODE_ID_             VARCHAR(128)         NULL DEFAULT NULL,
   TASK_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   QUALIFIED_ID_        VARCHAR(255)         NULL DEFAULT NULL,
   QUALIFIED_NAME_      VARCHAR(512)         NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   VOTE_RESULT_         VARCHAR(20)          NULL DEFAULT NULL,
   VOTE_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   VOTER_               VARCHAR(40)          NULL DEFAULT NULL,
   VOTE_TIME_           TIMESTAMP                 NULL,
   INDEX_               INT4                 NULL DEFAULT NULL,
   IS_ACTIVE_           INT4                 NULL DEFAULT NULL,
   TYPE_                VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_TASK_SIGNDATA PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_TASK_SIGNDATA IS
'会签数据';

COMMENT ON COLUMN BPM_TASK_SIGNDATA.DEF_ID_ IS
'流程定义ID';

COMMENT ON COLUMN BPM_TASK_SIGNDATA.INST_ID_ IS
'流程实例ID';

COMMENT ON COLUMN BPM_TASK_SIGNDATA.EXECUTE_ID_ IS
'act运行实例Id';

COMMENT ON COLUMN BPM_TASK_SIGNDATA.ACT_INST_ID_ IS
'ACT流程实例ID';

COMMENT ON COLUMN BPM_TASK_SIGNDATA.NODE_ID_ IS
'节点ID';

COMMENT ON COLUMN BPM_TASK_SIGNDATA.TASK_ID_ IS
'流程任务ID';

COMMENT ON COLUMN BPM_TASK_SIGNDATA.QUALIFIED_ID_ IS
'有资格审批的成员ID';

COMMENT ON COLUMN BPM_TASK_SIGNDATA.QUALIFIED_NAME_ IS
'有资格审批的成员名称';

COMMENT ON COLUMN BPM_TASK_SIGNDATA.VOTE_RESULT_ IS
'投票结果(no 未投票 通过 agree,abandon 弃权,oppose 反对)';

COMMENT ON COLUMN BPM_TASK_SIGNDATA.VOTE_ID_ IS
'投票人';

COMMENT ON COLUMN BPM_TASK_SIGNDATA.VOTER_ IS
'投票人';

COMMENT ON COLUMN BPM_TASK_SIGNDATA.INDEX_ IS
'投票次序';

COMMENT ON COLUMN BPM_TASK_SIGNDATA.IS_ACTIVE_ IS
'是否活动';

COMMENT ON COLUMN BPM_TASK_SIGNDATA.TYPE_ IS
'流程定义ID';

CREATE TABLE BPM_TASK_SIGN_LINE (
   ID_                  VARCHAR(64)          NOT NULL,
   INSTANCE_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   TASK_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   PARENT_TASK_ID_      VARCHAR(64)          NULL DEFAULT NULL,
   PATH_                VARCHAR(512)         NULL DEFAULT NULL,
   STATUS_              VARCHAR(64)          NULL DEFAULT NULL,
   EXECUTOR_            VARCHAR(2048)        NULL DEFAULT NULL,
   ACTION_              VARCHAR(64)          NULL DEFAULT NULL,
   NODE_ID_             VARCHAR(128)         NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_TASK_SIGN_LINE PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_TASK_SIGN_LINE IS
'并行签署';

COMMENT ON COLUMN BPM_TASK_SIGN_LINE.INSTANCE_ID_ IS
'流程实例';

COMMENT ON COLUMN BPM_TASK_SIGN_LINE.TASK_ID_ IS
'任务ID';

COMMENT ON COLUMN BPM_TASK_SIGN_LINE.PATH_ IS
'路径';

COMMENT ON COLUMN BPM_TASK_SIGN_LINE.EXECUTOR_ IS
'执行人';

COMMENT ON COLUMN BPM_TASK_SIGN_LINE.ACTION_ IS
'并行签署后的动作 submit提交 back返回 ';

COMMENT ON COLUMN BPM_TASK_SIGN_LINE.NODE_ID_ IS
'节点id';

CREATE TABLE BPM_TASK_SIGN_SEQUENCE (
   ID_                  VARCHAR(64)          NOT NULL,
   INSTANCE_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   NODE_ID_             VARCHAR(128)         NULL DEFAULT NULL,
   TASK_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   NEXT_TASK_ID_        VARCHAR(64)          NULL DEFAULT NULL,
   PARENT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   STATUS_              VARCHAR(64)          NULL DEFAULT NULL,
   PATH_                VARCHAR(512)         NULL DEFAULT NULL,
   SEQ_                 INT2                 NULL DEFAULT NULL,
   EXECUTOR_            VARCHAR(2048)        NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_TASK_SIGN_SEQUENCE PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_TASK_SIGN_SEQUENCE IS
'顺序签署人员';

COMMENT ON COLUMN BPM_TASK_SIGN_SEQUENCE.INSTANCE_ID_ IS
'流程实例';

COMMENT ON COLUMN BPM_TASK_SIGN_SEQUENCE.NODE_ID_ IS
'节点key';

COMMENT ON COLUMN BPM_TASK_SIGN_SEQUENCE.TASK_ID_ IS
'任务ID';

COMMENT ON COLUMN BPM_TASK_SIGN_SEQUENCE.NEXT_TASK_ID_ IS
'下一任务ID';

COMMENT ON COLUMN BPM_TASK_SIGN_SEQUENCE.PATH_ IS
'路径';

COMMENT ON COLUMN BPM_TASK_SIGN_SEQUENCE.SEQ_ IS
'顺序';

COMMENT ON COLUMN BPM_TASK_SIGN_SEQUENCE.EXECUTOR_ IS
'执行人';

CREATE TABLE BPM_TASK_TRANS (
   ID_                  VARCHAR(64)          NOT NULL,
   INSTANCE_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   TASK_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   ACTION_              VARCHAR(20)          NULL DEFAULT NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATOR_             VARCHAR(128)         NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   DECIDE_TYPE_         VARCHAR(20)          NULL DEFAULT NULL,
   VOTE_TYPE_           VARCHAR(20)          NULL DEFAULT NULL,
   VOTE_AMOUNT_         INT2                 NULL DEFAULT NULL,
   SIGN_TYPE_           VARCHAR(20)          NULL DEFAULT NULL,
   INQU_TYPE_           VARCHAR(20)          NULL,
   TOTAL_AMOUNT_        INT2                 NULL DEFAULT NULL,
   AGREE_AMOUNT_        INT2                 NULL DEFAULT NULL,
   OPPOSE_AMOUNT_       INT2                 NULL DEFAULT NULL,
   SEQ_                 INT2                 NULL DEFAULT NULL,
   USER_JSON_           VARCHAR(4000)        NULL DEFAULT NULL,
   ALLOW_FORM_EDIT_     INT2                 NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_TASK_TRANS PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_TASK_TRANS IS
'流程流转';

COMMENT ON COLUMN BPM_TASK_TRANS.INSTANCE_ID_ IS
'流程实例';

COMMENT ON COLUMN BPM_TASK_TRANS.TASK_ID_ IS
'任务ID\r\n流转任务ID';

COMMENT ON COLUMN BPM_TASK_TRANS.ACTION_ IS
'完成后的操作';

COMMENT ON COLUMN BPM_TASK_TRANS.CREATOR_ IS
'创建人';

COMMENT ON COLUMN BPM_TASK_TRANS.DECIDE_TYPE_ IS
'决策类型\r\nagree\r\noppose';

COMMENT ON COLUMN BPM_TASK_TRANS.VOTE_TYPE_ IS
'投票类型\r\namount\r\npercent';

COMMENT ON COLUMN BPM_TASK_TRANS.VOTE_AMOUNT_ IS
'票数';

COMMENT ON COLUMN BPM_TASK_TRANS.SIGN_TYPE_ IS
'会签类型\r\nparallel,seq';

COMMENT ON COLUMN BPM_TASK_TRANS.INQU_TYPE_ IS
'征询类型 direct step';

COMMENT ON COLUMN BPM_TASK_TRANS.TOTAL_AMOUNT_ IS
'总票数';

COMMENT ON COLUMN BPM_TASK_TRANS.AGREE_AMOUNT_ IS
'通过票数';

COMMENT ON COLUMN BPM_TASK_TRANS.OPPOSE_AMOUNT_ IS
'反对票数';

COMMENT ON COLUMN BPM_TASK_TRANS.SEQ_ IS
'投票次序';

COMMENT ON COLUMN BPM_TASK_TRANS.USER_JSON_ IS
'用户数据';

COMMENT ON COLUMN BPM_TASK_TRANS.ALLOW_FORM_EDIT_ IS
'表单允许编辑';

CREATE TABLE BPM_TASK_TRANS_RECORD (
   ID_                  VARCHAR(64)          NOT NULL,
   PROC_INST_ID_        VARCHAR(64)          NULL DEFAULT NULL,
   TASK_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   ACTION_              VARCHAR(20)          NULL DEFAULT NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATOR_             VARCHAR(128)         NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   DECIDE_TYPE          VARCHAR(20)          NULL DEFAULT NULL,
   VOTE_TYPE_           VARCHAR(20)          NULL DEFAULT NULL,
   VOTE_AMOUNT_         INT2                 NULL DEFAULT NULL,
   SIGN_TYPE_           VARCHAR(20)          NULL DEFAULT NULL,
   TOTAL_AMOUNT_        INT2                 NULL DEFAULT NULL,
   AGREE_AMOUNT_        INT2                 NULL DEFAULT NULL,
   OPPOSE_AMOUNT_       INT2                 NULL DEFAULT NULL,
   TRANS_USERS_         VARCHAR(300)         NULL DEFAULT NULL,
   TASK_NAME_           VARCHAR(200)         NULL DEFAULT NULL,
   TASK_SUBJECT_        VARCHAR(300)         NULL DEFAULT NULL,
   STATUS_              INT2                 NULL DEFAULT NULL,
   TRANS_USER_IDS_      VARCHAR(300)         NULL DEFAULT NULL,
   TRANS_OPINION_       VARCHAR(200)         NULL DEFAULT NULL,
   TRANS_TIME_          TIMESTAMP                 NULL,
   DEF_NAME_            VARCHAR(200)         NULL DEFAULT NULL,
   TRANS_OWNER_         VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_TASK_TRANS_RECORD PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_TASK_TRANS_RECORD IS
'流程流转记录';

COMMENT ON COLUMN BPM_TASK_TRANS_RECORD.PROC_INST_ID_ IS
'流程实例';

COMMENT ON COLUMN BPM_TASK_TRANS_RECORD.TASK_ID_ IS
'任务ID\r\n流转任务ID';

COMMENT ON COLUMN BPM_TASK_TRANS_RECORD.ACTION_ IS
'完成后的操作';

COMMENT ON COLUMN BPM_TASK_TRANS_RECORD.CREATOR_ IS
'创建人';

COMMENT ON COLUMN BPM_TASK_TRANS_RECORD.DECIDE_TYPE IS
'决策类型\r\n同意 agree\r\n反对  oppose';

COMMENT ON COLUMN BPM_TASK_TRANS_RECORD.VOTE_TYPE_ IS
'投票类型';

COMMENT ON COLUMN BPM_TASK_TRANS_RECORD.VOTE_AMOUNT_ IS
'票数';

COMMENT ON COLUMN BPM_TASK_TRANS_RECORD.SIGN_TYPE_ IS
'会签类型';

COMMENT ON COLUMN BPM_TASK_TRANS_RECORD.TOTAL_AMOUNT_ IS
'总票数';

COMMENT ON COLUMN BPM_TASK_TRANS_RECORD.AGREE_AMOUNT_ IS
'通过票数';

COMMENT ON COLUMN BPM_TASK_TRANS_RECORD.OPPOSE_AMOUNT_ IS
'反对票数';

COMMENT ON COLUMN BPM_TASK_TRANS_RECORD.TRANS_USERS_ IS
'流转人员';

COMMENT ON COLUMN BPM_TASK_TRANS_RECORD.TASK_NAME_ IS
'任务名称';

COMMENT ON COLUMN BPM_TASK_TRANS_RECORD.TASK_SUBJECT_ IS
'流转任务标题';

COMMENT ON COLUMN BPM_TASK_TRANS_RECORD.STATUS_ IS
'状态：0流转中 1流转结束 2已撤销';

COMMENT ON COLUMN BPM_TASK_TRANS_RECORD.TRANS_USER_IDS_ IS
'流转人员ids';

COMMENT ON COLUMN BPM_TASK_TRANS_RECORD.TRANS_OPINION_ IS
'流转意见(原因)';

COMMENT ON COLUMN BPM_TASK_TRANS_RECORD.DEF_NAME_ IS
'流程名称';

COMMENT ON COLUMN BPM_TASK_TRANS_RECORD.TRANS_OWNER_ IS
'流转任务所属人ID';

CREATE TABLE BPM_TASK_TURN (
   ID_                  VARCHAR(64)          NOT NULL,
   TASK_ID_             VARCHAR(64)          NOT NULL,
   TASK_NAME_           VARCHAR(64)          NOT NULL,
   TASK_SUBJECT_        VARCHAR(128)         NOT NULL,
   NODE_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   PROC_INST_ID_        VARCHAR(64)          NOT NULL,
   OWNER_ID_            VARCHAR(64)          NULL DEFAULT NULL,
   OWNER_NAME_          VARCHAR(64)          NULL DEFAULT NULL,
   ASSIGNEE_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   ASSIGNEE_NAME_       VARCHAR(64)          NULL DEFAULT NULL,
   STATUS_              VARCHAR(40)          NULL DEFAULT NULL,
   TURN_TYPE_           VARCHAR(40)          NULL DEFAULT NULL,
   TYPE_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   FINISH_TIME_         TIMESTAMP                 NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_TASK_TURN PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_TASK_TURN IS
'任务的执行更改，更改类型。agent=代理；shift=转办；copy_to=抄送';

COMMENT ON COLUMN BPM_TASK_TURN.TASK_ID_ IS
'任务ID';

COMMENT ON COLUMN BPM_TASK_TURN.TASK_NAME_ IS
'任务名称';

COMMENT ON COLUMN BPM_TASK_TURN.TASK_SUBJECT_ IS
'待办事项标题';

COMMENT ON COLUMN BPM_TASK_TURN.NODE_ID_ IS
'关联 - 任务节点ID';

COMMENT ON COLUMN BPM_TASK_TURN.PROC_INST_ID_ IS
'关联 - 流程实例ID';

COMMENT ON COLUMN BPM_TASK_TURN.OWNER_ID_ IS
'任务所属人ID';

COMMENT ON COLUMN BPM_TASK_TURN.OWNER_NAME_ IS
'任务所属人姓名';

COMMENT ON COLUMN BPM_TASK_TURN.ASSIGNEE_ID_ IS
'任务执行人ID';

COMMENT ON COLUMN BPM_TASK_TURN.ASSIGNEE_NAME_ IS
'任务执行人姓名';

COMMENT ON COLUMN BPM_TASK_TURN.STATUS_ IS
'状态。running=正在运行；finish=完成；cancel=取消';

COMMENT ON COLUMN BPM_TASK_TURN.TURN_TYPE_ IS
'更改类型。agent=代理；shift=转办；copy_to=抄送';

COMMENT ON COLUMN BPM_TASK_TURN.TYPE_ID_ IS
'所属分类ID';

CREATE TABLE BPM_TASK_TURNASSIGN (
   ID_                  VARCHAR(64)          NOT NULL,
   TASK_TURN_ID_        VARCHAR(64)          NULL DEFAULT NULL,
   FROM_USER_ID_        VARCHAR(64)          NULL DEFAULT NULL,
   FROM_USER_           VARCHAR(64)          NULL DEFAULT NULL,
   RECEIVER_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   RECEIVER             VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   COMMENT_             VARCHAR(1024)        NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_TASK_TURNASSIGN PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_TASK_TURNASSIGN IS
'任务指派人员';

COMMENT ON COLUMN BPM_TASK_TURNASSIGN.TASK_TURN_ID_ IS
'转交ID和task_turn表主键关联';

COMMENT ON COLUMN BPM_TASK_TURNASSIGN.FROM_USER_ID_ IS
'任务转交人ID';

COMMENT ON COLUMN BPM_TASK_TURNASSIGN.FROM_USER_ IS
'任务转交人';

COMMENT ON COLUMN BPM_TASK_TURNASSIGN.RECEIVER_ID_ IS
'接收人ID';

COMMENT ON COLUMN BPM_TASK_TURNASSIGN.RECEIVER IS
'接收人';

COMMENT ON COLUMN BPM_TASK_TURNASSIGN.COMMENT_ IS
'备注';

CREATE TABLE BPM_TASK_URGENT (
   ID_                  VARCHAR(255)         NOT NULL,
   TASK_ID_             VARCHAR(255)         NULL DEFAULT NULL,
   NODE_NAME_           VARCHAR(255)         NULL DEFAULT NULL,
   INST_ID_             VARCHAR(255)         NULL DEFAULT NULL,
   SUBJECT_             VARCHAR(255)         NULL DEFAULT NULL,
   CONTENT_             TEXT                 NULL,
   URGRNT_DATE_         TIMESTAMP                 NULL,
   PROMOTER_ID_         VARCHAR(255)         NULL DEFAULT NULL,
   PROMOTER_            VARCHAR(255)         NULL DEFAULT NULL,
   APPOINTEE_ID_        VARCHAR(255)         NULL DEFAULT NULL,
   APPOINTEE_           VARCHAR(2000)        NULL DEFAULT NULL,
   TYPE_                VARCHAR(255)         NULL DEFAULT NULL,
   APPOINTEE_SECRETARY_CONF_ VARCHAR(1024)        NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_TASK_URGENT PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_TASK_URGENT IS
'人工催办表';

COMMENT ON COLUMN BPM_TASK_URGENT.TASK_ID_ IS
'任务ID';

COMMENT ON COLUMN BPM_TASK_URGENT.NODE_NAME_ IS
'节点名称';

COMMENT ON COLUMN BPM_TASK_URGENT.INST_ID_ IS
'流程实例ID';

COMMENT ON COLUMN BPM_TASK_URGENT.SUBJECT_ IS
'流程标题';

COMMENT ON COLUMN BPM_TASK_URGENT.CONTENT_ IS
'催办内容';

COMMENT ON COLUMN BPM_TASK_URGENT.PROMOTER_ID_ IS
'催办人ID';

COMMENT ON COLUMN BPM_TASK_URGENT.PROMOTER_ IS
'催办人';

COMMENT ON COLUMN BPM_TASK_URGENT.APPOINTEE_ID_ IS
'被催办人ID';

COMMENT ON COLUMN BPM_TASK_URGENT.APPOINTEE_ IS
'被催办人';

COMMENT ON COLUMN BPM_TASK_URGENT.TYPE_ IS
'催办类型';

COMMENT ON COLUMN BPM_TASK_URGENT.APPOINTEE_SECRETARY_CONF_ IS
'催办的领导和秘书的id关系map，方便秘书回复时确定代哪个领导审批的';

CREATE TABLE BPM_TEST_CASE (
   ID_                  VARCHAR(64)          NOT NULL,
   NAME_                VARCHAR(128)         NULL DEFAULT NULL,
   BO_FORM_DATA_        TEXT                 NULL,
   FLOW_VARS_           VARCHAR(4000)        NULL DEFAULT NULL,
   ACTION_TYPE_         VARCHAR(4000)        NULL DEFAULT NULL,
   STARTOR_             VARCHAR(4000)        NULL DEFAULT NULL,
   BPM_DEBUGGER_        VARCHAR(4000)        NULL DEFAULT NULL,
   DEF_KEY_             VARCHAR(64)          NULL DEFAULT NULL,
   STARTOR_ACCOUNT_     VARCHAR(64)          NULL DEFAULT NULL,
   STARTOR_FULL_NAME_   VARCHAR(128)         NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_TEST_CASE PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_TEST_CASE IS
'流程仿真测试用例表';

COMMENT ON COLUMN BPM_TEST_CASE.NAME_ IS
'测试用例名称';

COMMENT ON COLUMN BPM_TEST_CASE.BO_FORM_DATA_ IS
'表单数据';

COMMENT ON COLUMN BPM_TEST_CASE.FLOW_VARS_ IS
'流程变量';

COMMENT ON COLUMN BPM_TEST_CASE.ACTION_TYPE_ IS
'审批动作， 默认动作时 agree';

COMMENT ON COLUMN BPM_TEST_CASE.STARTOR_ IS
'发起人json';

COMMENT ON COLUMN BPM_TEST_CASE.BPM_DEBUGGER_ IS
'断点测试设置';

COMMENT ON COLUMN BPM_TEST_CASE.DEF_KEY_ IS
'流程定义key';

COMMENT ON COLUMN BPM_TEST_CASE.STARTOR_ACCOUNT_ IS
'发起人账号';

COMMENT ON COLUMN BPM_TEST_CASE.STARTOR_FULL_NAME_ IS
'发起人姓名';

CREATE TABLE BPM_TEST_CASE_LOGS (
   ID_                  VARCHAR(64)          NOT NULL,
   OPE_NAME_            VARCHAR(128)         NULL DEFAULT NULL,
   EXECUTION_TIME_      TIMESTAMP                 NULL DEFAULT NULL,
   OPE_CONTENT_         TEXT                 NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(255)         NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_TEST_CASE_LOGS PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_TEST_CASE_LOGS IS
'流程仿真异常日志';

COMMENT ON COLUMN BPM_TEST_CASE_LOGS.ID_ IS
'主键ID';

COMMENT ON COLUMN BPM_TEST_CASE_LOGS.OPE_NAME_ IS
'操作名称';

COMMENT ON COLUMN BPM_TEST_CASE_LOGS.OPE_CONTENT_ IS
'操作内容';

COMMENT ON COLUMN BPM_TEST_CASE_LOGS.TENANT_ID_ IS
'租户ID';

CREATE TABLE BPM_TRANS_RECEIVER (
   ID_                  VARCHAR(64)          NOT NULL,
   TRANS_RECORDID_      VARCHAR(64)          NULL DEFAULT NULL,
   RECEIVER_            VARCHAR(100)         NULL DEFAULT NULL,
   RECEIVER_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   STATUS_              INT2                 NULL DEFAULT NULL,
   OPINION_             VARCHAR(200)         NULL DEFAULT NULL,
   RECEIVER_TIME_       TIMESTAMP                 NULL,
   CHECK_TIME_          TIMESTAMP                 NULL,
   CHECK_TYPE_          INT2                 NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_TRANS_RECEIVER PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_TRANS_RECEIVER IS
'流转任务接收人';

COMMENT ON COLUMN BPM_TRANS_RECEIVER.TRANS_RECORDID_ IS
'流转任务记录ID';

COMMENT ON COLUMN BPM_TRANS_RECEIVER.RECEIVER_ IS
'流转接受人员';

COMMENT ON COLUMN BPM_TRANS_RECEIVER.RECEIVER_ID_ IS
'流转接收人id';

COMMENT ON COLUMN BPM_TRANS_RECEIVER.STATUS_ IS
'状态:0尚未处理1已处理';

COMMENT ON COLUMN BPM_TRANS_RECEIVER.OPINION_ IS
'审核意见';

COMMENT ON COLUMN BPM_TRANS_RECEIVER.CHECK_TYPE_ IS
'审核状态';

CREATE TABLE BPM_TRANS_RECORD (
   ID_                  VARCHAR(64)          NOT NULL,
   TYPE_                VARCHAR(20)          NULL DEFAULT NULL,
   TRANSFER_            VARCHAR(64)          NULL DEFAULT NULL,
   TRANSFER_NAME_       VARCHAR(64)          NULL DEFAULT NULL,
   TRANSFERED_          VARCHAR(64)          NULL DEFAULT NULL,
   TRANSFERED_NAME_     VARCHAR(64)          NULL DEFAULT NULL,
   REASON_              VARCHAR(2000)        NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   RESULT_              VARCHAR(2000)        NULL DEFAULT NULL,
   VAR_                 INT4                 NULL DEFAULT NULL,
   PROC_INST_IDS_       VARCHAR(2000)        NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_TRANS_RECORD PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_TRANS_RECORD IS
'移交记录';

COMMENT ON COLUMN BPM_TRANS_RECORD.TYPE_ IS
'移交类型';

COMMENT ON COLUMN BPM_TRANS_RECORD.TRANSFER_ IS
'移交人ID';

COMMENT ON COLUMN BPM_TRANS_RECORD.TRANSFER_NAME_ IS
'移交人姓名';

COMMENT ON COLUMN BPM_TRANS_RECORD.TRANSFERED_NAME_ IS
'被移交人姓名';

COMMENT ON COLUMN BPM_TRANS_RECORD.REASON_ IS
'移交原因';

COMMENT ON COLUMN BPM_TRANS_RECORD.CREATE_BY_ IS
'创建人ID';

COMMENT ON COLUMN BPM_TRANS_RECORD.RESULT_ IS
'移交结果';

COMMENT ON COLUMN BPM_TRANS_RECORD.VAR_ IS
'移交方式';

COMMENT ON COLUMN BPM_TRANS_RECORD.PROC_INST_IDS_ IS
'流程实例ID';

CREATE TABLE BPM_WATERMARK (
   ID_                  VARCHAR(64)          NOT NULL,
   NAME_                VARCHAR(128)         NULL DEFAULT NULL,
   CONTENT_             TEXT                 NULL,
   TYPE_                INT2                 NULL DEFAULT NULL,
   COLOR_               VARCHAR(32)          NULL DEFAULT NULL,
   AMOUNT_              INT4                 NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL DEFAULT NULL,
   CREATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(64)          NULL DEFAULT NULL,
   CREATE_ORG_ID_       VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_WATERMARK PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_WATERMARK IS
'流程水印';

COMMENT ON COLUMN BPM_WATERMARK.ID_ IS
'主键';

COMMENT ON COLUMN BPM_WATERMARK.NAME_ IS
'名称';

COMMENT ON COLUMN BPM_WATERMARK.CONTENT_ IS
'内容';

COMMENT ON COLUMN BPM_WATERMARK.TYPE_ IS
'类型 1文字 2图片';

COMMENT ON COLUMN BPM_WATERMARK.COLOR_ IS
'颜色 透明度';

COMMENT ON COLUMN BPM_WATERMARK.AMOUNT_ IS
'页面展示数量';

COMMENT ON COLUMN BPM_WATERMARK.CREATE_TIME_ IS
'创建时间';

COMMENT ON COLUMN BPM_WATERMARK.CREATE_BY_ IS
'创建人';

COMMENT ON COLUMN BPM_WATERMARK.UPDATE_TIME_ IS
'更新时间';

COMMENT ON COLUMN BPM_WATERMARK.UPDATE_BY_ IS
'更新人';

COMMENT ON COLUMN BPM_WATERMARK.CREATE_ORG_ID_ IS
'创建人组织ID';

COMMENT ON COLUMN BPM_WATERMARK.TENANT_ID_ IS
'租户ID';

CREATE TABLE BPM_WATERMARK_PROCESS (
   ID_                  VARCHAR(64)          NOT NULL,
   PROC_DEF_ID_         VARCHAR(64)          NULL DEFAULT NULL,
   PROC_DEF_KEY_        VARCHAR(128)         NULL DEFAULT NULL,
   PROC_DEF_NAME_       VARCHAR(128)         NULL DEFAULT NULL,
   WATERMARK_ID_        VARCHAR(64)          NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_WATERMARK_PROCESS PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_WATERMARK_PROCESS IS
'水印分配流程';

COMMENT ON COLUMN BPM_WATERMARK_PROCESS.ID_ IS
'ID';

COMMENT ON COLUMN BPM_WATERMARK_PROCESS.PROC_DEF_ID_ IS
'流程ID';

COMMENT ON COLUMN BPM_WATERMARK_PROCESS.PROC_DEF_KEY_ IS
'流程KEY';

COMMENT ON COLUMN BPM_WATERMARK_PROCESS.PROC_DEF_NAME_ IS
'流程名称';

COMMENT ON COLUMN BPM_WATERMARK_PROCESS.WATERMARK_ID_ IS
'水印ID';

COMMENT ON COLUMN BPM_WATERMARK_PROCESS.TENANT_ID_ IS
'租户ID';

CREATE TABLE BPM_WATERMARK_TYPE (
   ID_                  VARCHAR(64)          NOT NULL,
   TYPE_ID_             VARCHAR(64)          NULL DEFAULT NULL,
   WATERMARK_ID_        VARCHAR(64)          NULL DEFAULT NULL,
   TYPE_NAME_           VARCHAR(256)         NULL DEFAULT NULL,
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_BPM_WATERMARK_TYPE PRIMARY KEY (ID_)
);

COMMENT ON TABLE BPM_WATERMARK_TYPE IS
'水印分配分类';

COMMENT ON COLUMN BPM_WATERMARK_TYPE.ID_ IS
'主键';

COMMENT ON COLUMN BPM_WATERMARK_TYPE.TYPE_ID_ IS
'分类ID';

COMMENT ON COLUMN BPM_WATERMARK_TYPE.WATERMARK_ID_ IS
'水印ID';

COMMENT ON COLUMN BPM_WATERMARK_TYPE.TYPE_NAME_ IS
'分类名称';

COMMENT ON COLUMN BPM_WATERMARK_TYPE.TENANT_ID_ IS
'租户ID';

CREATE TABLE PORTAL_SHORTURL_MANAGE (
   ID_                  VARCHAR(64)          NOT NULL,
   URL_                 VARCHAR(2000)        NOT NULL,
   URL_DESC_            VARCHAR(2000)        NULL DEFAULT NULL,
   SHORT_URL_           VARCHAR(255)         NULL DEFAULT NULL,
   CREATE_BY_           VARCHAR(255)         NULL DEFAULT NULL,
   CREATE_TIME_         TIMESTAMP                 NULL,
   LOSE_TIME_           TIMESTAMP                 NULL,
   CREATE_ORG_ID_       VARCHAR(255)         NULL DEFAULT NULL,
   UPDATE_BY_           VARCHAR(255)         NULL DEFAULT NULL,
   UPDATE_TIME_         TIMESTAMP                 NULL,
   ENABLED_             VARCHAR(1)           NULL DEFAULT '1',
   TENANT_ID_           VARCHAR(64)          NULL DEFAULT NULL,
   CONSTRAINT PK_PORTAL_SHORTURL_MANAGE PRIMARY KEY (ID_)
);

COMMENT ON TABLE PORTAL_SHORTURL_MANAGE IS
'短连接管理表';

COMMENT ON COLUMN PORTAL_SHORTURL_MANAGE.ID_ IS
'主键';

COMMENT ON COLUMN PORTAL_SHORTURL_MANAGE.URL_ IS
'原链接';

COMMENT ON COLUMN PORTAL_SHORTURL_MANAGE.URL_DESC_ IS
'原链接描述';

COMMENT ON COLUMN PORTAL_SHORTURL_MANAGE.SHORT_URL_ IS
'短链接';

COMMENT ON COLUMN PORTAL_SHORTURL_MANAGE.CREATE_BY_ IS
'创建人';

COMMENT ON COLUMN PORTAL_SHORTURL_MANAGE.CREATE_ORG_ID_ IS
'创建人组织ID';

COMMENT ON COLUMN PORTAL_SHORTURL_MANAGE.UPDATE_BY_ IS
'更新人';

COMMENT ON COLUMN PORTAL_SHORTURL_MANAGE.ENABLED_ IS
'是否启用.1:启用，2：禁用';

