1 SET FOREIGN_KEY_CHECKS = 0;
3 CREATE TABLE `activity` (
4 `id` int(11) NOT NULL auto_increment,
5 `user_id` int(11) NOT NULL,
6 `activity_type` smallint(6) NOT NULL,
7 `active_at` datetime NOT NULL,
8 `content_type_id` int(11) NOT NULL,
9 `object_id` int(10) unsigned NOT NULL,
10 `is_auditted` tinyint(1) default '0',
12 KEY `activity_user_id` (`user_id`),
13 KEY `activity_content_type_id` (`content_type_id`)
14 ) ENGINE=MyISAM AUTO_INCREMENT=103 DEFAULT CHARSET=utf8;
17 CREATE TABLE `answer` (
18 `id` int(11) NOT NULL auto_increment,
19 `question_id` int(11) NOT NULL,
20 `author_id` int(11) NOT NULL,
21 `added_at` datetime NOT NULL,
22 `wiki` tinyint(1) NOT NULL,
23 `wikified_at` datetime default NULL,
24 `accepted` tinyint(1) NOT NULL,
25 `deleted` tinyint(1) NOT NULL,
26 `deleted_by_id` int(11) default NULL,
27 `locked` tinyint(1) NOT NULL,
28 `locked_by_id` int(11) default NULL,
29 `locked_at` datetime default NULL,
30 `score` int(11) NOT NULL,
31 `comment_count` int(10) unsigned NOT NULL,
32 `offensive_flag_count` smallint(6) NOT NULL,
33 `last_edited_at` datetime default NULL,
34 `last_edited_by_id` int(11) default NULL,
35 `html` longtext NOT NULL,
36 `vote_up_count` int(11) NOT NULL,
37 `vote_down_count` int(11) NOT NULL,
39 KEY `answer_question_id` (`question_id`),
40 KEY `answer_author_id` (`author_id`),
41 KEY `answer_deleted_by_id` (`deleted_by_id`),
42 KEY `answer_locked_by_id` (`locked_by_id`),
43 KEY `answer_last_edited_by_id` (`last_edited_by_id`),
44 CONSTRAINT `author_id_refs_id_192b0170` FOREIGN KEY (`author_id`) REFERENCES `auth_user` (`id`),
45 CONSTRAINT `deleted_by_id_refs_id_192b0170` FOREIGN KEY (`deleted_by_id`) REFERENCES `auth_user` (`id`),
46 CONSTRAINT `last_edited_by_id_refs_id_192b0170` FOREIGN KEY (`last_edited_by_id`) REFERENCES `auth_user` (`id`),
47 CONSTRAINT `locked_by_id_refs_id_192b0170` FOREIGN KEY (`locked_by_id`) REFERENCES `auth_user` (`id`),
48 CONSTRAINT `question_id_refs_id_7d6550c9` FOREIGN KEY (`question_id`) REFERENCES `question` (`id`)
49 ) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8;
52 CREATE TABLE `answer_revision` (
53 `id` int(11) NOT NULL auto_increment,
54 `answer_id` int(11) NOT NULL,
55 `revision` int(10) unsigned NOT NULL,
56 `author_id` int(11) NOT NULL,
57 `revised_at` datetime NOT NULL,
58 `summary` varchar(300) collate utf8_unicode_ci NOT NULL,
59 `text` longtext collate utf8_unicode_ci NOT NULL,
61 KEY `answer_revision_answer_id` (`answer_id`),
62 KEY `answer_revision_author_id` (`author_id`)
63 ) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8;
66 CREATE TABLE `auth_group` (
67 `id` int(11) NOT NULL auto_increment,
68 `name` varchar(80) NOT NULL,
70 UNIQUE KEY `name` (`name`)
71 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
74 CREATE TABLE `auth_group_permissions` (
75 `id` int(11) NOT NULL auto_increment,
76 `group_id` int(11) NOT NULL,
77 `permission_id` int(11) NOT NULL,
79 UNIQUE KEY `group_id` (`group_id`,`permission_id`),
80 KEY `permission_id_refs_id_5886d21f` (`permission_id`),
81 CONSTRAINT `group_id_refs_id_3cea63fe` FOREIGN KEY (`group_id`) REFERENCES `auth_group` (`id`),
82 CONSTRAINT `permission_id_refs_id_5886d21f` FOREIGN KEY (`permission_id`) REFERENCES `auth_permission` (`id`)
83 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
86 CREATE TABLE `auth_message` (
87 `id` int(11) NOT NULL auto_increment,
88 `user_id` int(11) NOT NULL,
89 `message` longtext NOT NULL,
91 KEY `auth_message_user_id` (`user_id`),
92 CONSTRAINT `user_id_refs_id_650f49a6` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`)
93 ) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8;
96 CREATE TABLE `auth_permission` (
97 `id` int(11) NOT NULL auto_increment,
98 `name` varchar(50) NOT NULL,
99 `content_type_id` int(11) NOT NULL,
100 `codename` varchar(100) NOT NULL,
102 UNIQUE KEY `content_type_id` (`content_type_id`,`codename`),
103 KEY `auth_permission_content_type_id` (`content_type_id`),
104 CONSTRAINT `content_type_id_refs_id_728de91f` FOREIGN KEY (`content_type_id`) REFERENCES `django_content_type` (`id`)
105 ) ENGINE=InnoDB AUTO_INCREMENT=88 DEFAULT CHARSET=utf8;
108 CREATE TABLE `auth_user` (
109 `id` int(11) NOT NULL auto_increment,
110 `username` varchar(30) NOT NULL,
111 `first_name` varchar(30) NOT NULL,
112 `last_name` varchar(30) NOT NULL,
113 `email` varchar(75) NOT NULL,
114 `password` varchar(128) NOT NULL,
115 `is_staff` tinyint(1) NOT NULL,
116 `is_active` tinyint(1) NOT NULL,
117 `is_superuser` tinyint(1) NOT NULL,
118 `last_login` datetime NOT NULL,
119 `date_joined` datetime NOT NULL,
120 `gold` smallint(6) NOT NULL default '0',
121 `silver` smallint(5) unsigned NOT NULL default '0',
122 `bronze` smallint(5) unsigned NOT NULL default '0',
123 `reputation` int(10) unsigned default '1',
124 `gravatar` varchar(128) default NULL,
125 `questions_per_page` smallint(5) unsigned default '10',
126 `last_seen` datetime default NULL,
127 `real_name` varchar(100) default NULL,
128 `website` varchar(200) default NULL,
129 `location` varchar(100) default NULL,
130 `date_of_birth` datetime default NULL,
133 UNIQUE KEY `username` (`username`)
134 ) ENGINE=InnoDB AUTO_INCREMENT=104 DEFAULT CHARSET=utf8;
137 CREATE TABLE `auth_user_groups` (
138 `id` int(11) NOT NULL auto_increment,
139 `user_id` int(11) NOT NULL,
140 `group_id` int(11) NOT NULL,
142 UNIQUE KEY `user_id` (`user_id`,`group_id`),
143 KEY `group_id_refs_id_f116770` (`group_id`),
144 CONSTRAINT `group_id_refs_id_f116770` FOREIGN KEY (`group_id`) REFERENCES `auth_group` (`id`),
145 CONSTRAINT `user_id_refs_id_7ceef80f` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`)
146 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
149 CREATE TABLE `auth_user_user_permissions` (
150 `id` int(11) NOT NULL auto_increment,
151 `user_id` int(11) NOT NULL,
152 `permission_id` int(11) NOT NULL,
154 UNIQUE KEY `user_id` (`user_id`,`permission_id`),
155 KEY `permission_id_refs_id_67e79cb` (`permission_id`),
156 CONSTRAINT `permission_id_refs_id_67e79cb` FOREIGN KEY (`permission_id`) REFERENCES `auth_permission` (`id`),
157 CONSTRAINT `user_id_refs_id_dfbab7d` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`)
158 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
161 CREATE TABLE `award` (
162 `id` int(11) NOT NULL auto_increment,
163 `user_id` int(11) NOT NULL,
164 `badge_id` int(11) NOT NULL,
165 `awarded_at` datetime NOT NULL,
166 `notified` tinyint(1) NOT NULL,
167 `content_type_id` int(11) default NULL,
168 `object_id` int(10) default NULL,
170 KEY `award_user_id` (`user_id`),
171 KEY `award_badge_id` (`badge_id`),
172 CONSTRAINT `badge_id_refs_id_651af0e1` FOREIGN KEY (`badge_id`) REFERENCES `badge` (`id`),
173 CONSTRAINT `user_id_refs_id_2d83e9b6` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`)
174 ) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8;
177 CREATE TABLE `badge` (
178 `id` int(11) NOT NULL auto_increment,
179 `name` varchar(50) NOT NULL,
180 `type` smallint(6) NOT NULL,
181 `slug` varchar(50) NOT NULL,
182 `description` varchar(300) NOT NULL,
183 `multiple` tinyint(1) NOT NULL,
184 `awarded_count` int(10) unsigned NOT NULL,
186 UNIQUE KEY `name` (`name`,`type`),
187 KEY `badge_slug` (`slug`)
188 ) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8;
191 CREATE TABLE `comment` (
192 `id` int(11) NOT NULL auto_increment,
193 `content_type_id` int(11) NOT NULL,
194 `object_id` int(10) unsigned NOT NULL,
195 `user_id` int(11) NOT NULL,
196 `comment` varchar(300) NOT NULL,
197 `added_at` datetime NOT NULL,
199 KEY `comment_content_type_id` (`content_type_id`),
200 KEY `comment_user_id` (`user_id`),
201 KEY `content_type_id` (`content_type_id`,`object_id`,`user_id`),
202 CONSTRAINT `content_type_id_refs_id_13a5866c` FOREIGN KEY (`content_type_id`) REFERENCES `django_content_type` (`id`),
203 CONSTRAINT `user_id_refs_id_6be725e8` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`)
204 ) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8;
207 CREATE TABLE `django_admin_log` (
208 `id` int(11) NOT NULL auto_increment,
209 `action_time` datetime NOT NULL,
210 `user_id` int(11) NOT NULL,
211 `content_type_id` int(11) default NULL,
212 `object_id` longtext,
213 `object_repr` varchar(200) NOT NULL,
214 `action_flag` smallint(5) unsigned NOT NULL,
215 `change_message` longtext NOT NULL,
217 KEY `django_admin_log_user_id` (`user_id`),
218 KEY `django_admin_log_content_type_id` (`content_type_id`),
219 CONSTRAINT `content_type_id_refs_id_288599e6` FOREIGN KEY (`content_type_id`) REFERENCES `django_content_type` (`id`),
220 CONSTRAINT `user_id_refs_id_c8665aa` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`)
221 ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
224 CREATE TABLE `django_authopenid_association` (
225 `id` int(11) NOT NULL auto_increment,
226 `server_url` longtext NOT NULL,
227 `handle` varchar(255) NOT NULL,
228 `secret` longtext NOT NULL,
229 `issued` int(11) NOT NULL,
230 `lifetime` int(11) NOT NULL,
231 `assoc_type` longtext NOT NULL,
233 ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
236 CREATE TABLE `django_authopenid_nonce` (
237 `id` int(11) NOT NULL auto_increment,
238 `server_url` varchar(255) NOT NULL,
239 `timestamp` int(11) NOT NULL,
240 `salt` varchar(40) NOT NULL,
242 ) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8;
245 CREATE TABLE `django_authopenid_userassociation` (
246 `id` int(11) NOT NULL auto_increment,
247 `openid_url` varchar(255) NOT NULL,
248 `user_id` int(11) NOT NULL,
250 UNIQUE KEY `user_id` (`user_id`),
251 CONSTRAINT `user_id_refs_id_163d208d` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`)
252 ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
255 CREATE TABLE `django_authopenid_userpasswordqueue` (
256 `id` int(11) NOT NULL auto_increment,
257 `user_id` int(11) NOT NULL,
258 `new_password` varchar(30) NOT NULL,
259 `confirm_key` varchar(40) NOT NULL,
261 UNIQUE KEY `user_id` (`user_id`),
262 CONSTRAINT `user_id_refs_id_76bcaaa4` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`)
263 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
266 CREATE TABLE `django_content_type` (
267 `id` int(11) NOT NULL auto_increment,
268 `name` varchar(100) NOT NULL,
269 `app_label` varchar(100) NOT NULL,
270 `model` varchar(100) NOT NULL,
272 UNIQUE KEY `app_label` (`app_label`,`model`)
273 ) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8;
276 CREATE TABLE `django_session` (
277 `session_key` varchar(40) NOT NULL,
278 `session_data` longtext NOT NULL,
279 `expire_date` datetime NOT NULL,
280 PRIMARY KEY (`session_key`)
281 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
284 CREATE TABLE `django_site` (
285 `id` int(11) NOT NULL auto_increment,
286 `domain` varchar(100) NOT NULL,
287 `name` varchar(50) NOT NULL,
289 ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
292 CREATE TABLE `favorite_question` (
293 `id` int(11) NOT NULL auto_increment,
294 `question_id` int(11) NOT NULL,
295 `user_id` int(11) NOT NULL,
296 `added_at` datetime NOT NULL,
298 KEY `favorite_question_question_id` (`question_id`),
299 KEY `favorite_question_user_id` (`user_id`),
300 CONSTRAINT `question_id_refs_id_1ebe1cc3` FOREIGN KEY (`question_id`) REFERENCES `question` (`id`),
301 CONSTRAINT `user_id_refs_id_52853822` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`)
302 ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
305 CREATE TABLE `flagged_item` (
306 `id` int(11) NOT NULL auto_increment,
307 `content_type_id` int(11) NOT NULL,
308 `object_id` int(10) unsigned NOT NULL,
309 `user_id` int(11) NOT NULL,
310 `flagged_at` datetime NOT NULL,
312 UNIQUE KEY `content_type_id` (`content_type_id`,`object_id`,`user_id`),
313 KEY `flagged_item_content_type_id` (`content_type_id`),
314 KEY `flagged_item_user_id` (`user_id`),
315 CONSTRAINT `content_type_id_refs_id_76e44d74` FOREIGN KEY (`content_type_id`) REFERENCES `django_content_type` (`id`),
316 CONSTRAINT `user_id_refs_id_35e3c608` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`)
317 ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
320 CREATE TABLE `question` (
321 `id` int(11) NOT NULL auto_increment,
322 `title` varchar(300) NOT NULL,
323 `author_id` int(11) NOT NULL,
324 `added_at` datetime NOT NULL,
325 `wiki` tinyint(1) NOT NULL,
326 `wikified_at` datetime default NULL,
327 `answer_accepted` tinyint(1) NOT NULL,
328 `closed` tinyint(1) NOT NULL,
329 `closed_by_id` int(11) default NULL,
330 `closed_at` datetime default NULL,
331 `close_reason` smallint(6) default NULL,
332 `deleted` tinyint(1) NOT NULL,
333 `deleted_at` datetime default NULL,
334 `deleted_by_id` int(11) default NULL,
335 `locked` tinyint(1) NOT NULL,
336 `locked_by_id` int(11) default NULL,
337 `locked_at` datetime default NULL,
338 `score` int(11) NOT NULL,
339 `answer_count` int(10) unsigned NOT NULL,
340 `comment_count` int(10) unsigned NOT NULL,
341 `view_count` int(10) unsigned NOT NULL,
342 `offensive_flag_count` smallint(6) NOT NULL,
343 `favourite_count` int(10) unsigned NOT NULL,
344 `last_edited_at` datetime default NULL,
345 `last_edited_by_id` int(11) default NULL,
346 `last_activity_at` datetime NOT NULL,
347 `last_activity_by_id` int(11) NOT NULL,
348 `tagnames` varchar(125) NOT NULL,
349 `summary` varchar(180) NOT NULL,
350 `html` longtext NOT NULL,
351 `vote_up_count` int(11) NOT NULL,
352 `vote_down_count` int(11) NOT NULL,
354 KEY `question_author_id` (`author_id`),
355 KEY `question_closed_by_id` (`closed_by_id`),
356 KEY `question_deleted_by_id` (`deleted_by_id`),
357 KEY `question_locked_by_id` (`locked_by_id`),
358 KEY `question_last_edited_by_id` (`last_edited_by_id`),
359 KEY `question_last_activity_by_id` (`last_activity_by_id`),
360 CONSTRAINT `author_id_refs_id_56e9d00c` FOREIGN KEY (`author_id`) REFERENCES `auth_user` (`id`),
361 CONSTRAINT `closed_by_id_refs_id_56e9d00c` FOREIGN KEY (`closed_by_id`) REFERENCES `auth_user` (`id`),
362 CONSTRAINT `deleted_by_id_refs_id_56e9d00c` FOREIGN KEY (`deleted_by_id`) REFERENCES `auth_user` (`id`),
363 CONSTRAINT `last_activity_by_id_refs_id_56e9d00c` FOREIGN KEY (`last_activity_by_id`) REFERENCES `auth_user` (`id`),
364 CONSTRAINT `last_edited_by_id_refs_id_56e9d00c` FOREIGN KEY (`last_edited_by_id`) REFERENCES `auth_user` (`id`),
365 CONSTRAINT `locked_by_id_refs_id_56e9d00c` FOREIGN KEY (`locked_by_id`) REFERENCES `auth_user` (`id`)
366 ) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8;
369 CREATE TABLE `question_revision` (
370 `id` int(11) NOT NULL auto_increment,
371 `question_id` int(11) NOT NULL,
372 `revision` int(10) unsigned NOT NULL,
373 `title` varchar(300) NOT NULL,
374 `author_id` int(11) NOT NULL,
375 `revised_at` datetime NOT NULL,
376 `tagnames` varchar(125) NOT NULL,
377 `summary` varchar(300) NOT NULL,
378 `text` longtext NOT NULL,
380 KEY `question_revision_question_id` (`question_id`),
381 KEY `question_revision_author_id` (`author_id`)
382 ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;
385 CREATE TABLE `question_tags` (
386 `id` int(11) NOT NULL auto_increment,
387 `question_id` int(11) NOT NULL,
388 `tag_id` int(11) NOT NULL,
390 UNIQUE KEY `question_id` (`question_id`,`tag_id`),
391 KEY `tag_id_refs_id_43fcb953` (`tag_id`),
392 CONSTRAINT `question_id_refs_id_266147c6` FOREIGN KEY (`question_id`) REFERENCES `question` (`id`),
393 CONSTRAINT `tag_id_refs_id_43fcb953` FOREIGN KEY (`tag_id`) REFERENCES `tag` (`id`)
394 ) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8;
397 CREATE TABLE `repute` (
398 `id` int(11) NOT NULL auto_increment,
399 `user_id` int(11) NOT NULL,
400 `positive` smallint(6) NOT NULL,
401 `negative` smallint(6) NOT NULL,
402 `question_id` int(11) NOT NULL,
403 `reputed_at` datetime NOT NULL,
404 `reputation_type` smallint(6) NOT NULL,
405 `reputation` int(11) NOT NULL,
407 KEY `repute_user_id` (`user_id`),
408 KEY `repute_question_id` (`question_id`)
409 ) ENGINE=MyISAM AUTO_INCREMENT=17 DEFAULT CHARSET=utf8;
413 `id` int(11) NOT NULL auto_increment,
414 `name` varchar(255) NOT NULL,
415 `created_by_id` int(11) NOT NULL,
416 `used_count` int(10) unsigned NOT NULL,
418 UNIQUE KEY `name` (`name`),
419 KEY `tag_created_by_id` (`created_by_id`),
420 CONSTRAINT `created_by_id_refs_id_47205d6d` FOREIGN KEY (`created_by_id`) REFERENCES `auth_user` (`id`)
421 ) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8;
424 CREATE TABLE `user_badge` (
425 `id` int(10) unsigned NOT NULL auto_increment,
426 `user_id` int(10) unsigned NOT NULL,
427 `badge_id` int(10) unsigned NOT NULL,
429 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
432 CREATE TABLE `user_favorite_questions` (
433 `id` int(10) unsigned NOT NULL auto_increment,
434 `user_id` int(10) unsigned NOT NULL,
435 `question_id` int(10) unsigned NOT NULL,
437 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
440 CREATE TABLE `vote` (
441 `id` int(11) NOT NULL auto_increment,
442 `content_type_id` int(11) NOT NULL,
443 `object_id` int(10) unsigned NOT NULL,
444 `user_id` int(11) NOT NULL,
445 `vote` smallint(6) NOT NULL,
446 `voted_at` datetime NOT NULL,
448 UNIQUE KEY `content_type_id` (`content_type_id`,`object_id`,`user_id`),
449 KEY `vote_content_type_id` (`content_type_id`),
450 KEY `vote_user_id` (`user_id`),
451 CONSTRAINT `content_type_id_refs_id_50124414` FOREIGN KEY (`content_type_id`) REFERENCES `django_content_type` (`id`),
452 CONSTRAINT `user_id_refs_id_760a4df0` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`)
453 ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
456 SET FOREIGN_KEY_CHECKS = 1;