From 2e7969db716f47f360b835aa3a41d51b22198221 Mon Sep 17 00:00:00 2001 From: carlyin <449036249@qq.com> Date: Fri, 22 Oct 2021 16:02:08 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=95=B0=E6=8D=AE=E5=BA=93=E8=A1=A8?= =?UTF-8?q?=E5=90=8C=E6=AD=A5projectId=E6=95=B0=E6=8D=AE=20#5339?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sql/2008_ci_process-update_v1.7_mysql.sql | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 support-files/sql/2008_ci_process-update_v1.7_mysql.sql diff --git a/support-files/sql/2008_ci_process-update_v1.7_mysql.sql b/support-files/sql/2008_ci_process-update_v1.7_mysql.sql new file mode 100644 index 00000000000..aa49e4dd705 --- /dev/null +++ b/support-files/sql/2008_ci_process-update_v1.7_mysql.sql @@ -0,0 +1,107 @@ +USE devops_ci_process; +SET NAMES utf8mb4; + +DROP PROCEDURE IF EXISTS ci_process_schema_update; + +DELIMITER + +CREATE PROCEDURE ci_process_schema_update() +BEGIN + + DECLARE db VARCHAR(100); + SET AUTOCOMMIT = 0; + SELECT DATABASE() INTO db; + + IF NOT EXISTS(SELECT 1 + FROM information_schema.COLUMNS + WHERE TABLE_SCHEMA = db + AND TABLE_NAME = 'T_PIPELINE_BUILD_DETAIL' + AND COLUMN_NAME = 'PROJECT_ID') THEN + ALTER TABLE T_PIPELINE_BUILD_DETAIL ADD COLUMN `PROJECT_ID` varchar(64) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '项目ID'; + END IF; + + IF NOT EXISTS(SELECT 1 + FROM information_schema.COLUMNS + WHERE TABLE_SCHEMA = db + AND TABLE_NAME = 'T_PIPELINE_BUILD_TASK' + AND COLUMN_NAME = 'SUB_PROJECT_ID') THEN + ALTER TABLE T_PIPELINE_BUILD_TASK ADD COLUMN `SUB_PROJECT_ID` varchar(64) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '子流水线项目ID'; + END IF; + + IF NOT EXISTS(SELECT 1 + FROM information_schema.COLUMNS + WHERE TABLE_SCHEMA = db + AND TABLE_NAME = 'T_PIPELINE_LABEL' + AND COLUMN_NAME = 'PROJECT_ID') THEN + ALTER TABLE T_PIPELINE_LABEL ADD COLUMN `PROJECT_ID` varchar(64) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '项目ID'; + END IF; + + IF NOT EXISTS(SELECT 1 + FROM information_schema.COLUMNS + WHERE TABLE_SCHEMA = db + AND TABLE_NAME = 'T_PIPELINE_LABEL_PIPELINE' + AND COLUMN_NAME = 'PROJECT_ID') THEN + ALTER TABLE T_PIPELINE_LABEL_PIPELINE ADD COLUMN `PROJECT_ID` varchar(64) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '项目ID'; + END IF; + + IF NOT EXISTS(SELECT 1 + FROM information_schema.COLUMNS + WHERE TABLE_SCHEMA = db + AND TABLE_NAME = 'T_PIPELINE_VIEW_LABEL' + AND COLUMN_NAME = 'PROJECT_ID') THEN + ALTER TABLE T_PIPELINE_VIEW_LABEL ADD COLUMN `PROJECT_ID` varchar(64) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '项目ID'; + END IF; + + IF NOT EXISTS(SELECT 1 + FROM information_schema.COLUMNS + WHERE TABLE_SCHEMA = db + AND TABLE_NAME = 'T_PIPELINE_PAUSE_VALUE' + AND COLUMN_NAME = 'PROJECT_ID') THEN + ALTER TABLE T_PIPELINE_PAUSE_VALUE ADD COLUMN `PROJECT_ID` varchar(64) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '项目ID'; + END IF; + + IF NOT EXISTS(SELECT 1 + FROM information_schema.COLUMNS + WHERE TABLE_SCHEMA = db + AND TABLE_NAME = 'T_PIPELINE_RESOURCE' + AND COLUMN_NAME = 'PROJECT_ID') THEN + ALTER TABLE T_PIPELINE_RESOURCE ADD COLUMN `PROJECT_ID` varchar(64) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '项目ID'; + END IF; + + IF NOT EXISTS(SELECT 1 + FROM information_schema.COLUMNS + WHERE TABLE_SCHEMA = db + AND TABLE_NAME = 'T_PIPELINE_RESOURCE_VERSION' + AND COLUMN_NAME = 'PROJECT_ID') THEN + ALTER TABLE T_PIPELINE_RESOURCE_VERSION ADD COLUMN `PROJECT_ID` varchar(64) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '项目ID'; + END IF; + + IF NOT EXISTS(SELECT 1 + FROM information_schema.COLUMNS + WHERE TABLE_SCHEMA = db + AND TABLE_NAME = 'T_PIPELINE_WEBHOOK_QUEUE' + AND COLUMN_NAME = 'PROJECT_ID') THEN + ALTER TABLE T_PIPELINE_WEBHOOK_QUEUE ADD COLUMN `PROJECT_ID` varchar(64) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '项目ID'; + END IF; + + IF NOT EXISTS(SELECT 1 + FROM information_schema.COLUMNS + WHERE TABLE_SCHEMA = db + AND TABLE_NAME = 'T_TEMPLATE_INSTANCE_ITEM' + AND COLUMN_NAME = 'PROJECT_ID') THEN + ALTER TABLE T_TEMPLATE_INSTANCE_ITEM ADD COLUMN `PROJECT_ID` varchar(64) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '项目ID'; + END IF; + + IF NOT EXISTS(SELECT 1 + FROM information_schema.COLUMNS + WHERE TABLE_SCHEMA = db + AND TABLE_NAME = 'T_TEMPLATE_PIPELINE' + AND COLUMN_NAME = 'PROJECT_ID') THEN + ALTER TABLE T_TEMPLATE_PIPELINE ADD COLUMN `PROJECT_ID` varchar(64) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '项目ID'; + END IF; + + COMMIT; +END +DELIMITER ; +COMMIT; +CALL ci_process_schema_update();