You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

migrate.sql 12 kB

1 year ago
1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. /* v7.0.0-beta.3 */
  2. CREATE TABLE `builtin_metrics` (
  3. `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'unique identifier',
  4. `collector` varchar(191) NOT NULL COMMENT 'type of collector',
  5. `typ` varchar(191) NOT NULL COMMENT 'type of metric',
  6. `name` varchar(191) NOT NULL COMMENT 'name of metric',
  7. `unit` varchar(191) NOT NULL COMMENT 'unit of metric',
  8. `lang` varchar(191) NOT NULL DEFAULT '' COMMENT 'language of metric',
  9. `note` varchar(4096) NOT NULL COMMENT 'description of metric in Chinese',
  10. `expression` varchar(4096) NOT NULL COMMENT 'expression of metric',
  11. `created_at` bigint NOT NULL DEFAULT 0 COMMENT 'create time',
  12. `created_by` varchar(191) NOT NULL DEFAULT '' COMMENT 'creator',
  13. `updated_at` bigint NOT NULL DEFAULT 0 COMMENT 'update time',
  14. `updated_by` varchar(191) NOT NULL DEFAULT '' COMMENT 'updater',
  15. PRIMARY KEY (`id`),
  16. INDEX `idx_collector` (`collector`),
  17. INDEX `idx_typ` (`typ`),
  18. INDEX `idx_name` (`name`),
  19. INDEX `idx_lang` (`lang`)
  20. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  21. CREATE TABLE `metric_filter` (
  22. `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'unique identifier',
  23. `name` varchar(191) NOT NULL COMMENT 'name of metric filter',
  24. `configs` varchar(4096) NOT NULL COMMENT 'configuration of metric filter',
  25. `groups_perm` text,
  26. `create_at` bigint NOT NULL DEFAULT '0' COMMENT 'create time',
  27. `create_by` varchar(191) NOT NULL DEFAULT '' COMMENT 'creator',
  28. `update_at` bigint NOT NULL DEFAULT '0' COMMENT 'update time',
  29. `update_by` varchar(191) NOT NULL DEFAULT '' COMMENT 'updater',
  30. PRIMARY KEY (`id`),
  31. KEY `idx_name` (`name`)
  32. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  33. CREATE TABLE `board_busigroup` (
  34. `busi_group_id` bigint(20) NOT NULL DEFAULT '0' COMMENT 'busi group id',
  35. `board_id` bigint(20) NOT NULL DEFAULT '0' COMMENT 'board id',
  36. PRIMARY KEY (`busi_group_id`, `board_id`)
  37. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  38. /* v7.0.0-beta.6 */
  39. CREATE TABLE `builtin_components` (
  40. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '''unique identifier''',
  41. `ident` varchar(191) NOT NULL COMMENT '''identifier of component''',
  42. `logo` varchar(191) NOT NULL COMMENT '''logo of component''',
  43. `readme` text NOT NULL COMMENT '''readme of component''',
  44. `created_at` bigint(20) NOT NULL DEFAULT 0 COMMENT '''create time''',
  45. `created_by` varchar(191) NOT NULL DEFAULT '' COMMENT '''creator''',
  46. `updated_at` bigint(20) NOT NULL DEFAULT 0 COMMENT '''update time''',
  47. `updated_by` varchar(191) NOT NULL DEFAULT '' COMMENT '''updater''',
  48. PRIMARY KEY (`id`),
  49. KEY `idx_ident` (`ident`)
  50. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  51. CREATE TABLE `builtin_payloads` (
  52. `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '''unique identifier''',
  53. `uuid` bigint(20) NOT NULL COMMENT '''uuid of payload''',
  54. `type` varchar(191) NOT NULL COMMENT '''type of payload''',
  55. `component` varchar(191) NOT NULL COMMENT '''component of payload''',
  56. `cate` varchar(191) NOT NULL COMMENT '''category of payload''',
  57. `name` varchar(191) NOT NULL COMMENT '''name of payload''',
  58. `tags` varchar(191) NOT NULL DEFAULT '' COMMENT '''tags of payload''',
  59. `content` longtext NOT NULL COMMENT '''content of payload''',
  60. `created_at` bigint(20) NOT NULL DEFAULT 0 COMMENT '''create time''',
  61. `created_by` varchar(191) NOT NULL DEFAULT '' COMMENT '''creator''',
  62. `updated_at` bigint(20) NOT NULL DEFAULT 0 COMMENT '''update time''',
  63. `updated_by` varchar(191) NOT NULL DEFAULT '' COMMENT '''updater''',
  64. PRIMARY KEY (`id`),
  65. KEY `idx_component` (`component`),
  66. KEY `idx_name` (`name`),
  67. KEY `idx_cate` (`cate`),
  68. KEY `idx_uuid` (`uuid`),
  69. KEY `idx_type` (`type`)
  70. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  71. /* v7.0.0-beta.7 */
  72. ALTER TABLE users ADD COLUMN last_active_time BIGINT NOT NULL DEFAULT 0;
  73. /* v7.0.0-beta.13 */
  74. ALTER TABLE recording_rule ADD COLUMN cron_pattern VARCHAR(255) DEFAULT '' COMMENT 'cron pattern';
  75. /* v7.0.0-beta.14 */
  76. ALTER TABLE alert_cur_event ADD COLUMN original_tags TEXT COMMENT 'labels key=val,,k2=v2';
  77. ALTER TABLE alert_his_event ADD COLUMN original_tags TEXT COMMENT 'labels key=val,,k2=v2';
  78. /* v7.1.0 */
  79. ALTER TABLE target ADD COLUMN os VARCHAR(31) DEFAULT '' COMMENT 'os type';
  80. /* v7.2.0 */
  81. CREATE TABLE notification_record (
  82. `id` BIGINT PRIMARY KEY AUTO_INCREMENT,
  83. `event_id` BIGINT NOT NULL,
  84. `sub_id` BIGINT NOT NULL,
  85. `channel` VARCHAR(255) NOT NULL,
  86. `status` TINYINT NOT NULL DEFAULT 0,
  87. `target` VARCHAR(1024) NOT NULL,
  88. `details` VARCHAR(2048),
  89. `created_at` BIGINT NOT NULL,
  90. INDEX idx_evt (event_id)
  91. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  92. /* v7.3.0 2024-08-26 */
  93. ALTER TABLE `target` ADD COLUMN `host_tags` TEXT COMMENT 'global labels set in conf file';
  94. /* v7.3.4 2024-08-28 */
  95. ALTER TABLE `builtin_payloads` ADD COLUMN `component_id` bigint(20) NOT NULL DEFAULT 0 COMMENT 'component_id';
  96. /* v7.4.0 2024-09-20 */
  97. CREATE TABLE `target_busi_group` (
  98. `id` bigint NOT NULL AUTO_INCREMENT,
  99. `target_ident` varchar(191) NOT NULL,
  100. `group_id` bigint NOT NULL,
  101. `update_at` bigint NOT NULL,
  102. PRIMARY KEY (`id`),
  103. UNIQUE KEY `idx_target_group` (`target_ident`,`group_id`)
  104. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  105. /* v7.7.0 2024-11-13 */
  106. ALTER TABLE `recording_rule` ADD COLUMN `datasource_queries` TEXT;
  107. ALTER TABLE `alert_rule` ADD COLUMN `datasource_queries` TEXT;
  108. /* v7.7.2 2024-12-02 */
  109. ALTER TABLE alert_subscribe MODIFY COLUMN rule_ids varchar(1024);
  110. ALTER TABLE alert_subscribe MODIFY COLUMN busi_groups varchar(4096);
  111. /* v8.0.0-beta.1 2024-12-13 */
  112. ALTER TABLE `alert_rule` ADD COLUMN `cron_pattern` VARCHAR(64);
  113. ALTER TABLE `builtin_components` MODIFY COLUMN `logo` mediumtext COMMENT '''logo of component''';
  114. /* v8.0.0-beta.2 2024-12-26 */
  115. ALTER TABLE `es_index_pattern` ADD COLUMN `cross_cluster_enabled` int not null default 0;
  116. /* v8.0.0-beta.3 2025-01-03 */
  117. ALTER TABLE `builtin_components` ADD COLUMN `disabled` INT NOT NULL DEFAULT 0 COMMENT 'is disabled or not';
  118. CREATE TABLE `dash_annotation` (
  119. `id` bigint unsigned not null auto_increment,
  120. `dashboard_id` bigint not null comment 'dashboard id',
  121. `panel_id` varchar(191) not null comment 'panel id',
  122. `tags` text comment 'tags array json string',
  123. `description` text comment 'annotation description',
  124. `config` text comment 'annotation config',
  125. `time_start` bigint not null default 0 comment 'start timestamp',
  126. `time_end` bigint not null default 0 comment 'end timestamp',
  127. `create_at` bigint not null default 0 comment 'create time',
  128. `create_by` varchar(64) not null default '' comment 'creator',
  129. `update_at` bigint not null default 0 comment 'update time',
  130. `update_by` varchar(64) not null default '' comment 'updater',
  131. PRIMARY KEY (`id`),
  132. KEY `idx_dashboard_id` (`dashboard_id`)
  133. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  134. /* v8.0.0-beta.5 2025-02-05 */
  135. CREATE TABLE `user_token` (
  136. `id` bigint NOT NULL AUTO_INCREMENT,
  137. `username` varchar(255) NOT NULL DEFAULT '',
  138. `token_name` varchar(255) NOT NULL DEFAULT '',
  139. `token` varchar(255) NOT NULL DEFAULT '',
  140. `create_at` bigint NOT NULL DEFAULT 0,
  141. `last_used` bigint NOT NULL DEFAULT 0,
  142. PRIMARY KEY (`id`)
  143. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  144. /* v8.0.0-beta.7 2025-03-01 */
  145. CREATE TABLE `notify_rule` (
  146. `id` bigint unsigned not null auto_increment,
  147. `name` varchar(255) not null,
  148. `description` text,
  149. `enable` tinyint(1) not null default 0,
  150. `user_group_ids` varchar(255) not null default '',
  151. `notify_configs` text,
  152. `create_at` bigint not null default 0,
  153. `create_by` varchar(64) not null default '',
  154. `update_at` bigint not null default 0,
  155. `update_by` varchar(64) not null default '',
  156. PRIMARY KEY (`id`)
  157. ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4;
  158. CREATE TABLE `notify_channel` (
  159. `id` bigint unsigned not null auto_increment,
  160. `name` varchar(255) not null,
  161. `ident` varchar(255) not null,
  162. `description` text,
  163. `enable` tinyint(1) not null default 0,
  164. `param_config` text,
  165. `request_type` varchar(50) not null,
  166. `request_config` text,
  167. `create_at` bigint not null default 0,
  168. `create_by` varchar(64) not null default '',
  169. `update_at` bigint not null default 0,
  170. `update_by` varchar(64) not null default '',
  171. PRIMARY KEY (`id`)
  172. ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4;
  173. CREATE TABLE `message_template` (
  174. `id` bigint unsigned not null auto_increment,
  175. `name` varchar(64) not null,
  176. `ident` varchar(64) not null,
  177. `content` text,
  178. `user_group_ids` varchar(64),
  179. `notify_channel_ident` varchar(64) not null default '',
  180. `private` int not null default 0,
  181. `create_at` bigint not null default 0,
  182. `create_by` varchar(64) not null default '',
  183. `update_at` bigint not null default 0,
  184. `update_by` varchar(64) not null default '',
  185. PRIMARY KEY (`id`)
  186. ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4;
  187. ALTER TABLE `alert_rule` ADD COLUMN `notify_rule_ids` varchar(1024) DEFAULT '';
  188. ALTER TABLE `alert_rule` ADD COLUMN `notify_version` int DEFAULT 0;
  189. ALTER TABLE `alert_subscribe` ADD COLUMN `notify_rule_ids` varchar(1024) DEFAULT '';
  190. ALTER TABLE `alert_subscribe` ADD COLUMN `notify_version` int DEFAULT 0;
  191. ALTER TABLE `notification_record` ADD COLUMN `notify_rule_id` BIGINT NOT NULL DEFAULT 0;
  192. /* v8.0.0-beta.9 2025-03-17 */
  193. ALTER TABLE `message_template` ADD COLUMN `weight` int not null default 0;
  194. ALTER TABLE `notify_channel` ADD COLUMN `weight` int not null default 0;
  195. /* v8.0.0-beta.11 2025-04-10 */
  196. ALTER TABLE `es_index_pattern` ADD COLUMN `note` varchar(1024) not null default '';
  197. ALTER TABLE `datasource` ADD COLUMN `identifier` varchar(255) not null default '';
  198. /* v8.0.0-beta.11 2025-05-15 */
  199. ALTER TABLE `notify_rule` ADD COLUMN `pipeline_configs` text;
  200. CREATE TABLE `event_pipeline` (
  201. `id` bigint unsigned not null auto_increment,
  202. `name` varchar(128) not null,
  203. `team_ids` text,
  204. `description` varchar(255) not null default '',
  205. `filter_enable` tinyint(1) not null default 0,
  206. `label_filters` text,
  207. `attribute_filters` text,
  208. `processors` text,
  209. `create_at` bigint not null default 0,
  210. `create_by` varchar(64) not null default '',
  211. `update_at` bigint not null default 0,
  212. `update_by` varchar(64) not null default '',
  213. PRIMARY KEY (`id`)
  214. ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4;
  215. /* v8.0.0 2025-05-15 */
  216. CREATE TABLE `embedded_product` (
  217. `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  218. `name` varchar(255) DEFAULT NULL,
  219. `url` varchar(255) DEFAULT NULL,
  220. `is_private` boolean DEFAULT NULL,
  221. `team_ids` varchar(255),
  222. `create_at` bigint not null default 0,
  223. `create_by` varchar(64) not null default '',
  224. `update_at` bigint not null default 0,
  225. `update_by` varchar(64) not null default '',
  226. PRIMARY KEY (`id`)
  227. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  228. /* v8.0.0 2025-05-29 */
  229. CREATE TABLE `source_token` (
  230. `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  231. `source_type` varchar(64) NOT NULL DEFAULT '' COMMENT 'source type',
  232. `source_id` varchar(255) NOT NULL DEFAULT '' COMMENT 'source identifier',
  233. `token` varchar(255) NOT NULL DEFAULT '' COMMENT 'access token',
  234. `expire_at` bigint NOT NULL DEFAULT 0 COMMENT 'expire timestamp',
  235. `create_at` bigint NOT NULL DEFAULT 0 COMMENT 'create timestamp',
  236. `create_by` varchar(64) NOT NULL DEFAULT '' COMMENT 'creator',
  237. PRIMARY KEY (`id`),
  238. KEY `idx_source_type_id_token` (`source_type`, `source_id`, `token`)
  239. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  240. /* Add translation column for builtin metrics */
  241. ALTER TABLE `builtin_metrics` ADD COLUMN `translation` TEXT COMMENT 'translation of metric' AFTER `lang`;
  242. /* v8.0.0-beta.12 2025-06-03 */
  243. ALTER TABLE `alert_his_event` ADD COLUMN `notify_rule_ids` text COMMENT 'notify rule ids';
  244. ALTER TABLE `alert_cur_event` ADD COLUMN `notify_rule_ids` text COMMENT 'notify rule ids';
  245. /* v8.0.0-beta.13 */
  246. -- 删除 builtin_metrics 表的 idx_collector_typ_name 唯一索引
  247. DROP INDEX IF EXISTS `idx_collector_typ_name` ON `builtin_metrics`;