Skip to content

Commit c078119

Browse files
committed
adding SQL DDL script for blog app
1 parent f183ef0 commit c078119

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

myblog-ddl-script.sql

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
DROP TABLE IF EXISTS `posts`;
2+
/*!40101 SET @saved_cs_client = @@character_set_client */;
3+
/*!50503 SET character_set_client = utf8mb4 */;
4+
CREATE TABLE `posts` (
5+
`id` bigint NOT NULL AUTO_INCREMENT,
6+
`content` varchar(255) NOT NULL,
7+
`description` varchar(255) NOT NULL,
8+
`title` varchar(255) NOT NULL,
9+
PRIMARY KEY (`id`),
10+
UNIQUE KEY `UKmchce1gm7f6otpphxd6ixsdps` (`title`)
11+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
12+
13+
DROP TABLE IF EXISTS `comments`;
14+
/*!40101 SET @saved_cs_client = @@character_set_client */;
15+
/*!50503 SET character_set_client = utf8mb4 */;
16+
CREATE TABLE `comments` (
17+
`id` bigint NOT NULL AUTO_INCREMENT,
18+
`body` varchar(255) DEFAULT NULL,
19+
`email` varchar(255) DEFAULT NULL,
20+
`name` varchar(255) DEFAULT NULL,
21+
`post_id` bigint NOT NULL,
22+
PRIMARY KEY (`id`),
23+
KEY `FKh4c7lvsc298whoyd4w9ta25cr` (`post_id`),
24+
CONSTRAINT `FKh4c7lvsc298whoyd4w9ta25cr` FOREIGN KEY (`post_id`) REFERENCES `posts` (`id`)
25+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
26+
27+
DROP TABLE IF EXISTS `users`;
28+
/*!40101 SET @saved_cs_client = @@character_set_client */;
29+
/*!50503 SET character_set_client = utf8mb4 */;
30+
CREATE TABLE `users` (
31+
`id` bigint NOT NULL AUTO_INCREMENT,
32+
`email` varchar(255) DEFAULT NULL,
33+
`name` varchar(255) DEFAULT NULL,
34+
`password` varchar(255) DEFAULT NULL,
35+
`username` varchar(255) DEFAULT NULL,
36+
PRIMARY KEY (`id`),
37+
UNIQUE KEY `UKr43af9ap4edm43mmtq01oddj6` (`username`),
38+
UNIQUE KEY `UK6dotkott2kjsp8vw4d0m25fb7` (`email`)
39+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
40+
41+
DROP TABLE IF EXISTS `roles`;
42+
/*!40101 SET @saved_cs_client = @@character_set_client */;
43+
/*!50503 SET character_set_client = utf8mb4 */;
44+
CREATE TABLE `roles` (
45+
`id` bigint NOT NULL AUTO_INCREMENT,
46+
`name` varchar(60) DEFAULT NULL,
47+
PRIMARY KEY (`id`)
48+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
49+
50+
DROP TABLE IF EXISTS `user_roles`;
51+
/*!40101 SET @saved_cs_client = @@character_set_client */;
52+
/*!50503 SET character_set_client = utf8mb4 */;
53+
CREATE TABLE `user_roles` (
54+
`user_id` bigint NOT NULL,
55+
`role_id` bigint NOT NULL,
56+
PRIMARY KEY (`user_id`,`role_id`),
57+
KEY `FKh8ciramu9cc9q3qcqiv4ue8a6` (`role_id`),
58+
CONSTRAINT `FKh8ciramu9cc9q3qcqiv4ue8a6` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`),
59+
CONSTRAINT `FKhfh9dx7w3ubf1co1vdev94g3f` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
60+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

0 commit comments

Comments
 (0)