hoj/sqlAndsetting/hoj-update.sql

592 lines
19 KiB
MySQL
Raw Permalink Normal View History

2021-08-07 23:03:12 +08:00
USE `hoj`;
/*
2021-08-08 12:12:48 +08:00
* 2021.08.07 OI题目得分在OI排行榜新计分字段 OI题目总得分*0.1+2*
2021-08-07 23:03:12 +08:00
*/
2021-08-08 12:12:48 +08:00
DROP PROCEDURE
IF EXISTS judge_Add_oi_rank_score;
DELIMITER $$
CREATE PROCEDURE judge_Add_oi_rank_score ()
BEGIN
IF NOT EXISTS (
SELECT
1
FROM
information_schema.`COLUMNS`
WHERE
table_name = 'judge'
2021-09-21 18:13:07 +08:00
AND column_name = 'oi_rank'
2021-08-08 12:12:48 +08:00
) THEN
2021-09-21 18:13:07 +08:00
ALTER TABLE judge ADD COLUMN oi_rank INT(11) NULL COMMENT '该题在OI排行榜的分数';
2021-08-08 12:12:48 +08:00
END
IF ; END$$
DELIMITER ;
CALL judge_Add_oi_rank_score ;
2021-08-14 12:04:46 +08:00
DROP PROCEDURE judge_Add_oi_rank_score;
/*
* 2021.08.08 vjudge_submit_id在vjudge判题获取提交id后存储id直接获取结果
vjudge_usernamevjudge_password分别记录提交账号密码
*/
DROP PROCEDURE
IF EXISTS judge_Add_vjudge_submit_id;
DELIMITER $$
CREATE PROCEDURE judge_Add_vjudge_submit_id ()
BEGIN
IF NOT EXISTS (
SELECT
1
FROM
information_schema.`COLUMNS`
WHERE
table_name = 'judge'
AND column_name = 'vjudge_submit_id'
) THEN
ALTER TABLE judge ADD COLUMN vjudge_submit_id BIGINT UNSIGNED NULL COMMENT 'vjudge判题在其它oj的提交id';
ALTER TABLE judge ADD COLUMN vjudge_username VARCHAR(255) NULL COMMENT 'vjudge判题在其它oj的提交用户名';
ALTER TABLE judge ADD COLUMN vjudge_password VARCHAR(255) NULL COMMENT 'vjudge判题在其它oj的提交账号密码';
END
IF ; END$$
DELIMITER ;
CALL judge_Add_vjudge_submit_id ;
DROP PROCEDURE judge_Add_vjudge_submit_id;
2021-09-21 18:13:07 +08:00
/*
* 2021.09.21
*/
DROP PROCEDURE
IF EXISTS contest_Add_print_and_limit;
DELIMITER $$
CREATE PROCEDURE contest_Add_print_and_limit ()
BEGIN
IF NOT EXISTS (
SELECT
1
FROM
information_schema.`COLUMNS`
WHERE
table_name = 'contest'
AND column_name = 'open_print'
) THEN
ALTER TABLE contest ADD COLUMN open_print tinyint(1) DEFAULT '0' COMMENT '是否打开打印功能';
ALTER TABLE contest ADD COLUMN open_account_limit tinyint(1) DEFAULT '0' COMMENT '是否开启账号限制';
ALTER TABLE contest ADD COLUMN account_limit_rule mediumtext COMMENT '账号限制规则';
ALTER TABLE `hoj`.`user_info` CHANGE `realname` `realname` VARCHAR(100) CHARSET utf8 COLLATE utf8_general_ci NULL COMMENT '真实姓名';
END
IF ; END$$
DELIMITER ;
CALL contest_Add_print_and_limit ;
DROP PROCEDURE contest_Add_print_and_limit;
DROP PROCEDURE
IF EXISTS Add_contest_print;
DELIMITER $$
CREATE PROCEDURE Add_contest_print ()
BEGIN
IF NOT EXISTS (
SELECT
1
FROM
information_schema.`COLUMNS`
WHERE
table_name = 'contest_print'
) THEN
CREATE TABLE `contest_print` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`username` varchar(100) DEFAULT NULL,
`realname` varchar(100) DEFAULT NULL,
`cid` bigint(20) unsigned DEFAULT NULL,
`content` longtext NOT NULL,
`status` int(11) DEFAULT '0',
`gmt_create` datetime DEFAULT CURRENT_TIMESTAMP,
`gmt_modified` datetime DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `cid` (`cid`),
KEY `username` (`username`),
CONSTRAINT `contest_print_ibfk_1` FOREIGN KEY (`cid`) REFERENCES `contest` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `contest_print_ibfk_2` FOREIGN KEY (`username`) REFERENCES `user_info` (`username`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
END
IF ; END$$
DELIMITER ;
CALL Add_contest_print ;
DROP PROCEDURE Add_contest_print;
/*
* 2021.10.04
*/
DROP PROCEDURE
IF EXISTS Add_msg_table;
DELIMITER $$
CREATE PROCEDURE Add_msg_table ()
BEGIN
IF NOT EXISTS (
SELECT
1
FROM
information_schema.`COLUMNS`
WHERE
table_name = 'msg_remind'
) THEN
CREATE TABLE `admin_sys_notice` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(255) DEFAULT NULL COMMENT '标题',
`content` longtext COMMENT '内容',
`type` varchar(255) DEFAULT NULL COMMENT '发给哪些用户类型',
`state` tinyint(1) DEFAULT '0' COMMENT '是否已拉取给用户',
`recipient_id` varchar(32) DEFAULT NULL COMMENT '接受通知的用户id',
`admin_id` varchar(32) DEFAULT NULL COMMENT '发送通知的管理员id',
`gmt_create` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`gmt_modified` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
PRIMARY KEY (`id`),
KEY `recipient_id` (`recipient_id`),
KEY `admin_id` (`admin_id`),
CONSTRAINT `admin_sys_notice_ibfk_1` FOREIGN KEY (`recipient_id`) REFERENCES `user_info` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `admin_sys_notice_ibfk_2` FOREIGN KEY (`admin_id`) REFERENCES `user_info` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `msg_remind` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`action` varchar(255) NOT NULL COMMENT '动作类型如点赞讨论帖Like_Post、点赞评论Like_Discuss、评论Discuss、回复Reply等',
`source_id` int(10) unsigned DEFAULT NULL COMMENT '消息来源id讨论id或比赛id',
`source_type` varchar(255) DEFAULT NULL COMMENT '事件源类型:''Discussion''''Contest''',
`source_content` varchar(255) DEFAULT NULL COMMENT '事件源的内容,比如回复的内容,评论的帖子标题等等',
`quote_id` int(10) unsigned DEFAULT NULL COMMENT '事件引用上一级评论或回复id',
`quote_type` varchar(255) DEFAULT NULL COMMENT '事件引用上一级的类型Comment、Reply',
`url` varchar(255) DEFAULT NULL COMMENT '事件所发生的地点链接 url',
`state` tinyint(1) DEFAULT '0' COMMENT '是否已读',
`sender_id` varchar(32) DEFAULT NULL COMMENT '操作者的id',
`recipient_id` varchar(32) DEFAULT NULL COMMENT '接受消息的用户id',
`gmt_create` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`gmt_modified` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
PRIMARY KEY (`id`),
KEY `sender_id` (`sender_id`),
KEY `recipient_id` (`recipient_id`),
CONSTRAINT `msg_remind_ibfk_1` FOREIGN KEY (`sender_id`) REFERENCES `user_info` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `msg_remind_ibfk_2` FOREIGN KEY (`recipient_id`) REFERENCES `user_info` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `user_sys_notice` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`sys_notice_id` bigint(20) unsigned DEFAULT NULL COMMENT '系统通知的id',
`recipient_id` varchar(32) DEFAULT NULL COMMENT '接受通知的用户id',
`type` varchar(255) DEFAULT NULL COMMENT '消息类型系统通知sys、我的信息mine',
`state` tinyint(1) DEFAULT '0' COMMENT '是否已读',
`gmt_create` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '读取时间',
`gmt_modified` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `sys_notice_id` (`sys_notice_id`),
KEY `recipient_id` (`recipient_id`),
CONSTRAINT `user_sys_notice_ibfk_1` FOREIGN KEY (`sys_notice_id`) REFERENCES `admin_sys_notice` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `user_sys_notice_ibfk_2` FOREIGN KEY (`recipient_id`) REFERENCES `user_info` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
END
IF ; END$$
DELIMITER ;
CALL Add_msg_table;
DROP PROCEDURE Add_msg_table;
/*
* 2021.10.06 user_info增加性别列gender
*/
DROP PROCEDURE
IF EXISTS user_info_Add_gender;
DELIMITER $$
CREATE PROCEDURE user_info_Add_gender ()
BEGIN
IF NOT EXISTS (
SELECT
1
FROM
information_schema.`COLUMNS`
WHERE
table_name = 'user_info'
AND column_name = 'gender'
) THEN
ALTER TABLE user_info ADD COLUMN gender varchar(20) DEFAULT 'secrecy' NOT NULL COMMENT '性别';
END
IF ; END$$
DELIMITER ;
CALL user_info_Add_gender ;
DROP PROCEDURE user_info_Add_gender;
DROP PROCEDURE
IF EXISTS contest_Add_rank_show_name;
DELIMITER $$
CREATE PROCEDURE contest_Add_rank_show_name ()
BEGIN
IF NOT EXISTS (
SELECT
1
FROM
information_schema.`COLUMNS`
WHERE
table_name = 'contest'
AND column_name = 'rank_show_name'
) THEN
ALTER TABLE contest ADD COLUMN rank_show_name varchar(20) DEFAULT 'username' COMMENT '排行榜显示username、nickname、realname';
END
IF ; END$$
DELIMITER ;
CALL contest_Add_rank_show_name ;
DROP PROCEDURE contest_Add_rank_show_name;
2021-10-08 22:06:39 +08:00
/*
* 2021.10.08 user_info增加性别列gender
*/
DROP PROCEDURE
IF EXISTS contest_problem_Add_color;
DELIMITER $$
CREATE PROCEDURE contest_problem_Add_color ()
BEGIN
IF NOT EXISTS (
SELECT
1
FROM
information_schema.`COLUMNS`
WHERE
table_name = 'contest_problem'
AND column_name = 'color'
) THEN
ALTER TABLE contest_problem ADD COLUMN `color` VARCHAR(255) NULL COMMENT '气球颜色';
ALTER TABLE user_info ADD COLUMN `title_name` VARCHAR(255) NULL COMMENT '头衔、称号';
ALTER TABLE user_info ADD COLUMN `title_color` VARCHAR(255) NULL COMMENT '头衔、称号的颜色';
END
IF ; END$$
DELIMITER ;
CALL contest_problem_Add_color ;
2021-10-08 22:06:39 +08:00
DROP PROCEDURE contest_problem_Add_color;
2021-11-24 21:48:33 +08:00
/*
* 2021.11.17 judge_server增加cf_submittable控制单台判题机只能一个账号提交CF
*/
DROP PROCEDURE
IF EXISTS judge_server_Add_cf_submittable;
DELIMITER $$
CREATE PROCEDURE judge_serverm_Add_cf_submittable ()
BEGIN
IF NOT EXISTS (
SELECT
1
FROM
information_schema.`COLUMNS`
WHERE
table_name = 'judge_server'
AND column_name = 'cf_submittable'
) THEN
ALTER TABLE `hoj`.`judge_server` ADD COLUMN `cf_submittable` BOOLEAN DEFAULT 1 NULL COMMENT '是否可提交CF';
END
IF ; END$$
DELIMITER ;
CALL judge_serverm_Add_cf_submittable ;
DROP PROCEDURE judge_serverm_Add_cf_submittable;
2021-11-28 11:05:33 +08:00
/*
* 2021.11.29
*/
DROP PROCEDURE
IF EXISTS Add_training_table;
DELIMITER $$
CREATE PROCEDURE Add_training_table ()
BEGIN
IF NOT EXISTS (
SELECT
1
FROM
information_schema.`COLUMNS`
WHERE
table_name = 'training'
) THEN
CREATE TABLE `training` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(255) DEFAULT NULL COMMENT '训练题单名称',
`description` longtext COMMENT '训练题单简介',
`author` varchar(255) NOT NULL COMMENT '训练题单创建者用户名',
`auth` varchar(255) NOT NULL COMMENT '训练题单权限类型Public、Private',
`private_pwd` varchar(255) DEFAULT NULL COMMENT '训练题单权限为Private时的密码',
`rank` int DEFAULT '0' COMMENT '编号,升序',
`status` tinyint(1) DEFAULT '1' COMMENT '是否可用',
`gmt_create` datetime DEFAULT CURRENT_TIMESTAMP,
`gmt_modified` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `training_category` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`color` varchar(255) DEFAULT NULL,
`gmt_create` datetime DEFAULT CURRENT_TIMESTAMP,
`gmt_modified` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `training_problem` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
2021-11-28 11:05:33 +08:00
`tid` bigint unsigned NOT NULL COMMENT '训练id',
`pid` bigint unsigned NOT NULL COMMENT '题目id',
`rank` int DEFAULT '0',
`display_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
2021-11-28 11:05:33 +08:00
`gmt_create` datetime DEFAULT CURRENT_TIMESTAMP,
`gmt_modified` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `tid` (`tid`),
KEY `pid` (`pid`),
KEY `display_id` (`display_id`),
2021-11-28 11:05:33 +08:00
CONSTRAINT `training_problem_ibfk_1` FOREIGN KEY (`tid`) REFERENCES `training` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `training_problem_ibfk_2` FOREIGN KEY (`pid`) REFERENCES `problem` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `training_problem_ibfk_3` FOREIGN KEY (`display_id`) REFERENCES `problem` (`problem_id`) ON DELETE CASCADE ON UPDATE CASCADE
2021-11-28 11:05:33 +08:00
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `training_record` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`tid` bigint unsigned NOT NULL,
`tpid` bigint unsigned NOT NULL,
`pid` bigint unsigned NOT NULL,
`uid` varchar(255) NOT NULL,
`submit_id` bigint unsigned NOT NULL,
`gmt_create` datetime DEFAULT CURRENT_TIMESTAMP,
`gmt_modified` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `tid` (`tid`),
KEY `tpid` (`tpid`),
KEY `pid` (`pid`),
KEY `uid` (`uid`),
KEY `submit_id` (`submit_id`),
CONSTRAINT `training_record_ibfk_1` FOREIGN KEY (`tid`) REFERENCES `training` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `training_record_ibfk_2` FOREIGN KEY (`tpid`) REFERENCES `training_problem` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `training_record_ibfk_3` FOREIGN KEY (`pid`) REFERENCES `problem` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `training_record_ibfk_4` FOREIGN KEY (`uid`) REFERENCES `user_info` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `training_record_ibfk_5` FOREIGN KEY (`submit_id`) REFERENCES `judge` (`submit_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `training_register` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`tid` bigint unsigned NOT NULL COMMENT '训练id',
`uid` varchar(255) NOT NULL COMMENT '用户id',
`status` tinyint(1) DEFAULT '1' COMMENT '是否可用',
`gmt_create` datetime DEFAULT CURRENT_TIMESTAMP,
`gmt_modified` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `tid` (`tid`),
KEY `uid` (`uid`),
CONSTRAINT `training_register_ibfk_1` FOREIGN KEY (`tid`) REFERENCES `training` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `training_register_ibfk_2` FOREIGN KEY (`uid`) REFERENCES `user_info` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `mapping_training_category` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`tid` bigint unsigned NOT NULL,
`cid` bigint unsigned NOT NULL,
`gmt_create` datetime DEFAULT CURRENT_TIMESTAMP,
`gmt_modified` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `tid` (`tid`),
KEY `cid` (`cid`),
CONSTRAINT `mapping_training_category_ibfk_1` FOREIGN KEY (`tid`) REFERENCES `training` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `mapping_training_category_ibfk_2` FOREIGN KEY (`cid`) REFERENCES `training_category` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `hoj`.`judge` ADD COLUMN `tid` BIGINT UNSIGNED NULL AFTER `cpid`,
ADD FOREIGN KEY (`tid`) REFERENCES `hoj`.`training`(`id`) ON UPDATE CASCADE ON DELETE CASCADE;
END
IF ; END$$
DELIMITER ;
CALL Add_training_table;
DROP PROCEDURE Add_training_table;
/*
* 2021.12.05 contest增加auto_real_rank比赛结束是否自动解除封榜,
*/
DROP PROCEDURE
IF EXISTS contest_Add_auto_real_rank;
DELIMITER $$
2021-12-07 07:53:51 +08:00
CREATE PROCEDURE contest_Add_auto_real_rank()
BEGIN
IF NOT EXISTS (
SELECT
1
FROM
information_schema.`COLUMNS`
WHERE
2021-12-07 07:53:51 +08:00
table_name = 'contest'
AND column_name = 'auto_real_rank'
) THEN
ALTER TABLE `hoj`.`contest` ADD COLUMN `auto_real_rank` BOOLEAN DEFAULT 1 NULL COMMENT '比赛结束是否自动解除封榜,自动转换成真实榜单';
DROP TABLE `hoj`.`training_problem`;
DROP TABLE `hoj`.`training_record`;
CREATE TABLE `training_problem` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`tid` bigint unsigned NOT NULL COMMENT '训练id',
`pid` bigint unsigned NOT NULL COMMENT '题目id',
`rank` int DEFAULT '0',
`display_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`gmt_create` datetime DEFAULT CURRENT_TIMESTAMP,
`gmt_modified` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `tid` (`tid`),
KEY `pid` (`pid`),
KEY `display_id` (`display_id`),
CONSTRAINT `training_problem_ibfk_1` FOREIGN KEY (`tid`) REFERENCES `training` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `training_problem_ibfk_2` FOREIGN KEY (`pid`) REFERENCES `problem` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `training_problem_ibfk_3` FOREIGN KEY (`display_id`) REFERENCES `problem` (`problem_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `training_record` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT,
`tid` bigint unsigned NOT NULL,
`tpid` bigint unsigned NOT NULL,
`pid` bigint unsigned NOT NULL,
`uid` varchar(255) NOT NULL,
`submit_id` bigint unsigned NOT NULL,
`gmt_create` datetime DEFAULT CURRENT_TIMESTAMP,
`gmt_modified` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `tid` (`tid`),
KEY `tpid` (`tpid`),
KEY `pid` (`pid`),
KEY `uid` (`uid`),
KEY `submit_id` (`submit_id`),
CONSTRAINT `training_record_ibfk_1` FOREIGN KEY (`tid`) REFERENCES `training` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `training_record_ibfk_2` FOREIGN KEY (`tpid`) REFERENCES `training_problem` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `training_record_ibfk_3` FOREIGN KEY (`pid`) REFERENCES `problem` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `training_record_ibfk_4` FOREIGN KEY (`uid`) REFERENCES `user_info` (`uuid`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `training_record_ibfk_5` FOREIGN KEY (`submit_id`) REFERENCES `judge` (`submit_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
END
IF ; END$$
DELIMITER ;
2021-12-07 07:53:51 +08:00
CALL contest_Add_auto_real_rank;
2021-12-07 07:53:51 +08:00
DROP PROCEDURE contest_Add_auto_real_rank;
2021-12-19 10:55:02 +08:00
/*
* 2021.12.07 contest增加打星账号列表
*/
DROP PROCEDURE
IF EXISTS contest_Add_star_account_And_open_rank;
DELIMITER $$
CREATE PROCEDURE contest_Add_star_account_And_open_rank ()
BEGIN
IF NOT EXISTS (
SELECT
1
FROM
information_schema.`COLUMNS`
WHERE
table_name = 'contest'
AND column_name = 'star_account'
) THEN
ALTER TABLE `hoj`.`contest` ADD COLUMN `star_account` mediumtext COMMENT '打星用户列表';
ALTER TABLE `hoj`.`contest` ADD COLUMN `open_rank` BOOLEAN DEFAULT 0 NULL COMMENT '是否开放比赛榜单';
END
IF ; END$$
DELIMITER ;
CALL contest_Add_star_account_And_open_rank ;
DROP PROCEDURE contest_Add_star_account_And_open_rank;
/*
* 2021.12.19 judge表删除tid
*/
DROP PROCEDURE
IF EXISTS judge_Delete_tid;
DELIMITER $$
CREATE PROCEDURE judge_Delete_tid ()
BEGIN
IF EXISTS (
SELECT
1
FROM
information_schema.`COLUMNS`
WHERE
table_name = 'judge'
AND column_name = 'tid'
) THEN
ALTER TABLE `hoj`.`judge` DROP foreign key `judge_ibfk_4`;
ALTER TABLE `hoj`.`judge` DROP COLUMN `tid`;
END
IF ; END$$
DELIMITER ;
CALL judge_Delete_tid ;
DROP PROCEDURE judge_Delete_tid;