From c865d16f67d460105f5cce8a4df2f45e5ed5f2e7 Mon Sep 17 00:00:00 2001 From: hejieehe <904696180@qq.com> Date: Fri, 13 Dec 2024 15:13:11 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E6=94=AF=E6=8C=81=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=88=91=E7=9A=84=20OAUTH=20#10995=20=E8=A1=A5?= =?UTF-8?q?=E5=85=85SQL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sql/1001_ci_repository_ddl_mysql.sql | 3 ++ .../2030_ci_repository-update_v3.0_mysql.sql | 45 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 support-files/sql/2004_v3.x/2030_ci_repository-update_v3.0_mysql.sql diff --git a/support-files/sql/1001_ci_repository_ddl_mysql.sql b/support-files/sql/1001_ci_repository_ddl_mysql.sql index 3d994cb272a..8d393b00def 100644 --- a/support-files/sql/1001_ci_repository_ddl_mysql.sql +++ b/support-files/sql/1001_ci_repository_ddl_mysql.sql @@ -127,6 +127,7 @@ CREATE TABLE IF NOT EXISTS `T_REPOSITORY_GITHUB_TOKEN` ( `CREATE_TIME` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `UPDATE_TIME` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', `TYPE` varchar(32) DEFAULT 'GITHUB_APP' COMMENT 'GitHub token类型(GITHUB_APP、OAUTH_APP)', + `OPERATOR` varchar(64) NOT NULL COMMENT '操作人', PRIMARY KEY (`ID`), UNIQUE KEY `USER_ID` (`USER_ID`, `TYPE`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='github oauth token表'; @@ -143,6 +144,8 @@ CREATE TABLE IF NOT EXISTS `T_REPOSITORY_GIT_TOKEN` ( `TOKEN_TYPE` varchar(64) DEFAULT NULL COMMENT 'token类型', `EXPIRES_IN` bigint(20) DEFAULT NULL COMMENT '过期时间', `CREATE_TIME` datetime DEFAULT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'token的创建时间', + `UPDATE_TIME` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间', + `OPERATOR` varchar(64) DEFAULT NULL COMMENT '操作人', PRIMARY KEY (`ID`), UNIQUE KEY `USER_ID` (`USER_ID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='工蜂commit checker表'; diff --git a/support-files/sql/2004_v3.x/2030_ci_repository-update_v3.0_mysql.sql b/support-files/sql/2004_v3.x/2030_ci_repository-update_v3.0_mysql.sql new file mode 100644 index 00000000000..6819bbd3fc6 --- /dev/null +++ b/support-files/sql/2004_v3.x/2030_ci_repository-update_v3.0_mysql.sql @@ -0,0 +1,45 @@ +USE devops_ci_repository; +SET NAMES utf8mb4; + +DROP PROCEDURE IF EXISTS ci_repository_schema_update; + +DELIMITER + +CREATE PROCEDURE ci_repository_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_REPOSITORY_GIT_TOKEN' + AND COLUMN_NAME = 'UPDATE_TIME') THEN + ALTER TABLE T_REPOSITORY_GIT_TOKEN + ADD COLUMN `UPDATE_TIME` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间'; + END IF; + + IF NOT EXISTS(SELECT 1 + FROM information_schema.COLUMNS + WHERE TABLE_SCHEMA = db + AND TABLE_NAME = 'T_REPOSITORY_GIT_TOKEN' + AND COLUMN_NAME = 'OPERATOR') THEN + ALTER TABLE T_REPOSITORY_GIT_TOKEN + ADD COLUMN `OPERATOR` varchar(64) DEFAULT NULL COMMENT '操作人'; + END IF; + + IF NOT EXISTS(SELECT 1 + FROM information_schema.COLUMNS + WHERE TABLE_SCHEMA = db + AND TABLE_NAME = 'T_REPOSITORY_GITHUB_TOKEN' + AND COLUMN_NAME = 'OPERATOR') THEN + ALTER TABLE T_REPOSITORY_GITHUB_TOKEN + ADD COLUMN `OPERATOR` varchar(64) DEFAULT NULL COMMENT '操作人'; + END IF; + + COMMIT; +END +DELIMITER ; +COMMIT; +CALL ci_repository_schema_update();