From c31087bd950b54ecf12c077e060e839b0518f14d Mon Sep 17 00:00:00 2001 From: Jiajie Zhong Date: Wed, 3 Aug 2022 11:29:28 +0800 Subject: [PATCH] fix: Upgrade database DDL to avoid log path too long error --- .../main/resources/sql/dolphinscheduler_h2.sql | 2 +- .../resources/sql/dolphinscheduler_mysql.sql | 2 +- .../sql/dolphinscheduler_postgresql.sql | 2 +- .../mysql/dolphinscheduler_ddl.sql | 18 ++++++++++++++++++ .../postgresql/dolphinscheduler_ddl.sql | 3 +++ 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql index 092a773571..0467b291b3 100644 --- a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql +++ b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql @@ -844,7 +844,7 @@ CREATE TABLE t_ds_task_instance end_time datetime DEFAULT NULL, host varchar(135) DEFAULT NULL, execute_path varchar(200) DEFAULT NULL, - log_path varchar(200) DEFAULT NULL, + log_path longtext DEFAULT NULL, alert_flag tinyint(4) DEFAULT NULL, retry_times int(4) DEFAULT '0', pid int(4) DEFAULT NULL, diff --git a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql index 4df9d79eb4..14dbaa5221 100644 --- a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql +++ b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql @@ -837,7 +837,7 @@ CREATE TABLE `t_ds_task_instance` ( `end_time` datetime DEFAULT NULL COMMENT 'task end time', `host` varchar(135) DEFAULT NULL COMMENT 'host of task running on', `execute_path` varchar(200) DEFAULT NULL COMMENT 'task execute path in the host', - `log_path` varchar(200) DEFAULT NULL COMMENT 'task log path', + `log_path` longtext DEFAULT NULL COMMENT 'task log path', `alert_flag` tinyint(4) DEFAULT NULL COMMENT 'whether alert', `retry_times` int(4) DEFAULT '0' COMMENT 'task retry times', `pid` int(4) DEFAULT NULL COMMENT 'pid of task', diff --git a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql index 9bd84e1e5d..db83a0faf4 100644 --- a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql +++ b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql @@ -742,7 +742,7 @@ CREATE TABLE t_ds_task_instance ( end_time timestamp DEFAULT NULL , host varchar(135) DEFAULT NULL , execute_path varchar(200) DEFAULT NULL , - log_path varchar(200) DEFAULT NULL , + log_path text DEFAULT NULL , alert_flag int DEFAULT NULL , retry_times int DEFAULT '0' , pid int DEFAULT NULL , diff --git a/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.0.0_schema/mysql/dolphinscheduler_ddl.sql b/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.0.0_schema/mysql/dolphinscheduler_ddl.sql index 9a19da50a6..c5b15ec884 100644 --- a/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.0.0_schema/mysql/dolphinscheduler_ddl.sql +++ b/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.0.0_schema/mysql/dolphinscheduler_ddl.sql @@ -477,6 +477,24 @@ delimiter ; CALL add_t_ds_alert_col_project_code; DROP PROCEDURE add_t_ds_alert_col_project_code; +-- t_ds_task_instance +drop PROCEDURE if EXISTS alter_t_ds_task_instance_col_log_path; +delimiter d// +CREATE PROCEDURE alter_t_ds_task_instance_col_log_path() +BEGIN + IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS + WHERE TABLE_NAME='t_ds_task_instance' + AND TABLE_SCHEMA=(SELECT DATABASE()) + AND COLUMN_NAME='log_path') + THEN +ALTER TABLE `t_ds_task_instance` MODIFY COLUMN `log_path` longtext DEFAULT NULL COMMENT 'task log path'; +END IF; +END; +d// +delimiter ; +CALL alter_t_ds_task_instance_col_log_path; +DROP PROCEDURE alter_t_ds_task_instance_col_log_path; + -- -- Table structure for table `t_ds_dq_comparison_type` -- diff --git a/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.0.0_schema/postgresql/dolphinscheduler_ddl.sql b/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.0.0_schema/postgresql/dolphinscheduler_ddl.sql index fa0d864f08..393bda87fc 100644 --- a/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.0.0_schema/postgresql/dolphinscheduler_ddl.sql +++ b/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.0.0_schema/postgresql/dolphinscheduler_ddl.sql @@ -18,6 +18,9 @@ --- Drop table: Some table forget delete in the past, should be delete in version 1.2.0 DROP TABLE IF EXISTS t_ds_worker_server; +--- alter table +ALTER TABLE t_ds_task_instance ALTER COLUMN log_path TYPE text; + --- Add CONSTRAINT key ALTER TABLE t_ds_task_instance DROP CONSTRAINT IF EXISTS foreign_key_instance_id; ALTER TABLE t_ds_task_instance ADD CONSTRAINT foreign_key_instance_id FOREIGN KEY(process_instance_id) REFERENCES t_ds_process_instance(id) ON DELETE CASCADE;