2021-02-08 01:10:24 +08:00
/*
SQLyog Professional v12 . 09 ( 64 bit )
MySQL - 5 . 7 . 29 - 0 ubuntu0 . 18 . 04 . 1 : Database - hoj
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* /
/* !40101 SET NAMES utf8 */ ;
/* !40101 SET SQL_MODE='' */ ;
/* !40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */ ;
/* !40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */ ;
/* !40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */ ;
/* !40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */ ;
CREATE DATABASE /* !32312 IF NOT EXISTS */ ` hoj ` /* !40100 DEFAULT CHARACTER SET utf8 */ ;
USE ` hoj ` ;
/* Table structure for table `announcement` */
DROP TABLE IF EXISTS ` announcement ` ;
CREATE TABLE ` announcement ` (
` id ` bigint ( 20 ) unsigned NOT NULL AUTO_INCREMENT ,
` title ` varchar ( 255 ) NOT NULL ,
` content ` longtext ,
` uid ` varchar ( 255 ) DEFAULT NULL ,
` status ` int ( 11 ) DEFAULT ' 0 ' COMMENT ' 0可见, 1不可见 ' ,
` gmt_create ` datetime DEFAULT CURRENT_TIMESTAMP ,
` gmt_modified ` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
PRIMARY KEY ( ` id ` ) ,
KEY ` uid ` ( ` uid ` ) ,
CONSTRAINT ` announcement_ibfk_1 ` FOREIGN KEY ( ` uid ` ) REFERENCES ` user_info ` ( ` uuid ` ) ON DELETE CASCADE ON UPDATE CASCADE
2021-04-13 12:59:57 +08:00
) ENGINE = InnoDB AUTO_INCREMENT = 2 DEFAULT CHARSET = utf8 ;
2021-02-08 01:10:24 +08:00
/* Table structure for table `auth` */
DROP TABLE IF EXISTS ` auth ` ;
CREATE TABLE ` auth ` (
` id ` bigint ( 20 ) unsigned NOT NULL AUTO_INCREMENT ,
` name ` varchar ( 100 ) DEFAULT NULL COMMENT ' 权限名称 ' ,
` permission ` varchar ( 100 ) DEFAULT NULL COMMENT ' 权限字符串 ' ,
` status ` tinyint ( 4 ) NOT NULL DEFAULT ' 0 ' COMMENT ' 0可用, 1不可用 ' ,
` gmt_create ` datetime DEFAULT CURRENT_TIMESTAMP ,
` gmt_modified ` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
PRIMARY KEY ( ` id ` )
) ENGINE = InnoDB AUTO_INCREMENT = 8 DEFAULT CHARSET = utf8 ;
2021-05-09 23:41:34 +08:00
/* Table structure for table `category` */
DROP TABLE IF EXISTS ` category ` ;
CREATE TABLE ` category ` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` name ` 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 AUTO_INCREMENT = 6 DEFAULT CHARSET = utf8 ;
2021-04-24 19:59:56 +08:00
/* Table structure for table `code_template` */
DROP TABLE IF EXISTS ` code_template ` ;
CREATE TABLE ` code_template ` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` pid ` bigint ( 20 ) unsigned NOT NULL ,
` lid ` bigint ( 20 ) unsigned NOT NULL ,
` code ` longtext NOT NULL ,
` status ` tinyint ( 1 ) DEFAULT ' 0 ' ,
` gmt_create ` datetime DEFAULT CURRENT_TIMESTAMP ,
` gmt_modified ` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
PRIMARY KEY ( ` id ` ) ,
KEY ` pid ` ( ` pid ` ) ,
KEY ` lid ` ( ` lid ` ) ,
CONSTRAINT ` code_template_ibfk_1 ` FOREIGN KEY ( ` pid ` ) REFERENCES ` problem ` ( ` id ` ) ON DELETE CASCADE ON UPDATE CASCADE ,
CONSTRAINT ` code_template_ibfk_2 ` FOREIGN KEY ( ` lid ` ) REFERENCES ` language ` ( ` id ` ) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE = InnoDB AUTO_INCREMENT = 10 DEFAULT CHARSET = utf8 ;
2021-02-08 01:10:24 +08:00
/* Table structure for table `comment` */
DROP TABLE IF EXISTS ` comment ` ;
CREATE TABLE ` comment ` (
2021-05-09 23:41:34 +08:00
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` cid ` bigint ( 20 ) unsigned DEFAULT NULL COMMENT ' null表示无引用比赛 ' ,
` did ` int ( 11 ) DEFAULT NULL COMMENT ' null表示无引用讨论 ' ,
` content ` longtext COMMENT ' 评论内容 ' ,
` from_uid ` varchar ( 32 ) NOT NULL COMMENT ' 评论者id ' ,
` from_name ` varchar ( 255 ) DEFAULT NULL COMMENT ' 评论者用户名 ' ,
` from_avatar ` varchar ( 255 ) DEFAULT NULL COMMENT ' 评论组头像地址 ' ,
` from_role ` varchar ( 20 ) DEFAULT NULL COMMENT ' 评论者角色 ' ,
` like_num ` int ( 11 ) DEFAULT ' 0 ' COMMENT ' 点赞数量 ' ,
` gmt_create ` datetime DEFAULT CURRENT_TIMESTAMP ,
` gmt_modified ` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
PRIMARY KEY ( ` id ` ) ,
KEY ` uid ` ( ` from_uid ` ) ,
KEY ` from_avatar ` ( ` from_avatar ` ) ,
KEY ` comment_ibfk_7 ` ( ` did ` ) ,
KEY ` cid ` ( ` cid ` ) ,
CONSTRAINT ` comment_ibfk_6 ` FOREIGN KEY ( ` from_avatar ` ) REFERENCES ` user_info ` ( ` avatar ` ) ON DELETE NO ACTION ON UPDATE CASCADE ,
CONSTRAINT ` comment_ibfk_7 ` FOREIGN KEY ( ` did ` ) REFERENCES ` discussion ` ( ` id ` ) ON DELETE CASCADE ON UPDATE CASCADE ,
CONSTRAINT ` comment_ibfk_8 ` FOREIGN KEY ( ` cid ` ) REFERENCES ` contest ` ( ` id ` ) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE = InnoDB AUTO_INCREMENT = 17 DEFAULT CHARSET = utf8 ;
/* Table structure for table `comment_like` */
DROP TABLE IF EXISTS ` comment_like ` ;
CREATE TABLE ` comment_like ` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` uid ` varchar ( 255 ) NOT NULL ,
` cid ` int ( 11 ) NOT NULL ,
2021-02-08 01:10:24 +08:00
` gmt_create ` datetime DEFAULT CURRENT_TIMESTAMP ,
` gmt_modified ` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
PRIMARY KEY ( ` id ` ) ,
KEY ` uid ` ( ` uid ` ) ,
KEY ` cid ` ( ` cid ` ) ,
2021-05-09 23:41:34 +08:00
CONSTRAINT ` comment_like_ibfk_1 ` FOREIGN KEY ( ` uid ` ) REFERENCES ` user_info ` ( ` uuid ` ) ON DELETE NO ACTION ON UPDATE CASCADE ,
CONSTRAINT ` comment_like_ibfk_2 ` FOREIGN KEY ( ` cid ` ) REFERENCES ` comment ` ( ` id ` ) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE = InnoDB AUTO_INCREMENT = 5 DEFAULT CHARSET = utf8 ;
2021-02-08 01:10:24 +08:00
/* Table structure for table `contest` */
DROP TABLE IF EXISTS ` contest ` ;
CREATE TABLE ` contest ` (
` id ` bigint ( 20 ) unsigned NOT NULL AUTO_INCREMENT ,
` uid ` varchar ( 32 ) NOT NULL COMMENT ' 比赛创建者id ' ,
` author ` varchar ( 255 ) DEFAULT NULL COMMENT ' 比赛创建者的用户名 ' ,
` title ` varchar ( 255 ) DEFAULT NULL COMMENT ' 比赛标题 ' ,
` type ` int ( 11 ) NOT NULL DEFAULT ' 0 ' COMMENT ' 0为acm赛制, 1为比分赛制 ' ,
` description ` longtext COMMENT ' 比赛说明 ' ,
` source ` int ( 11 ) DEFAULT ' 0 ' COMMENT ' 比赛来源, 原创为0, 克隆赛为比赛id ' ,
` auth ` int ( 11 ) NOT NULL COMMENT ' 0为公开赛, 1为私有赛( 访问有密码) , 2为保护赛( 提交有密码) ' ,
` pwd ` varchar ( 255 ) DEFAULT NULL COMMENT ' 比赛密码 ' ,
` start_time ` datetime DEFAULT NULL COMMENT ' 开始时间 ' ,
` end_time ` datetime DEFAULT NULL COMMENT ' 结束时间 ' ,
` duration ` bigint ( 20 ) DEFAULT NULL COMMENT ' 比赛时长(s) ' ,
` seal_rank ` tinyint ( 1 ) DEFAULT ' 0 ' COMMENT ' 是否开启封榜 ' ,
` seal_rank_time ` datetime DEFAULT NULL COMMENT ' 封榜起始时间,一直到比赛结束,不刷新榜单 ' ,
` status ` int ( 11 ) DEFAULT NULL COMMENT ' -1为未开始, 0为进行中, 1为已结束 ' ,
` gmt_create ` datetime DEFAULT CURRENT_TIMESTAMP ,
` gmt_modified ` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
PRIMARY KEY ( ` id ` , ` uid ` ) ,
KEY ` uid ` ( ` uid ` ) ,
CONSTRAINT ` contest_ibfk_1 ` FOREIGN KEY ( ` uid ` ) REFERENCES ` user_info ` ( ` uuid ` ) ON DELETE NO ACTION ON UPDATE CASCADE
2021-04-24 19:59:56 +08:00
) ENGINE = InnoDB AUTO_INCREMENT = 1002 DEFAULT CHARSET = utf8 ;
2021-02-08 01:10:24 +08:00
/* Table structure for table `contest_announcement` */
DROP TABLE IF EXISTS ` contest_announcement ` ;
CREATE TABLE ` contest_announcement ` (
` id ` bigint ( 20 ) unsigned NOT NULL AUTO_INCREMENT ,
` aid ` bigint ( 20 ) unsigned NOT NULL COMMENT ' 公告id ' ,
` cid ` bigint ( 20 ) unsigned NOT NULL COMMENT ' 比赛id ' ,
` gmt_create ` datetime DEFAULT CURRENT_TIMESTAMP ,
` gmt_modified ` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
PRIMARY KEY ( ` id ` ) ,
KEY ` contest_announcement_ibfk_1 ` ( ` cid ` ) ,
KEY ` contest_announcement_ibfk_2 ` ( ` aid ` ) ,
CONSTRAINT ` contest_announcement_ibfk_1 ` FOREIGN KEY ( ` cid ` ) REFERENCES ` contest ` ( ` id ` ) ON DELETE CASCADE ON UPDATE CASCADE ,
CONSTRAINT ` contest_announcement_ibfk_2 ` FOREIGN KEY ( ` aid ` ) REFERENCES ` announcement ` ( ` id ` ) ON DELETE CASCADE ON UPDATE CASCADE
2021-04-13 12:59:57 +08:00
) ENGINE = InnoDB DEFAULT CHARSET = utf8 ;
2021-02-08 01:10:24 +08:00
/* Table structure for table `contest_explanation` */
DROP TABLE IF EXISTS ` contest_explanation ` ;
CREATE TABLE ` contest_explanation ` (
` id ` bigint ( 20 ) unsigned NOT NULL AUTO_INCREMENT ,
` cid ` bigint ( 20 ) unsigned NOT NULL ,
` uid ` varchar ( 32 ) NOT NULL COMMENT ' 发布者(必须为比赛创建者或者超级管理员才能) ' ,
` content ` longtext COMMENT ' 内容(支持markdown) ' ,
` gmt_create ` datetime DEFAULT CURRENT_TIMESTAMP ,
` gmt_modified ` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
PRIMARY KEY ( ` id ` ) ,
KEY ` uid ` ( ` uid ` ) ,
KEY ` contest_explanation_ibfk_1 ` ( ` cid ` ) ,
CONSTRAINT ` contest_explanation_ibfk_1 ` FOREIGN KEY ( ` cid ` ) REFERENCES ` contest ` ( ` id ` ) ON DELETE CASCADE ON UPDATE CASCADE ,
CONSTRAINT ` contest_explanation_ibfk_2 ` FOREIGN KEY ( ` uid ` ) REFERENCES ` user_info ` ( ` uuid ` ) ON DELETE NO ACTION ON UPDATE CASCADE
) ENGINE = InnoDB DEFAULT CHARSET = utf8 ;
/* Table structure for table `contest_problem` */
DROP TABLE IF EXISTS ` contest_problem ` ;
CREATE TABLE ` contest_problem ` (
` id ` bigint ( 20 ) unsigned NOT NULL AUTO_INCREMENT COMMENT ' 主键 ' ,
` display_id ` varchar ( 255 ) NOT NULL COMMENT ' 该题目在比赛中的顺序id ' ,
` cid ` bigint ( 20 ) unsigned NOT NULL COMMENT ' 比赛id ' ,
` pid ` bigint ( 20 ) unsigned NOT NULL COMMENT ' 题目id ' ,
` display_title ` varchar ( 255 ) NOT NULL COMMENT ' 该题目在比赛中的标题,默认为原名字 ' ,
` gmt_create ` datetime DEFAULT CURRENT_TIMESTAMP ,
` gmt_modified ` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
PRIMARY KEY ( ` id ` , ` cid ` , ` pid ` ) ,
UNIQUE KEY ` display_id ` ( ` display_id ` , ` cid ` , ` pid ` ) ,
KEY ` contest_problem_ibfk_1 ` ( ` cid ` ) ,
KEY ` contest_problem_ibfk_2 ` ( ` pid ` ) ,
CONSTRAINT ` contest_problem_ibfk_1 ` FOREIGN KEY ( ` cid ` ) REFERENCES ` contest ` ( ` id ` ) ON DELETE CASCADE ON UPDATE CASCADE ,
CONSTRAINT ` contest_problem_ibfk_2 ` FOREIGN KEY ( ` pid ` ) REFERENCES ` problem ` ( ` id ` ) ON DELETE CASCADE ON UPDATE CASCADE
2021-04-24 19:59:56 +08:00
) ENGINE = InnoDB AUTO_INCREMENT = 7 DEFAULT CHARSET = utf8 ;
2021-02-08 01:10:24 +08:00
/* Table structure for table `contest_record` */
DROP TABLE IF EXISTS ` contest_record ` ;
CREATE TABLE ` contest_record ` (
` id ` bigint ( 20 ) unsigned NOT NULL AUTO_INCREMENT COMMENT ' 主键 ' ,
` cid ` bigint ( 20 ) unsigned DEFAULT NULL COMMENT ' 比赛id ' ,
` uid ` varchar ( 255 ) NOT NULL COMMENT ' 用户id ' ,
` pid ` bigint ( 20 ) unsigned DEFAULT NULL COMMENT ' 题目id ' ,
` cpid ` bigint ( 20 ) unsigned DEFAULT NULL COMMENT ' 比赛中的题目的id ' ,
` username ` varchar ( 255 ) DEFAULT NULL COMMENT ' 用户名 ' ,
` realname ` varchar ( 255 ) DEFAULT NULL COMMENT ' 真实姓名 ' ,
` display_id ` varchar ( 255 ) DEFAULT NULL COMMENT ' 比赛中展示的id ' ,
` submit_id ` bigint ( 20 ) unsigned NOT NULL COMMENT ' 提交id, 用于可重判 ' ,
` status ` int ( 11 ) DEFAULT NULL COMMENT ' 提交结果, 0表示未AC通过不罚时, 1表示AC通过, -1为未AC通过算罚时 ' ,
` submit_time ` datetime NOT NULL COMMENT ' 具体提交时间 ' ,
` time ` bigint ( 20 ) unsigned DEFAULT NULL COMMENT ' 提交时间,为提交时间减去比赛时间 ' ,
` score ` int ( 11 ) DEFAULT NULL COMMENT ' OI比赛的得分 ' ,
` first_blood ` tinyint ( 1 ) DEFAULT ' 0 ' COMMENT ' 是否为一血AC ' ,
` checked ` tinyint ( 1 ) DEFAULT ' 0 ' COMMENT ' AC是否已校验 ' ,
` gmt_create ` datetime DEFAULT CURRENT_TIMESTAMP ,
` gmt_modified ` datetime DEFAULT CURRENT_TIMESTAMP ,
PRIMARY KEY ( ` id ` , ` submit_id ` ) ,
KEY ` uid ` ( ` uid ` ) ,
KEY ` pid ` ( ` pid ` ) ,
KEY ` cpid ` ( ` cpid ` ) ,
KEY ` submit_id ` ( ` submit_id ` ) ,
KEY ` index_cid ` ( ` cid ` ) ,
KEY ` index_time ` ( ` time ` ) ,
CONSTRAINT ` contest_record_ibfk_1 ` FOREIGN KEY ( ` cid ` ) REFERENCES ` contest ` ( ` id ` ) ON DELETE SET NULL ON UPDATE CASCADE ,
CONSTRAINT ` contest_record_ibfk_2 ` FOREIGN KEY ( ` uid ` ) REFERENCES ` user_info ` ( ` uuid ` ) ON DELETE NO ACTION ON UPDATE CASCADE ,
CONSTRAINT ` contest_record_ibfk_3 ` FOREIGN KEY ( ` pid ` ) REFERENCES ` problem ` ( ` id ` ) ON DELETE NO ACTION ON UPDATE CASCADE ,
CONSTRAINT ` contest_record_ibfk_4 ` FOREIGN KEY ( ` cpid ` ) REFERENCES ` contest_problem ` ( ` id ` ) ON DELETE NO ACTION ON UPDATE CASCADE ,
CONSTRAINT ` contest_record_ibfk_5 ` FOREIGN KEY ( ` submit_id ` ) REFERENCES ` judge ` ( ` submit_id ` ) ON DELETE NO ACTION ON UPDATE CASCADE
2021-04-24 19:59:56 +08:00
) ENGINE = InnoDB AUTO_INCREMENT = 33 DEFAULT CHARSET = utf8 ;
2021-02-08 01:10:24 +08:00
/* Table structure for table `contest_register` */
DROP TABLE IF EXISTS ` contest_register ` ;
CREATE TABLE ` contest_register ` (
` id ` bigint ( 20 ) unsigned NOT NULL AUTO_INCREMENT ,
` cid ` bigint ( 20 ) unsigned NOT NULL COMMENT ' 比赛id ' ,
` uid ` varchar ( 32 ) NOT NULL COMMENT ' 用户id ' ,
` status ` int ( 11 ) DEFAULT ' 0 ' COMMENT ' 默认为0表示正常, 1为失效。 ' ,
` gmt_create ` datetime DEFAULT CURRENT_TIMESTAMP ,
` gmt_modified ` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
PRIMARY KEY ( ` id ` , ` cid ` , ` uid ` ) ,
UNIQUE KEY ` cid_uid_unique ` ( ` cid ` , ` uid ` ) ,
KEY ` contest_register_ibfk_2 ` ( ` uid ` ) ,
CONSTRAINT ` contest_register_ibfk_1 ` FOREIGN KEY ( ` cid ` ) REFERENCES ` contest ` ( ` id ` ) ON DELETE CASCADE ON UPDATE CASCADE ,
CONSTRAINT ` contest_register_ibfk_2 ` FOREIGN KEY ( ` uid ` ) REFERENCES ` user_info ` ( ` uuid ` ) ON DELETE CASCADE ON UPDATE CASCADE
2021-04-13 12:59:57 +08:00
) ENGINE = InnoDB DEFAULT CHARSET = utf8 ;
2021-02-08 01:10:24 +08:00
/* Table structure for table `contest_score` */
DROP TABLE IF EXISTS ` contest_score ` ;
CREATE TABLE ` contest_score ` (
` id ` bigint ( 20 ) unsigned NOT NULL AUTO_INCREMENT ,
` cid ` bigint ( 20 ) unsigned NOT NULL ,
` last ` int ( 11 ) DEFAULT NULL COMMENT ' 比赛前的score得分 ' ,
` change ` int ( 11 ) DEFAULT NULL COMMENT ' Score比分变化 ' ,
` now ` int ( 11 ) DEFAULT NULL COMMENT ' 现在的score ' ,
` gmt_create ` datetime DEFAULT CURRENT_TIMESTAMP ,
` gmt_modified ` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
PRIMARY KEY ( ` id ` , ` cid ` ) ,
KEY ` contest_score_ibfk_1 ` ( ` cid ` ) ,
CONSTRAINT ` contest_score_ibfk_1 ` FOREIGN KEY ( ` cid ` ) REFERENCES ` contest ` ( ` id ` ) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE = InnoDB DEFAULT CHARSET = utf8 ;
2021-05-09 23:41:34 +08:00
/* Table structure for table `discussion` */
DROP TABLE IF EXISTS ` discussion ` ;
CREATE TABLE ` discussion ` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` category_id ` int ( 11 ) NOT NULL COMMENT ' 分类id ' ,
` title ` varchar ( 255 ) DEFAULT NULL COMMENT ' 讨论标题 ' ,
` description ` varchar ( 255 ) DEFAULT NULL COMMENT ' 讨论简介 ' ,
` content ` longtext COMMENT ' 讨论内容 ' ,
` pid ` varchar ( 255 ) DEFAULT NULL COMMENT ' 关联题目id ' ,
` uid ` varchar ( 32 ) NOT NULL COMMENT ' 发表者id ' ,
` author ` varchar ( 255 ) NOT NULL COMMENT ' 发表者用户名 ' ,
` avatar ` varchar ( 255 ) DEFAULT NULL COMMENT ' 发表讨论者头像 ' ,
` role ` varchar ( 25 ) DEFAULT ' user ' COMMENT ' 发表者角色 ' ,
` view_num ` int ( 11 ) DEFAULT ' 0 ' COMMENT ' 浏览数量 ' ,
` like_num ` int ( 11 ) DEFAULT ' 0 ' COMMENT ' 点赞数量 ' ,
` top_priority ` tinyint ( 1 ) DEFAULT ' 0 ' COMMENT ' 优先级,是否置顶 ' ,
` status ` tinyint ( 1 ) DEFAULT ' 0 ' COMMENT ' 是否封禁 ' ,
` gmt_create ` datetime DEFAULT CURRENT_TIMESTAMP ,
` gmt_modified ` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
PRIMARY KEY ( ` id ` ) ,
KEY ` category_id ` ( ` category_id ` ) ,
KEY ` discussion_ibfk_4 ` ( ` avatar ` ) ,
KEY ` discussion_ibfk_1 ` ( ` uid ` ) ,
KEY ` pid ` ( ` pid ` ) ,
CONSTRAINT ` discussion_ibfk_1 ` FOREIGN KEY ( ` uid ` ) REFERENCES ` user_info ` ( ` uuid ` ) ON DELETE NO ACTION ON UPDATE CASCADE ,
CONSTRAINT ` discussion_ibfk_2 ` FOREIGN KEY ( ` category_id ` ) REFERENCES ` category ` ( ` id ` ) ON DELETE NO ACTION ON UPDATE CASCADE ,
CONSTRAINT ` discussion_ibfk_4 ` FOREIGN KEY ( ` avatar ` ) REFERENCES ` user_info ` ( ` avatar ` ) ON DELETE NO ACTION ON UPDATE CASCADE ,
CONSTRAINT ` discussion_ibfk_6 ` FOREIGN KEY ( ` pid ` ) REFERENCES ` problem ` ( ` problem_id ` ) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE = InnoDB AUTO_INCREMENT = 6 DEFAULT CHARSET = utf8 ;
/* Table structure for table `discussion_like` */
DROP TABLE IF EXISTS ` discussion_like ` ;
CREATE TABLE ` discussion_like ` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` uid ` varchar ( 255 ) NOT NULL ,
` did ` int ( 11 ) NOT NULL ,
` gmt_create ` datetime DEFAULT CURRENT_TIMESTAMP ,
` gmt_modified ` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
PRIMARY KEY ( ` id ` ) ,
KEY ` did ` ( ` did ` ) ,
KEY ` uid ` ( ` uid ` ) ,
CONSTRAINT ` discussion_like_ibfk_1 ` FOREIGN KEY ( ` did ` ) REFERENCES ` discussion ` ( ` id ` ) ON DELETE CASCADE ON UPDATE CASCADE ,
CONSTRAINT ` discussion_like_ibfk_2 ` FOREIGN KEY ( ` uid ` ) REFERENCES ` user_info ` ( ` uuid ` ) ON DELETE NO ACTION ON UPDATE CASCADE
) ENGINE = InnoDB AUTO_INCREMENT = 4 DEFAULT CHARSET = utf8 ;
2021-02-08 01:10:24 +08:00
/* Table structure for table `file` */
DROP TABLE IF EXISTS ` file ` ;
CREATE TABLE ` file ` (
` id ` bigint ( 32 ) unsigned NOT NULL AUTO_INCREMENT COMMENT ' 主键 ' ,
` uid ` varchar ( 32 ) DEFAULT NULL COMMENT ' 用户id ' ,
` name ` varchar ( 255 ) NOT NULL COMMENT ' 文件名 ' ,
` suffix ` varchar ( 255 ) NOT NULL COMMENT ' 文件后缀格式 ' ,
` folder_path ` varchar ( 255 ) NOT NULL COMMENT ' 文件所在文件夹的路径 ' ,
` file_path ` varchar ( 255 ) DEFAULT NULL COMMENT ' 文件绝对路径 ' ,
` type ` varchar ( 255 ) DEFAULT NULL COMMENT ' 文件所属类型, 例如avatar ' ,
` delete ` tinyint ( 1 ) DEFAULT ' 0 ' COMMENT ' 是否删除 ' ,
` gmt_create ` datetime DEFAULT CURRENT_TIMESTAMP ,
` gmt_modified ` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
PRIMARY KEY ( ` id ` ) ,
KEY ` uid ` ( ` uid ` ) ,
CONSTRAINT ` file_ibfk_1 ` FOREIGN KEY ( ` uid ` ) REFERENCES ` user_info ` ( ` uuid ` ) ON DELETE SET NULL ON UPDATE CASCADE
2021-04-24 19:59:56 +08:00
) ENGINE = InnoDB AUTO_INCREMENT = 27 DEFAULT CHARSET = utf8 ;
2021-02-08 01:10:24 +08:00
/* Table structure for table `judge` */
DROP TABLE IF EXISTS ` judge ` ;
CREATE TABLE ` judge ` (
` submit_id ` bigint ( 20 ) unsigned NOT NULL AUTO_INCREMENT ,
` pid ` bigint ( 20 ) unsigned NOT NULL COMMENT ' 题目id ' ,
2021-03-03 21:22:41 +08:00
` display_pid ` varchar ( 255 ) NOT NULL COMMENT ' 题目展示id ' ,
2021-02-08 01:10:24 +08:00
` uid ` varchar ( 32 ) NOT NULL COMMENT ' 用户id ' ,
` username ` varchar ( 255 ) DEFAULT NULL COMMENT ' 用户名 ' ,
` submit_time ` datetime NOT NULL COMMENT ' 提交的时间 ' ,
` status ` int ( 11 ) DEFAULT NULL COMMENT ' 结果码具体参考文档 ' ,
` share ` tinyint ( 1 ) DEFAULT ' 0 ' COMMENT ' 0为仅自己可见, 1为全部人可见。 ' ,
` error_message ` mediumtext COMMENT ' 错误提醒( 编译错误, 或者vj提醒) ' ,
` time ` int ( 11 ) DEFAULT NULL COMMENT ' 运行时间(ms) ' ,
` memory ` int ( 11 ) DEFAULT NULL COMMENT ' 运行内存( kb) ' ,
` score ` int ( 11 ) DEFAULT NULL COMMENT ' IO判题则不为空 ' ,
` length ` int ( 11 ) DEFAULT NULL COMMENT ' 代码长度 ' ,
` code ` longtext NOT NULL COMMENT ' 代码 ' ,
` language ` varchar ( 30 ) DEFAULT NULL COMMENT ' 代码语言 ' ,
` cid ` bigint ( 20 ) unsigned NOT NULL DEFAULT ' 0 ' COMMENT ' 比赛id, 非比赛题目默认为0 ' ,
` cpid ` bigint ( 20 ) unsigned DEFAULT ' 0 ' COMMENT ' 比赛中题目排序id, 非比赛题目默认为0 ' ,
` judger ` varchar ( 20 ) DEFAULT NULL COMMENT ' 判题机ip ' ,
` ip ` varchar ( 20 ) DEFAULT NULL COMMENT ' 提交者所在ip ' ,
` version ` int ( 11 ) NOT NULL DEFAULT ' 0 ' COMMENT ' 乐观锁 ' ,
` gmt_create ` datetime DEFAULT CURRENT_TIMESTAMP ,
` gmt_modified ` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
2021-03-03 21:22:41 +08:00
PRIMARY KEY ( ` submit_id ` , ` pid ` , ` display_pid ` , ` uid ` , ` cid ` ) ,
2021-02-08 01:10:24 +08:00
KEY ` pid ` ( ` pid ` ) ,
KEY ` uid ` ( ` uid ` ) ,
KEY ` username ` ( ` username ` ) ,
CONSTRAINT ` judge_ibfk_1 ` FOREIGN KEY ( ` pid ` ) REFERENCES ` problem ` ( ` id ` ) ON DELETE NO ACTION ON UPDATE CASCADE ,
CONSTRAINT ` judge_ibfk_2 ` FOREIGN KEY ( ` uid ` ) REFERENCES ` user_info ` ( ` uuid ` ) ON DELETE NO ACTION ON UPDATE CASCADE ,
CONSTRAINT ` judge_ibfk_3 ` FOREIGN KEY ( ` username ` ) REFERENCES ` user_info ` ( ` username ` ) ON DELETE NO ACTION ON UPDATE CASCADE
2021-05-09 23:41:34 +08:00
) ENGINE = InnoDB AUTO_INCREMENT = 145 DEFAULT CHARSET = utf8 ;
2021-02-08 01:10:24 +08:00
/* Table structure for table `judge_case` */
DROP TABLE IF EXISTS ` judge_case ` ;
CREATE TABLE ` judge_case ` (
` id ` bigint ( 20 ) unsigned NOT NULL AUTO_INCREMENT ,
` submit_id ` bigint ( 20 ) unsigned NOT NULL COMMENT ' 提交判题id ' ,
` uid ` varchar ( 32 ) NOT NULL COMMENT ' 用户id ' ,
` pid ` bigint ( 20 ) unsigned NOT NULL COMMENT ' 题目id ' ,
2021-04-24 19:59:56 +08:00
` case_id ` bigint ( 20 ) DEFAULT NULL COMMENT ' 测试样例id ' ,
2021-02-08 01:10:24 +08:00
` status ` int ( 11 ) DEFAULT NULL COMMENT ' 具体看结果码 ' ,
` time ` int ( 11 ) DEFAULT NULL COMMENT ' 测试该样例所用时间ms ' ,
` memory ` int ( 11 ) DEFAULT NULL COMMENT ' 测试该样例所用空间KB ' ,
` score ` int ( 11 ) DEFAULT NULL COMMENT ' IO得分 ' ,
` input_data ` longtext COMMENT ' 样例输入,比赛不可看 ' ,
` output_data ` longtext COMMENT ' 样例输出,比赛不可看 ' ,
` user_output ` longtext COMMENT ' 用户样例输出,比赛不可看 ' ,
` gmt_create ` datetime DEFAULT CURRENT_TIMESTAMP ,
` gmt_modified ` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
PRIMARY KEY ( ` id ` , ` submit_id ` , ` uid ` , ` pid ` ) ,
KEY ` case_id ` ( ` case_id ` ) ,
KEY ` judge_case_ibfk_1 ` ( ` uid ` ) ,
KEY ` judge_case_ibfk_2 ` ( ` pid ` ) ,
KEY ` judge_case_ibfk_3 ` ( ` submit_id ` ) ,
CONSTRAINT ` judge_case_ibfk_1 ` FOREIGN KEY ( ` uid ` ) REFERENCES ` user_info ` ( ` uuid ` ) ON DELETE CASCADE ON UPDATE CASCADE ,
CONSTRAINT ` judge_case_ibfk_2 ` FOREIGN KEY ( ` pid ` ) REFERENCES ` problem ` ( ` id ` ) ON DELETE CASCADE ON UPDATE CASCADE ,
2021-04-24 19:59:56 +08:00
CONSTRAINT ` judge_case_ibfk_3 ` FOREIGN KEY ( ` submit_id ` ) REFERENCES ` judge ` ( ` submit_id ` ) ON DELETE CASCADE ON UPDATE CASCADE
2021-05-09 23:41:34 +08:00
) ENGINE = InnoDB AUTO_INCREMENT = 1733 DEFAULT CHARSET = utf8 ;
2021-04-15 23:31:30 +08:00
/* Table structure for table `judge_server` */
DROP TABLE IF EXISTS ` judge_server ` ;
CREATE TABLE ` judge_server ` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` name ` varchar ( 255 ) DEFAULT NULL COMMENT ' 判题服务名字 ' ,
` ip ` varchar ( 255 ) NOT NULL COMMENT ' 判题机ip ' ,
` port ` int ( 11 ) NOT NULL COMMENT ' 判题机端口号 ' ,
` url ` varchar ( 255 ) DEFAULT NULL COMMENT ' ip:port ' ,
` cpu_core ` int ( 11 ) DEFAULT ' 0 ' COMMENT ' 判题机所在服务器cpu核心数 ' ,
` task_number ` int ( 11 ) NOT NULL DEFAULT ' 0 ' COMMENT ' 当前判题数 ' ,
` max_task_number ` int ( 11 ) NOT NULL COMMENT ' 判题并发最大数 ' ,
` status ` int ( 11 ) DEFAULT ' 0 ' COMMENT ' 0可用, 1不可用 ' ,
` version ` bigint ( 20 ) DEFAULT ' 0 ' COMMENT ' 版本控制 ' ,
` is_remote ` tinyint ( 1 ) DEFAULT NULL COMMENT ' 是否为远程判题vj ' ,
` gmt_create ` datetime DEFAULT CURRENT_TIMESTAMP ,
` gmt_modified ` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
PRIMARY KEY ( ` id ` )
2021-05-09 23:41:34 +08:00
) ENGINE = InnoDB AUTO_INCREMENT = 132 DEFAULT CHARSET = utf8 ;
2021-02-08 01:10:24 +08:00
/* Table structure for table `language` */
DROP TABLE IF EXISTS ` language ` ;
CREATE TABLE ` language ` (
` id ` bigint ( 20 ) unsigned NOT NULL AUTO_INCREMENT COMMENT ' 主键 ' ,
` content_type ` varchar ( 255 ) DEFAULT NULL COMMENT ' 语言类型 ' ,
` description ` varchar ( 255 ) DEFAULT NULL COMMENT ' 语言描述 ' ,
` name ` varchar ( 255 ) DEFAULT NULL COMMENT ' 语言名字 ' ,
` compile_command ` mediumtext COMMENT ' 编译指令 ' ,
` template ` longtext COMMENT ' 模板 ' ,
2021-04-24 19:59:56 +08:00
` code_template ` longtext COMMENT ' 语言默认代码模板 ' ,
2021-02-08 01:10:24 +08:00
` is_spj ` tinyint ( 1 ) DEFAULT ' 0 ' COMMENT ' 是否可作为特殊判题的一种语言 ' ,
2021-03-03 21:22:41 +08:00
` oj ` varchar ( 255 ) DEFAULT NULL COMMENT ' 该语言属于哪个oj, 自身oj用ME ' ,
2021-02-08 01:10:24 +08:00
` gmt_create ` datetime DEFAULT CURRENT_TIMESTAMP ,
` gmt_modified ` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
PRIMARY KEY ( ` id ` )
2021-04-15 23:31:30 +08:00
) ENGINE = InnoDB AUTO_INCREMENT = 44 DEFAULT CHARSET = utf8 ;
2021-02-08 01:10:24 +08:00
/* Table structure for table `problem` */
DROP TABLE IF EXISTS ` problem ` ;
CREATE TABLE ` problem ` (
` id ` bigint ( 20 ) unsigned NOT NULL AUTO_INCREMENT ,
2021-03-03 21:22:41 +08:00
` problem_id ` varchar ( 255 ) NOT NULL COMMENT ' 问题的自定义ID 例如( HOJ-1000) ' ,
2021-02-08 01:10:24 +08:00
` title ` varchar ( 255 ) NOT NULL COMMENT ' 题目 ' ,
` author ` varchar ( 255 ) DEFAULT ' 未知 ' COMMENT ' 作者 ' ,
` type ` int ( 11 ) NOT NULL DEFAULT ' 0 ' COMMENT ' 0为ACM,1为OI ' ,
` time_limit ` int ( 11 ) DEFAULT ' 1000 ' COMMENT ' 单位ms ' ,
` memory_limit ` int ( 11 ) DEFAULT ' 65535 ' COMMENT ' 单位kb ' ,
` description ` longtext COMMENT ' 描述 ' ,
` input ` longtext COMMENT ' 输入描述 ' ,
` output ` longtext COMMENT ' 输出描述 ' ,
` examples ` longtext COMMENT ' 题面样例 ' ,
2021-03-03 21:22:41 +08:00
` is_remote ` tinyint ( 1 ) DEFAULT ' 0 ' COMMENT ' 是否为vj判题 ' ,
` source ` text COMMENT ' 题目来源 ' ,
2021-02-08 01:10:24 +08:00
` difficulty ` int ( 11 ) DEFAULT ' 0 ' COMMENT ' 题目难度,0简单, 1中等, 2困难 ' ,
` hint ` longtext COMMENT ' 备注,提醒 ' ,
` auth ` int ( 11 ) DEFAULT ' 1 ' COMMENT ' 默认为1公开, 2为私有, 3为比赛题目 ' ,
` io_score ` int ( 11 ) DEFAULT ' 100 ' COMMENT ' 当该题目为io题目时的分数 ' ,
` code_share ` tinyint ( 1 ) DEFAULT ' 1 ' COMMENT ' 该题目对应的相关提交代码,用户是否可用分享 ' ,
` spj_code ` longtext COMMENT ' 特判程序代码 空代表非特判 ' ,
` spj_language ` varchar ( 255 ) DEFAULT NULL COMMENT ' 特判程序的语言 ' ,
` is_remove_end_blank ` tinyint ( 1 ) DEFAULT ' 1 ' COMMENT ' 是否默认去除用户代码的文末空格 ' ,
` open_case_result ` tinyint ( 1 ) DEFAULT ' 1 ' COMMENT ' 是否默认开启该题目的测试样例结果查看 ' ,
` case_version ` varchar ( 40 ) DEFAULT ' 0 ' COMMENT ' 题目测试数据的版本号 ' ,
` gmt_create ` datetime DEFAULT CURRENT_TIMESTAMP ,
` gmt_modified ` datetime DEFAULT CURRENT_TIMESTAMP ,
2021-05-09 23:41:34 +08:00
PRIMARY KEY ( ` id ` ) ,
2021-02-08 01:10:24 +08:00
KEY ` author ` ( ` author ` ) ,
2021-05-09 23:41:34 +08:00
KEY ` problem_id ` ( ` problem_id ` ) ,
2021-02-08 01:10:24 +08:00
CONSTRAINT ` problem_ibfk_1 ` FOREIGN KEY ( ` author ` ) REFERENCES ` user_info ` ( ` username ` ) ON DELETE NO ACTION ON UPDATE CASCADE
2021-04-24 19:59:56 +08:00
) ENGINE = InnoDB AUTO_INCREMENT = 1065 DEFAULT CHARSET = utf8 ;
2021-02-08 01:10:24 +08:00
/* Table structure for table `problem_case` */
DROP TABLE IF EXISTS ` problem_case ` ;
CREATE TABLE ` problem_case ` (
` id ` bigint ( 20 ) unsigned NOT NULL AUTO_INCREMENT COMMENT ' 主键id ' ,
` pid ` bigint ( 20 ) unsigned NOT NULL COMMENT ' 题目id ' ,
` input ` longtext COMMENT ' 测试样例的输入 ' ,
` output ` longtext COMMENT ' 测试样例的输出 ' ,
` score ` int ( 11 ) DEFAULT NULL COMMENT ' 该测试样例的IO得分 ' ,
` status ` int ( 11 ) DEFAULT ' 0 ' COMMENT ' 0可用, 1不可用 ' ,
` gmt_create ` datetime DEFAULT CURRENT_TIMESTAMP ,
` gmt_modified ` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
PRIMARY KEY ( ` id ` ) ,
KEY ` pid ` ( ` pid ` ) ,
CONSTRAINT ` problem_case_ibfk_1 ` FOREIGN KEY ( ` pid ` ) REFERENCES ` problem ` ( ` id ` ) ON DELETE CASCADE ON UPDATE CASCADE
2021-04-24 19:59:56 +08:00
) ENGINE = InnoDB AUTO_INCREMENT = 102 DEFAULT CHARSET = utf8 ;
2021-02-08 01:10:24 +08:00
/* Table structure for table `problem_count` */
DROP TABLE IF EXISTS ` problem_count ` ;
CREATE TABLE ` problem_count ` (
` id ` bigint ( 20 ) unsigned NOT NULL AUTO_INCREMENT ,
` pid ` bigint ( 20 ) unsigned NOT NULL ,
` total ` int ( 10 ) unsigned DEFAULT ' 0 ' ,
` ac ` int ( 10 ) unsigned DEFAULT ' 0 ' ,
` mle ` int ( 10 ) unsigned DEFAULT ' 0 ' COMMENT ' 空间超限 ' ,
` tle ` int ( 10 ) unsigned DEFAULT ' 0 ' COMMENT ' 时间超限 ' ,
` re ` int ( 10 ) unsigned DEFAULT ' 0 ' COMMENT ' 运行错误 ' ,
` pe ` int ( 10 ) unsigned DEFAULT ' 0 ' COMMENT ' 格式错误 ' ,
` ce ` int ( 10 ) unsigned DEFAULT ' 0 ' COMMENT ' 编译错误 ' ,
` wa ` int ( 10 ) unsigned DEFAULT ' 0 ' COMMENT ' 答案错误 ' ,
` se ` int ( 10 ) unsigned DEFAULT ' 0 ' COMMENT ' 系统错误 ' ,
` pa ` int ( 11 ) DEFAULT ' 0 ' COMMENT ' 部分通过, OI题目 ' ,
` version ` bigint ( 20 ) NOT NULL DEFAULT ' 0 ' COMMENT ' 乐观锁 ' ,
` gmt_create ` datetime DEFAULT CURRENT_TIMESTAMP ,
` gmt_modified ` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
PRIMARY KEY ( ` id ` , ` pid ` ) ,
UNIQUE KEY ` pid ` ( ` pid ` ) ,
CONSTRAINT ` problem_count_ibfk_1 ` FOREIGN KEY ( ` pid ` ) REFERENCES ` problem ` ( ` id ` ) ON DELETE CASCADE ON UPDATE CASCADE
2021-04-24 19:59:56 +08:00
) ENGINE = InnoDB AUTO_INCREMENT = 54 DEFAULT CHARSET = utf8 ;
2021-02-08 01:10:24 +08:00
/* Table structure for table `problem_language` */
DROP TABLE IF EXISTS ` problem_language ` ;
CREATE TABLE ` problem_language ` (
` id ` bigint ( 20 ) unsigned NOT NULL AUTO_INCREMENT ,
` pid ` bigint ( 20 ) unsigned NOT NULL ,
` lid ` bigint ( 20 ) unsigned NOT NULL ,
` gmt_create ` datetime DEFAULT CURRENT_TIMESTAMP ,
` gmt_modified ` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
PRIMARY KEY ( ` id ` ) ,
KEY ` pid ` ( ` pid ` ) ,
KEY ` lid ` ( ` lid ` ) ,
CONSTRAINT ` problem_language_ibfk_1 ` FOREIGN KEY ( ` pid ` ) REFERENCES ` problem ` ( ` id ` ) ON DELETE CASCADE ON UPDATE CASCADE ,
CONSTRAINT ` problem_language_ibfk_2 ` FOREIGN KEY ( ` lid ` ) REFERENCES ` language ` ( ` id ` ) ON DELETE CASCADE ON UPDATE CASCADE
2021-04-24 19:59:56 +08:00
) ENGINE = InnoDB AUTO_INCREMENT = 786 DEFAULT CHARSET = utf8 ;
2021-02-08 01:10:24 +08:00
/* Table structure for table `problem_tag` */
DROP TABLE IF EXISTS ` problem_tag ` ;
CREATE TABLE ` problem_tag ` (
` id ` bigint ( 20 ) unsigned NOT NULL AUTO_INCREMENT ,
` pid ` bigint ( 20 ) unsigned NOT NULL ,
` tid ` bigint ( 20 ) unsigned NOT NULL ,
` gmt_create ` datetime DEFAULT CURRENT_TIMESTAMP ,
` gmt_modified ` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
PRIMARY KEY ( ` id ` ) ,
KEY ` pid ` ( ` pid ` ) ,
KEY ` tid ` ( ` tid ` ) ,
CONSTRAINT ` problem_tag_ibfk_1 ` FOREIGN KEY ( ` pid ` ) REFERENCES ` problem ` ( ` id ` ) ON DELETE CASCADE ON UPDATE CASCADE ,
CONSTRAINT ` problem_tag_ibfk_2 ` FOREIGN KEY ( ` tid ` ) REFERENCES ` tag ` ( ` id ` ) ON DELETE CASCADE ON UPDATE CASCADE
2021-04-24 19:59:56 +08:00
) ENGINE = InnoDB AUTO_INCREMENT = 71 DEFAULT CHARSET = utf8 ;
2021-02-08 01:10:24 +08:00
2021-05-09 23:41:34 +08:00
/* Table structure for table `reply` */
DROP TABLE IF EXISTS ` reply ` ;
CREATE TABLE ` reply ` (
` id ` int ( 11 ) NOT NULL AUTO_INCREMENT ,
` comment_id ` int ( 11 ) NOT NULL COMMENT ' 被回复的评论id ' ,
` from_uid ` varchar ( 255 ) NOT NULL COMMENT ' 发起回复的用户id ' ,
` from_name ` varchar ( 255 ) NOT NULL COMMENT ' 发起回复的用户名 ' ,
` from_avatar ` varchar ( 255 ) DEFAULT NULL COMMENT ' 发起回复的用户头像地址 ' ,
` from_role ` varchar ( 255 ) DEFAULT NULL COMMENT ' 发起回复的用户角色 ' ,
` to_uid ` varchar ( 255 ) NOT NULL COMMENT ' 被回复的用户id ' ,
` to_name ` varchar ( 255 ) NOT NULL COMMENT ' 被回复的用户名 ' ,
` to_avatar ` varchar ( 255 ) DEFAULT NULL COMMENT ' 被回复的用户头像地址 ' ,
` content ` longtext COMMENT ' 回复的内容 ' ,
` gmt_create ` datetime DEFAULT CURRENT_TIMESTAMP ,
` gmt_modified ` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
PRIMARY KEY ( ` id ` ) ,
KEY ` comment_id ` ( ` comment_id ` ) ,
KEY ` from_avatar ` ( ` from_avatar ` ) ,
KEY ` to_avatar ` ( ` to_avatar ` ) ,
CONSTRAINT ` reply_ibfk_1 ` FOREIGN KEY ( ` comment_id ` ) REFERENCES ` comment ` ( ` id ` ) ON DELETE CASCADE ON UPDATE CASCADE ,
CONSTRAINT ` reply_ibfk_2 ` FOREIGN KEY ( ` from_avatar ` ) REFERENCES ` user_info ` ( ` avatar ` ) ON DELETE CASCADE ON UPDATE CASCADE ,
CONSTRAINT ` reply_ibfk_3 ` FOREIGN KEY ( ` to_avatar ` ) REFERENCES ` user_info ` ( ` avatar ` ) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE = InnoDB AUTO_INCREMENT = 23 DEFAULT CHARSET = utf8 ;
2021-02-08 01:10:24 +08:00
/* Table structure for table `role` */
DROP TABLE IF EXISTS ` role ` ;
CREATE TABLE ` role ` (
` id ` bigint ( 20 ) unsigned zerofill NOT NULL ,
` role ` varchar ( 50 ) NOT NULL COMMENT ' 角色 ' ,
` description ` varchar ( 100 ) DEFAULT NULL COMMENT ' 描述 ' ,
` status ` tinyint ( 4 ) NOT NULL DEFAULT ' 0 ' COMMENT ' 默认0可用, 1不可用 ' ,
` gmt_create ` datetime DEFAULT CURRENT_TIMESTAMP COMMENT ' 创建时间 ' ,
` gmt_modified ` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT ' 修改时间 ' ,
PRIMARY KEY ( ` id ` )
) ENGINE = InnoDB DEFAULT CHARSET = utf8 ;
/* Table structure for table `role_auth` */
DROP TABLE IF EXISTS ` role_auth ` ;
CREATE TABLE ` role_auth ` (
` id ` bigint ( 20 ) unsigned NOT NULL AUTO_INCREMENT ,
` auth_id ` bigint ( 20 ) unsigned NOT NULL ,
` role_id ` bigint ( 20 ) unsigned NOT NULL ,
` gmt_create ` datetime DEFAULT CURRENT_TIMESTAMP ,
` gmt_modified ` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
PRIMARY KEY ( ` id ` ) ,
KEY ` auth_id ` ( ` auth_id ` ) USING BTREE ,
KEY ` role_id ` ( ` role_id ` ) USING BTREE ,
CONSTRAINT ` role_auth_ibfk_1 ` FOREIGN KEY ( ` auth_id ` ) REFERENCES ` auth ` ( ` id ` ) ON DELETE CASCADE ON UPDATE CASCADE ,
CONSTRAINT ` role_auth_ibfk_2 ` FOREIGN KEY ( ` role_id ` ) REFERENCES ` role ` ( ` id ` ) ON DELETE NO ACTION ON UPDATE CASCADE
) ENGINE = InnoDB AUTO_INCREMENT = 4 DEFAULT CHARSET = utf8 ;
/* Table structure for table `session` */
DROP TABLE IF EXISTS ` session ` ;
CREATE TABLE ` session ` (
` id ` bigint ( 20 ) unsigned NOT NULL AUTO_INCREMENT ,
` uid ` varchar ( 255 ) NOT NULL ,
2021-04-13 12:59:57 +08:00
` user_agent ` varchar ( 512 ) DEFAULT NULL ,
2021-02-08 01:10:24 +08:00
` ip ` varchar ( 255 ) DEFAULT NULL ,
` gmt_create ` datetime DEFAULT CURRENT_TIMESTAMP ,
` gmt_modified ` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
PRIMARY KEY ( ` id ` ) ,
KEY ` uid ` ( ` uid ` ) ,
CONSTRAINT ` session_ibfk_1 ` FOREIGN KEY ( ` uid ` ) REFERENCES ` user_info ` ( ` uuid ` ) ON DELETE CASCADE ON UPDATE CASCADE
2021-05-09 23:41:34 +08:00
) ENGINE = InnoDB AUTO_INCREMENT = 118 DEFAULT CHARSET = utf8 ;
2021-02-08 01:10:24 +08:00
/* Table structure for table `tag` */
DROP TABLE IF EXISTS ` tag ` ;
CREATE TABLE ` tag ` (
` id ` bigint ( 20 ) unsigned NOT NULL AUTO_INCREMENT ,
` name ` varchar ( 255 ) NOT NULL COMMENT ' 标签名字 ' ,
` color ` varchar ( 10 ) DEFAULT NULL COMMENT ' 标签颜色 ' ,
` gmt_create ` datetime DEFAULT CURRENT_TIMESTAMP ,
` gmt_modified ` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
2021-03-03 21:22:41 +08:00
PRIMARY KEY ( ` id ` , ` name ` ) ,
2021-02-08 01:10:24 +08:00
UNIQUE KEY ` name ` ( ` name ` )
2021-04-24 19:59:56 +08:00
) ENGINE = InnoDB AUTO_INCREMENT = 40 DEFAULT CHARSET = utf8 ;
2021-02-08 01:10:24 +08:00
/* Table structure for table `user_acproblem` */
DROP TABLE IF EXISTS ` user_acproblem ` ;
CREATE TABLE ` user_acproblem ` (
` id ` bigint ( 20 ) NOT NULL AUTO_INCREMENT ,
` uid ` varchar ( 32 ) NOT NULL COMMENT ' 用户id ' ,
` pid ` bigint ( 20 ) unsigned NOT NULL COMMENT ' ac的题目id ' ,
` submit_id ` bigint ( 20 ) unsigned NOT NULL COMMENT ' 提交id ' ,
` gmt_create ` datetime DEFAULT CURRENT_TIMESTAMP ,
` gmt_modified ` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
PRIMARY KEY ( ` id ` ) ,
KEY ` submit_id ` ( ` submit_id ` ) ,
KEY ` uid ` ( ` uid ` ) ,
KEY ` pid ` ( ` pid ` ) ,
CONSTRAINT ` user_acproblem_ibfk_1 ` FOREIGN KEY ( ` uid ` ) REFERENCES ` user_info ` ( ` uuid ` ) ON DELETE CASCADE ON UPDATE CASCADE ,
CONSTRAINT ` user_acproblem_ibfk_2 ` FOREIGN KEY ( ` pid ` ) REFERENCES ` problem ` ( ` id ` ) ON DELETE CASCADE ON UPDATE CASCADE ,
CONSTRAINT ` user_acproblem_ibfk_3 ` FOREIGN KEY ( ` submit_id ` ) REFERENCES ` judge ` ( ` submit_id ` ) ON DELETE CASCADE ON UPDATE CASCADE
2021-05-09 23:41:34 +08:00
) ENGINE = InnoDB AUTO_INCREMENT = 306 DEFAULT CHARSET = utf8 ;
2021-02-08 01:10:24 +08:00
/* Table structure for table `user_info` */
DROP TABLE IF EXISTS ` user_info ` ;
CREATE TABLE ` user_info ` (
` uuid ` varchar ( 32 ) NOT NULL ,
` username ` varchar ( 100 ) NOT NULL COMMENT ' 用户名 ' ,
` password ` varchar ( 100 ) NOT NULL COMMENT ' 密码 ' ,
2021-02-09 22:22:06 +08:00
` nickname ` varchar ( 100 ) DEFAULT NULL COMMENT ' 昵称 ' ,
2021-02-08 01:10:24 +08:00
` school ` varchar ( 100 ) DEFAULT NULL COMMENT ' 学校 ' ,
` course ` varchar ( 100 ) DEFAULT NULL COMMENT ' 专业 ' ,
` number ` varchar ( 20 ) DEFAULT NULL COMMENT ' 学号 ' ,
` realname ` varchar ( 10 ) DEFAULT NULL COMMENT ' 真实姓名 ' ,
` github ` varchar ( 255 ) DEFAULT NULL COMMENT ' github地址 ' ,
` blog ` varchar ( 255 ) DEFAULT NULL COMMENT ' 博客地址 ' ,
` cf_username ` varchar ( 255 ) DEFAULT NULL COMMENT ' cf的username ' ,
` email ` varchar ( 320 ) DEFAULT NULL COMMENT ' 邮箱 ' ,
` avatar ` varchar ( 255 ) DEFAULT NULL COMMENT ' 头像地址 ' ,
` signature ` mediumtext COMMENT ' 个性签名 ' ,
` status ` int ( 11 ) NOT NULL DEFAULT ' 0 ' COMMENT ' 0可用, 1不可用 ' ,
` gmt_create ` datetime DEFAULT CURRENT_TIMESTAMP COMMENT ' 创建时间 ' ,
` gmt_modified ` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT ' 修改时间 ' ,
PRIMARY KEY ( ` uuid ` ) ,
UNIQUE KEY ` USERNAME_UNIQUE ` ( ` username ` ) ,
2021-05-09 23:41:34 +08:00
UNIQUE KEY ` EMAIL_UNIQUE ` ( ` email ` ) ,
UNIQUE KEY ` avatar ` ( ` avatar ` )
2021-02-08 01:10:24 +08:00
) ENGINE = InnoDB DEFAULT CHARSET = utf8 ;
/* Table structure for table `user_record` */
DROP TABLE IF EXISTS ` user_record ` ;
CREATE TABLE ` user_record ` (
` id ` bigint ( 20 ) NOT NULL AUTO_INCREMENT ,
` uid ` varchar ( 32 ) NOT NULL COMMENT ' 用户id ' ,
` submissions ` int ( 11 ) DEFAULT ' 0 ' COMMENT ' 总提交数 ' ,
` total_score ` int ( 11 ) DEFAULT ' 0 ' COMMENT ' IO题目总得分 ' ,
` rating ` int ( 11 ) DEFAULT NULL COMMENT ' cf得分 ' ,
` version ` int ( 11 ) DEFAULT ' 0 ' COMMENT ' 乐观锁 ' ,
` gmt_create ` datetime DEFAULT CURRENT_TIMESTAMP ,
` gmt_modified ` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
PRIMARY KEY ( ` id ` , ` uid ` ) ,
KEY ` uid ` ( ` uid ` ) ,
CONSTRAINT ` user_record_ibfk_1 ` FOREIGN KEY ( ` uid ` ) REFERENCES ` user_info ` ( ` uuid ` ) ON DELETE CASCADE ON UPDATE CASCADE
2021-05-09 23:41:34 +08:00
) ENGINE = InnoDB AUTO_INCREMENT = 305 DEFAULT CHARSET = utf8 ;
2021-02-08 01:10:24 +08:00
/* Table structure for table `user_role` */
DROP TABLE IF EXISTS ` user_role ` ;
CREATE TABLE ` user_role ` (
` id ` bigint ( 20 ) unsigned NOT NULL AUTO_INCREMENT ,
` uid ` varchar ( 32 ) NOT NULL ,
` role_id ` bigint ( 20 ) unsigned NOT NULL ,
` gmt_create ` datetime DEFAULT CURRENT_TIMESTAMP ,
` gmt_modified ` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ,
PRIMARY KEY ( ` id ` ) ,
KEY ` uid ` ( ` uid ` ) USING BTREE ,
KEY ` role_id ` ( ` role_id ` ) USING BTREE ,
CONSTRAINT ` user_role_ibfk_1 ` FOREIGN KEY ( ` uid ` ) REFERENCES ` user_info ` ( ` uuid ` ) ON DELETE CASCADE ON UPDATE CASCADE ,
CONSTRAINT ` user_role_ibfk_2 ` FOREIGN KEY ( ` role_id ` ) REFERENCES ` role ` ( ` id ` ) ON DELETE CASCADE ON UPDATE CASCADE
2021-05-09 23:41:34 +08:00
) ENGINE = InnoDB AUTO_INCREMENT = 307 DEFAULT CHARSET = utf8 ;
2021-02-08 01:10:24 +08:00
/* Trigger structure for table `contest` */
DELIMITER $ $
/* !50003 DROP TRIGGER */ /* !50032 IF EXISTS */ /* !50003 `contest_trigger` */ $ $
/* !50003 CREATE */ /* !50017 DEFINER = 'root'@'localhost' */ /* !50003 TRIGGER `contest_trigger` BEFORE INSERT ON `contest` FOR EACH ROW BEGIN
set new . status = (
CASE
WHEN NOW ( ) < new . start_time THEN - 1
WHEN NOW ( ) > = new . start_time AND NOW ( ) < new . end_time THEN 0
WHEN NOW ( ) > = new . end_time THEN 1
END ) ;
END * / $ $
DELIMITER ;
/* !50106 set global event_scheduler = 1 */ ;
/* Event structure for event `contest_event` */
/* !50106 DROP EVENT IF EXISTS `contest_event` */ ;
DELIMITER $ $
2021-04-24 19:59:56 +08:00
/* !50106 CREATE DEFINER=`root`@`localhost` EVENT `contest_event` ON SCHEDULE EVERY 1 SECOND STARTS '2021-04-18 19:04:49' ON COMPLETION PRESERVE ENABLE DO CALL contest_status() */ $ $
2021-02-08 01:10:24 +08:00
DELIMITER ;
/* Procedure structure for procedure `contest_status` */
/* !50003 DROP PROCEDURE IF EXISTS `contest_status` */ ;
DELIMITER $ $
/* !50003 CREATE DEFINER=`root`@`localhost` PROCEDURE `contest_status`()
BEGIN
UPDATE contest
SET STATUS = (
CASE
WHEN NOW ( ) < start_time THEN - 1
WHEN NOW ( ) > = start_time AND NOW ( ) < end_time THEN 0
WHEN NOW ( ) > = end_time THEN 1
END ) ;
END * / $ $
DELIMITER ;
/* !40101 SET SQL_MODE=@OLD_SQL_MODE */ ;
/* !40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */ ;
/* !40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */ ;
/* !40111 SET SQL_NOTES=@OLD_SQL_NOTES */ ;