SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for alarm_event
-- ----------------------------
CREATE TABLE IF NOT EXISTS `alarm_event` (
  `id` int NOT NULL AUTO_INCREMENT,
  `ne_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元类型',
  `ne_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元ID',
  `alarm_seq` int DEFAULT '0' COMMENT '告警序号 同网元类型连续递增',
  `alarm_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '告警ID',
  `alarm_title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '告警标题',
  `alarm_code` int DEFAULT '0' COMMENT '告警状态码',
  `event_time` bigint DEFAULT '0' COMMENT '事件产生时间 秒级',
  `object_uid` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '对象ID',
  `object_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '对象名称',
  `object_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '对象类型',
  `location_info` varchar(2048) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '告警定位信息',
  `alarm_status` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '1' COMMENT '告警状态 0:clear, 1:active',
  `specific_problem` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '告警问题原因',
  `specific_problem_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '告警问题原因ID',
  `add_info` varchar(2048) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '告警辅助信息',
  `clear_type` int DEFAULT '0' COMMENT '清除状态 0: Unclear, 1: AutoClear, 2: ManualClear',
  `clear_time` bigint DEFAULT '0' COMMENT '清除时间',
  `clear_user` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '清除用户',
  `timestamp` bigint DEFAULT '0' COMMENT '创建时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `uk_ti_aid_aseq` (`ne_type`,`ne_id`,`alarm_id`,`alarm_seq`) USING BTREE,
  KEY `idx_astatus_etime` (`alarm_status`,`event_time`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='告警_事件记录表';

-- ----------------------------
-- COLUMN for alarm_event
-- ----------------------------
ALTER TABLE `alarm_event` DROP COLUMN `alarm_type`;
ALTER TABLE `alarm_event` DROP COLUMN `orig_severity`;
ALTER TABLE `alarm_event` DROP COLUMN `perceived_severity`;
ALTER TABLE `alarm_event` DROP COLUMN `pv_flag`;
ALTER TABLE `alarm_event` DROP COLUMN `ne_name`;
ALTER TABLE `alarm_event` DROP COLUMN `province`;
ALTER TABLE `alarm_event` DROP COLUMN `counter`;
ALTER TABLE `alarm_event` DROP COLUMN `latest_event_time`;
ALTER TABLE `alarm_event` DROP COLUMN `ack_state`;
ALTER TABLE `alarm_event` DROP COLUMN `ack_time`;
ALTER TABLE `alarm_event` DROP COLUMN `ack_user`;
ALTER TABLE `alarm_event` DROP INDEX `idx_pk_id`;
ALTER TABLE `alarm_event` DROP INDEX `idx_uni_aid_ne_aseq`;
ALTER TABLE `alarm_event` DROP INDEX `idx_event_time`;
ALTER TABLE `alarm_event` DROP INDEX `idx_severity_status`;
ALTER TABLE `alarm_event` COMMENT = '告警_事件记录表';
ALTER TABLE `alarm_event` MODIFY COLUMN `ne_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元类型' AFTER `id`;
ALTER TABLE `alarm_event` MODIFY COLUMN `ne_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '网元ID' AFTER `ne_type`;
ALTER TABLE `alarm_event` MODIFY COLUMN `alarm_seq` int(11) NULL DEFAULT 0 COMMENT '告警序号 同网元类型连续递增' AFTER `ne_id`;
ALTER TABLE `alarm_event` MODIFY COLUMN `alarm_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '告警ID' AFTER `alarm_seq`;
ALTER TABLE `alarm_event` MODIFY COLUMN `alarm_title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '告警标题' AFTER `alarm_id`;
ALTER TABLE `alarm_event` MODIFY COLUMN `alarm_code` int(11) NULL DEFAULT 0 COMMENT '告警状态码' AFTER `alarm_title`;
ALTER TABLE `alarm_event` MODIFY COLUMN `event_time` bigint(20) NULL DEFAULT 0 COMMENT '事件产生时间 秒级' AFTER `alarm_code`;
ALTER TABLE `alarm_event` MODIFY COLUMN `object_uid` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '对象ID' AFTER `event_time`;
ALTER TABLE `alarm_event` MODIFY COLUMN `object_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '对象名称' AFTER `object_uid`;
ALTER TABLE `alarm_event` MODIFY COLUMN `object_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '对象类型' AFTER `object_name`;
ALTER TABLE `alarm_event` MODIFY COLUMN `location_info` varchar(2048) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '告警定位信息' AFTER `object_type`;
ALTER TABLE `alarm_event` MODIFY COLUMN `alarm_status` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '1' COMMENT '告警状态 0:clear, 1:active' AFTER `location_info`;
ALTER TABLE `alarm_event` MODIFY COLUMN `specific_problem` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '告警问题原因' AFTER `alarm_status`;
ALTER TABLE `alarm_event` MODIFY COLUMN `specific_problem_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '告警问题原因ID' AFTER `specific_problem`;
ALTER TABLE `alarm_event` MODIFY COLUMN `add_info` varchar(2048) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '告警辅助信息' AFTER `specific_problem_id`;
ALTER TABLE `alarm_event` MODIFY COLUMN `clear_type` int(11) NULL DEFAULT 0 COMMENT '清除状态 0: Unclear, 1: AutoClear, 2: ManualClear' AFTER `add_info`;
ALTER TABLE `alarm_event` MODIFY COLUMN `clear_time` bigint(20) NULL DEFAULT 0 COMMENT '清除时间' AFTER `clear_type`;
ALTER TABLE `alarm_event` MODIFY COLUMN `clear_user` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '清除用户' AFTER `clear_time`;
ALTER TABLE `alarm_event` MODIFY COLUMN `timestamp` bigint(20) NULL DEFAULT 0 COMMENT '创建时间' AFTER `clear_user`;
ALTER TABLE `alarm_event` ADD UNIQUE INDEX `uk_ti_aid_aseq`(`ne_type`, `ne_id`, `alarm_id`, `alarm_seq`) USING BTREE;
ALTER TABLE `alarm_event` ADD INDEX `idx_astatus_etime`(`alarm_status`, `event_time`) USING BTREE;

SET FOREIGN_KEY_CHECKS = 1;

-- Dump completed on 2025-02-14 15:26:56
