添加SQL数据表

This commit is contained in:
洛水居室 2022-08-24 14:38:37 +08:00
parent d167391a1d
commit 3821e66af6
No known key found for this signature in database
GPG Key ID: C9DE87DA724B88FC

124
config/sql/paimon.sql Normal file
View File

@ -0,0 +1,124 @@
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for admin
-- ----------------------------
DROP TABLE IF EXISTS `admin`;
CREATE TABLE `admin` (
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`user_id` bigint(20) UNSIGNED NOT NULL,
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `user_id`(`user_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 0 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for answer
-- ----------------------------
DROP TABLE IF EXISTS `answer`;
CREATE TABLE `answer` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`question_id` int(11) UNSIGNED NULL DEFAULT NULL,
`is_correct` int(11) NULL DEFAULT NULL,
`text` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE,
INDEX `question_id`(`question_id`) USING BTREE,
CONSTRAINT `answer_ibfk_1` FOREIGN KEY (`question_id`) REFERENCES `question` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT
) ENGINE = InnoDB AUTO_INCREMENT = 0 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for chat
-- ----------------------------
DROP TABLE IF EXISTS `chat`;
CREATE TABLE `chat` (
`id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`chat_id` bigint(20) UNSIGNED NOT NULL,
`is_authorize` int(10) UNSIGNED NULL DEFAULT NULL,
`auth` int(10) NULL DEFAULT NULL,
PRIMARY KEY (`id`, `chat_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 0 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for hoyoverse_cookies
-- ----------------------------
DROP TABLE IF EXISTS `hoyoverse_cookies`;
CREATE TABLE `hoyoverse_cookies` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`user_id` bigint(20) NOT NULL,
`cookies` varchar(2000) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`status` enum('STATUS_SUCCESS','INVALID_COOKIES','TOO_MANY_REQUESTS') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`, `user_id`) USING BTREE,
UNIQUE INDEX `user_id`(`user_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 0 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for job
-- ----------------------------
DROP TABLE IF EXISTS `job`;
CREATE TABLE `job` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`time` date NULL DEFAULT NULL,
`last_time` date NULL DEFAULT NULL,
`status` int(11) NULL DEFAULT NULL,
PRIMARY KEY (`id`, `name`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 0 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for mihoyo_cookies
-- ----------------------------
DROP TABLE IF EXISTS `mihoyo_cookies`;
CREATE TABLE `mihoyo_cookies` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`user_id` bigint(20) NOT NULL,
`cookies` varchar(2000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`status` enum('STATUS_SUCCESS','INVALID_COOKIES','TOO_MANY_REQUESTS') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`, `user_id`) USING BTREE,
UNIQUE INDEX `user_id`(`user_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 0 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for question
-- ----------------------------
DROP TABLE IF EXISTS `question`;
CREATE TABLE `question` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`text` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 0 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Redundant;
-- ----------------------------
-- Table structure for sign
-- ----------------------------
DROP TABLE IF EXISTS `sign`;
CREATE TABLE `sign` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`chat_id` bigint(20) NULL DEFAULT NULL,
`time_created` datetime(0) NULL DEFAULT NULL,
`time_updated` datetime(0) NULL DEFAULT NULL,
`status` enum('STATUS_SUCCESS','INVALID_COOKIES','ALREADY_CLAIMED','GENSHIN_EXCEPTION','TIMEOUT_ERROR','BAD_REQUEST','FORBIDDEN') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`, `user_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 0 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`user_id` bigint(20) NOT NULL,
`yuanshen_uid` int(11) NULL DEFAULT NULL,
`genshin_uid` int(11) NULL DEFAULT NULL,
`region` enum('HYPERION','HOYOLAB') CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`id`, `user_id`) USING BTREE,
UNIQUE INDEX `user_id`(`user_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 0 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- View structure for quiz
-- ----------------------------
DROP VIEW IF EXISTS `quiz`;
CREATE ALGORITHM = UNDEFINED SQL SECURITY DEFINER VIEW `quiz` AS select `question`.`id` AS `question_id`,`question`.`text` AS `question`,`answer`.`text` AS `answer`,`answer`.`is_correct` AS `is_correct` from (`question` join `answer` on((`question`.`id` = `answer`.`question_id`)));
SET FOREIGN_KEY_CHECKS = 1;