From 994de4635aa4ea80c2073a21aee910efcd94e79b Mon Sep 17 00:00:00 2001 From: ning <710leo@gmail.com> Date: Mon, 2 Dec 2024 20:18:32 +0800 Subject: [PATCH] docs: update n9e.sql --- docker/initsql/a-n9e.sql | 234 +++++++++++++++++----------------- docker/migratesql/migrate.sql | 6 +- models/migrate/migrate.go | 21 +-- 3 files changed, 134 insertions(+), 127 deletions(-) diff --git a/docker/initsql/a-n9e.sql b/docker/initsql/a-n9e.sql index 7e982c1a..037a7912 100644 --- a/docker/initsql/a-n9e.sql +++ b/docker/initsql/a-n9e.sql @@ -58,8 +58,8 @@ CREATE TABLE `configs` ( `ckey` varchar(191) not null, `note` varchar(1024) NOT NULL DEFAULT '' COMMENT 'note', `cval` text COMMENT 'config value', - `external` bigint NOT NULL DEFAULT 0 COMMENT '0 means built-in 1 means external', - `encrypted` bigint DEFAULT 0 COMMENT '0 means plaintext 1 means ciphertext', + `external` bigint DEFAULT 0 COMMENT '0\\:built-in 1\\:external', + `encrypted` bigint DEFAULT 0 COMMENT '0\\:plaintext 1\\:ciphertext', `create_at` bigint DEFAULT 0 COMMENT 'create_at', `create_by` varchar(64) NOT NULL DEFAULT '' COMMENT 'cerate_by', `update_at` bigint DEFAULT 0 COMMENT 'update_at', @@ -290,12 +290,12 @@ CREATE TABLE `alert_rule` ( `runbook_url` varchar(4096), `append_tags` varchar(255) not null default '' comment 'split by space: service=n9e mod=api', `annotations` text not null comment 'annotations', - `extra_config` text not null comment 'extra_config', + `extra_config` text, `create_at` bigint not null default 0, `create_by` varchar(64) not null default '', `update_at` bigint not null default 0, `update_by` varchar(64) not null default '', - `cron_pattern` varchar(64) DEFAULT NULL, + `cron_pattern` varchar(64), `datasource_queries` text, PRIMARY KEY (`id`), KEY (`group_id`), @@ -345,10 +345,10 @@ CREATE TABLE `alert_subscribe` ( `redefine_channels` tinyint(1) default 0 comment 'is redefine channels?', `new_channels` varchar(255) not null default '' comment 'split by space: sms voice email dingtalk wecom', `user_group_ids` varchar(250) not null comment 'split by space 1 34 5, notify cc to user_group_ids', - `busi_groups` varchar(4096) NOT NULL, + `busi_groups` varchar(4096), `note` VARCHAR(1024) DEFAULT '' COMMENT 'note', `webhooks` text not null, - `extra_config` text not null comment 'extra_config', + `extra_config` text, `redefine_webhooks` tinyint(1) default 0, `for_duration` bigint not null default 0, `create_at` bigint not null default 0, @@ -750,9 +750,9 @@ CREATE TABLE `task_meta` `id` bigint unsigned NOT NULL AUTO_INCREMENT, `title` varchar(255) not null default '', `account` varchar(64) not null, - `batch` int unsigned not null default 0, - `tolerance` int unsigned not null default 0, - `timeout` int unsigned not null default 0, + `batch` bigint not null default 0, + `tolerance` bigint not null default 0, + `timeout` bigint not null default 0, `pause` varchar(255) not null default '', `script` text not null, `args` varchar(512) not null default '', @@ -760,8 +760,8 @@ CREATE TABLE `task_meta` `creator` varchar(64) not null default '', `created` timestamp not null default CURRENT_TIMESTAMP, PRIMARY KEY (`id`), - KEY (`creator`), - KEY (`created`) + KEY `idx_task_meta_creator` (`creator`), + KEY `idx_task_meta_created` (`created`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -785,9 +785,9 @@ CREATE TABLE `task_scheduler` CREATE TABLE `task_scheduler_health` ( - `scheduler` varchar(128) not null, - `clock` bigint not null, - UNIQUE KEY (`scheduler`), + `scheduler` varchar(128) NOT NULL, + `clock` bigint not null, + UNIQUE KEY `idx_task_scheduler_health_scheduler` (`scheduler`), KEY (`clock`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -798,8 +798,8 @@ CREATE TABLE `task_host_doing` `host` varchar(128) not null, `clock` bigint not null default 0, `action` varchar(16) not null, - KEY (`id`), - KEY (`host`) + KEY `idx_task_host_doing_id` (`id`), + KEY `idx_task_host_doing_host` (`host`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -811,7 +811,7 @@ CREATE TABLE task_host_0 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -824,7 +824,7 @@ CREATE TABLE task_host_1 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -837,7 +837,7 @@ CREATE TABLE task_host_2 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -850,7 +850,7 @@ CREATE TABLE task_host_3 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -863,7 +863,7 @@ CREATE TABLE task_host_4 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -876,7 +876,7 @@ CREATE TABLE task_host_5 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -889,7 +889,7 @@ CREATE TABLE task_host_6 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -902,7 +902,7 @@ CREATE TABLE task_host_7 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -915,7 +915,7 @@ CREATE TABLE task_host_8 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -928,7 +928,7 @@ CREATE TABLE task_host_9 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -941,7 +941,7 @@ CREATE TABLE task_host_10 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -954,7 +954,7 @@ CREATE TABLE task_host_11 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -967,7 +967,7 @@ CREATE TABLE task_host_12 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -980,7 +980,7 @@ CREATE TABLE task_host_13 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -993,7 +993,7 @@ CREATE TABLE task_host_14 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1006,7 +1006,7 @@ CREATE TABLE task_host_15 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1019,7 +1019,7 @@ CREATE TABLE task_host_16 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1032,7 +1032,7 @@ CREATE TABLE task_host_17 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1045,7 +1045,7 @@ CREATE TABLE task_host_18 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1058,7 +1058,7 @@ CREATE TABLE task_host_19 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1071,7 +1071,7 @@ CREATE TABLE task_host_20 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1084,7 +1084,7 @@ CREATE TABLE task_host_21 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1097,7 +1097,7 @@ CREATE TABLE task_host_22 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1110,7 +1110,7 @@ CREATE TABLE task_host_23 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1123,7 +1123,7 @@ CREATE TABLE task_host_24 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1136,7 +1136,7 @@ CREATE TABLE task_host_25 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1149,7 +1149,7 @@ CREATE TABLE task_host_26 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1162,7 +1162,7 @@ CREATE TABLE task_host_27 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1175,7 +1175,7 @@ CREATE TABLE task_host_28 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1188,7 +1188,7 @@ CREATE TABLE task_host_29 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1201,7 +1201,7 @@ CREATE TABLE task_host_30 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1214,7 +1214,7 @@ CREATE TABLE task_host_31 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1227,7 +1227,7 @@ CREATE TABLE task_host_32 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1240,7 +1240,7 @@ CREATE TABLE task_host_33 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1253,7 +1253,7 @@ CREATE TABLE task_host_34 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1266,7 +1266,7 @@ CREATE TABLE task_host_35 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1279,7 +1279,7 @@ CREATE TABLE task_host_36 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1292,7 +1292,7 @@ CREATE TABLE task_host_37 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1305,7 +1305,7 @@ CREATE TABLE task_host_38 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1318,7 +1318,7 @@ CREATE TABLE task_host_39 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1331,7 +1331,7 @@ CREATE TABLE task_host_40 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1344,7 +1344,7 @@ CREATE TABLE task_host_41 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1357,7 +1357,7 @@ CREATE TABLE task_host_42 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1370,7 +1370,7 @@ CREATE TABLE task_host_43 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1383,7 +1383,7 @@ CREATE TABLE task_host_44 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1396,7 +1396,7 @@ CREATE TABLE task_host_45 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1409,7 +1409,7 @@ CREATE TABLE task_host_46 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1422,7 +1422,7 @@ CREATE TABLE task_host_47 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1435,7 +1435,7 @@ CREATE TABLE task_host_48 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1448,7 +1448,7 @@ CREATE TABLE task_host_49 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1461,7 +1461,7 @@ CREATE TABLE task_host_50 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1474,7 +1474,7 @@ CREATE TABLE task_host_51 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1487,7 +1487,7 @@ CREATE TABLE task_host_52 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1500,7 +1500,7 @@ CREATE TABLE task_host_53 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1513,7 +1513,7 @@ CREATE TABLE task_host_54 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1526,7 +1526,7 @@ CREATE TABLE task_host_55 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1539,7 +1539,7 @@ CREATE TABLE task_host_56 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1552,7 +1552,7 @@ CREATE TABLE task_host_57 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1565,7 +1565,7 @@ CREATE TABLE task_host_58 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1578,7 +1578,7 @@ CREATE TABLE task_host_59 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1591,7 +1591,7 @@ CREATE TABLE task_host_60 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1604,7 +1604,7 @@ CREATE TABLE task_host_61 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1617,7 +1617,7 @@ CREATE TABLE task_host_62 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1630,7 +1630,7 @@ CREATE TABLE task_host_63 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1643,7 +1643,7 @@ CREATE TABLE task_host_64 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1656,7 +1656,7 @@ CREATE TABLE task_host_65 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1669,7 +1669,7 @@ CREATE TABLE task_host_66 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1682,7 +1682,7 @@ CREATE TABLE task_host_67 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1695,7 +1695,7 @@ CREATE TABLE task_host_68 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1708,7 +1708,7 @@ CREATE TABLE task_host_69 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1721,7 +1721,7 @@ CREATE TABLE task_host_70 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1734,7 +1734,7 @@ CREATE TABLE task_host_71 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1747,7 +1747,7 @@ CREATE TABLE task_host_72 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1760,7 +1760,7 @@ CREATE TABLE task_host_73 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1773,7 +1773,7 @@ CREATE TABLE task_host_74 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1786,7 +1786,7 @@ CREATE TABLE task_host_75 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1799,7 +1799,7 @@ CREATE TABLE task_host_76 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1812,7 +1812,7 @@ CREATE TABLE task_host_77 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1825,7 +1825,7 @@ CREATE TABLE task_host_78 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1838,7 +1838,7 @@ CREATE TABLE task_host_79 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1851,7 +1851,7 @@ CREATE TABLE task_host_80 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1864,7 +1864,7 @@ CREATE TABLE task_host_81 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1877,7 +1877,7 @@ CREATE TABLE task_host_82 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1890,7 +1890,7 @@ CREATE TABLE task_host_83 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1903,7 +1903,7 @@ CREATE TABLE task_host_84 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1916,7 +1916,7 @@ CREATE TABLE task_host_85 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1929,7 +1929,7 @@ CREATE TABLE task_host_86 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1942,7 +1942,7 @@ CREATE TABLE task_host_87 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1955,7 +1955,7 @@ CREATE TABLE task_host_88 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1968,7 +1968,7 @@ CREATE TABLE task_host_89 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1981,7 +1981,7 @@ CREATE TABLE task_host_90 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -1994,7 +1994,7 @@ CREATE TABLE task_host_91 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -2007,7 +2007,7 @@ CREATE TABLE task_host_92 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -2020,7 +2020,7 @@ CREATE TABLE task_host_93 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -2033,7 +2033,7 @@ CREATE TABLE task_host_94 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -2046,7 +2046,7 @@ CREATE TABLE task_host_95 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -2059,7 +2059,7 @@ CREATE TABLE task_host_96 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -2072,7 +2072,7 @@ CREATE TABLE task_host_97 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -2085,7 +2085,7 @@ CREATE TABLE task_host_98 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4; @@ -2098,7 +2098,7 @@ CREATE TABLE task_host_99 `status` varchar(32) not null, `stdout` text, `stderr` text, - UNIQUE KEY (`id`, `host`), + UNIQUE KEY `idx_id_host` (`id`, `host`), PRIMARY KEY (`ii`) ) ENGINE = InnoDB - DEFAULT CHARSET = utf8mb4; + DEFAULT CHARSET = utf8mb4; \ No newline at end of file diff --git a/docker/migratesql/migrate.sql b/docker/migratesql/migrate.sql index f62b6d5e..e0a8c6eb 100644 --- a/docker/migratesql/migrate.sql +++ b/docker/migratesql/migrate.sql @@ -116,4 +116,8 @@ CREATE TABLE `target_busi_group` ( `update_at` bigint NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `idx_target_group` (`target_ident`,`group_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; \ No newline at end of file +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +/* v7.7.2 2024-12-02 */ +ALTER TABLE alert_subscribe MODIFY COLUMN rule_ids varchar(1024); +ALTER TABLE alert_subscribe MODIFY COLUMN busi_groups varchar(4096); \ No newline at end of file diff --git a/models/migrate/migrate.go b/models/migrate/migrate.go index cb7fec81..f368df0f 100644 --- a/models/migrate/migrate.go +++ b/models/migrate/migrate.go @@ -28,7 +28,7 @@ func MigrateIbexTables(db *gorm.DB) { db = db.Set("gorm:table_options", tableOptions) } - dts := []interface{}{&imodels.TaskMeta{}, &imodels.TaskScheduler{}, &imodels.TaskSchedulerHealth{}, &TaskHostDoing{}, &imodels.TaskAction{}} + dts := []interface{}{&imodels.TaskMeta{}, &imodels.TaskScheduler{}, &TaskHostDoing{}, &imodels.TaskAction{}} for _, dt := range dts { err := db.AutoMigrate(dt) if err != nil { @@ -61,6 +61,10 @@ func MigrateTables(db *gorm.DB) error { &models.MetricFilter{}, &models.BuiltinComponent{}, &models.NotificaitonRecord{}, &models.TargetBusiGroup{}} + if !db.Migrator().HasColumn(&imodels.TaskSchedulerHealth{}, "scheduler") { + dts = append(dts, &imodels.TaskSchedulerHealth{}) + } + if !columnHasIndex(db, &AlertHisEvent{}, "original_tags") || !columnHasIndex(db, &AlertCurEvent{}, "original_tags") { asyncDts := []interface{}{&AlertHisEvent{}, &AlertCurEvent{}} @@ -186,18 +190,17 @@ func InsertPermPoints(db *gorm.DB) { } type AlertRule struct { - ExtraConfig string `gorm:"type:text;column:extra_config;not null;comment:extra_config"` // extra config - CronPattern string `gorm:"type:varchar(64);cron_pattern"` + ExtraConfig string `gorm:"type:text;column:extra_config"` + CronPattern string `gorm:"type:varchar(64);column:cron_pattern"` DatasourceQueries []models.DatasourceQuery `gorm:"datasource_queries;type:text;serializer:json"` // datasource queries } type AlertSubscribe struct { - ExtraConfig string `gorm:"type:text;column:extra_config;not null;comment:extra_config"` // extra config + ExtraConfig string `gorm:"type:text;column:extra_config"` // extra config Severities string `gorm:"column:severities;type:varchar(32);not null;default:''"` - RuleID int64 `gorm:"type:bigint;not null;default:0"` - RuleIds []int64 `gorm:"column:rule_ids;type:varchar(1024);"` - BusiGroups ormx.JSONArr `gorm:"column:busi_groups;type:varchar(4096);not null;"` + BusiGroups ormx.JSONArr `gorm:"column:busi_groups;type:varchar(4096)"` Note string `gorm:"column:note;type:varchar(1024);default:'';comment:note"` + RuleIds []int64 `gorm:"column:rule_ids;type:varchar(1024)"` } type AlertMute struct { @@ -247,8 +250,8 @@ type Configs struct { Note string `gorm:"column:note;type:varchar(1024);default:'';comment:note"` Cval string `gorm:"column:cval;type:text;comment:config value"` //mysql tinyint//postgresql smallint - External int64 `gorm:"column:external;type:bigint;default:0;comment:0 means built-in 1 means external"` - Encrypted int `gorm:"column:encrypted;type:int;default:0;comment:0 means plaintext 1 means ciphertext"` + External int `gorm:"column:external;type:int;default:0;comment:0\\:built-in 1\\:external"` + Encrypted int `gorm:"column:encrypted;type:int;default:0;comment:0\\:plaintext 1\\:ciphertext"` CreateAt int64 `gorm:"column:create_at;type:int;default:0;comment:create_at"` CreateBy string `gorm:"column:create_by;type:varchar(64);default:'';comment:cerate_by"` UpdateAt int64 `gorm:"column:update_at;type:int;default:0;comment:update_at"`