From e20e0660764dd57d22ea9e6499d0412a7d2bd256 Mon Sep 17 00:00:00 2001 From: BaiJv Date: Fri, 26 Jan 2024 20:51:17 +0800 Subject: [PATCH] [Fix] [Bug] Change default version of Workflow/TaskDefinition to `1` (#15498) --- .../src/main/resources/sql/dolphinscheduler_h2.sql | 12 ++++++------ .../main/resources/sql/dolphinscheduler_mysql.sql | 12 ++++++------ .../resources/sql/dolphinscheduler_postgresql.sql | 12 ++++++------ .../2.0.0_schema/mysql/dolphinscheduler_ddl.sql | 2 +- .../2.0.0_schema/postgresql/dolphinscheduler_ddl.sql | 2 +- .../3.2.1_schema/mysql/dolphinscheduler_ddl.sql | 9 ++++++++- .../3.2.1_schema/postgresql/dolphinscheduler_ddl.sql | 9 ++++++++- .../3.3.0_schema/mysql/dolphinscheduler_ddl.sql | 9 ++++++++- .../3.3.0_schema/postgresql/dolphinscheduler_ddl.sql | 9 ++++++++- 9 files changed, 52 insertions(+), 24 deletions(-) diff --git a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql index 4d470f9dfc..c22f12c09a 100644 --- a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql +++ b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql @@ -412,7 +412,7 @@ CREATE TABLE t_ds_process_definition id int(11) NOT NULL AUTO_INCREMENT, code bigint(20) NOT NULL, name varchar(255) DEFAULT NULL, - version int(11) DEFAULT NULL, + version int(11) NOT NULL DEFAULT 1, description text, project_code bigint(20) NOT NULL, release_state tinyint(4) DEFAULT NULL, @@ -443,7 +443,7 @@ CREATE TABLE t_ds_process_definition_log id int(11) NOT NULL AUTO_INCREMENT, code bigint(20) NOT NULL, name varchar(255) DEFAULT NULL, - version int(11) DEFAULT NULL, + version int(11) NOT NULL DEFAULT '1', description text, project_code bigint(20) NOT NULL, release_state tinyint(4) DEFAULT NULL, @@ -471,7 +471,7 @@ CREATE TABLE t_ds_task_definition id int(11) NOT NULL AUTO_INCREMENT, code bigint(20) NOT NULL, name varchar(255) DEFAULT NULL, - version int(11) DEFAULT NULL, + version int(11) NOT NULL DEFAULT '1', description text, project_code bigint(20) NOT NULL, user_id int(11) DEFAULT NULL, @@ -508,7 +508,7 @@ CREATE TABLE t_ds_task_definition_log id int(11) NOT NULL AUTO_INCREMENT, code bigint(20) NOT NULL, name varchar(255) DEFAULT NULL, - version int(11) DEFAULT NULL, + version int(11) NOT NULL DEFAULT '1', description text, project_code bigint(20) NOT NULL, user_id int(11) DEFAULT NULL, @@ -592,7 +592,7 @@ CREATE TABLE t_ds_process_instance ( id int(11) NOT NULL AUTO_INCREMENT, name varchar(255) DEFAULT NULL, - process_definition_version int(11) DEFAULT NULL, + process_definition_version int(11) NOT NULL DEFAULT '1', process_definition_code bigint(20) not NULL, project_code bigint(20) DEFAULT NULL, state tinyint(4) DEFAULT NULL, @@ -901,7 +901,7 @@ CREATE TABLE t_ds_task_instance task_type varchar(50) NOT NULL, task_execute_type int(11) DEFAULT '0', task_code bigint(20) NOT NULL, - task_definition_version int(11) DEFAULT NULL, + task_definition_version int(11) NOT NULL DEFAULT '1', process_instance_id int(11) DEFAULT NULL, process_instance_name varchar(255) DEFAULT NULL, project_code bigint(20) 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 f9ffde83f3..347acb0a64 100644 --- a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql +++ b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql @@ -415,7 +415,7 @@ CREATE TABLE `t_ds_process_definition` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'self-increasing id', `code` bigint(20) NOT NULL COMMENT 'encoding', `name` varchar(255) DEFAULT NULL COMMENT 'process definition name', - `version` int(11) DEFAULT '0' COMMENT 'process definition version', + `version` int(11) NOT NULL DEFAULT '1' 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', @@ -444,7 +444,7 @@ 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(255) DEFAULT NULL COMMENT 'process definition name', - `version` int(11) DEFAULT '0' COMMENT 'process definition version', + `version` int(11) NOT NULL DEFAULT '1' 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', @@ -471,7 +471,7 @@ 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(255) DEFAULT NULL COMMENT 'task definition name', - `version` int(11) DEFAULT '0' COMMENT 'task definition version', + `version` int(11) NOT NULL DEFAULT '1' 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', @@ -507,7 +507,7 @@ 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(255) DEFAULT NULL COMMENT 'task definition name', - `version` int(11) DEFAULT '0' COMMENT 'task definition version', + `version` int(11) NOT NULL DEFAULT '1' 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', @@ -595,7 +595,7 @@ CREATE TABLE `t_ds_process_instance` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'key', `name` varchar(255) DEFAULT NULL COMMENT 'process instance name', `process_definition_code` bigint(20) NOT NULL COMMENT 'process definition code', - `process_definition_version` int(11) DEFAULT '0' COMMENT 'process definition version', + `process_definition_version` int(11) NOT NULL DEFAULT '1' COMMENT 'process definition version', `project_code` bigint(20) DEFAULT NULL COMMENT 'project code', `state` tinyint(4) DEFAULT NULL COMMENT 'process instance Status: 0 commit succeeded, 1 running, 2 prepare to pause, 3 pause, 4 prepare to stop, 5 stop, 6 fail, 7 succeed, 8 need fault tolerance, 9 kill, 10 wait for thread, 11 wait for dependency to complete', `state_history` text DEFAULT NULL COMMENT 'state history desc', @@ -894,7 +894,7 @@ CREATE TABLE `t_ds_task_instance` ( `task_type` varchar(50) NOT NULL COMMENT 'task type', `task_execute_type` int(11) DEFAULT '0' COMMENT 'task execute type: 0-batch, 1-stream', `task_code` bigint(20) NOT NULL COMMENT 'task definition code', - `task_definition_version` int(11) DEFAULT '0' COMMENT 'task definition version', + `task_definition_version` int(11) NOT NULL DEFAULT '1' COMMENT 'task definition version', `process_instance_id` int(11) DEFAULT NULL COMMENT 'process instance id', `process_instance_name` varchar(255) DEFAULT NULL COMMENT 'process instance name', `project_code` bigint(20) DEFAULT NULL COMMENT 'project code', diff --git a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql index d8214c7a1f..66bcb17f38 100644 --- a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql +++ b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql @@ -332,7 +332,7 @@ CREATE TABLE t_ds_process_definition ( id int NOT NULL , code bigint NOT NULL, name varchar(255) DEFAULT NULL , - version int NOT NULL , + version int NOT NULL DEFAULT 1, description text , project_code bigint DEFAULT NULL , release_state int DEFAULT NULL , @@ -360,7 +360,7 @@ CREATE TABLE t_ds_process_definition_log ( id int NOT NULL , code bigint NOT NULL, name varchar(255) DEFAULT NULL , - version int NOT NULL , + version int NOT NULL DEFAULT '1', description text , project_code bigint DEFAULT NULL , release_state int DEFAULT NULL , @@ -389,7 +389,7 @@ CREATE TABLE t_ds_task_definition ( id int NOT NULL , code bigint NOT NULL, name varchar(255) DEFAULT NULL , - version int NOT NULL , + version int NOT NULL DEFAULT '1', description text , project_code bigint DEFAULT NULL , user_id int DEFAULT NULL , @@ -428,7 +428,7 @@ CREATE TABLE t_ds_task_definition_log ( id int NOT NULL , code bigint NOT NULL, name varchar(255) DEFAULT NULL , - version int NOT NULL , + version int NOT NULL DEFAULT '1', description text , project_code bigint DEFAULT NULL , user_id int DEFAULT NULL , @@ -522,7 +522,7 @@ CREATE TABLE t_ds_process_instance ( id int NOT NULL , name varchar(255) DEFAULT NULL , process_definition_code bigint DEFAULT NULL , - process_definition_version int DEFAULT NULL , + process_definition_version int NOT NULL DEFAULT 1 , project_code bigint DEFAULT NULL , state int DEFAULT NULL , state_history text, @@ -795,7 +795,7 @@ CREATE TABLE t_ds_task_instance ( task_type varchar(50) DEFAULT NULL , task_execute_type int DEFAULT '0', task_code bigint NOT NULL, - task_definition_version int DEFAULT NULL , + task_definition_version int NOT NULL DEFAULT '1' , process_instance_id int DEFAULT NULL , process_instance_name varchar(255) DEFAULT NULL, project_code bigint DEFAULT NULL, diff --git a/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/mysql/dolphinscheduler_ddl.sql b/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/mysql/dolphinscheduler_ddl.sql index 65f4dd1fde..8f79cd60bb 100644 --- a/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/mysql/dolphinscheduler_ddl.sql +++ b/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/mysql/dolphinscheduler_ddl.sql @@ -415,7 +415,7 @@ alter table t_ds_process_instance drop dependence_schedule_times; -- t_ds_task_instance note: Data migration is not supported alter table t_ds_task_instance change process_definition_id task_code bigint(20) NOT NULL COMMENT 'task definition code'; -alter table t_ds_task_instance add task_definition_version int(11) DEFAULT '0' COMMENT 'task definition version' AFTER task_code; +alter table t_ds_task_instance add task_definition_version int(11) DEFAULT '1' COMMENT 'task definition version' AFTER task_code; alter table t_ds_task_instance add task_params text COMMENT 'job custom parameters' AFTER app_link; alter table t_ds_task_instance add environment_code bigint(20) DEFAULT '-1' COMMENT 'environment code' AFTER worker_group; alter table t_ds_task_instance add environment_config text COMMENT 'this config contains many environment variables config' AFTER environment_code; diff --git a/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/postgresql/dolphinscheduler_ddl.sql b/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/postgresql/dolphinscheduler_ddl.sql index eb41df941c..d684effb76 100644 --- a/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/postgresql/dolphinscheduler_ddl.sql +++ b/dolphinscheduler-dao/src/main/resources/sql/upgrade/2.0.0_schema/postgresql/dolphinscheduler_ddl.sql @@ -63,7 +63,7 @@ BEGIN EXECUTE 'ALTER TABLE ' || quote_ident(v_schema) ||'.t_ds_process_instance ADD COLUMN IF NOT EXISTS "var_pool" text'; EXECUTE 'ALTER TABLE ' || quote_ident(v_schema) ||'.t_ds_process_instance ADD COLUMN IF NOT EXISTS "dry_run" int DEFAULT 0'; EXECUTE 'ALTER TABLE ' || quote_ident(v_schema) ||'.t_ds_process_instance ADD COLUMN IF NOT EXISTS "next_process_instance_id" int DEFAULT 0'; - EXECUTE 'ALTER TABLE ' || quote_ident(v_schema) ||'.t_ds_task_instance ADD COLUMN IF NOT EXISTS "task_definition_version" int DEFAULT 0'; + EXECUTE 'ALTER TABLE ' || quote_ident(v_schema) ||'.t_ds_task_instance ADD COLUMN IF NOT EXISTS "task_definition_version" int DEFAULT 1'; EXECUTE 'ALTER TABLE ' || quote_ident(v_schema) ||'.t_ds_task_instance ADD COLUMN IF NOT EXISTS "task_params" text'; EXECUTE 'ALTER TABLE ' || quote_ident(v_schema) ||'.t_ds_task_instance ADD COLUMN IF NOT EXISTS "environment_code" bigint DEFAULT -1'; EXECUTE 'ALTER TABLE ' || quote_ident(v_schema) ||'.t_ds_task_instance ADD COLUMN IF NOT EXISTS "environment_config" text'; diff --git a/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.2.1_schema/mysql/dolphinscheduler_ddl.sql b/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.2.1_schema/mysql/dolphinscheduler_ddl.sql index c71cca2941..957f072a43 100644 --- a/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.2.1_schema/mysql/dolphinscheduler_ddl.sql +++ b/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.2.1_schema/mysql/dolphinscheduler_ddl.sql @@ -102,4 +102,11 @@ delimiter ; CALL drop_t_ds_k8s_namespace_col_pod_request_memory; DROP PROCEDURE drop_t_ds_k8s_namespace_col_pod_request_memory; -ALTER TABLE `t_ds_project_parameter` MODIFY COLUMN `param_value` text NOT NULL COMMENT 'project parameter value'; \ No newline at end of file +ALTER TABLE `t_ds_project_parameter` MODIFY COLUMN `param_value` text NOT NULL COMMENT 'project parameter value'; + +ALTER TABLE `t_ds_process_definition` MODIFY COLUMN `version` int NOT NULL DEFAULT 1 COMMENT "process definition version"; +ALTER TABLE `t_ds_process_definition_log` MODIFY COLUMN `version` int NOT NULL DEFAULT 1 COMMENT "process definition version"; +ALTER TABLE `t_ds_process_instance` MODIFY COLUMN `process_definition_version` int NOT NULL DEFAULT 1 COMMENT "process definition version"; +ALTER TABLE `t_ds_task_definition` MODIFY COLUMN `version` int NOT NULL DEFAULT 1 COMMENT "task definition version"; +ALTER TABLE `t_ds_task_definition_log` MODIFY COLUMN `version` int NOT NULL DEFAULT 1 COMMENT "task definition version"; +ALTER TABLE `t_ds_task_instance` MODIFY COLUMN `task_definition_version` int NOT NULL DEFAULT 1 COMMENT "task definition version"; \ No newline at end of file diff --git a/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.2.1_schema/postgresql/dolphinscheduler_ddl.sql b/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.2.1_schema/postgresql/dolphinscheduler_ddl.sql index 80d8aaebf7..ce48a3374e 100644 --- a/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.2.1_schema/postgresql/dolphinscheduler_ddl.sql +++ b/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.2.1_schema/postgresql/dolphinscheduler_ddl.sql @@ -22,4 +22,11 @@ ALTER TABLE "t_ds_k8s_namespace" DROP COLUMN IF EXISTS "pod_replicas"; ALTER TABLE "t_ds_k8s_namespace" DROP COLUMN IF EXISTS "pod_request_cpu"; ALTER TABLE "t_ds_k8s_namespace" DROP COLUMN IF EXISTS "pod_request_memory"; -ALTER TABLE t_ds_project_parameter ALTER COLUMN param_value TYPE text; \ No newline at end of file +ALTER TABLE t_ds_project_parameter ALTER COLUMN param_value TYPE text; + +ALTER TABLE "t_ds_process_definition" ALTER COLUMN "version" SET DEFAULT 1; +ALTER TABLE "t_ds_process_definition_log" ALTER COLUMN "version" SET DEFAULT 1; +ALTER TABLE "t_ds_task_definition" ALTER COLUMN "version" SET DEFAULT 1; +ALTER TABLE "t_ds_task_definition_log" ALTER COLUMN "version" SET DEFAULT 1; +ALTER TABLE "t_ds_process_instance" ALTER COLUMN "process_definition_version" SET NOT NULL, ALTER COLUMN "process_definition_version" SET DEFAULT 1; +ALTER TABLE "t_ds_task_instance" ALTER COLUMN "task_definition_version" SET NOT NULL, ALTER COLUMN "task_definition_version" SET DEFAULT 1; \ No newline at end of file diff --git a/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.3.0_schema/mysql/dolphinscheduler_ddl.sql b/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.3.0_schema/mysql/dolphinscheduler_ddl.sql index 1daf4c153e..6c73e112da 100644 --- a/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.3.0_schema/mysql/dolphinscheduler_ddl.sql +++ b/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.3.0_schema/mysql/dolphinscheduler_ddl.sql @@ -73,4 +73,11 @@ END; d// delimiter ; CALL modify_data_value_t_ds_dq_rule_input_entry; -DROP PROCEDURE modify_data_value_t_ds_dq_rule_input_entry; \ No newline at end of file +DROP PROCEDURE modify_data_value_t_ds_dq_rule_input_entry; + +ALTER TABLE `t_ds_process_definition` MODIFY COLUMN `version` int NOT NULL DEFAULT 1 COMMENT "process definition version"; +ALTER TABLE `t_ds_process_definition_log` MODIFY COLUMN `version` int NOT NULL DEFAULT 1 COMMENT "process definition version"; +ALTER TABLE `t_ds_process_instance` MODIFY COLUMN `process_definition_version` int NOT NULL DEFAULT 1 COMMENT "process definition version"; +ALTER TABLE `t_ds_task_definition` MODIFY COLUMN `version` int NOT NULL DEFAULT 1 COMMENT "task definition version"; +ALTER TABLE `t_ds_task_definition_log` MODIFY COLUMN `version` int NOT NULL DEFAULT 1 COMMENT "task definition version"; +ALTER TABLE `t_ds_task_instance` MODIFY COLUMN `task_definition_version` int NOT NULL DEFAULT 1 COMMENT "task definition version"; \ No newline at end of file diff --git a/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.3.0_schema/postgresql/dolphinscheduler_ddl.sql b/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.3.0_schema/postgresql/dolphinscheduler_ddl.sql index 809be532a3..fd13ed3594 100644 --- a/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.3.0_schema/postgresql/dolphinscheduler_ddl.sql +++ b/dolphinscheduler-dao/src/main/resources/sql/upgrade/3.3.0_schema/postgresql/dolphinscheduler_ddl.sql @@ -61,4 +61,11 @@ $$ LANGUAGE plpgsql; d// select modify_data_type_t_ds_dq_rule_input_entry(); -DROP FUNCTION IF EXISTS modify_data_type_t_ds_dq_rule_input_entry(); \ No newline at end of file +DROP FUNCTION IF EXISTS modify_data_type_t_ds_dq_rule_input_entry(); + +ALTER TABLE "t_ds_process_definition" ALTER COLUMN "version" SET DEFAULT 1; +ALTER TABLE "t_ds_process_definition_log" ALTER COLUMN "version" SET DEFAULT 1; +ALTER TABLE "t_ds_task_definition" ALTER COLUMN "version" SET DEFAULT 1; +ALTER TABLE "t_ds_task_definition_log" ALTER COLUMN "version" SET DEFAULT 1; +ALTER TABLE "t_ds_process_instance" ALTER COLUMN "process_definition_version" SET NOT NULL, ALTER COLUMN "process_definition_version" SET DEFAULT 1; +ALTER TABLE "t_ds_task_instance" ALTER COLUMN "task_definition_version" SET NOT NULL, ALTER COLUMN "task_definition_version" SET DEFAULT 1; \ No newline at end of file