dolphinscheduler_ddl.sql 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
  18. -- uc_dolphin_T_t_ds_user_A_state
  19. drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_user_A_state;
  20. delimiter d//
  21. CREATE PROCEDURE uc_dolphin_T_t_ds_user_A_state()
  22. BEGIN
  23. IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
  24. WHERE TABLE_NAME='t_ds_user'
  25. AND TABLE_SCHEMA=(SELECT DATABASE())
  26. AND COLUMN_NAME ='state')
  27. THEN
  28. ALTER TABLE t_ds_user ADD `state` int(1) DEFAULT 1 COMMENT 'state 0:disable 1:enable';
  29. END IF;
  30. END;
  31. d//
  32. delimiter ;
  33. CALL uc_dolphin_T_t_ds_user_A_state;
  34. DROP PROCEDURE uc_dolphin_T_t_ds_user_A_state;
  35. -- uc_dolphin_T_t_ds_tenant_A_tenant_name
  36. drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_tenant_A_tenant_name;
  37. delimiter d//
  38. CREATE PROCEDURE uc_dolphin_T_t_ds_tenant_A_tenant_name()
  39. BEGIN
  40. IF EXISTS (SELECT 1 FROM information_schema.COLUMNS
  41. WHERE TABLE_NAME='t_ds_tenant'
  42. AND TABLE_SCHEMA=(SELECT DATABASE())
  43. AND COLUMN_NAME ='tenant_name')
  44. THEN
  45. ALTER TABLE t_ds_tenant DROP `tenant_name`;
  46. END IF;
  47. END;
  48. d//
  49. delimiter ;
  50. CALL uc_dolphin_T_t_ds_tenant_A_tenant_name;
  51. DROP PROCEDURE uc_dolphin_T_t_ds_tenant_A_tenant_name;
  52. -- uc_dolphin_T_t_ds_task_instance_A_first_submit_time
  53. drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_task_instance_A_first_submit_time;
  54. delimiter d//
  55. CREATE PROCEDURE uc_dolphin_T_t_ds_task_instance_A_first_submit_time()
  56. BEGIN
  57. IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
  58. WHERE TABLE_NAME='t_ds_task_instance'
  59. AND TABLE_SCHEMA=(SELECT DATABASE())
  60. AND COLUMN_NAME ='first_submit_time')
  61. THEN
  62. ALTER TABLE t_ds_task_instance ADD `first_submit_time` datetime DEFAULT NULL COMMENT 'task first submit time';
  63. END IF;
  64. END;
  65. d//
  66. delimiter ;
  67. CALL uc_dolphin_T_t_ds_task_instance_A_first_submit_time();
  68. DROP PROCEDURE uc_dolphin_T_t_ds_task_instance_A_first_submit_time;
  69. -- uc_dolphin_T_t_ds_task_instance_A_delay_time
  70. drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_task_instance_A_delay_time;
  71. delimiter d//
  72. CREATE PROCEDURE uc_dolphin_T_t_ds_task_instance_A_delay_time()
  73. BEGIN
  74. IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
  75. WHERE TABLE_NAME='t_ds_task_instance'
  76. AND TABLE_SCHEMA=(SELECT DATABASE())
  77. AND COLUMN_NAME ='delay_time')
  78. THEN
  79. ALTER TABLE t_ds_task_instance ADD `delay_time` int(4) DEFAULT '0' COMMENT 'task delay execution time';
  80. END IF;
  81. END;
  82. d//
  83. delimiter ;
  84. CALL uc_dolphin_T_t_ds_task_instance_A_delay_time();
  85. DROP PROCEDURE uc_dolphin_T_t_ds_task_instance_A_delay_time;
  86. -- uc_dolphin_T_t_ds_task_instance_A_var_pool
  87. drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_task_instance_A_var_pool;
  88. delimiter d//
  89. CREATE PROCEDURE uc_dolphin_T_t_ds_task_instance_A_var_pool()
  90. BEGIN
  91. IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
  92. WHERE TABLE_NAME='t_ds_task_instance'
  93. AND TABLE_SCHEMA=(SELECT DATABASE())
  94. AND COLUMN_NAME ='var_pool')
  95. THEN
  96. ALTER TABLE t_ds_task_instance ADD `var_pool` longtext NULL;
  97. END IF;
  98. END;
  99. d//
  100. delimiter ;
  101. CALL uc_dolphin_T_t_ds_task_instance_A_var_pool();
  102. DROP PROCEDURE uc_dolphin_T_t_ds_task_instance_A_var_pool;
  103. -- uc_dolphin_T_t_ds_task_instance_A_add_task_code
  104. drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_task_instance_A_add_task_code;
  105. delimiter d//
  106. CREATE PROCEDURE uc_dolphin_T_t_ds_task_instance_A_add_task_code()
  107. BEGIN
  108. IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
  109. WHERE TABLE_NAME='t_ds_task_instance'
  110. AND TABLE_SCHEMA=(SELECT DATABASE())
  111. AND COLUMN_NAME ='task_code')
  112. THEN
  113. ALTER TABLE t_ds_task_instance ADD `task_code` bigint(20) NOT NULL COMMENT 'task definition code';
  114. END IF;
  115. END;
  116. d//
  117. delimiter ;
  118. CALL uc_dolphin_T_t_ds_task_instance_A_add_task_code();
  119. DROP PROCEDURE uc_dolphin_T_t_ds_task_instance_A_add_task_code;
  120. -- uc_dolphin_T_t_ds_task_instance_A_add_task_definition_version
  121. drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_task_instance_A_add_task_definition_version;
  122. delimiter d//
  123. CREATE PROCEDURE uc_dolphin_T_t_ds_task_instance_A_add_task_definition_version()
  124. BEGIN
  125. IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
  126. WHERE TABLE_NAME='t_ds_task_instance'
  127. AND TABLE_SCHEMA=(SELECT DATABASE())
  128. AND COLUMN_NAME ='task_definition_version')
  129. THEN
  130. ALTER TABLE t_ds_task_instance ADD `task_definition_version` int(11) DEFAULT NULL COMMENT 'task definition version';
  131. END IF;
  132. END;
  133. d//
  134. delimiter ;
  135. CALL uc_dolphin_T_t_ds_task_instance_A_add_task_definition_version();
  136. DROP PROCEDURE uc_dolphin_T_t_ds_task_instance_A_add_task_definition_version;
  137. -- uc_dolphin_T_t_ds_task_instance_A_add_task_params
  138. drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_task_instance_A_add_task_params;
  139. delimiter d//
  140. CREATE PROCEDURE uc_dolphin_T_t_ds_task_instance_A_add_task_params()
  141. BEGIN
  142. IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
  143. WHERE TABLE_NAME='t_ds_task_instance'
  144. AND TABLE_SCHEMA=(SELECT DATABASE())
  145. AND COLUMN_NAME ='task_params')
  146. THEN
  147. ALTER TABLE t_ds_task_instance ADD `task_params` text COMMENT 'job custom parameters';
  148. END IF;
  149. END;
  150. d//
  151. delimiter ;
  152. CALL uc_dolphin_T_t_ds_task_instance_A_add_task_params();
  153. DROP PROCEDURE uc_dolphin_T_t_ds_task_instance_A_add_task_params;
  154. -- uc_dolphin_T_t_ds_process_instance_A_process_definition_version
  155. drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_process_instance_A_process_definition_version;
  156. delimiter d//
  157. CREATE PROCEDURE uc_dolphin_T_t_ds_process_instance_A_process_definition_version()
  158. BEGIN
  159. IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
  160. WHERE TABLE_NAME='t_ds_process_instance'
  161. AND TABLE_SCHEMA=(SELECT DATABASE())
  162. AND COLUMN_NAME ='process_definition_version')
  163. THEN
  164. ALTER TABLE t_ds_process_instance ADD `process_definition_version` int(11) DEFAULT NULL COMMENT 'process definition version';
  165. END IF;
  166. END;
  167. d//
  168. delimiter ;
  169. CALL uc_dolphin_T_t_ds_process_instance_A_process_definition_version();
  170. DROP PROCEDURE uc_dolphin_T_t_ds_process_instance_A_process_definition_version;
  171. -- uc_dolphin_T_t_ds_process_instance_A_process_definition_code
  172. drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_process_instance_A_process_definition_code;
  173. delimiter d//
  174. CREATE PROCEDURE uc_dolphin_T_t_ds_process_instance_A_process_definition_code()
  175. BEGIN
  176. IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
  177. WHERE TABLE_NAME='t_ds_process_instance'
  178. AND TABLE_SCHEMA=(SELECT DATABASE())
  179. AND COLUMN_NAME ='process_definition_code')
  180. THEN
  181. ALTER TABLE t_ds_process_instance ADD `process_definition_code` bigint(20) not NULL COMMENT 'process definition code';
  182. END IF;
  183. END;
  184. d//
  185. delimiter ;
  186. CALL uc_dolphin_T_t_ds_process_instance_A_process_definition_code();
  187. DROP PROCEDURE uc_dolphin_T_t_ds_process_instance_A_process_definition_code;
  188. -- uc_dolphin_T_t_ds_process_instance_A_var_pool
  189. drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_process_instance_A_var_pool;
  190. delimiter d//
  191. CREATE PROCEDURE uc_dolphin_T_t_ds_process_instance_A_var_pool()
  192. BEGIN
  193. IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
  194. WHERE TABLE_NAME='t_ds_process_instance'
  195. AND TABLE_SCHEMA=(SELECT DATABASE())
  196. AND COLUMN_NAME ='var_pool')
  197. THEN
  198. ALTER TABLE t_ds_process_instance ADD `var_pool` longtext NULL;
  199. END IF;
  200. END;
  201. d//
  202. delimiter ;
  203. CALL uc_dolphin_T_t_ds_process_instance_A_var_pool();
  204. DROP PROCEDURE uc_dolphin_T_t_ds_process_instance_A_var_pool;
  205. -- uc_dolphin_T_t_ds_process_definition_A_modify_by
  206. drop PROCEDURE if EXISTS ct_dolphin_T_t_ds_process_definition_version;
  207. delimiter d//
  208. CREATE PROCEDURE ct_dolphin_T_t_ds_process_definition_version()
  209. BEGIN
  210. CREATE TABLE IF NOT EXISTS `t_ds_process_definition_version` (
  211. `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'key',
  212. `process_definition_id` int(11) NOT NULL COMMENT 'process definition id',
  213. `version` int(11) DEFAULT NULL COMMENT 'process definition version',
  214. `process_definition_json` longtext COMMENT 'process definition json content',
  215. `description` text,
  216. `global_params` text COMMENT 'global parameters',
  217. `locations` text COMMENT 'Node location information',
  218. `connects` text COMMENT 'Node connection information',
  219. `receivers` text COMMENT 'receivers',
  220. `receivers_cc` text COMMENT 'cc',
  221. `create_time` datetime DEFAULT NULL COMMENT 'create time',
  222. `timeout` int(11) DEFAULT '0' COMMENT 'time out',
  223. `resource_ids` varchar(255) DEFAULT NULL COMMENT 'resource ids',
  224. PRIMARY KEY (`id`),
  225. UNIQUE KEY `process_definition_id_and_version` (`process_definition_id`,`version`) USING BTREE,
  226. KEY `process_definition_index` (`id`) USING BTREE
  227. ) ENGINE=InnoDB AUTO_INCREMENT=84 DEFAULT CHARSET=utf8;
  228. END;
  229. d//
  230. delimiter ;
  231. CALL ct_dolphin_T_t_ds_process_definition_version;
  232. DROP PROCEDURE ct_dolphin_T_t_ds_process_definition_version;
  233. -- uc_dolphin_T_t_ds_project_instance_A_add_code
  234. drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_project_instance_A_add_code;
  235. delimiter d//
  236. CREATE PROCEDURE uc_dolphin_T_t_ds_project_instance_A_add_code()
  237. BEGIN
  238. IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
  239. WHERE TABLE_NAME='t_ds_project'
  240. AND TABLE_SCHEMA=(SELECT DATABASE())
  241. AND COLUMN_NAME ='code')
  242. THEN
  243. ALTER TABLE t_ds_project ADD `code` bigint(20) NOT NULL COMMENT 'encoding';
  244. END IF;
  245. END;
  246. d//
  247. delimiter ;
  248. CALL uc_dolphin_T_t_ds_project_instance_A_add_code();
  249. DROP PROCEDURE uc_dolphin_T_t_ds_project_instance_A_add_code;
  250. -- uc_dolphin_T_t_ds_process_definition_A_add_code
  251. drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_process_definition_A_add_code;
  252. delimiter d//
  253. CREATE PROCEDURE uc_dolphin_T_t_ds_process_definition_A_add_code()
  254. BEGIN
  255. IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
  256. WHERE TABLE_NAME='t_ds_process_definition'
  257. AND TABLE_SCHEMA=(SELECT DATABASE())
  258. AND COLUMN_NAME ='code')
  259. THEN
  260. ALTER TABLE t_ds_process_definition ADD `code` bigint(20) NOT NULL COMMENT 'encoding';
  261. ALTER TABLE t_ds_process_definition ADD UNIQUE KEY `code_unique` (`code`);
  262. END IF;
  263. END;
  264. d//
  265. delimiter ;
  266. CALL uc_dolphin_T_t_ds_process_definition_A_add_code();
  267. DROP PROCEDURE uc_dolphin_T_t_ds_process_definition_A_add_code;
  268. -- uc_dolphin_T_t_ds_process_definition_A_add_project_code
  269. drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_process_definition_A_add_project_code;
  270. delimiter d//
  271. CREATE PROCEDURE uc_dolphin_T_t_ds_process_definition_A_add_project_code()
  272. BEGIN
  273. IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
  274. WHERE TABLE_NAME='t_ds_process_definition'
  275. AND TABLE_SCHEMA=(SELECT DATABASE())
  276. AND COLUMN_NAME ='project_code')
  277. THEN
  278. ALTER TABLE t_ds_process_definition ADD `project_code` bigint(20) NOT NULL COMMENT 'project code';
  279. ALTER TABLE t_ds_process_definition DROP INDEX `process_definition_unique`, ADD UNIQUE KEY `process_unique` (`name`,`project_code`) USING BTREE;
  280. ALTER TABLE t_ds_process_definition DROP `project_id`, DROP `process_definition_json`, DROP `receivers`, DROP `receivers_cc`, DROP `modify_by`, DROP `resource_ids`;
  281. END IF;
  282. END;
  283. d//
  284. delimiter ;
  285. CALL uc_dolphin_T_t_ds_process_definition_A_add_project_code();
  286. DROP PROCEDURE uc_dolphin_T_t_ds_process_definition_A_add_project_code;
  287. -- ----------------------------
  288. -- Table structure for t_ds_task_definition
  289. -- ----------------------------
  290. DROP TABLE IF EXISTS `t_ds_task_definition`;
  291. CREATE TABLE `t_ds_task_definition` (
  292. `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'self-increasing id',
  293. `code` bigint(20) NOT NULL COMMENT 'encoding',
  294. `name` varchar(200) DEFAULT NULL COMMENT 'task definition name',
  295. `version` int(11) DEFAULT NULL COMMENT 'task definition version',
  296. `description` text COMMENT 'description',
  297. `project_code` bigint(20) NOT NULL COMMENT 'project code',
  298. `user_id` int(11) DEFAULT NULL COMMENT 'task definition creator id',
  299. `task_type` varchar(50) NOT NULL COMMENT 'task type',
  300. `task_params` longtext COMMENT 'job custom parameters',
  301. `flag` tinyint(2) DEFAULT NULL COMMENT '0 not available, 1 available',
  302. `task_priority` tinyint(4) DEFAULT NULL COMMENT 'job priority',
  303. `worker_group` varchar(200) DEFAULT NULL COMMENT 'worker grouping',
  304. `fail_retry_times` int(11) DEFAULT NULL COMMENT 'number of failed retries',
  305. `fail_retry_interval` int(11) DEFAULT NULL COMMENT 'failed retry interval',
  306. `timeout_flag` tinyint(2) DEFAULT '0' COMMENT 'timeout flag:0 close, 1 open',
  307. `timeout_notify_strategy` tinyint(4) DEFAULT NULL COMMENT 'timeout notification policy: 0 warning, 1 fail',
  308. `timeout` int(11) DEFAULT '0' COMMENT 'timeout length,unit: minute',
  309. `delay_time` int(11) DEFAULT '0' COMMENT 'delay execution time,unit: minute',
  310. `resource_ids` varchar(255) DEFAULT NULL COMMENT 'resource id, separated by comma',
  311. `create_time` datetime NOT NULL COMMENT 'create time',
  312. `update_time` datetime DEFAULT NULL COMMENT 'update time',
  313. PRIMARY KEY (`id`,`code`),
  314. UNIQUE KEY `task_unique` (`name`,`project_code`) USING BTREE
  315. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
  316. create index task_definition_index on t_ds_task_definition (project_code,id);
  317. -- ----------------------------
  318. -- Table structure for t_ds_task_definition_log
  319. -- ----------------------------
  320. DROP TABLE IF EXISTS `t_ds_task_definition_log`;
  321. CREATE TABLE `t_ds_task_definition_log` (
  322. `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'self-increasing id',
  323. `code` bigint(20) NOT NULL COMMENT 'encoding',
  324. `name` varchar(200) DEFAULT NULL COMMENT 'task definition name',
  325. `version` int(11) DEFAULT NULL COMMENT 'task definition version',
  326. `description` text COMMENT 'description',
  327. `project_code` bigint(20) NOT NULL COMMENT 'project code',
  328. `user_id` int(11) DEFAULT NULL COMMENT 'task definition creator id',
  329. `task_type` varchar(50) NOT NULL COMMENT 'task type',
  330. `task_params` text COMMENT 'job custom parameters',
  331. `flag` tinyint(2) DEFAULT NULL COMMENT '0 not available, 1 available',
  332. `task_priority` tinyint(4) DEFAULT NULL COMMENT 'job priority',
  333. `worker_group` varchar(200) DEFAULT NULL COMMENT 'worker grouping',
  334. `fail_retry_times` int(11) DEFAULT NULL COMMENT 'number of failed retries',
  335. `fail_retry_interval` int(11) DEFAULT NULL COMMENT 'failed retry interval',
  336. `timeout_flag` tinyint(2) DEFAULT '0' COMMENT 'timeout flag:0 close, 1 open',
  337. `timeout_notify_strategy` tinyint(4) DEFAULT NULL COMMENT 'timeout notification policy: 0 warning, 1 fail',
  338. `timeout` int(11) DEFAULT '0' COMMENT 'timeout length,unit: minute',
  339. `delay_time` int(11) DEFAULT '0' COMMENT 'delay execution time,unit: minute',
  340. `resource_ids` varchar(255) DEFAULT NULL COMMENT 'resource id, separated by comma',
  341. `operator` int(11) DEFAULT NULL COMMENT 'operator user id',
  342. `operate_time` datetime DEFAULT NULL COMMENT 'operate time',
  343. `create_time` datetime NOT NULL COMMENT 'create time',
  344. `update_time` datetime DEFAULT NULL COMMENT 'update time',
  345. PRIMARY KEY (`id`)
  346. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
  347. -- ----------------------------
  348. -- Table structure for t_ds_process_task_relation
  349. -- ----------------------------
  350. DROP TABLE IF EXISTS `t_ds_process_task_relation`;
  351. CREATE TABLE `t_ds_process_task_relation` (
  352. `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'self-increasing id',
  353. `name` varchar(200) DEFAULT NULL COMMENT 'relation name',
  354. `process_definition_version` int(11) DEFAULT NULL COMMENT 'process version',
  355. `project_code` bigint(20) NOT NULL COMMENT 'project code',
  356. `process_definition_code` bigint(20) NOT NULL COMMENT 'process code',
  357. `pre_task_code` bigint(20) NOT NULL COMMENT 'pre task code',
  358. `pre_task_version` int(11) NOT NULL COMMENT 'pre task version',
  359. `post_task_code` bigint(20) NOT NULL COMMENT 'post task code',
  360. `post_task_version` int(11) NOT NULL COMMENT 'post task version',
  361. `condition_type` tinyint(2) DEFAULT NULL COMMENT 'condition type : 0 none, 1 judge 2 delay',
  362. `condition_params` text COMMENT 'condition params(json)',
  363. `create_time` datetime NOT NULL COMMENT 'create time',
  364. `update_time` datetime DEFAULT NULL COMMENT 'update time',
  365. PRIMARY KEY (`id`)
  366. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
  367. -- ----------------------------
  368. -- Table structure for t_ds_process_definition_log
  369. -- ----------------------------
  370. DROP TABLE IF EXISTS `t_ds_process_definition_log`;
  371. CREATE TABLE `t_ds_process_definition_log` (
  372. `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'self-increasing id',
  373. `code` bigint(20) NOT NULL COMMENT 'encoding',
  374. `name` varchar(200) DEFAULT NULL COMMENT 'process definition name',
  375. `version` int(11) DEFAULT NULL COMMENT 'process definition version',
  376. `description` text COMMENT 'description',
  377. `project_code` bigint(20) NOT NULL COMMENT 'project code',
  378. `release_state` tinyint(4) DEFAULT NULL COMMENT 'process definition release state:0:offline,1:online',
  379. `user_id` int(11) DEFAULT NULL COMMENT 'process definition creator id',
  380. `global_params` text COMMENT 'global parameters',
  381. `flag` tinyint(4) DEFAULT NULL COMMENT '0 not available, 1 available',
  382. `locations` text COMMENT 'Node location information',
  383. `connects` text COMMENT 'Node connection information',
  384. `warning_group_id` int(11) DEFAULT NULL COMMENT 'alert group id',
  385. `timeout` int(11) DEFAULT '0' COMMENT 'time out,unit: minute',
  386. `tenant_id` int(11) NOT NULL DEFAULT '-1' COMMENT 'tenant id',
  387. `operator` int(11) DEFAULT NULL COMMENT 'operator user id',
  388. `operate_time` datetime DEFAULT NULL COMMENT 'operate time',
  389. `create_time` datetime NOT NULL COMMENT 'create time',
  390. `update_time` datetime DEFAULT NULL COMMENT 'update time',
  391. PRIMARY KEY (`id`)
  392. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
  393. -- ----------------------------
  394. -- Table structure for t_ds_process_task_relation_log
  395. -- ----------------------------
  396. DROP TABLE IF EXISTS `t_ds_process_task_relation_log`;
  397. CREATE TABLE `t_ds_process_task_relation_log` (
  398. `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'self-increasing id',
  399. `name` varchar(200) DEFAULT NULL COMMENT 'relation name',
  400. `process_definition_version` int(11) DEFAULT NULL COMMENT 'process version',
  401. `project_code` bigint(20) NOT NULL COMMENT 'project code',
  402. `process_definition_code` bigint(20) NOT NULL COMMENT 'process code',
  403. `pre_task_code` bigint(20) NOT NULL COMMENT 'pre task code',
  404. `pre_task_version` int(11) NOT NULL COMMENT 'pre task version',
  405. `post_task_code` bigint(20) NOT NULL COMMENT 'post task code',
  406. `post_task_version` int(11) NOT NULL COMMENT 'post task version',
  407. `condition_type` tinyint(2) DEFAULT NULL COMMENT 'condition type : 0 none, 1 judge 2 delay',
  408. `condition_params` text COMMENT 'condition params(json)',
  409. `operator` int(11) DEFAULT NULL COMMENT 'operator user id',
  410. `operate_time` datetime DEFAULT NULL COMMENT 'operate time',
  411. `create_time` datetime NOT NULL COMMENT 'create time',
  412. `update_time` datetime DEFAULT NULL COMMENT 'update time',
  413. PRIMARY KEY (`id`)
  414. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
  415. -- ----------------------------
  416. -- Table structure for t_ds_plugin_define
  417. -- ----------------------------
  418. DROP TABLE IF EXISTS `t_ds_plugin_define`;
  419. CREATE TABLE `t_ds_plugin_define` (
  420. `id` int NOT NULL AUTO_INCREMENT,
  421. `plugin_name` varchar(100) NOT NULL COMMENT 'the name of plugin eg: email',
  422. `plugin_type` varchar(100) NOT NULL COMMENT 'plugin type . alert=alert plugin, job=job plugin',
  423. `plugin_params` text COMMENT 'plugin params',
  424. `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  425. `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  426. PRIMARY KEY (`id`),
  427. UNIQUE KEY `t_ds_plugin_define_UN` (`plugin_name`,`plugin_type`)
  428. ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
  429. -- ----------------------------
  430. -- Table structure for t_ds_alert_plugin_instance
  431. -- ----------------------------
  432. DROP TABLE IF EXISTS `t_ds_alert_plugin_instance`;
  433. CREATE TABLE `t_ds_alert_plugin_instance` (
  434. `id` int NOT NULL AUTO_INCREMENT,
  435. `plugin_define_id` int NOT NULL,
  436. `plugin_instance_params` text COMMENT 'plugin instance params. Also contain the params value which user input in web ui.',
  437. `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  438. `update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  439. `instance_name` varchar(200) DEFAULT NULL COMMENT 'alert instance name',
  440. PRIMARY KEY (`id`)
  441. ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  442. -- uc_dolphin_T_t_ds_process_definition_A_warning_group_id
  443. drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_process_definition_A_warning_group_id;
  444. delimiter d//
  445. CREATE PROCEDURE uc_dolphin_T_t_ds_process_definition_A_warning_group_id()
  446. BEGIN
  447. IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
  448. WHERE TABLE_NAME='t_ds_process_definition'
  449. AND TABLE_SCHEMA=(SELECT DATABASE())
  450. AND COLUMN_NAME ='warning_group_id')
  451. THEN
  452. ALTER TABLE t_ds_process_definition ADD COLUMN `warning_group_id` int(11) DEFAULT NULL COMMENT 'alert group id' AFTER `connects`;
  453. END IF;
  454. END;
  455. d//
  456. delimiter ;
  457. CALL uc_dolphin_T_t_ds_process_definition_A_warning_group_id();
  458. DROP PROCEDURE uc_dolphin_T_t_ds_process_definition_A_warning_group_id;
  459. -- uc_dolphin_T_t_ds_process_definition_version_A_warning_group_id
  460. drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_process_definition_version_A_warning_group_id;
  461. delimiter d//
  462. CREATE PROCEDURE uc_dolphin_T_t_ds_process_definition_version_A_warning_group_id()
  463. BEGIN
  464. IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
  465. WHERE TABLE_NAME='t_ds_process_definition_version'
  466. AND TABLE_SCHEMA=(SELECT DATABASE())
  467. AND COLUMN_NAME ='warning_group_id')
  468. THEN
  469. ALTER TABLE t_ds_process_definition_version ADD COLUMN `warning_group_id` int(11) DEFAULT NULL COMMENT 'alert group id' AFTER `connects`;
  470. END IF;
  471. END;
  472. d//
  473. delimiter ;
  474. CALL uc_dolphin_T_t_ds_process_definition_version_A_warning_group_id();
  475. DROP PROCEDURE uc_dolphin_T_t_ds_process_definition_version_A_warning_group_id;
  476. -- uc_dolphin_T_t_ds_alertgroup_A_alert_instance_ids
  477. drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_alertgroup_A_alert_instance_ids;
  478. delimiter d//
  479. CREATE PROCEDURE uc_dolphin_T_t_ds_alertgroup_A_alert_instance_ids()
  480. BEGIN
  481. IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
  482. WHERE TABLE_NAME='t_ds_alertgroup'
  483. AND TABLE_SCHEMA=(SELECT DATABASE())
  484. AND COLUMN_NAME ='alert_instance_ids')
  485. THEN
  486. ALTER TABLE t_ds_alertgroup ADD COLUMN `alert_instance_ids` varchar (255) DEFAULT NULL COMMENT 'alert instance ids' AFTER `id`;
  487. END IF;
  488. END;
  489. d//
  490. delimiter ;
  491. CALL uc_dolphin_T_t_ds_alertgroup_A_alert_instance_ids();
  492. DROP PROCEDURE uc_dolphin_T_t_ds_alertgroup_A_alert_instance_ids;
  493. -- uc_dolphin_T_t_ds_alertgroup_A_create_user_id
  494. drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_alertgroup_A_create_user_id;
  495. delimiter d//
  496. CREATE PROCEDURE uc_dolphin_T_t_ds_alertgroup_A_create_user_id()
  497. BEGIN
  498. IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
  499. WHERE TABLE_NAME='t_ds_alertgroup'
  500. AND TABLE_SCHEMA=(SELECT DATABASE())
  501. AND COLUMN_NAME ='create_user_id')
  502. THEN
  503. ALTER TABLE t_ds_alertgroup ADD COLUMN `create_user_id` int(11) DEFAULT NULL COMMENT 'create user id' AFTER `alert_instance_ids`;
  504. END IF;
  505. END;
  506. d//
  507. delimiter ;
  508. CALL uc_dolphin_T_t_ds_alertgroup_A_create_user_id();
  509. DROP PROCEDURE uc_dolphin_T_t_ds_alertgroup_A_create_user_id;
  510. -- uc_dolphin_T_t_ds_alertgroup_A_add_UN_groupName
  511. drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_alertgroup_A_add_UN_groupName;
  512. delimiter d//
  513. CREATE PROCEDURE uc_dolphin_T_t_ds_alertgroup_A_add_UN_groupName()
  514. BEGIN
  515. IF NOT EXISTS (SELECT 1 FROM information_schema.STATISTICS
  516. WHERE TABLE_NAME='t_ds_alertgroup'
  517. AND TABLE_SCHEMA=(SELECT DATABASE())
  518. AND INDEX_NAME ='t_ds_alertgroup_name_un')
  519. THEN
  520. ALTER TABLE t_ds_alertgroup ADD UNIQUE KEY `t_ds_alertgroup_name_un` (`group_name`);
  521. END IF;
  522. END;
  523. d//
  524. delimiter ;
  525. CALL uc_dolphin_T_t_ds_alertgroup_A_add_UN_groupName();
  526. DROP PROCEDURE uc_dolphin_T_t_ds_alertgroup_A_add_UN_groupName;
  527. -- uc_dolphin_T_t_ds_datasource_A_add_UN_datasourceName
  528. drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_datasource_A_add_UN_datasourceName;
  529. delimiter d//
  530. CREATE PROCEDURE uc_dolphin_T_t_ds_datasource_A_add_UN_datasourceName()
  531. BEGIN
  532. IF NOT EXISTS (SELECT 1 FROM information_schema.STATISTICS
  533. WHERE TABLE_NAME='t_ds_datasource'
  534. AND TABLE_SCHEMA=(SELECT DATABASE())
  535. AND INDEX_NAME ='t_ds_datasource_name_un')
  536. THEN
  537. ALTER TABLE t_ds_datasource ADD UNIQUE KEY `t_ds_datasource_name_un` (`name`, `type`);
  538. END IF;
  539. END;
  540. d//
  541. delimiter ;
  542. CALL uc_dolphin_T_t_ds_datasource_A_add_UN_datasourceName();
  543. DROP PROCEDURE uc_dolphin_T_t_ds_datasource_A_add_UN_datasourceName;
  544. -- uc_dolphin_T_t_ds_schedules_A_add_timezone
  545. drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_schedules_A_add_timezone;
  546. delimiter d//
  547. CREATE PROCEDURE uc_dolphin_T_t_ds_schedules_A_add_timezone()
  548. BEGIN
  549. IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS
  550. WHERE TABLE_NAME='t_ds_schedules'
  551. AND TABLE_SCHEMA=(SELECT DATABASE())
  552. AND COLUMN_NAME ='timezone_id')
  553. THEN
  554. ALTER TABLE t_ds_schedules ADD COLUMN `timezone_id` varchar(40) default NULL COMMENT 'schedule timezone id' AFTER `end_time`;
  555. END IF;
  556. END;
  557. d//
  558. delimiter ;
  559. CALL uc_dolphin_T_t_ds_schedules_A_add_timezone();
  560. DROP PROCEDURE uc_dolphin_T_t_ds_schedules_A_add_timezone;
  561. -- ----------------------------
  562. -- These columns will not be used in the new version,if you determine that the historical data is useless, you can delete it using the sql below
  563. -- ----------------------------
  564. -- ALTER TABLE t_ds_alert DROP `show_type`, DROP `alert_type`, DROP `receivers`, DROP `receivers_cc`;
  565. -- ALTER TABLE t_ds_alertgroup DROP `group_type`;
  566. -- ALTER TABLE t_ds_process_definition DROP `receivers`, DROP `receivers_cc`;
  567. -- ALTER TABLE t_ds_process_definition_version DROP `receivers`, DROP `receivers_cc`;
  568. -- DROP TABLE IF EXISTS t_ds_relation_user_alertgroup;
  569. -- ALTER TABLE t_ds_command DROP `dependence`;
  570. -- ALTER TABLE t_ds_error_command DROP `dependence`;