-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit_ddl.sql
More file actions
79 lines (72 loc) · 2.71 KB
/
init_ddl.sql
File metadata and controls
79 lines (72 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
CREATE TABLE `member` (
`id` bigint NOT NULL AUTO_INCREMENT,
`email` varchar(255) NOT NULL,
`password` varchar(255) DEFAULT NULL,
`nickname` varchar(255) NOT NULL,
`createDate` datetime(6) NOT NULL,
`provider` varchar(255) DEFAULT NULL,
`providerId` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `UK_member_email` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `pet` (
`id` bigint NOT NULL AUTO_INCREMENT,
`name` varchar(255) DEFAULT NULL,
`birthday` date DEFAULT NULL,
`member_id` bigint DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `post` (
`id` bigint NOT NULL AUTO_INCREMENT,
`content` text,
`createDate` datetime(6) DEFAULT NULL,
`member_id` bigint DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `image` (
`id` varchar(255) NOT NULL,
`name` varchar(255) DEFAULT NULL,
`url` varchar(255) DEFAULT NULL,
`thumbnail_url` varchar(255) DEFAULT NULL,
`description` varchar(500) DEFAULT NULL,
`provider` enum('NYANGMUNITY','TENOR') DEFAULT NULL,
`upload_date` datetime(6) NOT NULL,
`likes_count` int NOT NULL DEFAULT 0,
`views_count` int NOT NULL DEFAULT 0,
`expires_at` datetime(6) DEFAULT NULL,
`member_id` bigint DEFAULT NULL,
PRIMARY KEY (`id`),
INDEX `idx_upload_date` (`upload_date` DESC),
INDEX `idx_likes_count` (`likes_count` DESC),
INDEX `idx_views_count` (`views_count` DESC)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `image_like` (
`id` bigint NOT NULL AUTO_INCREMENT,
`image_id` varchar(255) DEFAULT NULL,
`member_id` bigint DEFAULT NULL,
`createDate` datetime(6) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `post_image` (
`id` bigint NOT NULL AUTO_INCREMENT,
`image_id` varchar(255) DEFAULT NULL,
`post_id` bigint DEFAULT NULL,
`createDate` datetime(6) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `tag` (
`id` bigint NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`usageCount` int NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY `UK_tag_name` (`name`),
INDEX `idx_tag_name` (`name`),
INDEX `idx_tag_usage_count` (`usageCount` DESC)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
CREATE TABLE `image_tag` (
`id` bigint NOT NULL AUTO_INCREMENT,
`image_id` varchar(255) NOT NULL,
`tag_id` bigint NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `UK_image_tag` (`image_id`, `tag_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;