SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

--
-- Table structure for table `alarm_forward_log`
--
CREATE TABLE IF NOT EXISTS `alarm_forward_log` (
  `id` int NOT NULL AUTO_INCREMENT,
  `ne_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '',
  `ne_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
  `alarm_seq` int DEFAULT '0' COMMENT '告警序号 连续递增',
  `alarm_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '告警ID',
  `alarm_code` int DEFAULT '0' COMMENT '告警状态码',
  `alarm_title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '告警标题',
  `alarm_status` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'Active' COMMENT '告警状态',
  `alarm_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '告警类型',
  `orig_severity` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'Minor' COMMENT '严重程度 ',
  `event_time` bigint DEFAULT '0' COMMENT '事件产生时间',
  `created_at` bigint DEFAULT '0' COMMENT '创建时间',
  `type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '转发方式 SMS/EMAIL',
  `target` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '发送目标用户',
  `result` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '发送结果',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='告警_转发日志记录';

-- ----------------------------
-- COLUMN for alarm_forward_log
-- ----------------------------
ALTER TABLE `alarm_forward_log` DROP COLUMN `interface`;
ALTER TABLE `alarm_forward_log` DROP COLUMN `to_user`;
ALTER TABLE `alarm_forward_log` DROP COLUMN `oper_result`;
ALTER TABLE `alarm_forward_log` DROP COLUMN `log_time`;
ALTER TABLE `alarm_forward_log` COMMENT = '告警_转发日志记录';
ALTER TABLE `alarm_forward_log` MODIFY COLUMN `ne_type` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' AFTER `id`;
ALTER TABLE `alarm_forward_log` MODIFY COLUMN `ne_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' AFTER `ne_type`;
ALTER TABLE `alarm_forward_log` MODIFY COLUMN `alarm_seq` int(11) NULL DEFAULT 0 COMMENT '告警序号 连续递增' AFTER `ne_id`;
ALTER TABLE `alarm_forward_log` MODIFY COLUMN `alarm_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '告警ID' AFTER `alarm_seq`;
ALTER TABLE `alarm_forward_log` ADD COLUMN `alarm_code` int(11) NULL DEFAULT 0 COMMENT '告警状态码' AFTER `alarm_id`;
ALTER TABLE `alarm_forward_log` MODIFY COLUMN `alarm_title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '告警标题' AFTER `alarm_code`;
ALTER TABLE `alarm_forward_log` ADD COLUMN `alarm_status` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'Active' COMMENT '告警状态' AFTER `alarm_title`;
ALTER TABLE `alarm_forward_log` MODIFY COLUMN `alarm_status` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'Active' COMMENT '告警状态' AFTER `alarm_title`;
ALTER TABLE `alarm_forward_log` ADD COLUMN `alarm_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '告警类型' AFTER `alarm_status`;
ALTER TABLE `alarm_forward_log` MODIFY COLUMN `alarm_type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '告警类型' AFTER `alarm_status`;
ALTER TABLE `alarm_forward_log` ADD COLUMN `orig_severity` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'Minor' COMMENT '严重程度' AFTER `alarm_type`;
ALTER TABLE `alarm_forward_log` MODIFY COLUMN `event_time` bigint(20) NULL DEFAULT 0 COMMENT '事件产生时间 秒级' AFTER `orig_severity`;
ALTER TABLE `alarm_forward_log` ADD COLUMN `created_at` bigint(20) NULL DEFAULT 0 COMMENT '创建时间' AFTER `event_time`;
ALTER TABLE `alarm_forward_log` ADD COLUMN `type` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '转发方式 SMS/EMAIL' AFTER `created_at`;
ALTER TABLE `alarm_forward_log` ADD COLUMN `target` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '发送目标用户' AFTER `type`;
ALTER TABLE `alarm_forward_log` ADD COLUMN `result` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' COMMENT '发送结果' AFTER `target`;
-- 更新数据
UPDATE `alarm_forward_log` SET `alarm_type` = 'CommunicationAlarm' WHERE `alarm_type` = '1';
UPDATE `alarm_forward_log` SET `alarm_type` = 'EquipmentAlarm' WHERE `alarm_type` = '2';
UPDATE `alarm_forward_log` SET `alarm_type` = 'ProcessingFailure' WHERE `alarm_type` = '3';
UPDATE `alarm_forward_log` SET `alarm_type` = 'EnvironmentalAlarm' WHERE `alarm_type` = '4';
UPDATE `alarm_forward_log` SET `alarm_type` = 'QualityOfServiceAlarm' WHERE `alarm_type` = '5';
UPDATE `alarm_forward_log` SET `orig_severity` = 'Critical' WHERE `orig_severity` = '1';
UPDATE `alarm_forward_log` SET `orig_severity` = 'Major' WHERE `orig_severity` = '2';
UPDATE `alarm_forward_log` SET `orig_severity` = 'Minor' WHERE `orig_severity` = '3';
UPDATE `alarm_forward_log` SET `orig_severity` = 'Warning' WHERE `orig_severity` = '4';
UPDATE `alarm_forward_log` SET `orig_severity` = 'Event' WHERE `orig_severity` = '5';
UPDATE `alarm_forward_log` SET `alarm_status` = 'Clear' WHERE `alarm_status` = '0';
UPDATE `alarm_forward_log` SET `alarm_status` = 'Active' WHERE `alarm_status` = '1';

SET FOREIGN_KEY_CHECKS=1;
