From c5bea3c77430e0b46a2f5a3a91a7fbbc78874196 Mon Sep 17 00:00:00 2001 From: kyoty Date: Tue, 15 Jun 2021 14:45:39 +0800 Subject: [PATCH] [Fix-5540][JSON Split] Fix some new tables and fields are missing in the sql upgrade script (#5611) * Update dolphinscheduler_ddl.sql * Update dolphinscheduler_ddl.sql * Update dolphinscheduler_ddl.sql * Update dolphinscheduler_ddl.sql * Update dolphinscheduler_ddl.sql * Update dolphinscheduler_ddl.sql * Update dolphinscheduler_ddl.sql * Update dolphinscheduler_ddl.sql * Create dolphinscheduler_ddl.sql * Update dolphinscheduler_postgre.sql * Update dolphinscheduler_ddl.sql * Update dolphinscheduler_ddl.sql * Update dolphinscheduler_ddl.sql * Create dolphinscheduler_ddl.sql * Update dolphinscheduler_mysql.sql * Update dolphinscheduler_postgre.sql * Update dolphinscheduler_ddl.sql * Update dolphinscheduler_ddl.sql * Update dolphinscheduler_postgre.sql --- sql/dolphinscheduler_mysql.sql | 5 +- sql/dolphinscheduler_postgre.sql | 3 +- .../mysql/dolphinscheduler_ddl.sql | 296 +++++++++++++++ .../postgresql/dolphinscheduler_ddl.sql | 339 +++++++++++++++++- 4 files changed, 639 insertions(+), 4 deletions(-) diff --git a/sql/dolphinscheduler_mysql.sql b/sql/dolphinscheduler_mysql.sql index 5f2814c600..55dcf1c8fe 100644 --- a/sql/dolphinscheduler_mysql.sql +++ b/sql/dolphinscheduler_mysql.sql @@ -408,8 +408,9 @@ CREATE TABLE `t_ds_process_definition` ( `tenant_id` int(11) NOT NULL DEFAULT '-1' COMMENT 'tenant id', `create_time` datetime NOT NULL COMMENT 'create time', `update_time` datetime DEFAULT NULL COMMENT 'update time', - PRIMARY KEY (`id`,`code`), - UNIQUE KEY `process_unique` (`name`,`project_code`) USING BTREE + PRIMARY KEY (`id`), + UNIQUE KEY `process_unique` (`name`,`project_code`) USING BTREE, + UNIQUE KEY `code_unique` (`code`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; -- ---------------------------- diff --git a/sql/dolphinscheduler_postgre.sql b/sql/dolphinscheduler_postgre.sql index 3393938c83..cd5dce969c 100644 --- a/sql/dolphinscheduler_postgre.sql +++ b/sql/dolphinscheduler_postgre.sql @@ -304,7 +304,8 @@ CREATE TABLE t_ds_process_definition ( create_time timestamp DEFAULT NULL , update_time timestamp DEFAULT NULL , PRIMARY KEY (id) , - CONSTRAINT process_definition_unique UNIQUE (name, project_code) + CONSTRAINT process_definition_unique UNIQUE (name, project_code) , + CONSTRAINT code_unique UNIQUE (code) ) ; create index process_definition_index on t_ds_process_definition (code,id); diff --git a/sql/upgrade/1.4.0_schema/mysql/dolphinscheduler_ddl.sql b/sql/upgrade/1.4.0_schema/mysql/dolphinscheduler_ddl.sql index 5071d148b7..eccd683bfa 100644 --- a/sql/upgrade/1.4.0_schema/mysql/dolphinscheduler_ddl.sql +++ b/sql/upgrade/1.4.0_schema/mysql/dolphinscheduler_ddl.sql @@ -117,6 +117,106 @@ delimiter ; CALL uc_dolphin_T_t_ds_task_instance_A_var_pool(); DROP PROCEDURE uc_dolphin_T_t_ds_task_instance_A_var_pool; +-- uc_dolphin_T_t_ds_task_instance_A_add_task_code +drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_task_instance_A_add_task_code; +delimiter d// +CREATE PROCEDURE uc_dolphin_T_t_ds_task_instance_A_add_task_code() + BEGIN + IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS + WHERE TABLE_NAME='t_ds_task_instance' + AND TABLE_SCHEMA=(SELECT DATABASE()) + AND COLUMN_NAME ='task_code') + THEN + ALTER TABLE t_ds_task_instance ADD `task_code` bigint(20) NOT NULL COMMENT 'task definition code'; + END IF; + END; + +d// + +delimiter ; +CALL uc_dolphin_T_t_ds_task_instance_A_add_task_code(); +DROP PROCEDURE uc_dolphin_T_t_ds_task_instance_A_add_task_code; + +-- uc_dolphin_T_t_ds_task_instance_A_add_task_definition_version +drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_task_instance_A_add_task_definition_version; +delimiter d// +CREATE PROCEDURE uc_dolphin_T_t_ds_task_instance_A_add_task_definition_version() + BEGIN + IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS + WHERE TABLE_NAME='t_ds_task_instance' + AND TABLE_SCHEMA=(SELECT DATABASE()) + AND COLUMN_NAME ='task_definition_version') + THEN + ALTER TABLE t_ds_task_instance ADD `task_definition_version` int(11) DEFAULT NULL COMMENT 'task definition version'; + END IF; + END; + +d// + +delimiter ; +CALL uc_dolphin_T_t_ds_task_instance_A_add_task_definition_version(); +DROP PROCEDURE uc_dolphin_T_t_ds_task_instance_A_add_task_definition_version; + +-- uc_dolphin_T_t_ds_task_instance_A_add_task_params +drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_task_instance_A_add_task_params; +delimiter d// +CREATE PROCEDURE uc_dolphin_T_t_ds_task_instance_A_add_task_params() + BEGIN + IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS + WHERE TABLE_NAME='t_ds_task_instance' + AND TABLE_SCHEMA=(SELECT DATABASE()) + AND COLUMN_NAME ='task_params') + THEN + ALTER TABLE t_ds_task_instance ADD `task_params` text COMMENT 'job custom parameters'; + END IF; + END; + +d// + +delimiter ; +CALL uc_dolphin_T_t_ds_task_instance_A_add_task_params(); +DROP PROCEDURE uc_dolphin_T_t_ds_task_instance_A_add_task_params; + +-- uc_dolphin_T_t_ds_process_instance_A_process_definition_version +drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_process_instance_A_process_definition_version; +delimiter d// +CREATE PROCEDURE uc_dolphin_T_t_ds_process_instance_A_process_definition_version() + BEGIN + IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS + WHERE TABLE_NAME='t_ds_process_instance' + AND TABLE_SCHEMA=(SELECT DATABASE()) + AND COLUMN_NAME ='process_definition_version') + THEN + ALTER TABLE t_ds_process_instance ADD `process_definition_version` int(11) DEFAULT NULL COMMENT 'process definition version'; + END IF; + END; + +d// + +delimiter ; +CALL uc_dolphin_T_t_ds_process_instance_A_process_definition_version(); +DROP PROCEDURE uc_dolphin_T_t_ds_process_instance_A_process_definition_version; + +-- uc_dolphin_T_t_ds_process_instance_A_process_definition_code +drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_process_instance_A_process_definition_code; +delimiter d// +CREATE PROCEDURE uc_dolphin_T_t_ds_process_instance_A_process_definition_code() + BEGIN + IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS + WHERE TABLE_NAME='t_ds_process_instance' + AND TABLE_SCHEMA=(SELECT DATABASE()) + AND COLUMN_NAME ='process_definition_code') + THEN + ALTER TABLE t_ds_process_instance ADD `process_definition_code` bigint(20) not NULL COMMENT 'process definition code'; + END IF; + END; + +d// + +delimiter ; +CALL uc_dolphin_T_t_ds_process_instance_A_process_definition_code(); +DROP PROCEDURE uc_dolphin_T_t_ds_process_instance_A_process_definition_code; + -- uc_dolphin_T_t_ds_process_instance_A_var_pool drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_process_instance_A_var_pool; delimiter d// @@ -168,6 +268,202 @@ delimiter ; CALL ct_dolphin_T_t_ds_process_definition_version; DROP PROCEDURE ct_dolphin_T_t_ds_process_definition_version; +-- uc_dolphin_T_t_ds_project_instance_A_add_code +drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_project_instance_A_add_code; +delimiter d// +CREATE PROCEDURE uc_dolphin_T_t_ds_project_instance_A_add_code() + BEGIN + IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS + WHERE TABLE_NAME='t_ds_project' + AND TABLE_SCHEMA=(SELECT DATABASE()) + AND COLUMN_NAME ='code') + THEN + ALTER TABLE t_ds_project ADD `code` bigint(20) NOT NULL COMMENT 'encoding'; + END IF; + END; + +d// + +delimiter ; +CALL uc_dolphin_T_t_ds_project_instance_A_add_code(); +DROP PROCEDURE uc_dolphin_T_t_ds_project_instance_A_add_code; + +-- uc_dolphin_T_t_ds_process_definition_A_add_code +drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_process_definition_A_add_code; +delimiter d// +CREATE PROCEDURE uc_dolphin_T_t_ds_process_definition_A_add_code() + BEGIN + IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS + WHERE TABLE_NAME='t_ds_process_definition' + AND TABLE_SCHEMA=(SELECT DATABASE()) + AND COLUMN_NAME ='code') + THEN + ALTER TABLE t_ds_process_definition ADD `code` bigint(20) NOT NULL COMMENT 'encoding'; + ALTER TABLE t_ds_process_definition ADD UNIQUE KEY `code_unique` (`code`); + END IF; + END; + +d// + +delimiter ; +CALL uc_dolphin_T_t_ds_process_definition_A_add_code(); +DROP PROCEDURE uc_dolphin_T_t_ds_process_definition_A_add_code; + +-- uc_dolphin_T_t_ds_process_definition_A_add_project_code +drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_process_definition_A_add_project_code; +delimiter d// +CREATE PROCEDURE uc_dolphin_T_t_ds_process_definition_A_add_project_code() + BEGIN + IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS + WHERE TABLE_NAME='t_ds_process_definition' + AND TABLE_SCHEMA=(SELECT DATABASE()) + AND COLUMN_NAME ='project_code') + THEN + ALTER TABLE t_ds_process_definition ADD `project_code` bigint(20) NOT NULL COMMENT 'project code'; + ALTER TABLE t_ds_process_definition DROP INDEX `process_definition_unique`, ADD UNIQUE KEY `process_unique` (`name`,`project_code`) USING BTREE; + ALTER TABLE t_ds_process_definition DROP `project_id`, DROP `process_definition_json`, DROP `receivers`, DROP `receivers_cc`, DROP `modify_by`, DROP `resource_ids`; + END IF; + END; + +d// + +delimiter ; +CALL uc_dolphin_T_t_ds_process_definition_A_add_project_code(); +DROP PROCEDURE uc_dolphin_T_t_ds_process_definition_A_add_project_code; + +-- ---------------------------- +-- Table structure for t_ds_task_definition +-- ---------------------------- +DROP TABLE IF EXISTS `t_ds_task_definition`; +CREATE TABLE `t_ds_task_definition` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'self-increasing id', + `code` bigint(20) NOT NULL COMMENT 'encoding', + `name` varchar(200) DEFAULT NULL COMMENT 'task definition name', + `version` int(11) DEFAULT NULL COMMENT 'task definition version', + `description` text COMMENT 'description', + `project_code` bigint(20) NOT NULL COMMENT 'project code', + `user_id` int(11) DEFAULT NULL COMMENT 'task definition creator id', + `task_type` varchar(50) NOT NULL COMMENT 'task type', + `task_params` longtext COMMENT 'job custom parameters', + `flag` tinyint(2) DEFAULT NULL COMMENT '0 not available, 1 available', + `task_priority` tinyint(4) DEFAULT NULL COMMENT 'job priority', + `worker_group` varchar(200) DEFAULT NULL COMMENT 'worker grouping', + `fail_retry_times` int(11) DEFAULT NULL COMMENT 'number of failed retries', + `fail_retry_interval` int(11) DEFAULT NULL COMMENT 'failed retry interval', + `timeout_flag` tinyint(2) DEFAULT '0' COMMENT 'timeout flag:0 close, 1 open', + `timeout_notify_strategy` tinyint(4) DEFAULT NULL COMMENT 'timeout notification policy: 0 warning, 1 fail', + `timeout` int(11) DEFAULT '0' COMMENT 'timeout length,unit: minute', + `delay_time` int(11) DEFAULT '0' COMMENT 'delay execution time,unit: minute', + `resource_ids` varchar(255) DEFAULT NULL COMMENT 'resource id, separated by comma', + `create_time` datetime NOT NULL COMMENT 'create time', + `update_time` datetime DEFAULT NULL COMMENT 'update time', + PRIMARY KEY (`id`,`code`), + UNIQUE KEY `task_unique` (`name`,`project_code`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; +create index task_definition_index on t_ds_task_definition (project_code,id); + +-- ---------------------------- +-- Table structure for t_ds_task_definition_log +-- ---------------------------- +DROP TABLE IF EXISTS `t_ds_task_definition_log`; +CREATE TABLE `t_ds_task_definition_log` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'self-increasing id', + `code` bigint(20) NOT NULL COMMENT 'encoding', + `name` varchar(200) DEFAULT NULL COMMENT 'task definition name', + `version` int(11) DEFAULT NULL COMMENT 'task definition version', + `description` text COMMENT 'description', + `project_code` bigint(20) NOT NULL COMMENT 'project code', + `user_id` int(11) DEFAULT NULL COMMENT 'task definition creator id', + `task_type` varchar(50) NOT NULL COMMENT 'task type', + `task_params` text COMMENT 'job custom parameters', + `flag` tinyint(2) DEFAULT NULL COMMENT '0 not available, 1 available', + `task_priority` tinyint(4) DEFAULT NULL COMMENT 'job priority', + `worker_group` varchar(200) DEFAULT NULL COMMENT 'worker grouping', + `fail_retry_times` int(11) DEFAULT NULL COMMENT 'number of failed retries', + `fail_retry_interval` int(11) DEFAULT NULL COMMENT 'failed retry interval', + `timeout_flag` tinyint(2) DEFAULT '0' COMMENT 'timeout flag:0 close, 1 open', + `timeout_notify_strategy` tinyint(4) DEFAULT NULL COMMENT 'timeout notification policy: 0 warning, 1 fail', + `timeout` int(11) DEFAULT '0' COMMENT 'timeout length,unit: minute', + `delay_time` int(11) DEFAULT '0' COMMENT 'delay execution time,unit: minute', + `resource_ids` varchar(255) DEFAULT NULL COMMENT 'resource id, separated by comma', + `operator` int(11) DEFAULT NULL COMMENT 'operator user id', + `operate_time` datetime DEFAULT NULL COMMENT 'operate time', + `create_time` datetime NOT NULL COMMENT 'create time', + `update_time` datetime DEFAULT NULL COMMENT 'update time', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; + +-- ---------------------------- +-- Table structure for t_ds_process_task_relation +-- ---------------------------- +DROP TABLE IF EXISTS `t_ds_process_task_relation`; +CREATE TABLE `t_ds_process_task_relation` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'self-increasing id', + `name` varchar(200) DEFAULT NULL COMMENT 'relation name', + `process_definition_version` int(11) DEFAULT NULL COMMENT 'process version', + `project_code` bigint(20) NOT NULL COMMENT 'project code', + `process_definition_code` bigint(20) NOT NULL COMMENT 'process code', + `pre_task_code` bigint(20) NOT NULL COMMENT 'pre task code', + `pre_task_version` int(11) NOT NULL COMMENT 'pre task version', + `post_task_code` bigint(20) NOT NULL COMMENT 'post task code', + `post_task_version` int(11) NOT NULL COMMENT 'post task version', + `condition_type` tinyint(2) DEFAULT NULL COMMENT 'condition type : 0 none, 1 judge 2 delay', + `condition_params` text COMMENT 'condition params(json)', + `create_time` datetime NOT NULL COMMENT 'create time', + `update_time` datetime DEFAULT NULL COMMENT 'update time', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; + +-- ---------------------------- +-- Table structure for t_ds_process_definition_log +-- ---------------------------- +DROP TABLE IF EXISTS `t_ds_process_definition_log`; +CREATE TABLE `t_ds_process_definition_log` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'self-increasing id', + `code` bigint(20) NOT NULL COMMENT 'encoding', + `name` varchar(200) DEFAULT NULL COMMENT 'process definition name', + `version` int(11) DEFAULT NULL COMMENT 'process definition version', + `description` text COMMENT 'description', + `project_code` bigint(20) NOT NULL COMMENT 'project code', + `release_state` tinyint(4) DEFAULT NULL COMMENT 'process definition release stateļ¼š0:offline,1:online', + `user_id` int(11) DEFAULT NULL COMMENT 'process definition creator id', + `global_params` text COMMENT 'global parameters', + `flag` tinyint(4) DEFAULT NULL COMMENT '0 not available, 1 available', + `locations` text COMMENT 'Node location information', + `connects` text COMMENT 'Node connection information', + `warning_group_id` int(11) DEFAULT NULL COMMENT 'alert group id', + `timeout` int(11) DEFAULT '0' COMMENT 'time out,unit: minute', + `tenant_id` int(11) NOT NULL DEFAULT '-1' COMMENT 'tenant id', + `operator` int(11) DEFAULT NULL COMMENT 'operator user id', + `operate_time` datetime DEFAULT NULL COMMENT 'operate time', + `create_time` datetime NOT NULL COMMENT 'create time', + `update_time` datetime DEFAULT NULL COMMENT 'update time', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; + +-- ---------------------------- +-- Table structure for t_ds_process_task_relation_log +-- ---------------------------- +DROP TABLE IF EXISTS `t_ds_process_task_relation_log`; +CREATE TABLE `t_ds_process_task_relation_log` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'self-increasing id', + `name` varchar(200) DEFAULT NULL COMMENT 'relation name', + `process_definition_version` int(11) DEFAULT NULL COMMENT 'process version', + `project_code` bigint(20) NOT NULL COMMENT 'project code', + `process_definition_code` bigint(20) NOT NULL COMMENT 'process code', + `pre_task_code` bigint(20) NOT NULL COMMENT 'pre task code', + `pre_task_version` int(11) NOT NULL COMMENT 'pre task version', + `post_task_code` bigint(20) NOT NULL COMMENT 'post task code', + `post_task_version` int(11) NOT NULL COMMENT 'post task version', + `condition_type` tinyint(2) DEFAULT NULL COMMENT 'condition type : 0 none, 1 judge 2 delay', + `condition_params` text COMMENT 'condition params(json)', + `operator` int(11) DEFAULT NULL COMMENT 'operator user id', + `operate_time` datetime DEFAULT NULL COMMENT 'operate time', + `create_time` datetime NOT NULL COMMENT 'create time', + `update_time` datetime DEFAULT NULL COMMENT 'update time', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; + -- ---------------------------- -- Table structure for t_ds_plugin_define -- ---------------------------- diff --git a/sql/upgrade/1.4.0_schema/postgresql/dolphinscheduler_ddl.sql b/sql/upgrade/1.4.0_schema/postgresql/dolphinscheduler_ddl.sql index 21a82b2513..d8d7db3ba6 100644 --- a/sql/upgrade/1.4.0_schema/postgresql/dolphinscheduler_ddl.sql +++ b/sql/upgrade/1.4.0_schema/postgresql/dolphinscheduler_ddl.sql @@ -112,6 +112,96 @@ delimiter ; SELECT uc_dolphin_T_t_ds_task_instance_A_var_pool(); DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_task_instance_A_var_pool(); +-- uc_dolphin_T_t_ds_task_instance_A_task_code +delimiter d// +CREATE OR REPLACE FUNCTION uc_dolphin_T_t_ds_task_instance_A_task_code() RETURNS void AS $$ +BEGIN + IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS + WHERE TABLE_NAME='t_ds_task_instance' + AND COLUMN_NAME ='task_code') + THEN + ALTER TABLE t_ds_task_instance ADD COLUMN task_code bigint NOT NULL; + END IF; +END; +$$ LANGUAGE plpgsql; +d// + +delimiter ; +SELECT uc_dolphin_T_t_ds_task_instance_A_task_code(); +DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_task_instance_A_task_code(); + +-- uc_dolphin_T_t_ds_task_instance_A_task_definition_version +delimiter d// +CREATE OR REPLACE FUNCTION uc_dolphin_T_t_ds_task_instance_A_task_definition_version() RETURNS void AS $$ +BEGIN + IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS + WHERE TABLE_NAME='t_ds_task_instance' + AND COLUMN_NAME ='task_definition_version') + THEN + ALTER TABLE t_ds_task_instance ADD COLUMN task_definition_version int DEFAULT NULL; + END IF; +END; +$$ LANGUAGE plpgsql; +d// + +delimiter ; +SELECT uc_dolphin_T_t_ds_task_instance_A_task_definition_version(); +DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_task_instance_A_task_definition_version(); + +-- uc_dolphin_T_t_ds_task_instance_A_task_params +delimiter d// +CREATE OR REPLACE FUNCTION uc_dolphin_T_t_ds_task_instance_A_task_params() RETURNS void AS $$ +BEGIN + IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS + WHERE TABLE_NAME='t_ds_task_instance' + AND COLUMN_NAME ='task_params') + THEN + ALTER TABLE t_ds_task_instance ADD COLUMN task_params text; + END IF; +END; +$$ LANGUAGE plpgsql; +d// + +delimiter ; +SELECT uc_dolphin_T_t_ds_task_instance_A_task_params(); +DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_task_instance_A_task_params(); + +-- uc_dolphin_T_t_ds_process_instance_A_process_definition_code +delimiter d// +CREATE OR REPLACE FUNCTION uc_dolphin_T_t_ds_process_instance_A_process_definition_code() RETURNS void AS $$ +BEGIN + IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS + WHERE TABLE_NAME='t_ds_process_instance' + AND COLUMN_NAME ='process_definition_code') + THEN + ALTER TABLE t_ds_process_instance ADD COLUMN process_definition_code bigint DEFAULT NULL; + END IF; +END; +$$ LANGUAGE plpgsql; +d// + +delimiter ; +SELECT uc_dolphin_T_t_ds_process_instance_A_process_definition_code(); +DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_process_instance_A_process_definition_code(); + +-- uc_dolphin_T_t_ds_process_instance_A_process_definition_version +delimiter d// +CREATE OR REPLACE FUNCTION uc_dolphin_T_t_ds_process_instance_A_process_definition_version() RETURNS void AS $$ +BEGIN + IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS + WHERE TABLE_NAME='t_ds_process_instance' + AND COLUMN_NAME ='process_definition_version') + THEN + ALTER TABLE t_ds_process_instance ADD COLUMN process_definition_version int DEFAULT NULL; + END IF; +END; +$$ LANGUAGE plpgsql; +d// + +delimiter ; +SELECT uc_dolphin_T_t_ds_process_instance_A_process_definition_version(); +DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_process_instance_A_process_definition_version(); + -- uc_dolphin_T_t_ds_process_instance_A_var_pool delimiter d// CREATE OR REPLACE FUNCTION uc_dolphin_T_t_ds_process_instance_A_var_pool() RETURNS void AS $$ @@ -130,6 +220,64 @@ delimiter ; SELECT uc_dolphin_T_t_ds_process_instance_A_var_pool(); DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_process_instance_A_var_pool(); +-- uc_dolphin_T_t_ds_project_A_code +delimiter d// +CREATE OR REPLACE FUNCTION uc_dolphin_T_t_ds_project_A_code() RETURNS void AS $$ +BEGIN + IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS + WHERE TABLE_NAME='t_ds_project' + AND COLUMN_NAME ='code') + THEN + ALTER TABLE t_ds_project ADD COLUMN code bigint NOT NULL; + END IF; +END; +$$ LANGUAGE plpgsql; +d// + +delimiter ; +SELECT uc_dolphin_T_t_ds_project_A_code(); +DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_project_A_code(); + +-- uc_dolphin_T_t_ds_process_definition_A_code +delimiter d// +CREATE OR REPLACE FUNCTION uc_dolphin_T_t_ds_process_definition_A_code() RETURNS void AS $$ +BEGIN + IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS + WHERE TABLE_NAME='t_ds_process_definition' + AND COLUMN_NAME ='code') + THEN + ALTER TABLE t_ds_process_definition ADD COLUMN code bigint NOT NULL; + ALTER TABLE t_ds_process_definition ADD CONSTRAINT code_unique UNIQUE (code); + END IF; +END; +$$ LANGUAGE plpgsql; +d// + +delimiter ; +SELECT uc_dolphin_T_t_ds_process_definition_A_code(); +DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_process_definition_A_code(); + +-- uc_dolphin_T_t_ds_process_definition_A_project_code +delimiter d// +CREATE OR REPLACE FUNCTION uc_dolphin_T_t_ds_process_definition_A_project_code() RETURNS void AS $$ +BEGIN + IF NOT EXISTS (SELECT 1 FROM information_schema.COLUMNS + WHERE TABLE_NAME='t_ds_process_definition' + AND COLUMN_NAME ='project_code') + THEN + ALTER TABLE t_ds_process_definition ADD COLUMN project_code bigint NOT NULL; + ALTER TABLE t_ds_process_definition DROP CONSTRAINT process_definition_unique, ADD CONSTRAINT process_definition_unique UNIQUE (name, project_code); + ALTER TABLE t_ds_process_definition DROP project_id, DROP process_definition_json, DROP receivers, DROP receivers_cc, DROP modify_by, DROP resource_ids; + + END IF; +END; +$$ LANGUAGE plpgsql; +d// + +delimiter ; +SELECT uc_dolphin_T_t_ds_process_definition_A_project_code(); +DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_process_definition_A_project_code(); + -- uc_dolphin_T_t_ds_process_definition_A_modify_by delimiter d// CREATE OR REPLACE FUNCTION ct_dolphin_T_t_ds_process_definition_version() RETURNS void AS $$ @@ -163,6 +311,195 @@ delimiter ; SELECT ct_dolphin_T_t_ds_process_definition_version(); DROP FUNCTION IF EXISTS ct_dolphin_T_t_ds_process_definition_version(); + +-- ct_dolphin_T_t_ds_task_definition +delimiter d// +CREATE OR REPLACE FUNCTION ct_dolphin_T_t_ds_task_definition() RETURNS void AS $$ +BEGIN + CREATE TABLE IF NOT EXISTS t_ds_task_definition ( + id int NOT NULL , + code bigint NOT NULL, + name varchar(255) DEFAULT NULL , + version int DEFAULT NULL , + description text , + project_code bigint DEFAULT NULL , + user_id int DEFAULT NULL , + task_type varchar(50) DEFAULT NULL , + task_params text , + flag int DEFAULT NULL , + task_priority int DEFAULT NULL , + worker_group varchar(255) DEFAULT NULL , + fail_retry_times int DEFAULT NULL , + fail_retry_interval int DEFAULT NULL , + timeout_flag int DEFAULT NULL , + timeout_notify_strategy int DEFAULT NULL , + timeout int DEFAULT '0' , + delay_time int DEFAULT '0' , + resource_ids varchar(255) DEFAULT NULL , + create_time timestamp DEFAULT NULL , + update_time timestamp DEFAULT NULL , + PRIMARY KEY (id) , + CONSTRAINT task_definition_unique UNIQUE (name, project_code) + ) ; + create index task_definition_index on t_ds_task_definition (project_code,id); + DROP SEQUENCE IF EXISTS t_ds_task_definition_id_sequence; + CREATE SEQUENCE t_ds_task_definition_id_sequence; + ALTER TABLE t_ds_task_definition ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_task_definition_id_sequence'); + +END; +$$ LANGUAGE plpgsql; +d// + +delimiter ; +SELECT ct_dolphin_T_t_ds_task_definition(); +DROP FUNCTION IF EXISTS ct_dolphin_T_t_ds_task_definition(); + +-- ct_dolphin_T_t_ds_task_definition_log +delimiter d// +CREATE OR REPLACE FUNCTION ct_dolphin_T_t_ds_task_definition_log() RETURNS void AS $$ +BEGIN + CREATE TABLE IF NOT EXISTS t_ds_task_definition_log ( + id int NOT NULL , + code bigint NOT NULL, + name varchar(255) DEFAULT NULL , + version int DEFAULT NULL , + description text , + project_code bigint DEFAULT NULL , + user_id int DEFAULT NULL , + task_type varchar(50) DEFAULT NULL , + task_params text , + flag int DEFAULT NULL , + task_priority int DEFAULT NULL , + worker_group varchar(255) DEFAULT NULL , + fail_retry_times int DEFAULT NULL , + fail_retry_interval int DEFAULT NULL , + timeout_flag int DEFAULT NULL , + timeout_notify_strategy int DEFAULT NULL , + timeout int DEFAULT '0' , + delay_time int DEFAULT '0' , + resource_ids varchar(255) DEFAULT NULL , + operator int DEFAULT NULL , + operate_time timestamp DEFAULT NULL , + create_time timestamp DEFAULT NULL , + update_time timestamp DEFAULT NULL , + PRIMARY KEY (id) + ) ; + DROP SEQUENCE IF EXISTS t_ds_task_definition_log_id_sequence; + CREATE SEQUENCE t_ds_task_definition_log_id_sequence; + ALTER TABLE t_ds_task_definition_log ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_task_definition_log_id_sequence'); + +END; +$$ LANGUAGE plpgsql; +d// + +delimiter ; +SELECT ct_dolphin_T_t_ds_task_definition_log(); +DROP FUNCTION IF EXISTS ct_dolphin_T_t_ds_task_definition_log(); + +-- ct_dolphin_T_t_ds_process_task_relation +delimiter d// +CREATE OR REPLACE FUNCTION ct_dolphin_T_t_ds_process_task_relation() RETURNS void AS $$ +BEGIN + CREATE TABLE IF NOT EXISTS t_ds_process_task_relation ( + id int NOT NULL , + name varchar(255) DEFAULT NULL , + process_definition_version int DEFAULT NULL , + project_code bigint DEFAULT NULL , + process_definition_code bigint DEFAULT NULL , + pre_task_code bigint DEFAULT NULL , + pre_task_version int DEFAULT '0' , + post_task_code bigint DEFAULT NULL , + post_task_version int DEFAULT '0' , + condition_type int DEFAULT NULL , + condition_params text , + create_time timestamp DEFAULT NULL , + update_time timestamp DEFAULT NULL , + PRIMARY KEY (id) + ) ; + DROP SEQUENCE IF EXISTS t_ds_process_task_relation_id_sequence; + CREATE SEQUENCE t_ds_process_task_relation_id_sequence; + ALTER TABLE t_ds_process_task_relation ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_process_task_relation_id_sequence'); + +END; +$$ LANGUAGE plpgsql; +d// + +delimiter ; +SELECT ct_dolphin_T_t_ds_process_task_relation(); +DROP FUNCTION IF EXISTS ct_dolphin_T_t_ds_process_task_relation(); + +-- ct_dolphin_T_t_ds_process_definition_log +delimiter d// +CREATE OR REPLACE FUNCTION ct_dolphin_T_t_ds_process_definition_log() RETURNS void AS $$ +BEGIN + CREATE TABLE IF NOT EXISTS t_ds_process_definition_log ( + id int NOT NULL , + code bigint NOT NULL, + name varchar(255) DEFAULT NULL , + version int DEFAULT NULL , + description text , + project_code bigint DEFAULT NULL , + release_state int DEFAULT NULL , + user_id int DEFAULT NULL , + global_params text , + locations text , + connects text , + warning_group_id int DEFAULT NULL , + flag int DEFAULT NULL , + timeout int DEFAULT '0' , + tenant_id int DEFAULT '-1' , + operator int DEFAULT NULL , + operate_time timestamp DEFAULT NULL , + create_time timestamp DEFAULT NULL , + update_time timestamp DEFAULT NULL , + PRIMARY KEY (id) + ) ; + DROP SEQUENCE IF EXISTS t_ds_process_definition_log_id_sequence; + CREATE SEQUENCE t_ds_process_definition_log_id_sequence; + ALTER TABLE t_ds_process_definition_log ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_process_definition_log_id_sequence'); + +END; +$$ LANGUAGE plpgsql; +d// + +delimiter ; +SELECT ct_dolphin_T_t_ds_process_definition_log(); +DROP FUNCTION IF EXISTS ct_dolphin_T_t_ds_process_definition_log(); + + +-- ct_dolphin_T_t_ds_process_task_relation_log +delimiter d// +CREATE OR REPLACE FUNCTION ct_dolphin_T_t_ds_process_task_relation_log() RETURNS void AS $$ +BEGIN + CREATE TABLE IF NOT EXISTS t_ds_process_task_relation_log ( + id int NOT NULL , + name varchar(255) DEFAULT NULL , + process_definition_version int DEFAULT NULL , + project_code bigint DEFAULT NULL , + process_definition_code bigint DEFAULT NULL , + pre_task_code bigint DEFAULT NULL , + pre_task_version int DEFAULT '0' , + post_task_code bigint DEFAULT NULL , + post_task_version int DEFAULT '0' , + condition_type int DEFAULT NULL , + condition_params text , + operator int DEFAULT NULL , + operate_time timestamp DEFAULT NULL , + create_time timestamp DEFAULT NULL , + update_time timestamp DEFAULT NULL , + PRIMARY KEY (id) + ) ; + DROP SEQUENCE IF EXISTS t_ds_process_task_relation_log_id_sequence; + CREATE SEQUENCE t_ds_process_task_relation_log_id_sequence; + ALTER TABLE t_ds_process_task_relation_log ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_process_task_relation_log_id_sequence'); +END; +$$ LANGUAGE plpgsql; +d// + +delimiter ; +SELECT ct_dolphin_T_t_ds_process_task_relation_log(); +DROP FUNCTION IF EXISTS ct_dolphin_T_t_ds_process_task_relation_log(); + -- ---------------------------- -- Table structure for t_ds_plugin_define -- ---------------------------- @@ -337,4 +674,4 @@ DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_schedules_A_add_timezone(); -- ALTER TABLE t_ds_command DROP COLUMN "dependence"; --- ALTER TABLE t_ds_error_command DROP COLUMN "dependence"; \ No newline at end of file +-- ALTER TABLE t_ds_error_command DROP COLUMN "dependence";