forked from TencentBlueKing/bk-ci
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:数据库表同步projectId数据 TencentBlueKing#5339
- Loading branch information
1 parent
9dba950
commit 2e7969d
Showing
1 changed file
with
107 additions
and
0 deletions.
There are no files selected for viewing
107 changes: 107 additions & 0 deletions
107
support-files/sql/2008_ci_process-update_v1.7_mysql.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
USE devops_ci_process; | ||
SET NAMES utf8mb4; | ||
|
||
DROP PROCEDURE IF EXISTS ci_process_schema_update; | ||
|
||
DELIMITER <CI_UBF> | ||
|
||
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 <CI_UBF> | ||
DELIMITER ; | ||
COMMIT; | ||
CALL ci_process_schema_update(); |