Skip to content

Commit

Permalink
feat: copilot 编辑器支持免登录 TencentBlueKing#11290 补充SQL
Browse files Browse the repository at this point in the history
  • Loading branch information
hejieehe committed Dec 6, 2024
1 parent cf21239 commit bd91889
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion support-files/sql/1001_ci_repository_ddl_mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ CREATE TABLE IF NOT EXISTS `T_REPOSITORY_GIT_TOKEN` (
`EXPIRES_IN` bigint(20) DEFAULT NULL COMMENT '过期时间',
`CREATE_TIME` datetime DEFAULT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'token的创建时间',
PRIMARY KEY (`ID`),
UNIQUE KEY `USER_ID` (`USER_ID`)
UNIQUE KEY `T_REPOSITORY_GIT_TOKEN_UNIQUE` (`USER_ID`, `TOKEN_TYPE`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='工蜂commit checker表';


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
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 EXISTS(SELECT 1
FROM information_schema.statistics
WHERE TABLE_SCHEMA = db
AND TABLE_NAME = 'T_REPOSITORY_GIT_TOKEN'
AND INDEX_NAME = 'USER_ID') THEN
ALTER TABLE T_REPOSITORY_GIT_TOKEN DROP INDEX `USER_ID`;
END IF;

IF NOT EXISTS(SELECT 1
FROM information_schema.statistics
WHERE TABLE_SCHEMA = db
AND TABLE_NAME = 'T_REPOSITORY_GIT_TOKEN'
AND INDEX_NAME = 'T_REPOSITORY_GIT_TOKEN_UNIQUE') THEN
ALTER TABLE T_REPOSITORY_GIT_TOKEN ADD INDEX `T_REPOSITORY_GIT_TOKEN_UNIQUE` (`USER_ID`,`TOKEN_TYPE`);
END IF;

COMMIT;
END <CI_UBF>
DELIMITER ;
COMMIT;
CALL ci_repository_schema_update();

0 comments on commit bd91889

Please sign in to comment.