This repository has been archived by the owner on Sep 5, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
db-create.sql
382 lines (327 loc) · 15.2 KB
/
db-create.sql
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
-- phpMyAdmin SQL Dump
-- version 4.7.0
-- https://www.phpmyadmin.net/
--
-- Host: localhost
-- Generation Time: Apr 19, 2017 at 11:34 PM
-- Server version: 5.7.17-0ubuntu0.16.04.1
-- PHP Version: 7.0.15-0ubuntu0.16.04.4
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";
--
-- Database: `grape`
--
-- --------------------------------------------------------
CREATE TABLE `bans` (
`operator` int(12) NOT NULL,
`reciever` int(12) NOT NULL,
`operation_id` bigint(20) NOT NULL,
`operation` int(8) NOT NULL DEFAULT '0' COMMENT '0 = restriction, 1 = tempban, 2 = permaban, 3 = deletion',
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`expires_at` datetime DEFAULT CURRENT_TIMESTAMP,
`finished` int(11) DEFAULT '0',
`comment` text COLLATE utf8mb4_bin
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
CREATE TABLE `communities` (
`olive_title_id` varchar(20) CHARACTER SET latin1 DEFAULT NULL,
`olive_community_id` varchar(20) CHARACTER SET latin1 NOT NULL,
`community_id` int(20) NOT NULL,
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`type` int(2) NOT NULL,
`min_perm` int(2) NOT NULL DEFAULT '0',
`allowed_pids` text COLLATE utf8mb4_bin,
`hidden` int(2) DEFAULT NULL,
`icon` mediumtext CHARACTER SET latin1,
`banner` mediumtext CHARACTER SET latin1,
`banner_3ds` mediumtext CHARACTER SET latin1,
`name` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
`description` text COLLATE utf8mb4_bin,
`comment` text CHARACTER SET latin1
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
CREATE TABLE `conversations` (
`conversation_id` bigint(20) NOT NULL,
`sender` int(12) NOT NULL,
`recipient` int(12) NOT NULL,
`created_at` datetime DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
CREATE TABLE `empathies` (
`id` varchar(25) CHARACTER SET latin1 NOT NULL COMMENT 'Post/reply/whateverID',
`pid` int(12) NOT NULL COMMENT 'User''s PID',
`empathy_id` bigint(20) NOT NULL,
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`created_from` varchar(50) CHARACTER SET latin1 DEFAULT NULL,
`feeling_id` int(1) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
CREATE TABLE `favorites` (
`settings_id` bigint(20) NOT NULL,
`pid` int(12) NOT NULL,
`community_id` int(20) NOT NULL,
`created_at` datetime DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
CREATE TABLE `friend_relationships` (
`relationship_id` bigint(20) NOT NULL,
`source` int(12) NOT NULL,
`target` int(12) NOT NULL,
`is_me2me` int(2) NOT NULL DEFAULT '0',
`updated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
CREATE TABLE `friend_requests` (
`sender` int(12) NOT NULL,
`recipient` int(12) NOT NULL,
`news_id` bigint(20) NOT NULL,
`message` text COLLATE utf8mb4_bin,
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`has_read` int(8) NOT NULL DEFAULT '0',
`finished` int(8) DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
CREATE TABLE `messages` (
`conversation_id` bigint(20) NOT NULL,
`id` varchar(25) COLLATE utf8mb4_bin NOT NULL COMMENT 'urlsafe base64',
`pid` int(12) NOT NULL,
`screenshot` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
`feeling_id` int(1) NOT NULL DEFAULT '0',
`platform_id` int(1) DEFAULT NULL,
`body` text COLLATE utf8mb4_bin,
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`is_spoiler` int(1) DEFAULT NULL,
`has_read` int(8) DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
CREATE TABLE `news` (
`from_pid` int(12) NOT NULL,
`to_pid` int(12) NOT NULL,
`news_id` bigint(20) NOT NULL,
`id` varchar(50) COLLATE utf8mb4_bin DEFAULT NULL COMMENT 'Full URI',
`news_context` int(8) NOT NULL,
`merged` bigint(20) DEFAULT NULL,
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`has_read` int(8) DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
CREATE TABLE `people` (
`pid` int(12) NOT NULL,
`user_id` varchar(20) CHARACTER SET latin1 NOT NULL,
`user_pass` varchar(255) CHARACTER SET latin1 NOT NULL,
`screen_name` varchar(30) COLLATE utf8mb4_bin NOT NULL,
`mii` varchar(130) CHARACTER SET latin1 DEFAULT NULL,
`mii_image` varchar(255) CHARACTER SET latin1 DEFAULT NULL,
`mii_hash` varchar(15) CHARACTER SET latin1 DEFAULT NULL,
`user_face` varchar(255) CHARACTER SET latin1 DEFAULT NULL,
`user_email` varchar(255) CHARACTER SET latin1 DEFAULT NULL,
`official_user` int(8) DEFAULT NULL,
`organization` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`platform_id` int(8) NOT NULL DEFAULT '1',
`created_from` varchar(50) COLLATE utf8mb4_bin DEFAULT NULL,
`device_id` decimal(12,0) DEFAULT NULL,
`device_cert` varchar(384) CHARACTER SET latin1 DEFAULT NULL,
`privilege` int(8) NOT NULL DEFAULT '0' COMMENT '0 = normal, 1 = special, 2 = mod, 3 = admin, 4 = superadmin, 5 = dev (god)',
`image_perm` int(8) DEFAULT '0',
`status` int(8) NOT NULL DEFAULT '0' COMMENT '0 = ok, 1 = cannot comment, 2 = tempban, 3 = permaban, 4 = device ban, 5 = deleted',
`empathy_restriction` int(8) DEFAULT NULL,
`ban_status` int(8) DEFAULT '0',
`comment` text CHARACTER SET latin1
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
CREATE TABLE `posts` (
`id` varchar(25) CHARACTER SET latin1 NOT NULL COMMENT 'urlsafe base64',
`pid` int(12) NOT NULL,
`_post_type` varchar(32) CHARACTER SET latin1 NOT NULL DEFAULT 'body',
`screenshot` varchar(255) CHARACTER SET latin1 DEFAULT NULL,
`feeling_id` int(1) NOT NULL DEFAULT '0',
`platform_id` int(1) DEFAULT NULL,
`body` text COLLATE utf8mb4_bin,
`url` text CHARACTER SET latin1,
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`community_id` int(20) NOT NULL,
`is_spoiler` varchar(1) COLLATE utf8mb4_bin NOT NULL DEFAULT '0',
`is_special` int(1) DEFAULT '0',
`is_hidden` int(1) DEFAULT '0',
`hidden_resp` int(1) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
CREATE TABLE `profiles` (
`pid` int(12) NOT NULL,
`last_updated` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`comment` text COLLATE utf8mb4_bin,
`birthday` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
`platform_id` int(8) DEFAULT '1',
`country` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
`gender` varchar(2) COLLATE utf8mb4_bin DEFAULT NULL,
`game_experience` varchar(8) COLLATE utf8mb4_bin DEFAULT NULL,
`favorite_screenshot` varchar(25) COLLATE utf8mb4_bin DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
CREATE TABLE `relationships` (
`relationship_id` bigint(20) NOT NULL,
`source` int(12) NOT NULL,
`target` int(12) NOT NULL,
`is_me2me` int(2) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
CREATE TABLE `replies` (
`id` varchar(25) CHARACTER SET latin1 NOT NULL,
`pid` int(12) NOT NULL,
`reply_to_id` varchar(25) CHARACTER SET latin1 NOT NULL,
`screenshot` varchar(255) CHARACTER SET latin1 DEFAULT NULL,
`feeling_id` int(1) NOT NULL DEFAULT '0',
`platform_id` int(1) DEFAULT NULL,
`body` text COLLATE utf8mb4_bin,
`created_from` varchar(50) COLLATE utf8mb4_bin DEFAULT NULL,
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`community_id` int(20) DEFAULT NULL,
`is_spoiler` varchar(1) COLLATE utf8mb4_bin NOT NULL DEFAULT '0',
`is_special` int(1) DEFAULT '0',
`is_hidden` int(1) DEFAULT '0',
`hidden_resp` int(1) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
CREATE TABLE `reports` (
`report_id` bigint(20) NOT NULL,
`source` int(12) NOT NULL,
`subject` varchar(45) COLLATE utf8mb4_bin DEFAULT NULL,
`type` int(8) NOT NULL DEFAULT '0',
`reason` int(8) NOT NULL DEFAULT '0',
`message` text COLLATE utf8mb4_bin,
`created_at` datetime DEFAULT CURRENT_TIMESTAMP,
`finished` int(8) DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
CREATE TABLE `settings_tutorial` (
`pid` int(12) NOT NULL,
`tutorial_id` bigint(20) NOT NULL,
`updated` datetime DEFAULT CURRENT_TIMESTAMP,
`my_news` int(2) DEFAULT '0',
`friend_messages` int(2) DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
CREATE TABLE `titles` (
`olive_title_id` varchar(20) CHARACTER SET latin1 NOT NULL,
`olive_community_id` varchar(20) CHARACTER SET latin1 DEFAULT NULL,
`created_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`unique_id` decimal(20,0) DEFAULT NULL,
`icon` mediumtext CHARACTER SET latin1,
`banner` mediumtext CHARACTER SET latin1,
`banner_3ds` mediumtext CHARACTER SET latin1,
`name` text COLLATE utf8mb4_bin,
`description` text COLLATE utf8mb4_bin,
`platform_id` varchar(8) CHARACTER SET latin1 DEFAULT NULL,
`platform_type` varchar(8) CHARACTER SET latin1 DEFAULT NULL,
`hidden` int(8) DEFAULT NULL,
`comment` text CHARACTER SET latin1
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
ALTER TABLE `bans`
ADD PRIMARY KEY (`operation_id`),
ADD KEY `bpid1` (`operator`);
ALTER TABLE `communities`
ADD PRIMARY KEY (`community_id`),
ADD KEY `olive_community2title` (`olive_title_id`);
ALTER TABLE `conversations`
ADD PRIMARY KEY (`conversation_id`),
ADD KEY `cpid2` (`sender`),
ADD KEY `cpidrecv` (`recipient`);
ALTER TABLE `empathies`
ADD PRIMARY KEY (`empathy_id`),
ADD KEY `pid_to_empathies` (`pid`);
ALTER TABLE `favorites`
ADD PRIMARY KEY (`settings_id`),
ADD KEY `cid` (`community_id`),
ADD KEY `cpid` (`pid`);
ALTER TABLE `friend_relationships`
ADD PRIMARY KEY (`relationship_id`),
ADD KEY `to_pid2` (`source`),
ADD KEY `from_pid2` (`target`);
ALTER TABLE `friend_requests`
ADD PRIMARY KEY (`news_id`),
ADD KEY `pid_from` (`sender`),
ADD KEY `pid_to` (`recipient`);
ALTER TABLE `messages`
ADD PRIMARY KEY (`id`),
ADD KEY `pidmess1` (`pid`),
ADD KEY `convmess1` (`conversation_id`);
ALTER TABLE `news`
ADD PRIMARY KEY (`news_id`),
ADD KEY `to_pid` (`to_pid`),
ADD KEY `from_pid` (`from_pid`);
ALTER TABLE `people`
ADD PRIMARY KEY (`pid`),
ADD UNIQUE KEY `user_id_unique` (`user_id`);
ALTER TABLE `posts`
ADD PRIMARY KEY (`id`),
ADD KEY `posts_ibfk_1` (`pid`),
ADD KEY `posts_ibfk_2` (`community_id`);
ALTER TABLE `profiles`
ADD PRIMARY KEY (`pid`);
ALTER TABLE `relationships`
ADD PRIMARY KEY (`relationship_id`),
ADD KEY `target` (`target`),
ADD KEY `source` (`source`) USING BTREE;
ALTER TABLE `replies`
ADD PRIMARY KEY (`id`),
ADD KEY `replies_ibfk_1` (`pid`),
ADD KEY `replies_ibfk_2` (`reply_to_id`);
ALTER TABLE `reports`
ADD PRIMARY KEY (`report_id`),
ADD KEY `rpid1` (`source`);
ALTER TABLE `settings_tutorial`
ADD PRIMARY KEY (`tutorial_id`),
ADD KEY `pids` (`pid`);
ALTER TABLE `titles`
ADD PRIMARY KEY (`olive_title_id`);
ALTER TABLE `bans`
MODIFY `operation_id` bigint(20) NOT NULL AUTO_INCREMENT;
ALTER TABLE `communities`
MODIFY `community_id` int(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=421;
ALTER TABLE `conversations`
MODIFY `conversation_id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=13;
ALTER TABLE `empathies`
MODIFY `empathy_id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=939;
ALTER TABLE `favorites`
MODIFY `settings_id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=22;
ALTER TABLE `friend_relationships`
MODIFY `relationship_id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=21;
ALTER TABLE `friend_requests`
MODIFY `news_id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=42;
ALTER TABLE `news`
MODIFY `news_id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=806;
ALTER TABLE `people`
MODIFY `pid` int(12) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1800000001;
ALTER TABLE `relationships`
MODIFY `relationship_id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=489;
ALTER TABLE `reports`
MODIFY `report_id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;
ALTER TABLE `settings_tutorial`
MODIFY `tutorial_id` bigint(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=21;
ALTER TABLE `bans`
ADD CONSTRAINT `bpid1` FOREIGN KEY (`operator`) REFERENCES `people` (`pid`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `communities`
ADD CONSTRAINT `olive_community2title` FOREIGN KEY (`olive_title_id`) REFERENCES `titles` (`olive_title_id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `conversations`
ADD CONSTRAINT `cpid1` FOREIGN KEY (`sender`) REFERENCES `people` (`pid`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `cpidrecv` FOREIGN KEY (`recipient`) REFERENCES `people` (`pid`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `empathies`
ADD CONSTRAINT `pid_to_empathies` FOREIGN KEY (`pid`) REFERENCES `people` (`pid`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `favorites`
ADD CONSTRAINT `cid` FOREIGN KEY (`community_id`) REFERENCES `communities` (`community_id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `cpid` FOREIGN KEY (`pid`) REFERENCES `people` (`pid`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `friend_relationships`
ADD CONSTRAINT `from_pid2` FOREIGN KEY (`target`) REFERENCES `people` (`pid`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `to_pid2` FOREIGN KEY (`source`) REFERENCES `people` (`pid`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `friend_requests`
ADD CONSTRAINT `pid_from` FOREIGN KEY (`sender`) REFERENCES `people` (`pid`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `pid_to` FOREIGN KEY (`recipient`) REFERENCES `people` (`pid`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `messages`
ADD CONSTRAINT `convmess1` FOREIGN KEY (`conversation_id`) REFERENCES `conversations` (`conversation_id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `pidmess1` FOREIGN KEY (`pid`) REFERENCES `people` (`pid`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `news`
ADD CONSTRAINT `from_pid` FOREIGN KEY (`from_pid`) REFERENCES `people` (`pid`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `to_pid` FOREIGN KEY (`to_pid`) REFERENCES `people` (`pid`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `posts`
ADD CONSTRAINT `posts_ibfk_1` FOREIGN KEY (`pid`) REFERENCES `people` (`pid`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `posts_ibfk_2` FOREIGN KEY (`community_id`) REFERENCES `communities` (`community_id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `profiles`
ADD CONSTRAINT `profiles_to_people` FOREIGN KEY (`pid`) REFERENCES `people` (`pid`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `relationships`
ADD CONSTRAINT `source` FOREIGN KEY (`source`) REFERENCES `people` (`pid`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `target` FOREIGN KEY (`target`) REFERENCES `people` (`pid`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `replies`
ADD CONSTRAINT `replies_ibfk_1` FOREIGN KEY (`pid`) REFERENCES `people` (`pid`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `replies_ibfk_2` FOREIGN KEY (`reply_to_id`) REFERENCES `posts` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `reports`
ADD CONSTRAINT `rpid1` FOREIGN KEY (`source`) REFERENCES `people` (`pid`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE `settings_tutorial`
ADD CONSTRAINT `pids` FOREIGN KEY (`pid`) REFERENCES `people` (`pid`) ON DELETE CASCADE ON UPDATE CASCADE;
COMMIT;