SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

CREATE TABLE IF NOT EXISTS `alarm_relation`  (
  `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  `root_alarm_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `alarm_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `relation_type` enum('derived','related') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '衍生关系：derived/related: 父子/兄弟',
  `add_info` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
  `created_at` datetime NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

ALTER TABLE `alarm_relation` 
DROP COLUMN IF EXISTS `updated_at`,
DROP COLUMN IF EXISTS `deleted_at`,
MODIFY COLUMN IF EXISTS `relation_type` enum('derived','related') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '衍生关系：derived/related: 父子/兄弟' AFTER `alarm_id`,
MODIFY COLUMN IF EXISTS `created_at` datetime NULL DEFAULT NULL AFTER `add_info`;

SET FOREIGN_KEY_CHECKS = 1;