加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
hoj-update.sql 18.93 KB
一键复制 编辑 原始数据 按行查看 历史
Himit_ZH 提交于 2021-12-19 10:55 . delete judge.tid
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
USE `hoj`;
/*
* 2021.08.07 修改OI题目得分在OI排行榜新计分字段 分数计算为:OI题目总得分*0.1+2*题目难度
*/
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'
AND column_name = 'oi_rank'
) THEN
ALTER TABLE judge ADD COLUMN oi_rank INT(11) NULL COMMENT '该题在OI排行榜的分数';
END
IF ; END$$
DELIMITER ;
CALL judge_Add_oi_rank_score ;
DROP PROCEDURE judge_Add_oi_rank_score;
/*
* 2021.08.08 增加vjudge_submit_id在vjudge判题获取提交id后存储,当等待结果超时,下次重判时可用该提交id直接获取结果。
同时vjudge_username、vjudge_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 比赛增加打印、账号限制的功能,增大真实姓名长度
*/
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 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 ;
DROP PROCEDURE contest_problem_Add_color;
/*
* 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.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,
`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;
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 $$
CREATE PROCEDURE contest_Add_auto_real_rank()
BEGIN
IF NOT EXISTS (
SELECT
1
FROM
information_schema.`COLUMNS`
WHERE
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 ;
CALL contest_Add_auto_real_rank;
DROP PROCEDURE contest_Add_auto_real_rank;
/*
* 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;
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化