Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:数据库表同步projectId数据 #5339 #5398

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions support-files/sql/2008_ci_process-update_v1.7_mysql.sql
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();