This repository has been archived by the owner on May 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
df_website.sql
364 lines (306 loc) · 10 KB
/
df_website.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
-- phpMyAdmin SQL Dump
-- version 4.4.15.10
-- https://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: May 02, 2019 at 01:50 PM
-- Server version: 5.5.56-MariaDB
-- PHP Version: 5.6.33
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!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 */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `df_website`
--
CREATE DATABASE IF NOT EXISTS `df_website` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `df_website`;
-- --------------------------------------------------------
--
-- Table structure for table `accounts`
--
CREATE TABLE IF NOT EXISTS `accounts` (
`username` varchar(16) NOT NULL,
`rank` enum('WebDev','Owner','Admin','Mod','JrMod','Expert','Helper','JrHelper','Overlord','Mythic','Emperor','Noble','') NOT NULL,
`uuid` varchar(64) NOT NULL,
`password` text NOT NULL,
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`code` varchar(8) NOT NULL,
`stayLoggedInCode` varchar(32) DEFAULT NULL,
`user_id` int(11) NOT NULL,
`authKey` varchar(64) DEFAULT NULL,
`authKeyExpires` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Used to store the created accounts for the Website.';
-- --------------------------------------------------------
--
-- Table structure for table `api_keys`
--
CREATE TABLE IF NOT EXISTS `api_keys` (
`api_key` varchar(32) NOT NULL,
`owner` varchar(32) DEFAULT '',
`access_level` tinyint(4) DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `devices`
--
CREATE TABLE IF NOT EXISTS `devices` (
`device_unique` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`stayLoggedIn` int(11) NOT NULL DEFAULT '0',
`loginTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`device` text NOT NULL,
`browser` text NOT NULL,
`version` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `dfuAnalytics`
--
CREATE TABLE IF NOT EXISTS `dfuAnalytics` (
`id` int(11) NOT NULL,
`type` varchar(64) NOT NULL,
`data` text,
`uuid` varchar(64) NOT NULL,
`version` varchar(16) NOT NULL,
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `forums`
--
CREATE TABLE IF NOT EXISTS `forums` (
`forum_id` int(11) NOT NULL,
`category_id` int(11) NOT NULL,
`creator` int(11) DEFAULT NULL,
`name` text NOT NULL,
`description` text NOT NULL,
`threads` int(11) DEFAULT '0',
`posts` int(11) DEFAULT '0',
`latest` int(11) DEFAULT NULL,
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`pinned` int(11) NOT NULL DEFAULT '0',
`locked` int(11) NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Forums that sit in forum categories';
-- --------------------------------------------------------
--
-- Table structure for table `forum_categories`
--
CREATE TABLE IF NOT EXISTS `forum_categories` (
`category_id` int(11) NOT NULL,
`name` text NOT NULL,
`creator` int(11) DEFAULT NULL,
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Organized forum categories for forums';
-- --------------------------------------------------------
--
-- Table structure for table `offenses`
--
CREATE TABLE IF NOT EXISTS `offenses` (
`case_id` int(11) NOT NULL,
`user_id` varchar(32) DEFAULT NULL,
`action` varchar(16) DEFAULT NULL,
`reason` varchar(128) DEFAULT NULL,
`expires` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `replies`
--
CREATE TABLE IF NOT EXISTS `replies` (
`reply_id` int(11) NOT NULL,
`thread_id` int(11) NOT NULL,
`content` longtext NOT NULL,
`likes` int(11) NOT NULL DEFAULT '0',
`creator` int(11) NOT NULL,
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Used to store the created replies for the Website.';
-- --------------------------------------------------------
--
-- Table structure for table `replyLikes`
--
CREATE TABLE IF NOT EXISTS `replyLikes` (
`reply_id` int(11) NOT NULL,
`user` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `threadLikes`
--
CREATE TABLE IF NOT EXISTS `threadLikes` (
`thread_id` int(11) NOT NULL,
`user` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------------------
--
-- Table structure for table `threads`
--
CREATE TABLE IF NOT EXISTS `threads` (
`thread_id` int(11) NOT NULL,
`forum_id` int(11) NOT NULL,
`name` text NOT NULL,
`content` longtext NOT NULL,
`replies` int(11) NOT NULL DEFAULT '0',
`views` int(11) NOT NULL DEFAULT '0',
`latest` int(11) DEFAULT NULL,
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`pinned` int(11) NOT NULL DEFAULT '0',
`locked` int(11) NOT NULL DEFAULT '0',
`creator` int(11) NOT NULL,
`description` text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Used to store the created forums for the Website.';
--
-- Indexes for dumped tables
--
--
-- Indexes for table `accounts`
--
ALTER TABLE `accounts`
ADD PRIMARY KEY (`user_id`),
ADD KEY `UUID` (`uuid`);
--
-- Indexes for table `devices`
--
ALTER TABLE `devices`
ADD PRIMARY KEY (`device_unique`),
ADD KEY `user_id` (`user_id`);
--
-- Indexes for table `dfuAnalytics`
--
ALTER TABLE `dfuAnalytics`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `forums`
--
ALTER TABLE `forums`
ADD PRIMARY KEY (`forum_id`),
ADD KEY `forum_category` (`category_id`) USING BTREE,
ADD KEY `creator` (`creator`) USING BTREE;
--
-- Indexes for table `forum_categories`
--
ALTER TABLE `forum_categories`
ADD PRIMARY KEY (`category_id`),
ADD KEY `UserID` (`creator`);
--
-- Indexes for table `offenses`
--
ALTER TABLE `offenses`
ADD PRIMARY KEY (`case_id`);
--
-- Indexes for table `replies`
--
ALTER TABLE `replies`
ADD PRIMARY KEY (`reply_id`),
ADD KEY `UserID` (`creator`),
ADD KEY `thread_id` (`thread_id`);
--
-- Indexes for table `replyLikes`
--
ALTER TABLE `replyLikes`
ADD KEY `userConnector` (`user`) USING BTREE,
ADD KEY `replyConnector` (`reply_id`) USING BTREE;
--
-- Indexes for table `threadLikes`
--
ALTER TABLE `threadLikes`
ADD KEY `userConnector` (`user`) USING BTREE,
ADD KEY `thread_id` (`thread_id`);
--
-- Indexes for table `threads`
--
ALTER TABLE `threads`
ADD PRIMARY KEY (`thread_id`),
ADD KEY `UserID` (`creator`),
ADD KEY `ForumID` (`forum_id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `accounts`
--
ALTER TABLE `accounts`
MODIFY `user_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `devices`
--
ALTER TABLE `devices`
MODIFY `device_unique` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `dfuAnalytics`
--
ALTER TABLE `dfuAnalytics`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `forums`
--
ALTER TABLE `forums`
MODIFY `forum_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `forum_categories`
--
ALTER TABLE `forum_categories`
MODIFY `category_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `offenses`
--
ALTER TABLE `offenses`
MODIFY `case_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `replies`
--
ALTER TABLE `replies`
MODIFY `reply_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `threads`
--
ALTER TABLE `threads`
MODIFY `thread_id` int(11) NOT NULL AUTO_INCREMENT;
--
-- Constraints for dumped tables
--
--
-- Constraints for table `devices`
--
ALTER TABLE `devices`
ADD CONSTRAINT `UC` FOREIGN KEY (`user_id`) REFERENCES `accounts` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `forums`
--
ALTER TABLE `forums`
ADD CONSTRAINT `FCC1` FOREIGN KEY (`category_id`) REFERENCES `forum_categories` (`category_id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `UC2` FOREIGN KEY (`creator`) REFERENCES `accounts` (`user_id`) ON DELETE SET NULL ON UPDATE CASCADE;
--
-- Constraints for table `forum_categories`
--
ALTER TABLE `forum_categories`
ADD CONSTRAINT `UC3` FOREIGN KEY (`creator`) REFERENCES `accounts` (`user_id`) ON DELETE SET NULL ON UPDATE CASCADE;
--
-- Constraints for table `replies`
--
ALTER TABLE `replies`
ADD CONSTRAINT `TC1` FOREIGN KEY (`thread_id`) REFERENCES `threads` (`thread_id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `UC6` FOREIGN KEY (`creator`) REFERENCES `accounts` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `replyLikes`
--
ALTER TABLE `replyLikes`
ADD CONSTRAINT `RC` FOREIGN KEY (`reply_id`) REFERENCES `replies` (`reply_id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `UC7` FOREIGN KEY (`user`) REFERENCES `accounts` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `threadLikes`
--
ALTER TABLE `threadLikes`
ADD CONSTRAINT `TC` FOREIGN KEY (`thread_id`) REFERENCES `threads` (`thread_id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `UC5` FOREIGN KEY (`user`) REFERENCES `accounts` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;
--
-- Constraints for table `threads`
--
ALTER TABLE `threads`
ADD CONSTRAINT `FC` FOREIGN KEY (`forum_id`) REFERENCES `forums` (`forum_id`) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT `UC4` FOREIGN KEY (`creator`) REFERENCES `accounts` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE;
/*!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 */;