流程引擎Activiti性能优化方案
基于关系型数据库层面优化
MySQL建表语句优化
Activiti在MySQL中创建默认字符集为utf8(即utf8mb3)格式,本文将默认字符集设置为utf8mb4,排序规则为utf8mb4_general_ci,并修改变量等类型为text。
建表初始化语句如下:
本文使用的activiti-engine版本为7.1.0.M6,版本信息初始化在ACT_GE_PROPERTY表中
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for ACT_EVT_LOG
-- ----------------------------
DROP TABLE IF EXISTS `ACT_EVT_LOG`;
CREATE TABLE `ACT_EVT_LOG` (
`LOG_NR_` bigint NOT NULL AUTO_INCREMENT,
`TYPE_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
`PROC_DEF_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
`PROC_INST_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
`EXECUTION_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
`TASK_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
`TIME_STAMP_` timestamp(3) NOT NULL,
`USER_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
`DATA_` longblob,
`LOCK_OWNER_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
`LOCK_TIME_` timestamp(3) NULL DEFAULT NULL,
`IS_PROCESSED_` tinyint DEFAULT '0',
PRIMARY KEY (`LOG_NR_`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='存储事件日志的数据库表,默认情况下会创建此表,如果不开启事件日志记录机制,则可以删除此表。';
-- ----------------------------
-- Table structure for ACT_GE_BYTEARRAY
-- ----------------------------
DROP TABLE IF EXISTS `ACT_GE_BYTEARRAY`;
CREATE TABLE `ACT_GE_BYTEARRAY` (
`ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '资源ID(主键)',
`REV_` int DEFAULT NULL COMMENT '版本(乐观锁)',
`NAME_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '资源名称',
`DEPLOYMENT_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '部署ID,与部署表ACT_RE_ DEPLOYMENT的主键关联',
`BYTES_` longblob COMMENT '资源,最大可存4GB数据',
`GENERATED_` tinyint DEFAULT NULL COMMENT '是否是Activiti自动产生的资源',
PRIMARY KEY (`ID_`),
KEY `ACT_FK_BYTEARR_DEPL` (`DEPLOYMENT_ID_`),
CONSTRAINT `ACT_FK_BYTEARR_DEPL` FOREIGN KEY (`DEPLOYMENT_ID_`) REFERENCES `ACT_RE_DEPLOYMENT` (`ID_`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='资源表用于存储与工作流引擎相关的资源数据,Activiti使用该资源表保存流程定义文件内容、流程图片内容和序列化流程变量等二进制数据。';
-- ----------------------------
-- Table structure for ACT_GE_PROPERTY
-- ----------------------------
DROP TABLE IF EXISTS `ACT_GE_PROPERTY`;
CREATE TABLE `ACT_GE_PROPERTY` (
`NAME_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '属性名称',
`VALUE_` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '属性值',
`REV_` int DEFAULT NULL COMMENT '版本(乐观锁)',
PRIMARY KEY (`NAME_`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='属性表,用于存储整个工作流引擎级别的属性数据,Activiti将全部属性抽象为key-value,每个属性都有相应的名称和值。';
-- ----------------------------
-- Records of ACT_GE_PROPERTY
-- ----------------------------
BEGIN;
INSERT INTO `ACT_GE_PROPERTY` (`NAME_`, `VALUE_`, `REV_`) VALUES ('cfg.execution-related-entities-count', 'false', 1);
INSERT INTO `ACT_GE_PROPERTY` (`NAME_`, `VALUE_`, `REV_`) VALUES ('next.dbid', '2501', 2);
INSERT INTO `ACT_GE_PROPERTY` (`NAME_`, `VALUE_`, `REV_`) VALUES ('schema.history', 'create(7.1.0-M6)', 1);
INSERT INTO `ACT_GE_PROPERTY` (`NAME_`, `VALUE_`, `REV_`) VALUES ('schema.version', '7.1.0-M6', 1);
COMMIT;
-- ----------------------------
-- Table structure for ACT_HI_ACTINST
-- ----------------------------
DROP TABLE IF EXISTS `ACT_HI_ACTINST`;
CREATE TABLE `ACT_HI_ACTINST` (
`ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '节点实例ID(主键)',
`PROC_DEF_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '流程定义ID',
`PROC_INST_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '流程实例ID',
`EXECUTION_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '执行实例ID',
`ACT_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '活动ID',
`TASK_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '任务实例ID',
`CALL_PROC_INST_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '调用流程实例ID',
`ACT_NAME_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '活动名称',
`ACT_TYPE_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '活动类型',
`ASSIGNEE_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '办理人',
`START_TIME_` datetime(3) NOT NULL COMMENT '开始时间',
`END_TIME_` datetime(3) DEFAULT NULL COMMENT '结束时间',
`DURATION_` bigint DEFAULT NULL COMMENT '耗时',
`DELETE_REASON_` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '删除理由',
`TENANT_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '租户ID',
PRIMARY KEY (`ID_`),
KEY `ACT_IDX_HI_ACT_INST_START` (`START_TIME_`),
KEY `ACT_IDX_HI_ACT_INST_END` (`END_TIME_`),
KEY `ACT_IDX_HI_ACT_INST_PROCINST` (`PROC_INST_ID_`,`ACT_ID_`),
KEY `ACT_IDX_HI_ACT_INST_EXEC` (`EXECUTION_ID_`,`ACT_ID_`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='历史节点表,该表主要用于存储历史节点实例数据、记录所有流程活动实例。通过该表可以追踪最完整的流程信息。';
-- ----------------------------
-- Table structure for ACT_HI_ATTACHMENT
-- ----------------------------
DROP TABLE IF EXISTS `ACT_HI_ATTACHMENT`;
CREATE TABLE `ACT_HI_ATTACHMENT` (
`ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '附件ID(主键)',
`REV_` int DEFAULT NULL COMMENT '版本(乐观锁)',
`USER_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '用户ID',
`NAME_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '附件名称',
`DESCRIPTION_` varchar(4000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '附件描述',
`TYPE_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '附件类型',
`TASK_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '关联的任务实例ID',
`PROC_INST_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '关联的流程实例ID',
`URL_` varchar(4000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '附件的URL',
`CONTENT_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '附件内容ID,内容存储在ACT_GE_BYTEARRAY资源表',
`TIME_` datetime(3) DEFAULT NULL COMMENT '附件上传时间',
PRIMARY KEY (`ID_`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='历史附件表,该表主要用于存储通过任务服务TaskService添加的附件记录。';
-- ----------------------------
-- Table structure for ACT_HI_COMMENT
-- ----------------------------
DROP TABLE IF EXISTS `ACT_HI_COMMENT`;
CREATE TABLE `ACT_HI_COMMENT` (
`ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '评论ID(主键)',
`TYPE_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '意见记录类型',
`TIME_` datetime(3) NOT NULL COMMENT '记录时间',
`USER_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '用户ID',
`TASK_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '任务实例ID',
`PROC_INST_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程实例ID',
`ACTION_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '行为类型',
`MESSAGE_` varchar(4000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '处理意见',
`FULL_MSG_` longblob COMMENT '全部消息',
PRIMARY KEY (`ID_`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='历史评论表,该表主要用于存储通过TaskService添加的评论记录。';
-- ----------------------------
-- Table structure for ACT_HI_DETAIL
-- ----------------------------
DROP TABLE IF EXISTS `ACT_HI_DETAIL`;
CREATE TABLE `ACT_HI_DETAIL` (
`ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '变量ID(主键)',
`TYPE_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '变量类型',
`PROC_INST_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程实例ID',
`EXECUTION_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '执行实例ID',
`TASK_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '任务实例ID',
`ACT_INST_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '活动实例ID',
`NAME_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '变量名称',
`VAR_TYPE_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '变量类型',
`REV_` int DEFAULT NULL COMMENT '版本(乐观锁)',
`TIME_` datetime(3) NOT NULL COMMENT '创建时间',
`BYTEARRAY_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '二进制数据ID,关联资源表',
`DOUBLE_` double DEFAULT NULL COMMENT '存储小数类型的变量值',
`LONG_` bigint DEFAULT NULL COMMENT '存储整数类型的变量值',
`TEXT_` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '存储字符串类型的变量值',
`TEXT2_` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '此处存储的是JPA持久化对象时,才会有值。此值为对象ID',
PRIMARY KEY (`ID_`),
KEY `ACT_IDX_HI_DETAIL_PROC_INST` (`PROC_INST_ID_`),
KEY `ACT_IDX_HI_DETAIL_ACT_INST` (`ACT_INST_ID_`),
KEY `ACT_IDX_HI_DETAIL_TIME` (`TIME_`),
KEY `ACT_IDX_HI_DETAIL_NAME` (`NAME_`),
KEY `ACT_IDX_HI_DETAIL_TASK_ID` (`TASK_ID_`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='历史流程详情表,该表主要用于存储流程执行过程中的明细数据。默认情况下,Activiti不保存流程明细数据,除非将工作流引擎的历史数据配置为full。';
-- ----------------------------
-- Table structure for ACT_HI_IDENTITYLINK
-- ----------------------------
DROP TABLE IF EXISTS `ACT_HI_IDENTITYLINK`;
CREATE TABLE `ACT_HI_IDENTITYLINK` (
`ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '关系ID(主键)',
`GROUP_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '用户组ID',
`TYPE_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '用户组类型',
`USER_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '用户ID',
`TASK_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '任务实例ID',
`PROC_INST_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程实例ID',
PRIMARY KEY (`ID_`),
KEY `ACT_IDX_HI_IDENT_LNK_USER` (`USER_ID_`),
KEY `ACT_IDX_HI_IDENT_LNK_TASK` (`TASK_ID_`),
KEY `ACT_IDX_HI_IDENT_LNK_PROCINST` (`PROC_INST_ID_`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='历史流程与身份关系表,该表主要用于存储历史流程实例、任务实例与参与者之间的关联关系。';
-- ----------------------------
-- Table structure for ACT_HI_PROCINST
-- ----------------------------
DROP TABLE IF EXISTS `ACT_HI_PROCINST`;
CREATE TABLE `ACT_HI_PROCINST` (
`ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '流程实例ID(主键)',
`PROC_INST_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '流程实例ID,值同ID',
`BUSINESS_KEY_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '业务主键',
`PROC_DEF_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '流程定义ID',
`START_TIME_` datetime(3) NOT NULL COMMENT '开始时间',
`END_TIME_` datetime(3) DEFAULT NULL COMMENT '结束时间',
`DURATION_` bigint DEFAULT NULL COMMENT '耗时',
`START_USER_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '发起人ID',
`START_ACT_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '开始节点',
`END_ACT_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '结束节点',
`SUPER_PROCESS_INSTANCE_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '父流程实例ID',
`DELETE_REASON_` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '删除理由',
`TENANT_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '租户ID',
`NAME_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程名称',
PRIMARY KEY (`ID_`),
UNIQUE KEY `PROC_INST_ID_` (`PROC_INST_ID_`),
KEY `ACT_IDX_HI_PRO_INST_END` (`END_TIME_`),
KEY `ACT_IDX_HI_PRO_I_BUSKEY` (`BUSINESS_KEY_`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='历史流程实例表,该表主要用于存储历史流程实例。流程启动后,保存ACT_RU_EXECUTION表的同时,会将流程实例写入ACT_HI_PROCINST表。';
-- ----------------------------
-- Table structure for ACT_HI_TASKINST
-- ----------------------------
DROP TABLE IF EXISTS `ACT_HI_TASKINST`;
CREATE TABLE `ACT_HI_TASKINST` (
`ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '任务实例ID(主键)',
`PROC_DEF_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程定义ID',
`TASK_DEF_KEY_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '任务定义KEY',
`PROC_INST_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程实例ID',
`EXECUTION_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '执行实例ID',
`NAME_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '任务名称',
`PARENT_TASK_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '父任务ID',
`DESCRIPTION_` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '描述',
`OWNER_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '拥有者',
`ASSIGNEE_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '办理人',
`START_TIME_` datetime(3) NOT NULL COMMENT '开始时间',
`CLAIM_TIME_` datetime(3) DEFAULT NULL COMMENT '认领时间',
`END_TIME_` datetime(3) DEFAULT NULL COMMENT '结束时间',
`DURATION_` bigint DEFAULT NULL COMMENT '耗时',
`DELETE_REASON_` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '删除原因',
`PRIORITY_` int DEFAULT NULL COMMENT '优先级',
`DUE_DATE_` datetime(3) DEFAULT NULL COMMENT '到期时间',
`FORM_KEY_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '表单模型key',
`CATEGORY_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '分类',
`TENANT_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '租户ID',
PRIMARY KEY (`ID_`),
KEY `ACT_IDX_HI_TASK_INST_PROCINST` (`PROC_INST_ID_`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='历史任务实例表,该表与运行时任务实例表类似,用于存储历史任务实例数据。当流程执行到某个节点时,就会向该表中写入历史任务数据。';
-- ----------------------------
-- Table structure for ACT_HI_VARINST
-- ----------------------------
DROP TABLE IF EXISTS `ACT_HI_VARINST`;
CREATE TABLE `ACT_HI_VARINST` (
`ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '变量ID(主键)',
`PROC_INST_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程实例ID',
`EXECUTION_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '执行实例ID',
`TASK_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '任务实例ID',
`NAME_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '变量名称',
`VAR_TYPE_` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '变量类型',
`REV_` int DEFAULT NULL COMMENT '版本(乐观锁)',
`BYTEARRAY_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '二进制数据ID,关联资源表',
`DOUBLE_` double DEFAULT NULL COMMENT '存储小数类型的变量值',
`LONG_` bigint DEFAULT NULL COMMENT '存储整数类型的变量值',
`TEXT_` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '存储字符串类型的变量值',
`TEXT2_` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '此处存储的是JPA持久化对象时,才会有值。此值为对象ID',
`CREATE_TIME_` datetime(3) DEFAULT NULL COMMENT '创建时间',
`LAST_UPDATED_TIME_` datetime(3) DEFAULT NULL COMMENT '最近更改时间',
PRIMARY KEY (`ID_`),
KEY `ACT_IDX_HI_PROCVAR_PROC_INST` (`PROC_INST_ID_`),
KEY `ACT_IDX_HI_PROCVAR_NAME_TYPE` (`NAME_`,`VAR_TYPE_`),
KEY `ACT_IDX_HI_PROCVAR_TASK_ID` (`TASK_ID_`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='历史变量表,该表主要用于存储历史流程的变量信息。';
-- ----------------------------
-- Table structure for ACT_PROCDEF_INFO
-- ----------------------------
DROP TABLE IF EXISTS `ACT_PROCDEF_INFO`;
CREATE TABLE `ACT_PROCDEF_INFO` (
`ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '变量ID(主键)',
`PROC_DEF_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '流程定义ID',
`REV_` int DEFAULT NULL COMMENT '版本(乐观锁)',
`INFO_JSON_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
PRIMARY KEY (`ID_`),
UNIQUE KEY `ACT_UNIQ_INFO_PROCDEF` (`PROC_DEF_ID_`),
KEY `ACT_IDX_INFO_PROCDEF` (`PROC_DEF_ID_`),
KEY `ACT_FK_INFO_JSON_BA` (`INFO_JSON_ID_`),
CONSTRAINT `ACT_FK_INFO_JSON_BA` FOREIGN KEY (`INFO_JSON_ID_`) REFERENCES `ACT_GE_BYTEARRAY` (`ID_`),
CONSTRAINT `ACT_FK_INFO_PROCDEF` FOREIGN KEY (`PROC_DEF_ID_`) REFERENCES `ACT_RE_PROCDEF` (`ID_`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='流程定义信息表。';
-- ----------------------------
-- Table structure for ACT_RE_DEPLOYMENT
-- ----------------------------
DROP TABLE IF EXISTS `ACT_RE_DEPLOYMENT`;
CREATE TABLE `ACT_RE_DEPLOYMENT` (
`ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '部署记录ID(主键)',
`NAME_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '部署的名称',
`CATEGORY_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '分类',
`KEY_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程模型标识',
`TENANT_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '租户ID',
`DEPLOY_TIME_` timestamp(3) NULL DEFAULT NULL COMMENT '部署的时间',
`ENGINE_VERSION_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '引擎版本',
`VERSION_` int DEFAULT '1',
`PROJECT_RELEASE_VERSION_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
PRIMARY KEY (`ID_`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='部署信息表,该表主要用于存储流程定义的部署信息。Activiti一次部署可以添加多个资源,资源保存在ACT_GE_BYTEARRAY资源表中,部署信息则保存在该表中。';
-- ----------------------------
-- Table structure for ACT_RE_MODEL
-- ----------------------------
DROP TABLE IF EXISTS `ACT_RE_MODEL`;
CREATE TABLE `ACT_RE_MODEL` (
`ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '流程模型ID(主键)',
`REV_` int DEFAULT NULL COMMENT '版本(乐观锁)',
`NAME_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程模型名称',
`KEY_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程模型标识',
`CATEGORY_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '分类',
`CREATE_TIME_` timestamp(3) NULL DEFAULT NULL COMMENT '创建时间',
`LAST_UPDATE_TIME_` timestamp(3) NULL DEFAULT NULL COMMENT '最后更新时间',
`VERSION_` int DEFAULT NULL COMMENT '流程版本',
`META_INFO_` varchar(4000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '采用JSON格式保存的流程模型',
`DEPLOYMENT_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '部署ID',
`EDITOR_SOURCE_VALUE_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '提供给用户存储私有定义文件,对应ACT_GE_BYTEARRAY资源表中的字段ID_,表示该模型对应的模型定义文件(JSON格式数据)',
`EDITOR_SOURCE_EXTRA_VALUE_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '提供给用户存储私有定义图片,对应ACT_GE_BYTEARRAY资源表中的字段ID_,表示该模型生成的图片文件',
`TENANT_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '租户ID',
PRIMARY KEY (`ID_`),
KEY `ACT_FK_MODEL_SOURCE` (`EDITOR_SOURCE_VALUE_ID_`),
KEY `ACT_FK_MODEL_SOURCE_EXTRA` (`EDITOR_SOURCE_EXTRA_VALUE_ID_`),
KEY `ACT_FK_MODEL_DEPLOYMENT` (`DEPLOYMENT_ID_`),
CONSTRAINT `ACT_FK_MODEL_DEPLOYMENT` FOREIGN KEY (`DEPLOYMENT_ID_`) REFERENCES `ACT_RE_DEPLOYMENT` (`ID_`),
CONSTRAINT `ACT_FK_MODEL_SOURCE` FOREIGN KEY (`EDITOR_SOURCE_VALUE_ID_`) REFERENCES `ACT_GE_BYTEARRAY` (`ID_`),
CONSTRAINT `ACT_FK_MODEL_SOURCE_EXTRA` FOREIGN KEY (`EDITOR_SOURCE_EXTRA_VALUE_ID_`) REFERENCES `ACT_GE_BYTEARRAY` (`ID_`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='流程设计模型表,该数据表主要用于存储流程的设计模型。';
-- ----------------------------
-- Table structure for ACT_RE_PROCDEF
-- ----------------------------
DROP TABLE IF EXISTS `ACT_RE_PROCDEF`;
CREATE TABLE `ACT_RE_PROCDEF` (
`ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '流程定义ID(主键)',
`REV_` int DEFAULT NULL COMMENT '版本(乐观锁)',
`CATEGORY_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程定义类型',
`NAME_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程定义名称',
`KEY_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '流程定义标识',
`VERSION_` int NOT NULL COMMENT '流程定义版本',
`DEPLOYMENT_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程定义部署对应的部署数据ID',
`RESOURCE_NAME_` varchar(4000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程定义对应的资源名称',
`DGRM_RESOURCE_NAME_` varchar(4000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程定义对应的流程图的资源名称',
`DESCRIPTION_` varchar(4000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程定义描述',
`HAS_START_FORM_KEY_` tinyint DEFAULT NULL COMMENT '是否存在开始表单标识',
`HAS_GRAPHICAL_NOTATION_` tinyint DEFAULT NULL COMMENT '是否存在图形信息',
`SUSPENSION_STATE_` int DEFAULT NULL COMMENT '流程定义的挂起状态',
`TENANT_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '租户ID',
`ENGINE_VERSION_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '引擎版本',
`APP_VERSION_` int DEFAULT NULL COMMENT '应用版本',
PRIMARY KEY (`ID_`),
UNIQUE KEY `ACT_UNIQ_PROCDEF` (`KEY_`,`VERSION_`,`TENANT_ID_`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='流程定义数据表,该表主要用于存储流程定义信息。Activiti部署流程时,除了将流程定义文件存储到资源表之外,还会解析流程定义文件内容,生成流程定义保存在该表中。';
-- ----------------------------
-- Table structure for ACT_RU_DEADLETTER_JOB
-- ----------------------------
DROP TABLE IF EXISTS `ACT_RU_DEADLETTER_JOB`;
CREATE TABLE `ACT_RU_DEADLETTER_JOB` (
`ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '无法执行的工作ID(主键)',
`REV_` int DEFAULT NULL COMMENT '版本(乐观锁)',
`TYPE_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '定时器类型',
`EXCLUSIVE_` tinyint(1) DEFAULT NULL COMMENT '是否唯一',
`EXECUTION_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '执行实例ID',
`PROCESS_INSTANCE_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程实例ID',
`PROC_DEF_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程定义ID',
`EXCEPTION_STACK_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '异常栈ID',
`EXCEPTION_MSG_` varchar(4000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '异常信息',
`DUEDATE_` timestamp(3) NULL DEFAULT NULL COMMENT '截止时间',
`REPEAT_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '重复执行信息,如重复次数',
`HANDLER_TYPE_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '处理器类型',
`HANDLER_CFG_` varchar(4000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '处理器配置',
`TENANT_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '租户ID',
PRIMARY KEY (`ID_`),
KEY `ACT_FK_DEADLETTER_JOB_EXECUTION` (`EXECUTION_ID_`),
KEY `ACT_FK_DEADLETTER_JOB_PROCESS_INSTANCE` (`PROCESS_INSTANCE_ID_`),
KEY `ACT_FK_DEADLETTER_JOB_PROC_DEF` (`PROC_DEF_ID_`),
KEY `ACT_FK_DEADLETTER_JOB_EXCEPTION` (`EXCEPTION_STACK_ID_`),
CONSTRAINT `ACT_FK_DEADLETTER_JOB_EXCEPTION` FOREIGN KEY (`EXCEPTION_STACK_ID_`) REFERENCES `ACT_GE_BYTEARRAY` (`ID_`),
CONSTRAINT `ACT_FK_DEADLETTER_JOB_EXECUTION` FOREIGN KEY (`EXECUTION_ID_`) REFERENCES `ACT_RU_EXECUTION` (`ID_`),
CONSTRAINT `ACT_FK_DEADLETTER_JOB_PROC_DEF` FOREIGN KEY (`PROC_DEF_ID_`) REFERENCES `ACT_RE_PROCDEF` (`ID_`),
CONSTRAINT `ACT_FK_DEADLETTER_JOB_PROCESS_INSTANCE` FOREIGN KEY (`PROCESS_INSTANCE_ID_`) REFERENCES `ACT_RU_EXECUTION` (`ID_`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='运行时无法执行的作业表,该表主要用于存储Activiti无法执行的定时任务数据。';
-- ----------------------------
-- Table structure for ACT_RU_EVENT_SUBSCR
-- ----------------------------
DROP TABLE IF EXISTS `ACT_RU_EVENT_SUBSCR`;
CREATE TABLE `ACT_RU_EVENT_SUBSCR` (
`ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '事件ID(主键)',
`REV_` int DEFAULT NULL COMMENT '版本(乐观锁)',
`EVENT_TYPE_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '事件类型,不同类型的事件会产生不同的事件订阅,但并非所有事件都会产生事件订阅',
`EVENT_NAME_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '事件名称',
`EXECUTION_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '事件所属的执行实例ID',
`PROC_INST_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '事件所属的流程实例ID',
`ACTIVITY_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '具体事件ID',
`CONFIGURATION_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '配置属性',
`CREATED_` timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建时间',
`PROC_DEF_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程定义ID',
`TENANT_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '租户ID',
PRIMARY KEY (`ID_`),
KEY `ACT_IDX_EVENT_SUBSCR_CONFIG_` (`CONFIGURATION_`),
KEY `ACT_FK_EVENT_EXEC` (`EXECUTION_ID_`),
CONSTRAINT `ACT_FK_EVENT_EXEC` FOREIGN KEY (`EXECUTION_ID_`) REFERENCES `ACT_RU_EXECUTION` (`ID_`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='运行时事件订阅表,该表主要用于存储流程运行时的事件订阅。流程执行到事件节点时,会在该表插入事件订阅,这些事件订阅决定事件的触发。';
-- ----------------------------
-- Table structure for ACT_RU_EXECUTION
-- ----------------------------
DROP TABLE IF EXISTS `ACT_RU_EXECUTION`;
CREATE TABLE `ACT_RU_EXECUTION` (
`ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '执行实例ID(主键)',
`REV_` int DEFAULT NULL COMMENT '版本(乐观锁)',
`PROC_INST_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '执行实例所属的流程实例ID,一个流程实例可能会产生多个执行实例',
`BUSINESS_KEY_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '业务主键',
`PARENT_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '父执行实例ID',
`PROC_DEF_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程定义ID',
`SUPER_EXEC_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '父流程实例对应的执行实例ID',
`ROOT_PROC_INST_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '主流程实例ID',
`ACT_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '当前执行实例的行为ID',
`IS_ACTIVE_` tinyint DEFAULT NULL COMMENT '是否为活跃的执行实例',
`IS_CONCURRENT_` tinyint DEFAULT NULL COMMENT '是否为并行的执行实例',
`IS_SCOPE_` tinyint DEFAULT NULL COMMENT '是否为父作用域',
`IS_EVENT_SCOPE_` tinyint DEFAULT NULL COMMENT '是否事件范围内',
`IS_MI_ROOT_` tinyint DEFAULT NULL COMMENT '是否多实例根执行流',
`SUSPENSION_STATE_` int DEFAULT NULL COMMENT '挂起状态',
`CACHED_ENT_STATE_` int DEFAULT NULL COMMENT '缓存结束状态',
`TENANT_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '租户ID',
`NAME_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '实例名称',
`START_TIME_` datetime(3) DEFAULT NULL COMMENT '实例开始时间',
`START_USER_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '实例启动用户',
`LOCK_TIME_` timestamp(3) NULL DEFAULT NULL COMMENT '锁定时间',
`IS_COUNT_ENABLED_` tinyint DEFAULT NULL COMMENT '是否启用计数',
`EVT_SUBSCR_COUNT_` int DEFAULT NULL COMMENT '事件的数量',
`TASK_COUNT_` int DEFAULT NULL COMMENT '任务的数量',
`JOB_COUNT_` int DEFAULT NULL COMMENT '作业的数量',
`TIMER_JOB_COUNT_` int DEFAULT NULL COMMENT '定时作业的数量',
`SUSP_JOB_COUNT_` int DEFAULT NULL COMMENT '挂起作业的数量',
`DEADLETTER_JOB_COUNT_` int DEFAULT NULL COMMENT '不可执行作业的数量',
`VAR_COUNT_` int DEFAULT NULL COMMENT '变量的数量',
`ID_LINK_COUNT_` int DEFAULT NULL COMMENT '身份关系的数量',
`APP_VERSION_` int DEFAULT NULL COMMENT '应用版本',
PRIMARY KEY (`ID_`),
KEY `ACT_IDX_EXEC_BUSKEY` (`BUSINESS_KEY_`),
KEY `ACT_IDC_EXEC_ROOT` (`ROOT_PROC_INST_ID_`),
KEY `ACT_FK_EXE_PROCINST` (`PROC_INST_ID_`),
KEY `ACT_FK_EXE_PARENT` (`PARENT_ID_`),
KEY `ACT_FK_EXE_SUPER` (`SUPER_EXEC_`),
KEY `ACT_FK_EXE_PROCDEF` (`PROC_DEF_ID_`),
CONSTRAINT `ACT_FK_EXE_PARENT` FOREIGN KEY (`PARENT_ID_`) REFERENCES `ACT_RU_EXECUTION` (`ID_`) ON DELETE CASCADE,
CONSTRAINT `ACT_FK_EXE_PROCDEF` FOREIGN KEY (`PROC_DEF_ID_`) REFERENCES `ACT_RE_PROCDEF` (`ID_`),
CONSTRAINT `ACT_FK_EXE_PROCINST` FOREIGN KEY (`PROC_INST_ID_`) REFERENCES `ACT_RU_EXECUTION` (`ID_`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `ACT_FK_EXE_SUPER` FOREIGN KEY (`SUPER_EXEC_`) REFERENCES `ACT_RU_EXECUTION` (`ID_`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='运行时流程执行实例表,该表主要用于存储流程运行时的执行实例。流程启动时,会生成一个流程实例,以及相应的执行实例,流程实例和执行实例都存储在ACT_RU_EXECUTION表中。如果流程实例只生成一个执行实例,则该表中只存储一条数据,这条数据既是流程实例也是执行实例。';
-- ----------------------------
-- Table structure for ACT_RU_IDENTITYLINK
-- ----------------------------
DROP TABLE IF EXISTS `ACT_RU_IDENTITYLINK`;
CREATE TABLE `ACT_RU_IDENTITYLINK` (
`ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '关系ID(主键)',
`REV_` int DEFAULT NULL COMMENT '版本(乐观锁)',
`GROUP_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '用户组ID',
`TYPE_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '关系类型:assignee、candidate等',
`USER_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '用户ID',
`TASK_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '任务ID',
`PROC_INST_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程实例ID',
`PROC_DEF_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程定义ID',
PRIMARY KEY (`ID_`),
KEY `ACT_IDX_IDENT_LNK_USER` (`USER_ID_`),
KEY `ACT_IDX_IDENT_LNK_GROUP` (`GROUP_ID_`),
KEY `ACT_IDX_ATHRZ_PROCEDEF` (`PROC_DEF_ID_`),
KEY `ACT_FK_TSKASS_TASK` (`TASK_ID_`),
KEY `ACT_FK_IDL_PROCINST` (`PROC_INST_ID_`),
CONSTRAINT `ACT_FK_ATHRZ_PROCEDEF` FOREIGN KEY (`PROC_DEF_ID_`) REFERENCES `ACT_RE_PROCDEF` (`ID_`),
CONSTRAINT `ACT_FK_IDL_PROCINST` FOREIGN KEY (`PROC_INST_ID_`) REFERENCES `ACT_RU_EXECUTION` (`ID_`),
CONSTRAINT `ACT_FK_TSKASS_TASK` FOREIGN KEY (`TASK_ID_`) REFERENCES `ACT_RU_TASK` (`ID_`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='运行时流程与身份关系表,该表主要用于存储运行时流程实例、任务实例与参与者之间的关系信息。';
-- ----------------------------
-- Table structure for ACT_RU_INTEGRATION
-- ----------------------------
DROP TABLE IF EXISTS `ACT_RU_INTEGRATION`;
CREATE TABLE `ACT_RU_INTEGRATION` (
`ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`EXECUTION_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
`PROCESS_INSTANCE_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
`PROC_DEF_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
`FLOW_NODE_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
`CREATED_DATE_` timestamp(3) NULL DEFAULT NULL,
PRIMARY KEY (`ID_`),
KEY `ACT_FK_INT_EXECUTION` (`EXECUTION_ID_`),
KEY `ACT_FK_INT_PROC_INST` (`PROCESS_INSTANCE_ID_`),
KEY `ACT_FK_INT_PROC_DEF` (`PROC_DEF_ID_`),
CONSTRAINT `ACT_FK_INT_EXECUTION` FOREIGN KEY (`EXECUTION_ID_`) REFERENCES `ACT_RU_EXECUTION` (`ID_`) ON DELETE CASCADE,
CONSTRAINT `ACT_FK_INT_PROC_DEF` FOREIGN KEY (`PROC_DEF_ID_`) REFERENCES `ACT_RE_PROCDEF` (`ID_`),
CONSTRAINT `ACT_FK_INT_PROC_INST` FOREIGN KEY (`PROCESS_INSTANCE_ID_`) REFERENCES `ACT_RU_EXECUTION` (`ID_`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='运行时综合表。';
-- ----------------------------
-- Table structure for ACT_RU_JOB
-- ----------------------------
DROP TABLE IF EXISTS `ACT_RU_JOB`;
CREATE TABLE `ACT_RU_JOB` (
`ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '运行时工作ID(主键)',
`REV_` int DEFAULT NULL COMMENT '版本(乐观锁)',
`TYPE_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '定时器类型',
`LOCK_EXP_TIME_` timestamp(3) NULL DEFAULT NULL COMMENT '锁定释放时间',
`LOCK_OWNER_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '锁定者',
`EXCLUSIVE_` tinyint(1) DEFAULT NULL COMMENT '是否排他',
`EXECUTION_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '执行实例ID',
`PROCESS_INSTANCE_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程实例ID',
`PROC_DEF_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程定义ID',
`RETRIES_` int DEFAULT NULL COMMENT '重试次数',
`EXCEPTION_STACK_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '异常栈ID',
`EXCEPTION_MSG_` varchar(4000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '异常信息',
`DUEDATE_` timestamp(3) NULL DEFAULT NULL COMMENT '截止时间',
`REPEAT_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '重复执行信息,如重复次数',
`HANDLER_TYPE_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '处理器类型',
`HANDLER_CFG_` varchar(4000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '处理器配置',
`TENANT_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '租户ID',
PRIMARY KEY (`ID_`),
KEY `ACT_FK_JOB_EXECUTION` (`EXECUTION_ID_`),
KEY `ACT_FK_JOB_PROCESS_INSTANCE` (`PROCESS_INSTANCE_ID_`),
KEY `ACT_FK_JOB_PROC_DEF` (`PROC_DEF_ID_`),
KEY `ACT_FK_JOB_EXCEPTION` (`EXCEPTION_STACK_ID_`),
CONSTRAINT `ACT_FK_JOB_EXCEPTION` FOREIGN KEY (`EXCEPTION_STACK_ID_`) REFERENCES `ACT_GE_BYTEARRAY` (`ID_`),
CONSTRAINT `ACT_FK_JOB_EXECUTION` FOREIGN KEY (`EXECUTION_ID_`) REFERENCES `ACT_RU_EXECUTION` (`ID_`),
CONSTRAINT `ACT_FK_JOB_PROC_DEF` FOREIGN KEY (`PROC_DEF_ID_`) REFERENCES `ACT_RE_PROCDEF` (`ID_`),
CONSTRAINT `ACT_FK_JOB_PROCESS_INSTANCE` FOREIGN KEY (`PROCESS_INSTANCE_ID_`) REFERENCES `ACT_RU_EXECUTION` (`ID_`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='运行时作业表,该表主要用于存储Activiti正在执行的定时任务数据。';
-- ----------------------------
-- Table structure for ACT_RU_SUSPENDED_JOB
-- ----------------------------
DROP TABLE IF EXISTS `ACT_RU_SUSPENDED_JOB`;
CREATE TABLE `ACT_RU_SUSPENDED_JOB` (
`ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '中断的工作ID(主健)',
`REV_` int DEFAULT NULL COMMENT '版本(乐观锁)',
`TYPE_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '定时器类型',
`EXCLUSIVE_` tinyint(1) DEFAULT NULL COMMENT '是否唯一',
`EXECUTION_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '执行实例ID',
`PROCESS_INSTANCE_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程实例ID',
`PROC_DEF_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程定义ID',
`RETRIES_` int DEFAULT NULL COMMENT '重试',
`EXCEPTION_STACK_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '异常栈ID',
`EXCEPTION_MSG_` varchar(4000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '异常信息',
`DUEDATE_` timestamp(3) NULL DEFAULT NULL COMMENT '截止时间',
`REPEAT_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '重复执行信息,如重复次数',
`HANDLER_TYPE_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '处理器类型',
`HANDLER_CFG_` varchar(4000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '处理器配置',
`TENANT_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '租户ID',
PRIMARY KEY (`ID_`),
KEY `ACT_FK_SUSPENDED_JOB_EXECUTION` (`EXECUTION_ID_`),
KEY `ACT_FK_SUSPENDED_JOB_PROCESS_INSTANCE` (`PROCESS_INSTANCE_ID_`),
KEY `ACT_FK_SUSPENDED_JOB_PROC_DEF` (`PROC_DEF_ID_`),
KEY `ACT_FK_SUSPENDED_JOB_EXCEPTION` (`EXCEPTION_STACK_ID_`),
CONSTRAINT `ACT_FK_SUSPENDED_JOB_EXCEPTION` FOREIGN KEY (`EXCEPTION_STACK_ID_`) REFERENCES `ACT_GE_BYTEARRAY` (`ID_`),
CONSTRAINT `ACT_FK_SUSPENDED_JOB_EXECUTION` FOREIGN KEY (`EXECUTION_ID_`) REFERENCES `ACT_RU_EXECUTION` (`ID_`),
CONSTRAINT `ACT_FK_SUSPENDED_JOB_PROC_DEF` FOREIGN KEY (`PROC_DEF_ID_`) REFERENCES `ACT_RE_PROCDEF` (`ID_`),
CONSTRAINT `ACT_FK_SUSPENDED_JOB_PROCESS_INSTANCE` FOREIGN KEY (`PROCESS_INSTANCE_ID_`) REFERENCES `ACT_RU_EXECUTION` (`ID_`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='运行时中断的作业表,该表主要用于存储Activiti中断的定时任务数据。';
-- ----------------------------
-- Table structure for ACT_RU_TASK
-- ----------------------------
DROP TABLE IF EXISTS `ACT_RU_TASK`;
CREATE TABLE `ACT_RU_TASK` (
`ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '任务实例ID(主键)',
`REV_` int DEFAULT NULL COMMENT '版本(乐观锁)',
`EXECUTION_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '执行实例ID',
`PROC_INST_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程实例ID',
`PROC_DEF_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程定义ID',
`NAME_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '任务实例名称',
`BUSINESS_KEY_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '业务主键',
`PARENT_TASK_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '父任务实例ID',
`DESCRIPTION_` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '节点描述',
`TASK_DEF_KEY_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '节点标识',
`OWNER_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '拥有者',
`ASSIGNEE_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '办理人',
`DELEGATION_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '委托类型',
`PRIORITY_` int DEFAULT NULL COMMENT '优先级',
`CREATE_TIME_` timestamp(3) NULL DEFAULT NULL COMMENT '创建时间',
`DUE_DATE_` datetime(3) DEFAULT NULL COMMENT '过期时间',
`CATEGORY_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '分类',
`SUSPENSION_STATE_` int DEFAULT NULL COMMENT '挂起状态',
`TENANT_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '租户ID',
`FORM_KEY_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '表单模型key',
`CLAIM_TIME_` datetime(3) DEFAULT NULL COMMENT '认领时间',
`APP_VERSION_` int DEFAULT NULL COMMENT '应用版本',
PRIMARY KEY (`ID_`),
KEY `ACT_IDX_TASK_CREATE` (`CREATE_TIME_`),
KEY `ACT_FK_TASK_EXE` (`EXECUTION_ID_`),
KEY `ACT_FK_TASK_PROCINST` (`PROC_INST_ID_`),
KEY `ACT_FK_TASK_PROCDEF` (`PROC_DEF_ID_`),
CONSTRAINT `ACT_FK_TASK_EXE` FOREIGN KEY (`EXECUTION_ID_`) REFERENCES `ACT_RU_EXECUTION` (`ID_`),
CONSTRAINT `ACT_FK_TASK_PROCDEF` FOREIGN KEY (`PROC_DEF_ID_`) REFERENCES `ACT_RE_PROCDEF` (`ID_`),
CONSTRAINT `ACT_FK_TASK_PROCINST` FOREIGN KEY (`PROC_INST_ID_`) REFERENCES `ACT_RU_EXECUTION` (`ID_`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='运行时任务节点表,该表主要用于存储流程运行过程中产生的任务实例数据。';
-- ----------------------------
-- Table structure for ACT_RU_TIMER_JOB
-- ----------------------------
DROP TABLE IF EXISTS `ACT_RU_TIMER_JOB`;
CREATE TABLE `ACT_RU_TIMER_JOB` (
`ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '定时工作ID(主键)',
`REV_` int DEFAULT NULL COMMENT '版本(乐观锁)',
`TYPE_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '定时器类型',
`LOCK_EXP_TIME_` timestamp(3) NULL DEFAULT NULL COMMENT '锁定释放时间',
`LOCK_OWNER_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '锁定者',
`EXCLUSIVE_` tinyint(1) DEFAULT NULL COMMENT '是否唯一',
`EXECUTION_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '执行实例ID',
`PROCESS_INSTANCE_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程实例ID',
`PROC_DEF_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程定义ID',
`RETRIES_` int DEFAULT NULL COMMENT '重试次数',
`EXCEPTION_STACK_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '异常栈ID',
`EXCEPTION_MSG_` varchar(4000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '异常信息',
`DUEDATE_` timestamp(3) NULL DEFAULT NULL COMMENT '截止时间',
`REPEAT_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '重复执行信息,如重复次数',
`HANDLER_TYPE_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '处理器类型',
`HANDLER_CFG_` varchar(4000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '处理器配置',
`TENANT_ID_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '租户ID',
PRIMARY KEY (`ID_`),
KEY `ACT_FK_TIMER_JOB_EXECUTION` (`EXECUTION_ID_`),
KEY `ACT_FK_TIMER_JOB_PROCESS_INSTANCE` (`PROCESS_INSTANCE_ID_`),
KEY `ACT_FK_TIMER_JOB_PROC_DEF` (`PROC_DEF_ID_`),
KEY `ACT_FK_TIMER_JOB_EXCEPTION` (`EXCEPTION_STACK_ID_`),
CONSTRAINT `ACT_FK_TIMER_JOB_EXCEPTION` FOREIGN KEY (`EXCEPTION_STACK_ID_`) REFERENCES `ACT_GE_BYTEARRAY` (`ID_`),
CONSTRAINT `ACT_FK_TIMER_JOB_EXECUTION` FOREIGN KEY (`EXECUTION_ID_`) REFERENCES `ACT_RU_EXECUTION` (`ID_`),
CONSTRAINT `ACT_FK_TIMER_JOB_PROC_DEF` FOREIGN KEY (`PROC_DEF_ID_`) REFERENCES `ACT_RE_PROCDEF` (`ID_`),
CONSTRAINT `ACT_FK_TIMER_JOB_PROCESS_INSTANCE` FOREIGN KEY (`PROCESS_INSTANCE_ID_`) REFERENCES `ACT_RU_EXECUTION` (`ID_`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='运行时定时器作业表,该表主要用于存储流程运行时的定时任务数据。流程执行到中间定时器事件节点或带有边界定时器事件的节点时,会生成一个定时任务,并将相关数据存储到该表中。';
-- ----------------------------
-- Table structure for ACT_RU_VARIABLE
-- ----------------------------
DROP TABLE IF EXISTS `ACT_RU_VARIABLE`;
CREATE TABLE `ACT_RU_VARIABLE` (
`ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '变量ID(主键)',
`REV_` int DEFAULT NULL COMMENT '版本(乐观锁)',
`TYPE_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '变量类型',
`NAME_` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '变量名称',
`EXECUTION_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '执行实例ID',
`PROC_INST_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '流程实例ID',
`TASK_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '任务实例ID',
`BYTEARRAY_ID_` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '复杂变量值存储在资源表中,此处存储关联的资源ID',
`DOUBLE_` double DEFAULT NULL COMMENT '存储小数类型的变量值',
`LONG_` bigint DEFAULT NULL COMMENT '存储整数类型的变量值',
`TEXT_` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '存储字符串类型的变量值',
`TEXT2_` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '此处存储的是JPA持久化对象时,才会有值。此值为对象ID',
PRIMARY KEY (`ID_`),
KEY `ACT_IDX_VARIABLE_TASK_ID` (`TASK_ID_`),
KEY `ACT_FK_VAR_EXE` (`EXECUTION_ID_`),
KEY `ACT_FK_VAR_PROCINST` (`PROC_INST_ID_`),
KEY `ACT_FK_VAR_BYTEARRAY` (`BYTEARRAY_ID_`),
CONSTRAINT `ACT_FK_VAR_BYTEARRAY` FOREIGN KEY (`BYTEARRAY_ID_`) REFERENCES `ACT_GE_BYTEARRAY` (`ID_`),
CONSTRAINT `ACT_FK_VAR_EXE` FOREIGN KEY (`EXECUTION_ID_`) REFERENCES `ACT_RU_EXECUTION` (`ID_`),
CONSTRAINT `ACT_FK_VAR_PROCINST` FOREIGN KEY (`PROC_INST_ID_`) REFERENCES `ACT_RU_EXECUTION` (`ID_`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='运行时流程变量数据表,该表主要用于存储流程运行中的变量,包括流程实例变量、执行实例变量和任务实例变量。';
SET FOREIGN_KEY_CHECKS = 1;
基于索引调优
此外,还可以针对索引进行优化。
在 varchar 字段上建立索引时,必须指定索引长度,没必要对全字段建立索引,根据实际文本区分度决定索引长度。
说明:索引的长度与区分度是一对矛盾体,一般对字符串类型数据,长度为 20 的索引,区分度会高达90%以上,可以使用 count(distinct left(列名,索引长度)) / count(*) 的区分度来确定。
ID生成器优化
Activiti中实体的ID(即数据库中主键字段ID_)需要由专门的生成器生成。Activiti ID生成器需要配置IdGenerator接口,该接口只有一个方法,即获取下一个ID:
public interface IdGenerator {
String getNextId();
}
Activiti自带的ID生成器有两个:数据库ID生成器(DbIdGenerator)和UUID生成器(StrongUuidGenerator)。
我们目前MySQL主要使用InnoDB存储引擎,InnoDB中的索引方案主要是B+树,主键索引为聚簇索引。聚簇索引并不是一种单独的索引类型,而是一种数据存储方式(所有的用户记录都存储在了叶子节点),也就是所谓的索引即数据,数据即索引 。优点是:数据访问更快;聚簇索引对于主键的排序查找和范围查找速度非常快,可以节省大量的I/O操作。同时带来了缺点:插入速度严重依赖于插入顺序,按照主键的顺序插入是最快的方式,否则将会出现⻚分裂,严重影响性能。
数据库ID生成器(DbIdGenerator)
通过数据库生成ID的实现方式是在数据库中创建一个表保存一个数字作为当前ID,并在获取当前ID后,在原来的基础上递增生成下一个ID。但是如果这样做,就要在每次生成一个ID时都查询和更新数据库,因此数据库的压力会比较大。此外,因为操作的都是同一张表的同一行数据,所以并发量比较大的情况下,容易产生数据库行锁冲突,效率会比较低。
基于数据库的ID生成器的优点是有序且长度较短,对使用InnoDB作为存储引擎的数据库来说,采用这种方式插入效率会比较高。其缺点是依赖数据库,并发压力比较大。此外,在分布式环境下,如果要生成全局唯一的ID,需要将ID生成器作为独立服务进行部署和维护,复杂度和运维成本会大幅度增加。
UUID生成器
Activiti的UUID是通过com.fasterxml.uuid.impl.TimeBasedGenerator生成的。UUID生成器的优点是不依赖其他服务,并发效率高,分布式情况下也能生成全局唯一ID。其缺点首先是无序,对于与InnoDB类似的存储引擎,插入时容易导致索引页分裂,影响插入的性能。其次,UUID的长度比较长,占用的空间相对较大。
上述两种ID生成器都有各自的优缺点,但在数据量大、并发和性能要求高的场景下都难以满足业务要求,需要采用更优的ID生成器来实现。更优的生成器需要既满足性能上的要求,又保证全局有序和唯一。这里采用流行ID生成算法“雪花算法”来实现。
自定义ID生成器(雪花算法)
雪花算法实现参考:
Leaf——美团点评分布式ID生成系统:https://tech.meituan.com/2017/04/21/mt-leaf.html
Leaf:美团分布式ID生成服务开源:https://tech.meituan.com/2019/03/07/open-source-project-leaf.html
Github地址:https://github.com/Meituan-Dianping/Leaf?tab=readme-ov-file
要实现自定义ID生成器,必须要继承Activiti的IdGenerator接口:
import org.activiti.engine.impl.cfg.IdGenerator;
public class SnowFlakeIdGenerator implements IdGenerator {
@Override
public String getNextId() {
// 实现自定义ID生成器逻辑
return ......;
}
}
完成自定义ID生成器的开发后,还需要配置工作流引擎使用自定义ID生成器,配置内容如下:
<!-- 定义自定义ID生成器 -->
<bean id="snowFlakeIdGenerator" class="com.lwy.it.util.SnowFlakeIdGenerator"></bean>
<!-- Activiti工作流引擎 -->
<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
<!-- ...其他配置项... -->
<!-- 配置idGenerator -->
<property name="idGenerator" ref="snowFlakeIdGenerator"/>
</bean>
基于减少ACT_GE_BYTEARRAY资源表操作
ACT_GE_BYTEARRAY资源表用于存储与工作流引擎相关的资源数据,Activiti使用该资源表保存流程定义文件内容、流程图片内容和序列化流程变量等二进制数据。
字段 | 类型 | 字段说明 |
---|---|---|
ID_ | VARCHAR(64) | 资源ID(主键) |
REV_ | INT | 版本(乐观锁) |
NAME_ | VARCHAR(255) | 资源名称 |
DEPLOYMENT_ID_ | VARCHAR(64) | 部署ID,与部署表ACT_RE_ DEPLOYMENT的主键关联 |
BYTES_ | LONGBLOB | 资源,最大可存4GB数据 |
GENERATED_ | TINYINT | 是否是Activiti自动产生的资源 |
流程变量默认TEXT_、TEXT2_默认类型为,VARCHAR(4000),用于存储字符串类型的变量值。
public int getMaxLengthString() {
// maxLengthStringVariableType不配置默认值为-1
if (maxLengthStringVariableType == -1) {
if ("oracle".equalsIgnoreCase(databaseType)) {
// public static final int DEFAULT_ORACLE_MAX_LENGTH_STRING = 2000
return DEFAULT_ORACLE_MAX_LENGTH_STRING;
} else {
// public static final int DEFAULT_GENERIC_MAX_LENGTH_STRING = 4000
return DEFAULT_GENERIC_MAX_LENGTH_STRING;
}
} else {
return maxLengthStringVariableType;
}
}
以MySQL为例,当变量长度超过4000时,便会存储在ACT_GE_BYTEARRAY表中BYTES_(类型为:LONGBLOB)。当实际业务中有比较长的变量时,建议:
- 修改流程变量TEXT_、TEXT2_类型为TEXT、MEDIUMTEXT、LONGTEXT(包含历史表等相关表要同步进行修改);
- 根据修改的流程变量类型来配置maxLengthStringVariableType的值;
上面建表语句已经将流程变量类型改成TEXT类型,同时更改配置:
<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
<!-- ...其他配置项... -->
<!-- 需要将varchar(4000)改成text类型,设置长度为8000 -->
<property name="maxLengthStringVariableType" value="8000"/>
</bean>
基于历史数据级别优化
为了提高流程执行的效率,Activiti将流程数据分为运行时数据和历史数据,从而避免历史数据积累影响工作流引擎性能。如果业务本身不需要历史数据,工作流引擎可以不保存历史数据,这样引擎性能会有进一步的提升。
Activiti在设计上采用了运行时与历史数据相分离的策略,Activiti的运行表和历史表在流程运行时可以同步记录数据,当流程实例结束或任务办理完成时,会自动删除运行表中的相关数据,而保留历史表中的相关数据。这种设计可以快速读取运行时数据,仅当需要查询历史数据时才从专门的历史数据表中读取历史数据,大幅提高了数据的存取效率。Activiti提供了history属性设置记录历史级别,实现按需存储历史数据。history 属性值可配置为none、activity、audit和full,级别由低到高。
- none(无):不保存任何历史数据,对于运行时流程执行来说性能最好,但流程结束后无可用的历史信息。
- activity(活动):级别高于none,归档所有流程实例和活动实例。在流程实例结束时,流程变量的最新值将复制到历史变量实例中,不保存任何详细信息。
- audit(审计):Activiti的默认级别。除activity级别会保存的数据外,还保存提交的表单属性,以便跟踪通过表单进行的所有用户交互,且可进行审计。
- full(完整):历史最高级别,性能较差。保存最完整的历史记录,除audit级别的信息之外,还记录所有其他可能的详细信息,主要是流程变量更新,如果需要日后跟踪详情可以开启full(一般不建议开启)。
其中,none级别不存储历史数据,其他3种级别都会存储历史数据。
<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
<!-- ...其他配置项... -->
<!-- 配置历史数据级别为activity(活动) -->
<property name="history" value="activity"/>
</bean>
基于架构优化
水平分库分表方案的局限性
水平分库分表指将单表的数据切分到多个分片中,每个分片具有相同结构的库与表,只是库、表存储的数据不同。水平分库分表可解决单机单库的性能瓶颈,突破IO、连接数等限制。但在Activiti中采用常规的水平分库分表方案存在一定的难度和问题,具体如下:
- 没有合适的分库分表依据
要采用水平分库分表方案,首先要决定采用何种分库分表策略。这通常需要根据业务的特性来决策,常见的分库分表策略有按范围或Hash取模拆分等。
对于基于范围的分库分表,可以按时间范围或者流程定义范围进行分库分表,如按年或者月进行分库分表等。但在流程领域,往往需要按流程实例ID、任务实例ID和人员ID等场景查询流程和任务,无法确定时间范围,导致这些场景的查询无法满足。按时间范围分库分表的另一个问题是:同一时间段的数据需要写入相同的库表中,无法通过多个数据库和表来分担并发压力。按流程定义分库分表方案也存在类似的问题。首先,流量并非按流程定义均匀分布的,少量的流程定义占据了大部分的数据,易导致分库分表方案失效。其次,该方案无法实现按流程实例ID、任务实例ID和人员ID等查询流程和任务的场景。
对于基于Hash取模的分库分表方案,可以按人员ID的Hash取模进行分库分表,如按人的维度将流程实例分布在不同的库和表上,能解决按人查询的场景需求。但在该方案下,同一个流程会关联多人,同一个任务也可能与多人关联,如同一个用户任务会存在多个候选人,这就导致按人分库分表时存在数据冗余。此外,该方案也无法实现基于流程实例ID或者任务ID进行数据查询的场景。当然,也可以按流程实例ID和任务ID进行分库分表,但这又无法实现按人员ID查询流程或任务的场景。
综合来说,没有一种合适的分库分表方案能够同时满足流程领域常见场景的需求。
- 常规分库分表方案改造成本高
分库分表实现本身的复杂度比较高,尤其是SQL比较复杂时,要自己实现一套完整的水平分库分表方案成本非常高昂。因此,通常会使用开源组件实现分库分表。常见的水平分库分表实现方案有两种:第一种是客户端水平分库分表,比较常见的是sharding-jdbc;第二种是通过代理进行分库分表,如Mycat。sharding-jdbc以JAR包的形式嵌入到代码中,对代码具有一定的侵入性,但运维成本较低。Mycat需要我们维护一套单独的集群,运维成本比较高,对代码无侵入性。无论采用哪种方式,都有部分功能实现起来比较复杂,对系统性能影响也比较大,甚至无法实现。例如,Activiti底层SQL中存在大量的join操作,一旦涉及多表的跨库操作,实现起来就非常困难。除join操作外,排序、分组、分页等常用的SQL操作性能也非常低。总之,想在Activiti基础上实现一套分库分表方案,无论是设计的难度还是开发的成本都非常高。
- 常规分库分表方案扩容困难
分库分表的另一个难题是扩容。出于成本考虑,一开始不可能拆分过多的库表。但是随着业务的发展,已有的库表无法满足业务需求,这时就需要对原有的库表进行扩容。扩容往往涉及数据迁移,而数据迁移过程风险比较大,难以在不停服且用户无感知的情况下完成迁移。虽然可以采用一致性哈希算法来减少迁移的数据量,但是无法彻底解决数据迁移问题,导致系统扩容比较困难。
Activiti数据存储机制
在Activiti中进行数据操作时,会先调用各个实体对象对应的EntityManager,而EntityManager又会委托给对应的DataManager来完成操作,最终通过DbSqlSession调用Mybatis实现数据的增、删、改、查操作。所有EntityManager和DataManager的初始化都是通过工作流引擎配置类ProcessEngineConfigurationImpl完成的。CommandContext在执行close()方法时会调用DbSqlSession的flush()方 法,实现数据的增、删、改操作。
通过对Activiti数据操作机制的分析,可以总结出两种实现历史数据异步化的思路。第一种思路是从DbSqlSession入手,在最终进行数据库操作时实现异步化。第二种思路是自定义DataManager,在自定义的DataManager中实现异步存储。对于历史数据,可以存储在原有的数据库表中,这样做的优点是历史数据的查询可以复用Activiti已有的查询方式,改造成本比较低。也可以采用其他存储方式,尤其是数据量比较大的情况下采用分布式数据库进行存储,如MongoDB。接下来分别介绍以下两种异步存储方式:
- 改造DbSqlSession,实现基于已有数据库表的历史数据异步化;
- 自定义DataManager,实现基于MongoDB的历史数据异步化。
基于已有数据库表的历史数据异步化
Activiti所有数据操作都是通过DbSqlSession完成的。DbSqlSession提供了对实体对象的缓存,并在Command完成时调用flush()方法进行数据库操作。因此,可以在进行数据库操作前先判断实体对象的类型,再决定数据存储的方式。例如,插入数据通过flush()调用flushInserts()来完成,因此可以在该方法中实现历史数据插入的异步化。Activiti历史数据包括历史任务、历史流程变量等,这里以流程历史变量的异步存储为例,讲解如何实现历史数据的异步化。将DbSqlSession的flushInserts()方法改造如下:
//创建线程池,通过线程池提交历史数据
private ExecutorService executorService = Executors.newFixedThreadPool(10);
protected void flushInserts() {
if (insertedObjects.size() == 0) {
return;
}
for (Class<? extends Entity> entityClass : EntityDependencyOrder.INSERT_ORDER) {
if (insertedObjects.containsKey(entityClass)) {
//历史变量数据的异步化
boolean isHistoricData = handleHistoricInsertEntities(entityClass, insertedObjects.get(entityClass).values());
//非历史变量数据,遵循原有的逻辑 if (!isHistoricData) {
flushInsertEntities(entityClass, insertedObjects.get(entityClass).values());
}
insertedObjects.remove(entityClass);
}
if (insertedObjects.size() > 0) {
for (Class<? extends Entity> entityClass : insertedObjects.keySet()) {
flushInsertEntities(entityClass, insertedObjects.get(entityClass).values());
}
}
insertedObjects.clear();
}
protected boolean handleHistoricInsertEntities(Class<? extends Entity> entityClass, Collection<Entity> entitiesToInsert) {
if (entityClass.equals(HistoricVariableInstanceEntityImpl.class)) {
executorService.submit(() -> {
for (Entity entity : entitiesToInsert) {
log.info("Async insert history data={}", entity);
flushInsertEntities(entityClass, insertedObjects.get(entityClass).values());
}
});
return true;
}
return false;
}
以上代码中的加粗部分代码是新添加的逻辑,实现了handleHistoricInsertEntities()方法。该方法的核心逻辑是判断要插入对象的类型是否是历史变量。如果是,则采用异步方式进行数据插入,否则就采用同步方式进行数据插入。
历史变量的插入是通过自定义逻辑实现的,其执行线程为自定义线程池中的线程,而其他数据则是通过执行请求的线程插入的。对于历史变量的查询,由于数据仍存在数据库的ACT_HI_VARINST表中,所以可以复用Activiti历史变量数据操作类MybatisHistoricVariableInstanceDataManager实现。历史变量的异步更新和删除,可以用类似的方法处理。
基于MongoDB的历史数据异步化
对于数据量较小的场景,可以采用已有的数据库表来实现历史数据异步化,但是面对海量历史数据的场景,就需要采用分布式数据存储机制来进行处理了。