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 11 kB

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