drop table if exists sp_def_state;

CREATE TABLE `sp_def_state` (
  `id` varchar(32) CHARACTER SET utf8 NOT NULL COMMENT '主键',
  `sp_id` varchar(32) CHARACTER SET utf8 NOT NULL COMMENT '状态流程定义',
  `label` varchar(32) CHARACTER SET utf8 NOT NULL COMMENT '状态名称',
  `memo` varchar(512) CHARACTER SET utf8 DEFAULT NULL COMMENT '详细描述',
  `is_initial_state` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否初始状态',
  `is_finished_state` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否最终状态',
  `catalog_code` varchar(32) CHARACTER SET utf8 NOT NULL COMMENT '状态类目代码',
  `state_type` varchar(32) CHARACTER SET utf8 NOT NULL COMMENT '状态类型',
  `is_used_interceptor` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否启用拦截器',
  `x` int(11) DEFAULT NULL COMMENT '横坐标',
  `y` int(11) DEFAULT NULL COMMENT '纵坐标',
  `shape` varchar(20) CHARACTER SET utf8 NOT NULL COMMENT '图形样式',
  `tenant_id` varchar(32) CHARACTER SET utf8 NOT NULL DEFAULT 'NK' COMMENT '租户',
  PRIMARY KEY (`id`),
  UNIQUE KEY `idx_sp_sn` (`sp_id`,`label`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='状态定义';