flowlong-mysql.sql 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. SET NAMES utf8mb4;
  2. SET FOREIGN_KEY_CHECKS = 0;
  3. -- ----------------------------
  4. -- 添加数据库初始化脚本+兼容5.6/5.7版本MYSQL
  5. -- ----------------------------
  6. DROP DATABASE IF EXISTS `flowlong`;
  7. CREATE DATABASE IF NOT EXISTS `flowlong` charset utf8mb4 collate utf8mb4_unicode_ci;
  8. USE `flowlong`;
  9. -- ----------------------------
  10. -- Table structure for flw_his_task_actor
  11. -- ----------------------------
  12. DROP TABLE IF EXISTS `flw_his_task_actor`;
  13. CREATE TABLE `flw_his_task_actor` (
  14. `id` bigint NOT NULL COMMENT '主键 ID',
  15. `tenant_id` varchar(50) COMMENT '租户ID',
  16. `instance_id` bigint NOT NULL COMMENT '流程实例ID',
  17. `task_id` bigint NOT NULL COMMENT '任务ID',
  18. `actor_id` varchar(100) NOT NULL COMMENT '参与者ID',
  19. `actor_name` varchar(100) NOT NULL COMMENT '参与者名称',
  20. `actor_type` int NOT NULL COMMENT '参与者类型 0,用户 1,角色 2,部门',
  21. `weight` int COMMENT '票签权重',
  22. PRIMARY KEY (`id`) USING BTREE,
  23. INDEX `idx_his_task_actor_task_id`(`task_id` ASC) USING BTREE,
  24. CONSTRAINT `fk_his_task_actor_task_id` FOREIGN KEY (`task_id`) REFERENCES `flw_his_task` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
  25. ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COMMENT = '历史任务参与者表' ROW_FORMAT = Dynamic;
  26. -- ----------------------------
  27. -- Table structure for flw_his_task
  28. -- ----------------------------
  29. DROP TABLE IF EXISTS `flw_his_task`;
  30. CREATE TABLE `flw_his_task` (
  31. `id` bigint NOT NULL COMMENT '主键ID',
  32. `tenant_id` varchar(50) COMMENT '租户ID',
  33. `create_id` varchar(50) NOT NULL COMMENT '创建人ID',
  34. `create_by` varchar(50) NOT NULL COMMENT '创建人名称',
  35. `create_time` timestamp NOT NULL COMMENT '创建时间',
  36. `instance_id` bigint NOT NULL COMMENT '流程实例ID',
  37. `parent_task_id` bigint COMMENT '父任务ID',
  38. `call_process_id` bigint COMMENT '调用外部流程定义ID',
  39. `call_instance_id` bigint COMMENT '调用外部流程实例ID',
  40. `task_name` varchar(100) NOT NULL COMMENT '任务名称',
  41. `display_name` varchar(200) NOT NULL COMMENT '任务显示名称',
  42. `task_type` tinyint(1) NOT NULL COMMENT '任务类型',
  43. `perform_type` tinyint(1) COMMENT '参与类型',
  44. `action_url` varchar(200) COMMENT '任务处理的url',
  45. `variable` text COMMENT '变量json',
  46. `assignor_id` varchar(100) COMMENT '委托人ID',
  47. `assignor` varchar(100) COMMENT '委托人',
  48. `expire_time` timestamp NULL DEFAULT NULL COMMENT '任务期望完成时间',
  49. `remind_time` timestamp NULL DEFAULT NULL COMMENT '提醒时间',
  50. `remind_repeat` tinyint(1) NOT NULL DEFAULT 0 COMMENT '提醒次数',
  51. `viewed` tinyint(1) NOT NULL DEFAULT 0 COMMENT '已阅 0,否 1,是',
  52. `finish_time` timestamp NULL DEFAULT NULL COMMENT '任务完成时间',
  53. `task_state` tinyint(1) NOT NULL DEFAULT 1 COMMENT '任务状态 0,活动 1,结束 2,拒绝 3,超时 4,终止 5,跳转',
  54. `duration` bigint COMMENT '处理耗时',
  55. PRIMARY KEY (`id`) USING BTREE,
  56. INDEX `idx_his_task_instance_id`(`instance_id` ASC) USING BTREE,
  57. INDEX `idx_his_task_parent_task_id`(`parent_task_id` ASC) USING BTREE,
  58. CONSTRAINT `fk_his_task_instance_id` FOREIGN KEY (`instance_id`) REFERENCES `flw_his_instance` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
  59. ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COMMENT = '历史任务表' ROW_FORMAT = Dynamic;
  60. -- ----------------------------
  61. -- Table structure for flw_task_actor
  62. -- ----------------------------
  63. DROP TABLE IF EXISTS `flw_task_actor`;
  64. CREATE TABLE `flw_task_actor` (
  65. `id` bigint NOT NULL COMMENT '主键 ID',
  66. `tenant_id` varchar(50) COMMENT '租户ID',
  67. `instance_id` bigint NOT NULL COMMENT '流程实例ID',
  68. `task_id` bigint NOT NULL COMMENT '任务ID',
  69. `actor_id` varchar(100) NOT NULL COMMENT '参与者ID',
  70. `actor_name` varchar(100) NOT NULL COMMENT '参与者名称',
  71. `actor_type` int NOT NULL COMMENT '参与者类型 0,用户 1,角色 2,部门',
  72. `weight` int COMMENT '票签权重',
  73. PRIMARY KEY (`id`) USING BTREE,
  74. INDEX `idx_task_actor_task_id`(`task_id` ASC) USING BTREE,
  75. CONSTRAINT `fk_task_actor_task_id` FOREIGN KEY (`task_id`) REFERENCES `flw_task` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
  76. ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COMMENT = '任务参与者表' ROW_FORMAT = Dynamic;
  77. -- ----------------------------
  78. -- Table structure for flw_task
  79. -- ----------------------------
  80. DROP TABLE IF EXISTS `flw_task`;
  81. CREATE TABLE `flw_task` (
  82. `id` bigint NOT NULL COMMENT '主键ID',
  83. `tenant_id` varchar(50) COMMENT '租户ID',
  84. `create_id` varchar(50) NOT NULL COMMENT '创建人ID',
  85. `create_by` varchar(50) NOT NULL COMMENT '创建人名称',
  86. `create_time` timestamp NOT NULL COMMENT '创建时间',
  87. `instance_id` bigint NOT NULL COMMENT '流程实例ID',
  88. `parent_task_id` bigint COMMENT '父任务ID',
  89. `task_name` varchar(100) NOT NULL COMMENT '任务名称',
  90. `display_name` varchar(200) NOT NULL COMMENT '任务显示名称',
  91. `task_type` tinyint(1) NOT NULL COMMENT '任务类型',
  92. `perform_type` tinyint(1) NULL COMMENT '参与类型',
  93. `action_url` varchar(200) COMMENT '任务处理的url',
  94. `variable` text COMMENT '变量json',
  95. `assignor_id` varchar(100) COMMENT '委托人ID',
  96. `assignor` varchar(100) COMMENT '委托人',
  97. `expire_time` timestamp NULL DEFAULT NULL COMMENT '任务期望完成时间',
  98. `remind_time` timestamp NULL DEFAULT NULL COMMENT '提醒时间',
  99. `remind_repeat` tinyint(1) NOT NULL DEFAULT 0 COMMENT '提醒次数',
  100. `viewed` tinyint(1) NOT NULL DEFAULT 0 COMMENT '已阅 0,否 1,是',
  101. PRIMARY KEY (`id`) USING BTREE,
  102. INDEX `idx_task_instance_id`(`instance_id` ASC) USING BTREE,
  103. CONSTRAINT `fk_task_instance_id` FOREIGN KEY (`instance_id`) REFERENCES `flw_instance` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
  104. ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COMMENT = '任务表' ROW_FORMAT = Dynamic;
  105. -- ----------------------------
  106. -- Table structure for flw_his_instance
  107. -- ----------------------------
  108. DROP TABLE IF EXISTS `flw_his_instance`;
  109. CREATE TABLE `flw_his_instance` (
  110. `id` bigint NOT NULL COMMENT '主键ID',
  111. `tenant_id` varchar(50) COMMENT '租户ID',
  112. `create_id` varchar(50) NOT NULL COMMENT '创建人ID',
  113. `create_by` varchar(50) NOT NULL COMMENT '创建人名称',
  114. `create_time` timestamp NOT NULL COMMENT '创建时间',
  115. `process_id` bigint NOT NULL COMMENT '流程定义ID',
  116. `parent_instance_id` bigint COMMENT '父流程实例ID',
  117. `priority` tinyint(1) COMMENT '优先级',
  118. `instance_no` varchar(50) COMMENT '流程实例编号',
  119. `business_key` varchar(100) COMMENT '业务KEY',
  120. `variable` text COMMENT '变量json',
  121. `current_node` varchar(100) NOT NULL COMMENT '当前所在节点',
  122. `expire_time` timestamp NULL DEFAULT NULL COMMENT '期望完成时间',
  123. `last_update_by` varchar(50) COMMENT '上次更新人',
  124. `last_update_time` timestamp NULL DEFAULT NULL COMMENT '上次更新时间',
  125. `instance_state` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态 0,审批中 1,审批通过 2,审批拒绝 3,撤销审批 4,超时结束 5,强制终止',
  126. `end_time` timestamp NULL DEFAULT NULL COMMENT '结束时间',
  127. `duration` bigint COMMENT '处理耗时',
  128. PRIMARY KEY (`id`) USING BTREE,
  129. INDEX `idx_his_instance_process_id`(`process_id` ASC) USING BTREE,
  130. CONSTRAINT `fk_his_instance_process_id` FOREIGN KEY (`process_id`) REFERENCES `flw_process` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
  131. ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COMMENT = '历史流程实例表' ROW_FORMAT = Dynamic;
  132. -- ----------------------------
  133. -- Table structure for flw_instance
  134. -- ----------------------------
  135. DROP TABLE IF EXISTS `flw_instance`;
  136. CREATE TABLE `flw_instance` (
  137. `id` bigint NOT NULL COMMENT '主键ID',
  138. `tenant_id` varchar(50) COMMENT '租户ID',
  139. `create_id` varchar(50) NOT NULL COMMENT '创建人ID',
  140. `create_by` varchar(50) NOT NULL COMMENT '创建人名称',
  141. `create_time` timestamp NOT NULL COMMENT '创建时间',
  142. `process_id` bigint NOT NULL COMMENT '流程定义ID',
  143. `parent_instance_id` bigint COMMENT '父流程实例ID',
  144. `priority` tinyint(1) COMMENT '优先级',
  145. `instance_no` varchar(50) COMMENT '流程实例编号',
  146. `business_key` varchar(100) COMMENT '业务KEY',
  147. `variable` text COMMENT '变量json',
  148. `current_node` varchar(100) NOT NULL COMMENT '当前所在节点',
  149. `expire_time` timestamp NULL DEFAULT NULL COMMENT '期望完成时间',
  150. `last_update_by` varchar(50) COMMENT '上次更新人',
  151. `last_update_time` timestamp NULL DEFAULT NULL COMMENT '上次更新时间',
  152. PRIMARY KEY (`id`) USING BTREE,
  153. INDEX `idx_instance_process_id`(`process_id` ASC) USING BTREE,
  154. CONSTRAINT `fk_instance_process_id` FOREIGN KEY (`process_id`) REFERENCES `flw_process` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
  155. ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COMMENT = '流程实例表' ROW_FORMAT = Dynamic;
  156. -- ----------------------------
  157. -- Table structure for flw_instance
  158. -- ----------------------------
  159. DROP TABLE IF EXISTS `flw_ext_instance`;
  160. CREATE TABLE `flw_ext_instance` (
  161. `id` bigint NOT NULL COMMENT '主键ID',
  162. `tenant_id` varchar(50) COMMENT '租户ID',
  163. `process_id` bigint NOT NULL COMMENT '流程定义ID',
  164. `model_content` text COMMENT '流程模型定义JSON内容',
  165. PRIMARY KEY (`id`) USING BTREE,
  166. CONSTRAINT `fk_ext_instance_id` FOREIGN KEY (`id`) REFERENCES `flw_his_instance` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
  167. ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COMMENT = '扩展流程实例表' ROW_FORMAT = Dynamic;
  168. -- ----------------------------
  169. -- Table structure for flw_process
  170. -- ----------------------------
  171. DROP TABLE IF EXISTS `flw_process`;
  172. CREATE TABLE `flw_process` (
  173. `id` bigint NOT NULL COMMENT '主键ID',
  174. `tenant_id` varchar(50) COMMENT '租户ID',
  175. `create_id` varchar(50) NOT NULL COMMENT '创建人ID',
  176. `create_by` varchar(50) NOT NULL COMMENT '创建人名称',
  177. `create_time` timestamp NOT NULL COMMENT '创建时间',
  178. `process_key` varchar(100) NOT NULL COMMENT '流程定义 key 唯一标识',
  179. `process_name` varchar(100) NOT NULL COMMENT '流程定义名称',
  180. `process_icon` varchar(255) DEFAULT NULL COMMENT '流程图标地址',
  181. `process_type` varchar(100) COMMENT '流程类型',
  182. `process_version` int NOT NULL DEFAULT 1 COMMENT '流程版本,默认 1',
  183. `instance_url` varchar(200) COMMENT '实例地址',
  184. `remark` varchar(255) COMMENT '备注说明',
  185. `use_scope` tinyint(1) NOT NULL DEFAULT 0 COMMENT '使用范围 0,全员 1,指定人员(业务关联) 2,均不可提交',
  186. `process_state` tinyint(1) NOT NULL DEFAULT 1 COMMENT '流程状态 0,不可用 1,可用',
  187. `model_content` text COMMENT '流程模型定义JSON内容',
  188. `sort` tinyint(1) DEFAULT 0 COMMENT '排序',
  189. PRIMARY KEY (`id`) USING BTREE,
  190. INDEX `idx_process_name`(`process_name` ASC) USING BTREE
  191. ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COMMENT = '流程定义表' ROW_FORMAT = Dynamic;