--
-- Table structure for table `trace_data`
--

CREATE TABLE IF NOT EXISTS `trace_data` (
  `id` int NOT NULL AUTO_INCREMENT,
  `trace_id` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '跟踪任务ID',
  `imsi` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT 'UE类型 IMSI',
  `msisdn` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT 'UE类型 可能存在',
  `src_addr` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '源地址',
  `dst_addr` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '目标地址',
  `if_type` varchar(16) COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '接口类型，未分类',
  `msg_type` int DEFAULT NULL COMMENT '消息类型，0-req, 1-rsp',
  `msg_direct` int DEFAULT NULL COMMENT '消息方向，0-recv,1-send',
  `msg_ne` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '消息网元',
  `msg_event` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '消息事件，e.g: CreateContextReq',
  `length` int DEFAULT NULL COMMENT '原始数据byte长度',
  `timestamp` bigint DEFAULT '0' COMMENT '纳秒时间戳',
  `raw_msg` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '原始数据byteBase64',
  PRIMARY KEY (`id`) USING BTREE,
  KEY `idx_task_id_time` (`trace_id`,`timestamp`) COMMENT '任务DI时间'
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='跟踪_任务数据';

-- Dump completed on 2025-04-14 14:26:59

ALTER TABLE `trace_data` COMMENT = '跟踪_任务数据';
ALTER TABLE `trace_data` ADD COLUMN IF NOT EXISTS `trace_id` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '跟踪任务ID' AFTER `id`;
ALTER TABLE `trace_data` ADD COLUMN IF NOT EXISTS `msg_ne` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '消息网元' AFTER `msg_direct`;
ALTER TABLE `trace_data` ADD COLUMN IF NOT EXISTS `msg_event` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '消息事件，e.g: CreateContextReq' AFTER `msg_ne`;
ALTER TABLE `trace_data` MODIFY COLUMN `id` int NOT NULL FIRST;
ALTER TABLE `trace_data` MODIFY COLUMN `imsi` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT 'UE类型 IMSI' AFTER `trace_id`;
ALTER TABLE `trace_data` MODIFY COLUMN `msisdn` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT 'UE类型 可能存在' AFTER `imsi`;
ALTER TABLE `trace_data` MODIFY COLUMN `src_addr` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '源地址' AFTER `msisdn`;
ALTER TABLE `trace_data` MODIFY COLUMN `dst_addr` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '目标地址' AFTER `src_addr`;
ALTER TABLE `trace_data` MODIFY COLUMN `if_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '接口类型，未分类' AFTER `dst_addr`;
ALTER TABLE `trace_data` MODIFY COLUMN `msg_type` int NULL DEFAULT NULL COMMENT '消息类型，0-req, 1-rsp' AFTER `if_type`;
ALTER TABLE `trace_data` MODIFY COLUMN `msg_direct` int NULL DEFAULT NULL COMMENT '消息方向，0-recv,1-send' AFTER `msg_type`;
ALTER TABLE `trace_data` MODIFY COLUMN `length` int NULL DEFAULT NULL COMMENT '原始数据byte长度' AFTER `msg_event`;
ALTER TABLE `trace_data` MODIFY COLUMN `timestamp` bigint NULL DEFAULT 0 COMMENT '纳秒时间戳' AFTER `length`;
ALTER TABLE `trace_data` MODIFY COLUMN `raw_msg` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '原始数据byteBase64' AFTER `timestamp`;
ALTER TABLE `trace_data` MODIFY COLUMN `id` int NOT NULL AUTO_INCREMENT;
ALTER TABLE `trace_data` DROP COLUMN IF EXISTS `task_id`;
ALTER TABLE `trace_data` DROP COLUMN IF EXISTS `dec_msg`;
ALTER TABLE `trace_data` ADD INDEX IF NOT EXISTS `idx_task_id_time`(`trace_id`, `timestamp`) USING BTREE COMMENT '任务DI时间';
