text: CREATE TABLE `task_receiver` (
    `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增主键',
    `task_id` int(10) NOT NULL COMMENT '任务ID',
    `policy` varchar(128) NOT NULL COMMENT '接收规则',
    `receivers` varchar(2048) NOT NULL DEFAULT '' COMMENT '接收人列表',
    `channels` varchar(128) NOT NULL DEFAULT 0 COMMENT '接收渠道列表',
    `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updated_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`),
    KEY `idx_task_id` (`task_id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 comment '任务接收人';
  
  
  CREATE TABLE `event` (
    `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增主键',
    `name` varchar(128) NOT NULL COMMENT '任务名称',
    `fingerprint` varchar(64) NOT NULL COMMENT '指纹',
    `level` tinyint NOT NULL COMMENT '事件等级',
    `metric` varchar(255) NOT NULL COMMENT '指标名称',
    `message` varchar(2048) NOT NULL DEFAULT '' COMMENT '消息内容',
    `expired` boolean NOT NULL COMMENT '事件是否过期',
    `acked` boolean NOT NULL COMMENT '事件是否确认',
    `ackuser` varchar(64) NOT NULL COMMENT '事件确认人',
    `closed` boolean NOT NULL COMMENT '事件是否关闭',
    `recovery` boolean NOT NULL COMMENT '事件是否恢复',
    `recovery_notice` boolean NOT NULL COMMENT '是否发送恢复通知',
    `notified` int NOT NULL COMMENT '通知次数',
    `close_time_unixnano` int NOT NULL DEFAULT 0 COMMENT '关闭时间',
    `expire_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '过期时间',
    `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updated_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`),
    KEY `idx_name` (`name`),
    KEY `idx_created_time` (`created_time`),
    UNIQUE KEY `uk_fingerprint_closetime` (`fingerprint`, `close_time_unixnano`) /*确保同一事件只有一个fingerprint 只有一个活动状态的事件*/
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 comment '告警事件';
  
  
  CREATE TABLE `event_handler` (
    `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增主键',
    `event_id` int(10) NOT NULL COMMENT '事件ID',
    `receivers` varchar(20) NOT NULL COMMENT '用户名',
    `channels` varchar(20) NOT NULL COMMENT '用户名',
    `everytime` boolean NOT NULL COMMENT '是否每次更新都通知',
    `delay` int NOT NULL COMMENT '延迟通知的时间',
    `interval` int NOT NULL COMMENT '通知的时间间隔',
    `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updated_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`),
    KEY `idx_event_id` (`event_id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 comment '事件处理策略表';
  
  
  CREATE TABLE `event_receiver` (
    `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增主键',
    `event_id` int(10) NOT NULL COMMENT '事件ID',
    `user` varchar(20) NOT NULL COMMENT '用户名',
    `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updated_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_task_id_key` (`event_id`, `user`),
    KEY `idx_event_user` (`user`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 comment '事件与接收人的关联表';
  
  
  CREATE TABLE `event_tag` (
    `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增主键',
    `event_id` int(10) NOT NULL COMMENT '事件ID',
    `tag` varchar(32) NOT NULL COMMENT '标签',
    `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updated_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`),
    KEY `idx_event_id` (`event_id`),
    KEY `idx_tag` (`tag`),
    UNIQUE KEY `uk_event_id_tag` (`event_id`, `tag`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 comment '事件标签';
  
  CREATE TABLE `mute` (
    `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增主键',
    `name` varchar(128) NOT NULL COMMENT '告警名',
    `fingerprint` varchar(64) NOT NULL COMMENT '指标名称',
    `user` varchar(20) NOT NULL COMMENT '用户',
    `deadline` timestamp NOT NULL COMMENT '截止时间',
    `description` text COMMENT '描述信息',
    `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updated_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`),
    KEY `idx_user` (`user`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 comment '屏蔽规则';
  
  CREATE TABLE `user` (
    `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增主键',
    `username` varchar(32) NOT NULL COMMENT '用户名',
    `password` varchar(32) NOT NULL COMMENT '密码',
    `name` varchar(32) NOT NULL COMMENT '用户名字',
    `permission` int NOT NULL COMMENT '权限',
    `message_receivers` text COMMENT '消息接收账号',
    `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updated_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_username` (`username`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 comment '用户';
  
  CREATE TABLE `group` (
    `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增主键',
    `name` varchar(32) NOT NULL COMMENT '组名',
    `public` boolean NOT NULL COMMENT '是否公开',
    `message_receivers` text COMMENT '消息接收账号',
    `description` varchar(256) COMMENT '描述信息',
    `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updated_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_name` (`name`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 comment '用户组';
  
  
  CREATE TABLE `group_user` (
    `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增主键',
    `groupname` varchar(32) NOT NULL COMMENT '组名',
    `username` varchar(32) NOT NULL COMMENT '用户名',
    `permission` int NOT NULL COMMENT '组的权限',
    `comment` varchar(128) COMMENT '备注信息',
    `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `updated_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_groupname_username` (`groupname`, `username`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 comment '组成员';