Skip to content

Commit

Permalink
feat:支持管理我的 OAUTH #10995 补充SQL
Browse files Browse the repository at this point in the history
  • Loading branch information
hejieehe committed Dec 13, 2024
1 parent b64a381 commit c865d16
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
3 changes: 3 additions & 0 deletions support-files/sql/1001_ci_repository_ddl_mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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表';
Expand All @@ -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表';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
USE devops_ci_repository;
SET NAMES utf8mb4;

DROP PROCEDURE IF EXISTS ci_repository_schema_update;

DELIMITER <CI_UBF>

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 <CI_UBF>
DELIMITER ;
COMMIT;
CALL ci_repository_schema_update();

0 comments on commit c865d16

Please sign in to comment.