You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
work/blog/_localhost-2024_12_30_10_31...

304 lines
90 KiB

-- MySQL dump 10.13 Distrib 8.0.40, for Win64 (x86_64)
--
-- Host: 127.0.0.1 Database: blog
-- ------------------------------------------------------
-- Server version 8.0.40
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!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 */;
--
-- Table structure for table `administrators`
--
DROP TABLE IF EXISTS `administrators`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `administrators` (
`admin_id` int NOT NULL AUTO_INCREMENT,
`user_id` int NOT NULL,
PRIMARY KEY (`admin_id`),
UNIQUE KEY `user_id` (`user_id`),
CONSTRAINT `administrators_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `administrators`
--
LOCK TABLES `administrators` WRITE;
/*!40000 ALTER TABLE `administrators` DISABLE KEYS */;
/*!40000 ALTER TABLE `administrators` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `announcements`
--
DROP TABLE IF EXISTS `announcements`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `announcements` (
`announcement_id` int NOT NULL AUTO_INCREMENT,
`admin_id` int NOT NULL,
`title` varchar(255) NOT NULL,
`content` text NOT NULL,
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`is_published` tinyint(1) DEFAULT '0',
PRIMARY KEY (`announcement_id`),
KEY `admin_id` (`admin_id`),
CONSTRAINT `announcements_ibfk_1` FOREIGN KEY (`admin_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `announcements`
--
LOCK TABLES `announcements` WRITE;
/*!40000 ALTER TABLE `announcements` DISABLE KEYS */;
INSERT INTO `announcements` VALUES (1,1,'公告1','Content of the first announcement.','2024-12-12 11:38:49','2024-12-28 00:09:37',1),(2,1,'公告2','Content of the second announcement.','2024-12-12 11:38:49','2024-12-28 00:09:37',1),(3,1,'公告3','Content of the twentieth announcement.','2024-12-12 11:38:49','2024-12-28 00:09:37',1);
/*!40000 ALTER TABLE `announcements` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `comments`
--
DROP TABLE IF EXISTS `comments`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `comments` (
`comment_id` int NOT NULL AUTO_INCREMENT,
`post_id` int NOT NULL,
`user_id` int NOT NULL,
`content` varchar(1024) NOT NULL,
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`is_deleted` tinyint(1) DEFAULT '0',
PRIMARY KEY (`comment_id`),
KEY `post_id` (`post_id`),
KEY `user_id` (`user_id`),
CONSTRAINT `comments_ibfk_1` FOREIGN KEY (`post_id`) REFERENCES `posts` (`post_id`) ON DELETE CASCADE,
CONSTRAINT `comments_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `comments`
--
LOCK TABLES `comments` WRITE;
/*!40000 ALTER TABLE `comments` DISABLE KEYS */;
INSERT INTO `comments` VALUES (1,9,1,'001','2024-12-27 13:35:21','2024-12-27 13:35:21',0),(2,9,1,'002','2024-12-27 13:35:21','2024-12-27 13:35:21',0),(3,37,4,'vue评论示例001','2024-12-27 14:57:50','2024-12-27 14:57:50',0),(11,52,4,'测试时间为2024年12月29日21:46:29','2024-12-29 13:46:31','2024-12-29 13:46:31',0);
/*!40000 ALTER TABLE `comments` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `posts`
--
DROP TABLE IF EXISTS `posts`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `posts` (
`post_id` int NOT NULL AUTO_INCREMENT,
`user_id` int NOT NULL,
`title` varchar(255) NOT NULL,
`content` longtext,
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`priority` int DEFAULT '0',
PRIMARY KEY (`post_id`),
KEY `user_id` (`user_id`),
CONSTRAINT `posts_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=53 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `posts`
--
LOCK TABLES `posts` WRITE;
/*!40000 ALTER TABLE `posts` DISABLE KEYS */;
INSERT INTO `posts` VALUES (9,2,'Third Post by User2','This is the content of the third post by user2. It is a detailed explanation of the topic.','2024-12-12 11:47:15','2024-12-12 11:47:15',0),(11,3,'Fourth Post by User2','This is the content of the fourth post by user2. It is a detailed explanation of the topic.','2024-12-12 11:47:15','2024-12-16 11:23:21',0),(12,1,'Fifth Post by User1','This is the content of the fifth post by user1. It is a detailed explanation of the topic.','2024-12-12 11:47:15','2024-12-12 11:47:15',0),(13,3,'Fifth Post by User2','This is the content of the fifth post by user2. It is a detailed explanation of the topic.','2024-12-12 11:47:15','2024-12-16 11:23:21',0),(14,3,'Sixth Post by User1','This is the content of the sixth post by user1. It is a detailed explanation of the topic.','2024-12-12 11:47:15','2024-12-16 11:23:21',0),(15,2,'Sixth Post by User2','This is the content of the sixth post by user2. It is a detailed explanation of the topic.','2024-12-12 11:47:15','2024-12-12 11:47:15',0),(16,1,'Seventh Post by User1','This is the content of the seventh post by user1. It is a detailed explanation of the topic.','2024-12-12 11:47:15','2024-12-12 11:47:15',0),(17,2,'Seventh Post by User2','This is the content of the seventh post by user2. It is a detailed explanation of the topic.','2024-12-12 11:47:15','2024-12-12 11:47:15',0),(18,1,'Eighth Post by User1','This is the content of the eighth post by user1. It is a detailed explanation of the topic.','2024-12-12 11:47:15','2024-12-12 11:47:15',0),(19,2,'Eighth Post by User2','This is the content of the eighth post by user2. It is a detailed explanation of the topic.','2024-12-12 11:47:15','2024-12-12 11:47:15',0),(20,1,'小20改','2024年12月17日12:56:12','2024-12-12 11:47:15','2024-12-17 04:57:08',0),(21,2,'Ninth Post by User2','This is the content of the ninth post by user2. It is a detailed explanation of the topic.','2024-12-12 11:47:15','2024-12-12 11:47:15',0),(22,1,'Tenth Post by User1','This is the content of the tenth post by user1. It is a detailed explanation of the topic.','2024-12-12 11:47:15','2024-12-12 11:47:15',0),(23,2,'Tenth Post by User2','This is the content of the tenth post by user2. It is a detailed explanation of the topic.','2024-12-12 11:47:15','2024-12-12 11:47:15',0),(25,1,'文章标题示例1','文章内容示例1','2024-12-13 16:36:32','2024-12-13 16:36:32',0),(26,4,'# 我的宠物','我有一只非常可爱的小狗,它的名字叫球球。球球全身毛茸茸的,颜色像雪一样白。它的眼睛又大又圆,每次看到我都会摇着尾巴欢迎我回家。\n\n球球最喜欢玩的游戏是“接飞盘”。每天放学后我都会带它到公园去玩这个游戏。球球跑得非常快总能准确地接住我扔出去的飞盘。我们玩得很开心常常引来其他小朋友羡慕的目光。\n\n除了游戏球球还是我的好伙伴。当我遇到困难或者心情不好时它总是静静地坐在我身边仿佛在安慰我。球球不仅是我最好的朋友也是我家的一员。\n','2024-12-14 16:31:47','2024-12-14 16:31:47',0),(27,4,'我的理想','# 我的理想\n\n每个人都有自己的理想而我的理想是成为一名医生。从小我就对医学充满了好奇经常看一些关于人体构造的书籍梦想着有一天能够帮助病人恢复健康。\n\n我知道要实现这个理想并不容易需要学习很多知识并且还要经过长时间的训练。但是我不怕困难因为这是我真心想要做的事情。我会努力学习争取考上一所好的医学院校将来成为一名优秀的医生。\n\n我相信只要坚持不懈地努力就一定可以实现自己的理想。我要用自己的双手去治愈更多的人让他们重新获得健康的笑容。','2024-12-14 16:34:12','2024-12-14 16:34:12',0),(28,4,'美丽的校园','# 美丽的校园\n\n我们的学校坐落在一条宁静的小河边周围环绕着青山绿水环境十分优美。走进校园首先映入眼帘的是宽阔的操场那里是<E9878C>
/*!40000 ALTER TABLE `posts` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `reactions`
--
DROP TABLE IF EXISTS `reactions`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `reactions` (
`reaction_id` int NOT NULL AUTO_INCREMENT,
`post_id` int NOT NULL,
`user_id` int NOT NULL,
`type` enum('like','dislike') NOT NULL,
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`reaction_id`),
UNIQUE KEY `post_id` (`post_id`,`user_id`),
UNIQUE KEY `unique_user_post_reaction` (`post_id`,`user_id`),
KEY `user_id` (`user_id`),
CONSTRAINT `reactions_ibfk_1` FOREIGN KEY (`post_id`) REFERENCES `posts` (`post_id`) ON DELETE CASCADE,
CONSTRAINT `reactions_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `users` (`user_id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `reactions`
--
LOCK TABLES `reactions` WRITE;
/*!40000 ALTER TABLE `reactions` DISABLE KEYS */;
INSERT INTO `reactions` VALUES (5,36,4,'like','2024-12-17 05:00:56');
/*!40000 ALTER TABLE `reactions` ENABLE KEYS */;
UNLOCK TABLES;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `update_priority_on_like` AFTER INSERT ON `reactions` FOR EACH ROW BEGIN
IF NEW.type = 'like' THEN
UPDATE posts
SET priority = (SELECT COUNT(*) FROM reactions WHERE post_id = NEW.post_id AND type = 'like') * 2 -
(SELECT COUNT(*) FROM reactions WHERE post_id = NEW.post_id AND type = 'dislike')
WHERE post_id = NEW.post_id;
END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `update_priority_on_dislike` AFTER INSERT ON `reactions` FOR EACH ROW BEGIN
IF NEW.type = 'dislike' THEN
UPDATE posts
SET priority = (SELECT COUNT(*) FROM reactions WHERE post_id = NEW.post_id AND type = 'like') * 2 -
(SELECT COUNT(*) FROM reactions WHERE post_id = NEW.post_id AND type = 'dislike')
WHERE post_id = NEW.post_id;
END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `update_priority_on_delete_like` AFTER DELETE ON `reactions` FOR EACH ROW BEGIN
IF OLD.type = 'like' THEN
UPDATE posts
SET priority = (SELECT COUNT(*) FROM reactions WHERE post_id = OLD.post_id AND type = 'like') * 2 -
(SELECT COUNT(*) FROM reactions WHERE post_id = OLD.post_id AND type = 'dislike')
WHERE post_id = OLD.post_id;
END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_0900_ai_ci */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50017 DEFINER=`root`@`localhost`*/ /*!50003 TRIGGER `update_priority_on_delete_dislike` AFTER DELETE ON `reactions` FOR EACH ROW BEGIN
IF OLD.type = 'dislike' THEN
UPDATE posts
SET priority = (SELECT COUNT(*) FROM reactions WHERE post_id = OLD.post_id AND type = 'like') * 2 -
(SELECT COUNT(*) FROM reactions WHERE post_id = OLD.post_id AND type = 'dislike')
WHERE post_id = OLD.post_id;
END IF;
END */;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
--
-- Table structure for table `users`
--
DROP TABLE IF EXISTS `users`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `users` (
`user_id` int NOT NULL AUTO_INCREMENT,
`username` varchar(50) NOT NULL,
`email` varchar(100) NOT NULL,
`password` varchar(255) NOT NULL,
`status` enum('admin','normal','blocked','deactivated','pending') DEFAULT 'pending',
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`is_active` tinyint(1) DEFAULT '1',
`activation_token` varchar(255) DEFAULT NULL,
`reset_password_token` varchar(255) DEFAULT NULL,
`reset_password_expires` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`user_id`),
UNIQUE KEY `username` (`username`),
UNIQUE KEY `email` (`email`),
UNIQUE KEY `email_2` (`email`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `users`
--
LOCK TABLES `users` WRITE;
/*!40000 ALTER TABLE `users` DISABLE KEYS */;
INSERT INTO `users` VALUES (1,'','user1@example.com','x','normal','2024-12-12 11:38:18','2024-12-16 07:42:27',1,NULL,NULL,NULL),(2,'user2','user2@example.com','654321','normal','2024-12-12 11:38:18','2024-12-14 01:53:08',1,NULL,NULL,NULL),(3,'user20','user20@example.com','111111','normal','2024-12-12 11:38:18','2024-12-14 01:53:08',1,NULL,NULL,NULL),(4,'sss','xxs@xxs.com','sss','normal','2024-12-14 16:31:18','2024-12-27 14:54:06',1,NULL,NULL,NULL),(5,'LeJingS','3489749586@qq.com','lejings_de_mima','normal','2024-12-16 05:07:41','2024-12-16 05:07:41',1,NULL,NULL,NULL),(8,'小号','2193629878@qq.com','xiaohao','pending','2024-12-16 07:04:43','2024-12-16 07:04:43',1,NULL,NULL,NULL);
/*!40000 ALTER TABLE `users` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2024-12-30 10:31:04