You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by zh...@apache.org on 2022/08/03 06:41:59 UTC

[dolphinscheduler] 01/02: fix: Upgrade database DDL to avoid log path too long error

This is an automated email from the ASF dual-hosted git repository.

zhongjiajie pushed a commit to branch 3.0.0-prepare
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git

commit c31087bd950b54ecf12c077e060e839b0518f14d
Author: Jiajie Zhong <zh...@gmail.com>
AuthorDate: Wed Aug 3 11:29:28 2022 +0800

    fix: Upgrade database DDL to avoid log path too long error
---
 .../src/main/resources/sql/dolphinscheduler_h2.sql     |  2 +-
 .../src/main/resources/sql/dolphinscheduler_mysql.sql  |  2 +-
 .../main/resources/sql/dolphinscheduler_postgresql.sql |  2 +-
 .../3.0.0_schema/mysql/dolphinscheduler_ddl.sql        | 18 ++++++++++++++++++
 .../3.0.0_schema/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;