4 /************ Update: Tables ***************/
6 /******************** Add Table: activity ************************/
8 /* Build Table Structure */
11 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
12 user_id INTEGER NOT NULL,
13 activity_type SMALLINT NOT NULL,
14 active_at DATETIME NOT NULL,
15 content_type_id INTEGER NOT NULL,
16 object_id INTEGER UNSIGNED NOT NULL,
17 is_auditted TINYINT NULL DEFAULT 0
18 ) ENGINE=MyISAM AUTO_INCREMENT=103 DEFAULT CHARSET=latin1;
20 /* Table Items: activity */
22 /* Add Indexes for: activity */
23 CREATE INDEX activity_content_type_id ON activity (content_type_id);
24 CREATE INDEX activity_user_id ON activity (user_id);
26 /******************** Add Table: answer ************************/
28 /* Build Table Structure */
31 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
32 question_id INTEGER NOT NULL,
33 author_id INTEGER NOT NULL,
34 added_at DATETIME NOT NULL,
35 wiki TINYINT NOT NULL,
36 wikified_at DATETIME NULL,
37 accepted TINYINT NOT NULL,
38 deleted TINYINT NOT NULL,
39 deleted_by_id INTEGER NULL,
40 locked TINYINT NOT NULL,
41 locked_by_id INTEGER NULL,
42 locked_at DATETIME NULL,
43 score INTEGER NOT NULL,
44 comment_count INTEGER UNSIGNED NOT NULL,
45 offensive_flag_count SMALLINT NOT NULL,
46 last_edited_at DATETIME NULL,
47 last_edited_by_id INTEGER NULL,
48 html LONGTEXT NOT NULL,
49 vote_up_count INTEGER NOT NULL,
50 vote_down_count INTEGER NOT NULL,
51 accepted_at DATETIME NULL
52 ) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8;
54 /* Table Items: answer */
56 /* Add Indexes for: answer */
57 CREATE INDEX answer_author_id ON answer (author_id);
58 CREATE INDEX answer_deleted_by_id ON answer (deleted_by_id);
59 CREATE INDEX answer_last_edited_by_id ON answer (last_edited_by_id);
60 CREATE INDEX answer_locked_by_id ON answer (locked_by_id);
61 CREATE INDEX answer_question_id ON answer (question_id);
63 /******************** Add Table: answer_revision ************************/
65 /* Build Table Structure */
66 CREATE TABLE answer_revision
68 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
69 answer_id INTEGER NOT NULL,
70 revision INTEGER UNSIGNED NOT NULL,
71 author_id INTEGER NOT NULL,
72 revised_at DATETIME NOT NULL,
73 summary TEXT NOT NULL,
74 `text` LONGTEXT NOT NULL
75 ) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
77 /* Table Items: answer_revision */
79 /* Add Indexes for: answer_revision */
80 CREATE INDEX answer_revision_answer_id ON answer_revision (answer_id);
81 CREATE INDEX answer_revision_author_id ON answer_revision (author_id);
83 /******************** Add Table: auth_group ************************/
85 /* Build Table Structure */
86 CREATE TABLE auth_group
88 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
89 name VARCHAR(80) NOT NULL
90 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
92 /* Table Items: auth_group */
94 /* Add Indexes for: auth_group */
95 CREATE UNIQUE INDEX name ON auth_group (name);
97 /******************** Add Table: auth_group_permissions ************************/
99 /* Build Table Structure */
100 CREATE TABLE auth_group_permissions
102 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
103 group_id INTEGER NOT NULL,
104 permission_id INTEGER NOT NULL
105 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
107 /* Table Items: auth_group_permissions */
109 /* Add Indexes for: auth_group_permissions */
110 CREATE UNIQUE INDEX group_id ON auth_group_permissions (group_id, permission_id);
111 CREATE INDEX permission_id_refs_id_5886d21f ON auth_group_permissions (permission_id);
113 /******************** Add Table: auth_message ************************/
115 /* Build Table Structure */
116 CREATE TABLE auth_message
118 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
119 user_id INTEGER NOT NULL,
120 message LONGTEXT NOT NULL
121 ) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8;
123 /* Table Items: auth_message */
125 /* Add Indexes for: auth_message */
126 CREATE INDEX auth_message_user_id ON auth_message (user_id);
128 /******************** Add Table: auth_permission ************************/
130 /* Build Table Structure */
131 CREATE TABLE auth_permission
133 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
134 name VARCHAR(50) NOT NULL,
135 content_type_id INTEGER NOT NULL,
136 codename VARCHAR(100) NOT NULL
137 ) ENGINE=InnoDB AUTO_INCREMENT=88 DEFAULT CHARSET=utf8;
139 /* Table Items: auth_permission */
141 /* Add Indexes for: auth_permission */
142 CREATE INDEX auth_permission_content_type_id ON auth_permission (content_type_id);
143 CREATE UNIQUE INDEX content_type_id ON auth_permission (content_type_id, codename);
145 /******************** Add Table: auth_user ************************/
147 /* Build Table Structure */
148 CREATE TABLE auth_user
150 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
151 username VARCHAR(30) NOT NULL,
152 first_name VARCHAR(30) NOT NULL,
153 last_name VARCHAR(30) NOT NULL,
154 email VARCHAR(75) NOT NULL,
155 password VARCHAR(128) NOT NULL,
156 is_staff TINYINT NOT NULL,
157 is_active TINYINT NOT NULL,
158 is_superuser TINYINT NOT NULL,
159 last_login DATETIME NOT NULL,
160 date_joined DATETIME NOT NULL,
161 gold SMALLINT NOT NULL DEFAULT 0,
162 silver SMALLINT UNSIGNED NOT NULL DEFAULT 0,
163 bronze SMALLINT UNSIGNED NOT NULL DEFAULT 0,
164 reputation INTEGER UNSIGNED NULL DEFAULT 1,
165 gravatar VARCHAR(128) NULL,
166 questions_per_page SMALLINT UNSIGNED NULL DEFAULT 10,
167 last_seen DATETIME NULL,
168 real_name VARCHAR(100) NULL,
169 website VARCHAR(200) NULL,
170 location VARCHAR(100) NULL,
171 date_of_birth DATETIME NULL,
173 ) ENGINE=InnoDB AUTO_INCREMENT=104 DEFAULT CHARSET=utf8;
175 /* Table Items: auth_user */
177 /* Add Indexes for: auth_user */
178 CREATE UNIQUE INDEX username ON auth_user (username);
180 /******************** Add Table: auth_user_groups ************************/
182 /* Build Table Structure */
183 CREATE TABLE auth_user_groups
185 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
186 user_id INTEGER NOT NULL,
187 group_id INTEGER NOT NULL
188 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
190 /* Table Items: auth_user_groups */
192 /* Add Indexes for: auth_user_groups */
193 CREATE INDEX group_id_refs_id_f116770 ON auth_user_groups (group_id);
194 CREATE UNIQUE INDEX user_id ON auth_user_groups (user_id, group_id);
196 /******************** Add Table: auth_user_user_permissions ************************/
198 /* Build Table Structure */
199 CREATE TABLE auth_user_user_permissions
201 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
202 user_id INTEGER NOT NULL,
203 permission_id INTEGER NOT NULL
204 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
206 /* Table Items: auth_user_user_permissions */
208 /* Add Indexes for: auth_user_user_permissions */
209 CREATE INDEX permission_id_refs_id_67e79cb ON auth_user_user_permissions (permission_id);
210 CREATE UNIQUE INDEX user_id ON auth_user_user_permissions (user_id, permission_id);
212 /******************** Add Table: award ************************/
214 /* Build Table Structure */
217 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
218 user_id INTEGER NOT NULL,
219 badge_id INTEGER NOT NULL,
220 awarded_at DATETIME NOT NULL,
221 notified TINYINT NOT NULL,
222 content_type_id INTEGER NULL,
223 object_id INTEGER NULL
224 ) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8;
226 /* Table Items: award */
228 /* Add Indexes for: award */
229 CREATE INDEX award_badge_id ON award (badge_id);
230 CREATE INDEX award_user_id ON award (user_id);
232 /******************** Add Table: badge ************************/
234 /* Build Table Structure */
237 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
238 name VARCHAR(50) NOT NULL,
239 `type` SMALLINT NOT NULL,
240 slug VARCHAR(50) NOT NULL,
241 description TEXT NOT NULL,
242 multiple TINYINT NOT NULL,
243 awarded_count INTEGER UNSIGNED NOT NULL
244 ) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8;
246 /* Table Items: badge */
248 /* Add Indexes for: badge */
249 CREATE INDEX badge_slug ON badge (slug);
250 CREATE UNIQUE INDEX name ON badge (name, `type`);
252 /******************** Add Table: book ************************/
254 /* Build Table Structure */
257 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
258 title VARCHAR(255) NOT NULL,
259 short_name VARCHAR(255) NOT NULL,
260 author VARCHAR(255) NOT NULL,
261 user_id INTEGER NULL,
262 price DECIMAL(10, 2) NULL,
264 published_at DATE NOT NULL,
265 publication VARCHAR(255) NOT NULL,
266 cover_img VARCHAR(255) NULL,
267 tagnames VARCHAR(125) NULL,
268 added_at DATETIME NOT NULL,
269 last_edited_at DATETIME NOT NULL
272 /* Table Items: book */
274 /* Add Indexes for: book */
275 CREATE UNIQUE INDEX book_short_name_Idx ON book (short_name);
276 CREATE INDEX fk_books_auth_user ON book (user_id);
278 /******************** Add Table: book_author_info ************************/
280 /* Build Table Structure */
281 CREATE TABLE book_author_info
283 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
284 blog_url VARCHAR(255) NULL,
285 user_id INTEGER NOT NULL,
286 added_at DATETIME NOT NULL,
287 last_edited_at DATETIME NOT NULL,
288 book_id INTEGER NOT NULL
291 /* Table Items: book_author_info */
293 /* Add Indexes for: book_author_info */
294 CREATE INDEX fk_book_author_info_auth_user ON book_author_info (user_id);
295 CREATE INDEX fk_book_author_info_book ON book_author_info (book_id);
297 /******************** Add Table: book_author_rss ************************/
299 /* Build Table Structure */
300 CREATE TABLE book_author_rss
302 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
303 title VARCHAR(255) NOT NULL,
304 url VARCHAR(255) NOT NULL,
305 rss_created_at DATETIME NOT NULL,
306 user_id INTEGER NOT NULL,
307 added_at DATETIME NOT NULL,
308 book_id INTEGER NOT NULL
311 /* Table Items: book_author_rss */
313 /* Add Indexes for: book_author_rss */
314 CREATE INDEX fk_book_author_rss_auth_user ON book_author_rss (user_id);
315 CREATE INDEX fk_book_author_rss_book ON book_author_rss (book_id);
317 /******************** Add Table: book_question ************************/
319 /* Build Table Structure */
320 CREATE TABLE book_question
322 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
323 book_id INTEGER NOT NULL,
324 question_id INTEGER NOT NULL
327 /* Table Items: book_question */
329 /* Add Indexes for: book_question */
330 CREATE INDEX fk_book_question_book ON book_question (book_id);
331 CREATE INDEX fk_book_question_question ON book_question (question_id);
333 /******************** Add Table: `comment` ************************/
335 /* Build Table Structure */
336 CREATE TABLE `comment`
338 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
339 content_type_id INTEGER NOT NULL,
340 object_id INTEGER UNSIGNED NOT NULL,
341 user_id INTEGER NOT NULL,
342 `comment` TEXT NOT NULL,
343 added_at DATETIME NOT NULL
344 ) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8;
346 /* Table Items: `comment` */
348 /* Add Indexes for: comment */
349 CREATE INDEX comment_content_type_id ON `comment` (content_type_id);
350 CREATE INDEX comment_user_id ON `comment` (user_id);
351 CREATE INDEX content_type_id ON `comment` (content_type_id, object_id, user_id);
353 /******************** Add Table: django_admin_log ************************/
355 /* Build Table Structure */
356 CREATE TABLE django_admin_log
358 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
359 action_time DATETIME NOT NULL,
360 user_id INTEGER NOT NULL,
361 content_type_id INTEGER NULL,
362 object_id LONGTEXT NULL,
363 object_repr VARCHAR(200) NOT NULL,
364 action_flag SMALLINT UNSIGNED NOT NULL,
365 change_message LONGTEXT NOT NULL
366 ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
368 /* Table Items: django_admin_log */
370 /* Add Indexes for: django_admin_log */
371 CREATE INDEX django_admin_log_content_type_id ON django_admin_log (content_type_id);
372 CREATE INDEX django_admin_log_user_id ON django_admin_log (user_id);
374 /******************** Add Table: django_authopenid_association ************************/
376 /* Build Table Structure */
377 CREATE TABLE django_authopenid_association
379 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
380 server_url LONGTEXT NOT NULL,
381 handle VARCHAR(255) NOT NULL,
382 secret LONGTEXT NOT NULL,
383 issued INTEGER NOT NULL,
384 lifetime INTEGER NOT NULL,
385 assoc_type LONGTEXT NOT NULL
386 ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
388 /******************** Add Table: django_authopenid_nonce ************************/
390 /* Build Table Structure */
391 CREATE TABLE django_authopenid_nonce
393 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
394 server_url VARCHAR(255) NOT NULL,
395 `timestamp` INTEGER NOT NULL,
396 salt VARCHAR(40) NOT NULL
397 ) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8;
399 /******************** Add Table: django_authopenid_userassociation ************************/
401 /* Build Table Structure */
402 CREATE TABLE django_authopenid_userassociation
404 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
405 openid_url VARCHAR(255) NOT NULL,
406 user_id INTEGER NOT NULL
407 ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
409 /* Table Items: django_authopenid_userassociation */
411 /* Add Indexes for: django_authopenid_userassociation */
412 CREATE UNIQUE INDEX user_id ON django_authopenid_userassociation (user_id);
414 /******************** Add Table: django_authopenid_userpasswordqueue ************************/
416 /* Build Table Structure */
417 CREATE TABLE django_authopenid_userpasswordqueue
419 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
420 user_id INTEGER NOT NULL,
421 new_password VARCHAR(30) NOT NULL,
422 confirm_key VARCHAR(40) NOT NULL
423 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
425 /* Table Items: django_authopenid_userpasswordqueue */
427 /* Add Indexes for: django_authopenid_userpasswordqueue */
428 CREATE UNIQUE INDEX user_id ON django_authopenid_userpasswordqueue (user_id);
430 /******************** Add Table: django_content_type ************************/
432 /* Build Table Structure */
433 CREATE TABLE django_content_type
435 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
436 name VARCHAR(100) NOT NULL,
437 app_label VARCHAR(100) NOT NULL,
438 model VARCHAR(100) NOT NULL
439 ) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8;
441 /* Table Items: django_content_type */
443 /* Add Indexes for: django_content_type */
444 CREATE UNIQUE INDEX app_label ON django_content_type (app_label, model);
446 /******************** Add Table: django_session ************************/
448 /* Build Table Structure */
449 CREATE TABLE django_session
451 session_key VARCHAR(40) NOT NULL,
452 session_data LONGTEXT NOT NULL,
453 expire_date DATETIME NOT NULL
454 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
456 /* Table Items: django_session */
457 ALTER TABLE django_session ADD CONSTRAINT pkdjango_session
458 PRIMARY KEY (session_key);
460 /******************** Add Table: django_site ************************/
462 /* Build Table Structure */
463 CREATE TABLE django_site
465 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
466 domain VARCHAR(100) NOT NULL,
467 name VARCHAR(50) NOT NULL
468 ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
470 /******************** Add Table: favorite_question ************************/
472 /* Build Table Structure */
473 CREATE TABLE favorite_question
475 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
476 question_id INTEGER NOT NULL,
477 user_id INTEGER NOT NULL,
478 added_at DATETIME NOT NULL
479 ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
481 /* Table Items: favorite_question */
483 /* Add Indexes for: favorite_question */
484 CREATE INDEX favorite_question_question_id ON favorite_question (question_id);
485 CREATE INDEX favorite_question_user_id ON favorite_question (user_id);
487 /******************** Add Table: flagged_item ************************/
489 /* Build Table Structure */
490 CREATE TABLE flagged_item
492 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
493 content_type_id INTEGER NOT NULL,
494 object_id INTEGER UNSIGNED NOT NULL,
495 user_id INTEGER NOT NULL,
496 flagged_at DATETIME NOT NULL
497 ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
499 /* Table Items: flagged_item */
501 /* Add Indexes for: flagged_item */
502 CREATE UNIQUE INDEX content_type_id ON flagged_item (content_type_id, object_id, user_id);
503 CREATE INDEX flagged_item_content_type_id ON flagged_item (content_type_id);
504 CREATE INDEX flagged_item_user_id ON flagged_item (user_id);
506 /******************** Add Table: question ************************/
508 /* Build Table Structure */
509 CREATE TABLE question
511 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
513 author_id INTEGER NOT NULL,
514 added_at DATETIME NOT NULL,
515 wiki TINYINT NOT NULL,
516 wikified_at DATETIME NULL,
517 answer_accepted TINYINT NOT NULL,
518 closed TINYINT NOT NULL,
519 closed_by_id INTEGER NULL,
520 closed_at DATETIME NULL,
521 close_reason SMALLINT NULL,
522 deleted TINYINT NOT NULL,
523 deleted_at DATETIME NULL,
524 deleted_by_id INTEGER NULL,
525 locked TINYINT NOT NULL,
526 locked_by_id INTEGER NULL,
527 locked_at DATETIME NULL,
528 score INTEGER NOT NULL,
529 answer_count INTEGER UNSIGNED NOT NULL,
530 comment_count INTEGER UNSIGNED NOT NULL,
531 view_count INTEGER UNSIGNED NOT NULL,
532 offensive_flag_count SMALLINT NOT NULL,
533 favourite_count INTEGER UNSIGNED NOT NULL,
534 last_edited_at DATETIME NULL,
535 last_edited_by_id INTEGER NULL,
536 last_activity_at DATETIME NOT NULL,
537 last_activity_by_id INTEGER NOT NULL,
538 tagnames VARCHAR(125) NOT NULL,
539 summary VARCHAR(180) NOT NULL,
540 html LONGTEXT NOT NULL,
541 vote_up_count INTEGER NOT NULL,
542 vote_down_count INTEGER NOT NULL
543 ) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8;
545 /* Table Items: question */
547 /* Add Indexes for: question */
548 CREATE INDEX question_author_id ON question (author_id);
549 CREATE INDEX question_closed_by_id ON question (closed_by_id);
550 CREATE INDEX question_deleted_by_id ON question (deleted_by_id);
551 CREATE INDEX question_last_activity_by_id ON question (last_activity_by_id);
552 CREATE INDEX question_last_edited_by_id ON question (last_edited_by_id);
553 CREATE INDEX question_locked_by_id ON question (locked_by_id);
555 /******************** Add Table: question_revision ************************/
557 /* Build Table Structure */
558 CREATE TABLE question_revision
560 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
561 question_id INTEGER NOT NULL,
562 revision INTEGER UNSIGNED NOT NULL,
564 author_id INTEGER NOT NULL,
565 revised_at DATETIME NOT NULL,
566 tagnames VARCHAR(125) NOT NULL,
567 summary TEXT NOT NULL,
568 `text` LONGTEXT NOT NULL
569 ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;
571 /* Table Items: question_revision */
573 /* Add Indexes for: question_revision */
574 CREATE INDEX question_revision_author_id ON question_revision (author_id);
575 CREATE INDEX question_revision_question_id ON question_revision (question_id);
577 /******************** Add Table: question_tags ************************/
579 /* Build Table Structure */
580 CREATE TABLE question_tags
582 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
583 question_id INTEGER NOT NULL,
584 tag_id INTEGER NOT NULL
585 ) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8;
587 /* Table Items: question_tags */
589 /* Add Indexes for: question_tags */
590 CREATE UNIQUE INDEX question_id ON question_tags (question_id, tag_id);
591 CREATE INDEX tag_id_refs_id_43fcb953 ON question_tags (tag_id);
593 /******************** Add Table: repute ************************/
595 /* Build Table Structure */
598 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
599 user_id INTEGER NOT NULL,
600 positive SMALLINT NOT NULL,
601 negative SMALLINT NOT NULL,
602 question_id INTEGER NOT NULL,
603 reputed_at DATETIME NOT NULL,
604 reputation_type SMALLINT NOT NULL,
605 reputation INTEGER NOT NULL
606 ) ENGINE=MyISAM AUTO_INCREMENT=17 DEFAULT CHARSET=latin1;
608 /* Table Items: repute */
610 /* Add Indexes for: repute */
611 CREATE INDEX repute_question_id ON repute (question_id);
612 CREATE INDEX repute_user_id ON repute (user_id);
614 /******************** Add Table: tag ************************/
616 /* Build Table Structure */
619 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
620 name VARCHAR(255) NOT NULL,
621 created_by_id INTEGER NOT NULL,
622 used_count INTEGER UNSIGNED NOT NULL
623 ) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8;
625 /* Table Items: tag */
627 /* Add Indexes for: tag */
628 CREATE UNIQUE INDEX name ON tag (name);
629 CREATE INDEX tag_created_by_id ON tag (created_by_id);
631 /******************** Add Table: user_badge ************************/
633 /* Build Table Structure */
634 CREATE TABLE user_badge
636 id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
637 user_id INTEGER NOT NULL,
638 badge_id INTEGER NOT NULL
639 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
641 /* Table Items: user_badge */
643 /* Add Indexes for: user_badge */
644 CREATE INDEX fk_user_badge_auth_user ON user_badge (user_id);
645 CREATE INDEX fk_user_badge_badge ON user_badge (badge_id);
647 /******************** Add Table: user_favorite_questions ************************/
649 /* Build Table Structure */
650 CREATE TABLE user_favorite_questions
652 id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
653 user_id INTEGER NOT NULL,
654 question_id INTEGER NOT NULL
655 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
657 /* Table Items: user_favorite_questions */
659 /* Add Indexes for: user_favorite_questions */
660 CREATE INDEX fk_user_favorite_questions_auth_user ON user_favorite_questions (user_id);
661 CREATE INDEX fk_user_favorite_questions_question ON user_favorite_questions (question_id);
663 /******************** Add Table: vote ************************/
665 /* Build Table Structure */
668 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
669 content_type_id INTEGER NOT NULL,
670 object_id INTEGER UNSIGNED NOT NULL,
671 user_id INTEGER NOT NULL,
672 vote SMALLINT NOT NULL,
673 voted_at DATETIME NOT NULL
674 ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
676 /* Table Items: vote */
678 /* Add Indexes for: vote */
679 CREATE UNIQUE INDEX content_type_id ON vote (content_type_id, object_id, user_id);
680 CREATE INDEX vote_content_type_id ON vote (content_type_id);
681 CREATE INDEX vote_user_id ON vote (user_id);
684 /************ Add Foreign Keys to Database ***************/
685 /*-----------------------------------------------------------
686 Warning: Versions of MySQL prior to 4.1.2 require indexes on all columns involved in a foreign key. The following indexes may be required:
687 fk_auth_group_permissions_auth_group may require an index on table: auth_group_permissions, column: group_id
688 fk_auth_user_groups_auth_user may require an index on table: auth_user_groups, column: user_id
689 fk_auth_user_user_permissions_auth_user may require an index on table: auth_user_user_permissions, column: user_id
690 fk_question_tags_question may require an index on table: question_tags, column: question_id
691 -----------------------------------------------------------
694 /************ Foreign Key: fk_activity_auth_user ***************/
695 ALTER TABLE activity ADD CONSTRAINT fk_activity_auth_user
696 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
698 /************ Foreign Key: deleted_by_id_refs_id_192b0170 ***************/
699 ALTER TABLE answer ADD CONSTRAINT deleted_by_id_refs_id_192b0170
700 FOREIGN KEY (deleted_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
702 /************ Foreign Key: fk_answer_auth_user ***************/
703 ALTER TABLE answer ADD CONSTRAINT fk_answer_auth_user
704 FOREIGN KEY (author_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
706 /************ Foreign Key: fk_answer_question ***************/
707 ALTER TABLE answer ADD CONSTRAINT fk_answer_question
708 FOREIGN KEY (question_id) REFERENCES question (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
710 /************ Foreign Key: last_edited_by_id_refs_id_192b0170 ***************/
711 ALTER TABLE answer ADD CONSTRAINT last_edited_by_id_refs_id_192b0170
712 FOREIGN KEY (last_edited_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
714 /************ Foreign Key: locked_by_id_refs_id_192b0170 ***************/
715 ALTER TABLE answer ADD CONSTRAINT locked_by_id_refs_id_192b0170
716 FOREIGN KEY (locked_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
718 /************ Foreign Key: fk_answer_revision_auth_user ***************/
719 ALTER TABLE answer_revision ADD CONSTRAINT fk_answer_revision_auth_user
720 FOREIGN KEY (author_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
722 /************ Foreign Key: fk_auth_group_permissions_auth_group ***************/
723 ALTER TABLE auth_group_permissions ADD CONSTRAINT fk_auth_group_permissions_auth_group
724 FOREIGN KEY (group_id) REFERENCES auth_group (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
726 /************ Foreign Key: fk_auth_group_permissions_auth_permission ***************/
727 ALTER TABLE auth_group_permissions ADD CONSTRAINT fk_auth_group_permissions_auth_permission
728 FOREIGN KEY (permission_id) REFERENCES auth_permission (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
730 /************ Foreign Key: fk_auth_message_auth_user ***************/
731 ALTER TABLE auth_message ADD CONSTRAINT fk_auth_message_auth_user
732 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
734 /************ Foreign Key: fk_auth_permission_django_content_type ***************/
735 ALTER TABLE auth_permission ADD CONSTRAINT fk_auth_permission_django_content_type
736 FOREIGN KEY (content_type_id) REFERENCES django_content_type (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
738 /************ Foreign Key: fk_auth_user_groups_auth_group ***************/
739 ALTER TABLE auth_user_groups ADD CONSTRAINT fk_auth_user_groups_auth_group
740 FOREIGN KEY (group_id) REFERENCES auth_group (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
742 /************ Foreign Key: fk_auth_user_groups_auth_user ***************/
743 ALTER TABLE auth_user_groups ADD CONSTRAINT fk_auth_user_groups_auth_user
744 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
746 /************ Foreign Key: fk_auth_user_user_permissions_auth_permission ***************/
747 ALTER TABLE auth_user_user_permissions ADD CONSTRAINT fk_auth_user_user_permissions_auth_permission
748 FOREIGN KEY (permission_id) REFERENCES auth_permission (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
750 /************ Foreign Key: fk_auth_user_user_permissions_auth_user ***************/
751 ALTER TABLE auth_user_user_permissions ADD CONSTRAINT fk_auth_user_user_permissions_auth_user
752 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
754 /************ Foreign Key: fk_award_auth_user ***************/
755 ALTER TABLE award ADD CONSTRAINT fk_award_auth_user
756 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
758 /************ Foreign Key: fk_award_badge ***************/
759 ALTER TABLE award ADD CONSTRAINT fk_award_badge
760 FOREIGN KEY (badge_id) REFERENCES badge (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
762 /************ Foreign Key: fk_books_auth_user ***************/
763 ALTER TABLE book ADD CONSTRAINT fk_books_auth_user
764 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
766 /************ Foreign Key: fk_book_author_info_auth_user ***************/
767 ALTER TABLE book_author_info ADD CONSTRAINT fk_book_author_info_auth_user
768 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
770 /************ Foreign Key: fk_book_author_info_book ***************/
771 ALTER TABLE book_author_info ADD CONSTRAINT fk_book_author_info_book
772 FOREIGN KEY (book_id) REFERENCES book (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
774 /************ Foreign Key: fk_book_author_rss_auth_user ***************/
775 ALTER TABLE book_author_rss ADD CONSTRAINT fk_book_author_rss_auth_user
776 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
778 /************ Foreign Key: fk_book_author_rss_book ***************/
779 ALTER TABLE book_author_rss ADD CONSTRAINT fk_book_author_rss_book
780 FOREIGN KEY (book_id) REFERENCES book (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
782 /************ Foreign Key: fk_book_question_book ***************/
783 ALTER TABLE book_question ADD CONSTRAINT fk_book_question_book
784 FOREIGN KEY (book_id) REFERENCES book (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
786 /************ Foreign Key: fk_book_question_question ***************/
787 ALTER TABLE book_question ADD CONSTRAINT fk_book_question_question
788 FOREIGN KEY (question_id) REFERENCES question (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
790 /************ Foreign Key: fk_comment_auth_user ***************/
791 ALTER TABLE `comment` ADD CONSTRAINT fk_comment_auth_user
792 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
794 /************ Foreign Key: fk_comment_django_content_type ***************/
795 ALTER TABLE `comment` ADD CONSTRAINT fk_comment_django_content_type
796 FOREIGN KEY (content_type_id) REFERENCES django_content_type (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
798 /************ Foreign Key: fk_django_admin_log_auth_user ***************/
799 ALTER TABLE django_admin_log ADD CONSTRAINT fk_django_admin_log_auth_user
800 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
802 /************ Foreign Key: fk_django_admin_log_django_content_type ***************/
803 ALTER TABLE django_admin_log ADD CONSTRAINT fk_django_admin_log_django_content_type
804 FOREIGN KEY (content_type_id) REFERENCES django_content_type (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
806 /************ Foreign Key: fk_django_authopenid_userassociation_auth_user ***************/
807 ALTER TABLE django_authopenid_userassociation ADD CONSTRAINT fk_django_authopenid_userassociation_auth_user
808 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
810 /************ Foreign Key: fk_django_authopenid_userpasswordqueue_auth_user ***************/
811 ALTER TABLE django_authopenid_userpasswordqueue ADD CONSTRAINT fk_django_authopenid_userpasswordqueue_auth_user
812 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
814 /************ Foreign Key: fk_favorite_question_auth_user ***************/
815 ALTER TABLE favorite_question ADD CONSTRAINT fk_favorite_question_auth_user
816 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
818 /************ Foreign Key: fk_favorite_question_question ***************/
819 ALTER TABLE favorite_question ADD CONSTRAINT fk_favorite_question_question
820 FOREIGN KEY (question_id) REFERENCES question (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
822 /************ Foreign Key: fk_flagged_item_auth_user ***************/
823 ALTER TABLE flagged_item ADD CONSTRAINT fk_flagged_item_auth_user
824 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
826 /************ Foreign Key: fk_flagged_item_django_content_type ***************/
827 ALTER TABLE flagged_item ADD CONSTRAINT fk_flagged_item_django_content_type
828 FOREIGN KEY (content_type_id) REFERENCES django_content_type (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
830 /************ Foreign Key: closed_by_id_refs_id_56e9d00c ***************/
831 ALTER TABLE question ADD CONSTRAINT closed_by_id_refs_id_56e9d00c
832 FOREIGN KEY (closed_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
834 /************ Foreign Key: deleted_by_id_refs_id_56e9d00c ***************/
835 ALTER TABLE question ADD CONSTRAINT deleted_by_id_refs_id_56e9d00c
836 FOREIGN KEY (deleted_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
838 /************ Foreign Key: fk_question_auth_user ***************/
839 ALTER TABLE question ADD CONSTRAINT fk_question_auth_user
840 FOREIGN KEY (author_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
842 /************ Foreign Key: last_activity_by_id_refs_id_56e9d00c ***************/
843 ALTER TABLE question ADD CONSTRAINT last_activity_by_id_refs_id_56e9d00c
844 FOREIGN KEY (last_activity_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
846 /************ Foreign Key: last_edited_by_id_refs_id_56e9d00c ***************/
847 ALTER TABLE question ADD CONSTRAINT last_edited_by_id_refs_id_56e9d00c
848 FOREIGN KEY (last_edited_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
850 /************ Foreign Key: locked_by_id_refs_id_56e9d00c ***************/
851 ALTER TABLE question ADD CONSTRAINT locked_by_id_refs_id_56e9d00c
852 FOREIGN KEY (locked_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
854 /************ Foreign Key: fk_question_revision_auth_user ***************/
855 ALTER TABLE question_revision ADD CONSTRAINT fk_question_revision_auth_user
856 FOREIGN KEY (author_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
858 /************ Foreign Key: fk_question_revision_question ***************/
859 ALTER TABLE question_revision ADD CONSTRAINT fk_question_revision_question
860 FOREIGN KEY (question_id) REFERENCES question (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
862 /************ Foreign Key: fk_question_tags_question ***************/
863 ALTER TABLE question_tags ADD CONSTRAINT fk_question_tags_question
864 FOREIGN KEY (question_id) REFERENCES question (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
866 /************ Foreign Key: fk_question_tags_tag ***************/
867 ALTER TABLE question_tags ADD CONSTRAINT fk_question_tags_tag
868 FOREIGN KEY (tag_id) REFERENCES tag (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
870 /************ Foreign Key: fk_repute_auth_user ***************/
871 ALTER TABLE repute ADD CONSTRAINT fk_repute_auth_user
872 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
874 /************ Foreign Key: fk_repute_question ***************/
875 ALTER TABLE repute ADD CONSTRAINT fk_repute_question
876 FOREIGN KEY (question_id) REFERENCES question (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
878 /************ Foreign Key: fk_tag_auth_user ***************/
879 ALTER TABLE tag ADD CONSTRAINT fk_tag_auth_user
880 FOREIGN KEY (created_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
882 /************ Foreign Key: fk_user_badge_auth_user ***************/
883 ALTER TABLE user_badge ADD CONSTRAINT fk_user_badge_auth_user
884 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
886 /************ Foreign Key: fk_user_badge_badge ***************/
887 ALTER TABLE user_badge ADD CONSTRAINT fk_user_badge_badge
888 FOREIGN KEY (badge_id) REFERENCES badge (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
890 /************ Foreign Key: fk_user_favorite_questions_auth_user ***************/
891 ALTER TABLE user_favorite_questions ADD CONSTRAINT fk_user_favorite_questions_auth_user
892 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
894 /************ Foreign Key: fk_user_favorite_questions_question ***************/
895 ALTER TABLE user_favorite_questions ADD CONSTRAINT fk_user_favorite_questions_question
896 FOREIGN KEY (question_id) REFERENCES question (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
898 /************ Foreign Key: fk_vote_auth_user ***************/
899 ALTER TABLE vote ADD CONSTRAINT fk_vote_auth_user
900 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
902 /************ Foreign Key: fk_vote_django_content_type ***************/
903 ALTER TABLE vote ADD CONSTRAINT fk_vote_django_content_type
904 FOREIGN KEY (content_type_id) REFERENCES django_content_type (id) ON UPDATE NO ACTION ON DELETE NO ACTION;