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 ) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8;
53 /* Table Items: answer */
55 /* Add Indexes for: answer */
56 CREATE INDEX answer_author_id ON answer (author_id);
57 CREATE INDEX answer_deleted_by_id ON answer (deleted_by_id);
58 CREATE INDEX answer_last_edited_by_id ON answer (last_edited_by_id);
59 CREATE INDEX answer_locked_by_id ON answer (locked_by_id);
60 CREATE INDEX answer_question_id ON answer (question_id);
62 /******************** Add Table: answer_revision ************************/
64 /* Build Table Structure */
65 CREATE TABLE answer_revision
67 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
68 answer_id INTEGER NOT NULL,
69 revision INTEGER UNSIGNED NOT NULL,
70 author_id INTEGER NOT NULL,
71 revised_at DATETIME NOT NULL,
72 summary TEXT NOT NULL,
73 `text` LONGTEXT NOT NULL
74 ) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
76 /* Table Items: answer_revision */
78 /* Add Indexes for: answer_revision */
79 CREATE INDEX answer_revision_answer_id ON answer_revision (answer_id);
80 CREATE INDEX answer_revision_author_id ON answer_revision (author_id);
82 /******************** Add Table: auth_group ************************/
84 /* Build Table Structure */
85 CREATE TABLE auth_group
87 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
88 name VARCHAR(80) NOT NULL
89 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
91 /* Table Items: auth_group */
93 /* Add Indexes for: auth_group */
94 CREATE UNIQUE INDEX name ON auth_group (name);
96 /******************** Add Table: auth_group_permissions ************************/
98 /* Build Table Structure */
99 CREATE TABLE auth_group_permissions
101 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
102 group_id INTEGER NOT NULL,
103 permission_id INTEGER NOT NULL
104 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
106 /* Table Items: auth_group_permissions */
108 /* Add Indexes for: auth_group_permissions */
109 CREATE UNIQUE INDEX group_id ON auth_group_permissions (group_id, permission_id);
110 CREATE INDEX permission_id_refs_id_5886d21f ON auth_group_permissions (permission_id);
112 /******************** Add Table: auth_message ************************/
114 /* Build Table Structure */
115 CREATE TABLE auth_message
117 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
118 user_id INTEGER NOT NULL,
119 message LONGTEXT NOT NULL
120 ) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8;
122 /* Table Items: auth_message */
124 /* Add Indexes for: auth_message */
125 CREATE INDEX auth_message_user_id ON auth_message (user_id);
127 /******************** Add Table: auth_permission ************************/
129 /* Build Table Structure */
130 CREATE TABLE auth_permission
132 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
133 name VARCHAR(50) NOT NULL,
134 content_type_id INTEGER NOT NULL,
135 codename VARCHAR(100) NOT NULL
136 ) ENGINE=InnoDB AUTO_INCREMENT=88 DEFAULT CHARSET=utf8;
138 /* Table Items: auth_permission */
140 /* Add Indexes for: auth_permission */
141 CREATE INDEX auth_permission_content_type_id ON auth_permission (content_type_id);
142 CREATE UNIQUE INDEX content_type_id ON auth_permission (content_type_id, codename);
144 /******************** Add Table: auth_user ************************/
146 /* Build Table Structure */
147 CREATE TABLE auth_user
149 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
150 username VARCHAR(30) NOT NULL,
151 first_name VARCHAR(30) NOT NULL,
152 last_name VARCHAR(30) NOT NULL,
153 email VARCHAR(75) NOT NULL,
154 password VARCHAR(128) NOT NULL,
155 is_staff TINYINT NOT NULL,
156 is_active TINYINT NOT NULL,
157 is_superuser TINYINT NOT NULL,
158 last_login DATETIME NOT NULL,
159 date_joined DATETIME NOT NULL,
160 gold SMALLINT NOT NULL DEFAULT 0,
161 silver SMALLINT UNSIGNED NOT NULL DEFAULT 0,
162 bronze SMALLINT UNSIGNED NOT NULL DEFAULT 0,
163 reputation INTEGER UNSIGNED NULL DEFAULT 1,
164 gravatar VARCHAR(128) NULL,
165 questions_per_page SMALLINT UNSIGNED NULL DEFAULT 10,
166 last_seen DATETIME NULL,
167 real_name VARCHAR(100) NULL,
168 website VARCHAR(200) NULL,
169 location VARCHAR(100) NULL,
170 date_of_birth DATETIME NULL,
172 ) ENGINE=InnoDB AUTO_INCREMENT=104 DEFAULT CHARSET=utf8;
174 /* Table Items: auth_user */
176 /* Add Indexes for: auth_user */
177 CREATE UNIQUE INDEX username ON auth_user (username);
179 /******************** Add Table: auth_user_groups ************************/
181 /* Build Table Structure */
182 CREATE TABLE auth_user_groups
184 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
185 user_id INTEGER NOT NULL,
186 group_id INTEGER NOT NULL
187 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
189 /* Table Items: auth_user_groups */
191 /* Add Indexes for: auth_user_groups */
192 CREATE INDEX group_id_refs_id_f116770 ON auth_user_groups (group_id);
193 CREATE UNIQUE INDEX user_id ON auth_user_groups (user_id, group_id);
195 /******************** Add Table: auth_user_user_permissions ************************/
197 /* Build Table Structure */
198 CREATE TABLE auth_user_user_permissions
200 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
201 user_id INTEGER NOT NULL,
202 permission_id INTEGER NOT NULL
203 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
205 /* Table Items: auth_user_user_permissions */
207 /* Add Indexes for: auth_user_user_permissions */
208 CREATE INDEX permission_id_refs_id_67e79cb ON auth_user_user_permissions (permission_id);
209 CREATE UNIQUE INDEX user_id ON auth_user_user_permissions (user_id, permission_id);
211 /******************** Add Table: award ************************/
213 /* Build Table Structure */
216 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
217 user_id INTEGER NOT NULL,
218 badge_id INTEGER NOT NULL,
219 awarded_at DATETIME NOT NULL,
220 notified TINYINT NOT NULL,
221 content_type_id INTEGER NULL,
222 object_id INTEGER NULL
223 ) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8;
225 /* Table Items: award */
227 /* Add Indexes for: award */
228 CREATE INDEX award_badge_id ON award (badge_id);
229 CREATE INDEX award_user_id ON award (user_id);
231 /******************** Add Table: badge ************************/
233 /* Build Table Structure */
236 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
237 name VARCHAR(50) NOT NULL,
238 `type` SMALLINT NOT NULL,
239 slug VARCHAR(50) NOT NULL,
240 description TEXT NOT NULL,
241 multiple TINYINT NOT NULL,
242 awarded_count INTEGER UNSIGNED NOT NULL
243 ) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8;
245 /* Table Items: badge */
247 /* Add Indexes for: badge */
248 CREATE INDEX badge_slug ON badge (slug);
249 CREATE UNIQUE INDEX name ON badge (name, `type`);
251 /******************** Add Table: book ************************/
253 /* Build Table Structure */
256 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
257 title VARCHAR(255) NOT NULL,
258 short_name VARCHAR(255) NOT NULL,
259 author VARCHAR(255) NOT NULL,
260 user_id INTEGER NULL,
261 price DECIMAL(10, 2) NULL,
263 published_at DATE NOT NULL,
264 publication VARCHAR(255) NOT NULL,
265 cover_img VARCHAR(255) NULL,
266 tagnames VARCHAR(125) NULL,
267 added_at DATETIME NOT NULL,
268 last_edited_at DATETIME NOT NULL
271 /* Table Items: book */
273 /* Add Indexes for: book */
274 CREATE UNIQUE INDEX book_short_name_Idx ON book (short_name);
275 CREATE INDEX fk_books_auth_user ON book (user_id);
277 /******************** Add Table: book_author_info ************************/
279 /* Build Table Structure */
280 CREATE TABLE book_author_info
282 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
283 blog_url VARCHAR(255) NULL,
284 user_id INTEGER NOT NULL,
285 added_at DATETIME NOT NULL,
286 last_edited_at DATETIME NOT NULL
289 /* Table Items: book_author_info */
291 /* Add Indexes for: book_author_info */
292 CREATE INDEX fk_book_author_info_auth_user ON book_author_info (user_id);
294 /******************** Add Table: book_author_rss ************************/
296 /* Build Table Structure */
297 CREATE TABLE book_author_rss
299 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
300 title VARCHAR(255) NOT NULL,
301 url VARCHAR(255) NOT NULL,
302 rss_created_at DATETIME NOT NULL,
303 user_id INTEGER NOT NULL,
304 added_at DATETIME NOT NULL
307 /* Table Items: book_author_rss */
309 /* Add Indexes for: book_author_rss */
310 CREATE INDEX fk_book_author_rss_auth_user ON book_author_rss (user_id);
312 /******************** Add Table: book_question ************************/
314 /* Build Table Structure */
315 CREATE TABLE book_question
317 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
318 book_id INTEGER NOT NULL,
319 question_id INTEGER NOT NULL
322 /* Table Items: book_question */
324 /* Add Indexes for: book_question */
325 CREATE INDEX fk_book_question_book ON book_question (book_id);
326 CREATE INDEX fk_book_question_question ON book_question (question_id);
328 /******************** Add Table: `comment` ************************/
330 /* Build Table Structure */
331 CREATE TABLE `comment`
333 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
334 content_type_id INTEGER NOT NULL,
335 object_id INTEGER UNSIGNED NOT NULL,
336 user_id INTEGER NOT NULL,
337 `comment` TEXT NOT NULL,
338 added_at DATETIME NOT NULL
339 ) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8;
341 /* Table Items: `comment` */
343 /* Add Indexes for: comment */
344 CREATE INDEX comment_content_type_id ON `comment` (content_type_id);
345 CREATE INDEX comment_user_id ON `comment` (user_id);
346 CREATE INDEX content_type_id ON `comment` (content_type_id, object_id, user_id);
348 /******************** Add Table: django_admin_log ************************/
350 /* Build Table Structure */
351 CREATE TABLE django_admin_log
353 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
354 action_time DATETIME NOT NULL,
355 user_id INTEGER NOT NULL,
356 content_type_id INTEGER NULL,
357 object_id LONGTEXT NULL,
358 object_repr VARCHAR(200) NOT NULL,
359 action_flag SMALLINT UNSIGNED NOT NULL,
360 change_message LONGTEXT NOT NULL
361 ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
363 /* Table Items: django_admin_log */
365 /* Add Indexes for: django_admin_log */
366 CREATE INDEX django_admin_log_content_type_id ON django_admin_log (content_type_id);
367 CREATE INDEX django_admin_log_user_id ON django_admin_log (user_id);
369 /******************** Add Table: django_authopenid_association ************************/
371 /* Build Table Structure */
372 CREATE TABLE django_authopenid_association
374 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
375 server_url LONGTEXT NOT NULL,
376 handle VARCHAR(255) NOT NULL,
377 secret LONGTEXT NOT NULL,
378 issued INTEGER NOT NULL,
379 lifetime INTEGER NOT NULL,
380 assoc_type LONGTEXT NOT NULL
381 ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
383 /******************** Add Table: django_authopenid_nonce ************************/
385 /* Build Table Structure */
386 CREATE TABLE django_authopenid_nonce
388 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
389 server_url VARCHAR(255) NOT NULL,
390 `timestamp` INTEGER NOT NULL,
391 salt VARCHAR(40) NOT NULL
392 ) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8;
394 /******************** Add Table: django_authopenid_userassociation ************************/
396 /* Build Table Structure */
397 CREATE TABLE django_authopenid_userassociation
399 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
400 openid_url VARCHAR(255) NOT NULL,
401 user_id INTEGER NOT NULL
402 ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
404 /* Table Items: django_authopenid_userassociation */
406 /* Add Indexes for: django_authopenid_userassociation */
407 CREATE UNIQUE INDEX user_id ON django_authopenid_userassociation (user_id);
409 /******************** Add Table: django_authopenid_userpasswordqueue ************************/
411 /* Build Table Structure */
412 CREATE TABLE django_authopenid_userpasswordqueue
414 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
415 user_id INTEGER NOT NULL,
416 new_password VARCHAR(30) NOT NULL,
417 confirm_key VARCHAR(40) NOT NULL
418 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
420 /* Table Items: django_authopenid_userpasswordqueue */
422 /* Add Indexes for: django_authopenid_userpasswordqueue */
423 CREATE UNIQUE INDEX user_id ON django_authopenid_userpasswordqueue (user_id);
425 /******************** Add Table: django_content_type ************************/
427 /* Build Table Structure */
428 CREATE TABLE django_content_type
430 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
431 name VARCHAR(100) NOT NULL,
432 app_label VARCHAR(100) NOT NULL,
433 model VARCHAR(100) NOT NULL
434 ) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8;
436 /* Table Items: django_content_type */
438 /* Add Indexes for: django_content_type */
439 CREATE UNIQUE INDEX app_label ON django_content_type (app_label, model);
441 /******************** Add Table: django_session ************************/
443 /* Build Table Structure */
444 CREATE TABLE django_session
446 session_key VARCHAR(40) NOT NULL,
447 session_data LONGTEXT NOT NULL,
448 expire_date DATETIME NOT NULL
449 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
451 /* Table Items: django_session */
452 ALTER TABLE django_session ADD CONSTRAINT pkdjango_session
453 PRIMARY KEY (session_key);
455 /******************** Add Table: django_site ************************/
457 /* Build Table Structure */
458 CREATE TABLE django_site
460 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
461 domain VARCHAR(100) NOT NULL,
462 name VARCHAR(50) NOT NULL
463 ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
465 /******************** Add Table: favorite_question ************************/
467 /* Build Table Structure */
468 CREATE TABLE favorite_question
470 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
471 question_id INTEGER NOT NULL,
472 user_id INTEGER NOT NULL,
473 added_at DATETIME NOT NULL
474 ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
476 /* Table Items: favorite_question */
478 /* Add Indexes for: favorite_question */
479 CREATE INDEX favorite_question_question_id ON favorite_question (question_id);
480 CREATE INDEX favorite_question_user_id ON favorite_question (user_id);
482 /******************** Add Table: flagged_item ************************/
484 /* Build Table Structure */
485 CREATE TABLE flagged_item
487 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
488 content_type_id INTEGER NOT NULL,
489 object_id INTEGER UNSIGNED NOT NULL,
490 user_id INTEGER NOT NULL,
491 flagged_at DATETIME NOT NULL
492 ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;
494 /* Table Items: flagged_item */
496 /* Add Indexes for: flagged_item */
497 CREATE UNIQUE INDEX content_type_id ON flagged_item (content_type_id, object_id, user_id);
498 CREATE INDEX flagged_item_content_type_id ON flagged_item (content_type_id);
499 CREATE INDEX flagged_item_user_id ON flagged_item (user_id);
501 /******************** Add Table: question ************************/
503 /* Build Table Structure */
504 CREATE TABLE question
506 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
508 author_id INTEGER NOT NULL,
509 added_at DATETIME NOT NULL,
510 wiki TINYINT NOT NULL,
511 wikified_at DATETIME NULL,
512 answer_accepted TINYINT NOT NULL,
513 closed TINYINT NOT NULL,
514 closed_by_id INTEGER NULL,
515 closed_at DATETIME NULL,
516 close_reason SMALLINT NULL,
517 deleted TINYINT NOT NULL,
518 deleted_at DATETIME NULL,
519 deleted_by_id INTEGER NULL,
520 locked TINYINT NOT NULL,
521 locked_by_id INTEGER NULL,
522 locked_at DATETIME NULL,
523 score INTEGER NOT NULL,
524 answer_count INTEGER UNSIGNED NOT NULL,
525 comment_count INTEGER UNSIGNED NOT NULL,
526 view_count INTEGER UNSIGNED NOT NULL,
527 offensive_flag_count SMALLINT NOT NULL,
528 favourite_count INTEGER UNSIGNED NOT NULL,
529 last_edited_at DATETIME NULL,
530 last_edited_by_id INTEGER NULL,
531 last_activity_at DATETIME NOT NULL,
532 last_activity_by_id INTEGER NOT NULL,
533 tagnames VARCHAR(125) NOT NULL,
534 summary VARCHAR(180) NOT NULL,
535 html LONGTEXT NOT NULL,
536 vote_up_count INTEGER NOT NULL,
537 vote_down_count INTEGER NOT NULL
538 ) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8;
540 /* Table Items: question */
542 /* Add Indexes for: question */
543 CREATE INDEX question_author_id ON question (author_id);
544 CREATE INDEX question_closed_by_id ON question (closed_by_id);
545 CREATE INDEX question_deleted_by_id ON question (deleted_by_id);
546 CREATE INDEX question_last_activity_by_id ON question (last_activity_by_id);
547 CREATE INDEX question_last_edited_by_id ON question (last_edited_by_id);
548 CREATE INDEX question_locked_by_id ON question (locked_by_id);
550 /******************** Add Table: question_revision ************************/
552 /* Build Table Structure */
553 CREATE TABLE question_revision
555 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
556 question_id INTEGER NOT NULL,
557 revision INTEGER UNSIGNED NOT NULL,
559 author_id INTEGER NOT NULL,
560 revised_at DATETIME NOT NULL,
561 tagnames VARCHAR(125) NOT NULL,
562 summary TEXT NOT NULL,
563 `text` LONGTEXT NOT NULL
564 ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;
566 /* Table Items: question_revision */
568 /* Add Indexes for: question_revision */
569 CREATE INDEX question_revision_author_id ON question_revision (author_id);
570 CREATE INDEX question_revision_question_id ON question_revision (question_id);
572 /******************** Add Table: question_tags ************************/
574 /* Build Table Structure */
575 CREATE TABLE question_tags
577 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
578 question_id INTEGER NOT NULL,
579 tag_id INTEGER NOT NULL
580 ) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8;
582 /* Table Items: question_tags */
584 /* Add Indexes for: question_tags */
585 CREATE UNIQUE INDEX question_id ON question_tags (question_id, tag_id);
586 CREATE INDEX tag_id_refs_id_43fcb953 ON question_tags (tag_id);
588 /******************** Add Table: repute ************************/
590 /* Build Table Structure */
593 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
594 user_id INTEGER NOT NULL,
595 positive SMALLINT NOT NULL,
596 negative SMALLINT NOT NULL,
597 question_id INTEGER NOT NULL,
598 reputed_at DATETIME NOT NULL,
599 reputation_type SMALLINT NOT NULL,
600 reputation INTEGER NOT NULL
601 ) ENGINE=MyISAM AUTO_INCREMENT=17 DEFAULT CHARSET=latin1;
603 /* Table Items: repute */
605 /* Add Indexes for: repute */
606 CREATE INDEX repute_question_id ON repute (question_id);
607 CREATE INDEX repute_user_id ON repute (user_id);
609 /******************** Add Table: tag ************************/
611 /* Build Table Structure */
614 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
615 name VARCHAR(255) NOT NULL,
616 created_by_id INTEGER NOT NULL,
617 used_count INTEGER UNSIGNED NOT NULL
618 ) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8;
620 /* Table Items: tag */
622 /* Add Indexes for: tag */
623 CREATE UNIQUE INDEX name ON tag (name);
624 CREATE INDEX tag_created_by_id ON tag (created_by_id);
626 /******************** Add Table: user_badge ************************/
628 /* Build Table Structure */
629 CREATE TABLE user_badge
631 id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
632 user_id INTEGER NOT NULL,
633 badge_id INTEGER NOT NULL
634 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
636 /* Table Items: user_badge */
638 /* Add Indexes for: user_badge */
639 CREATE INDEX fk_user_badge_auth_user ON user_badge (user_id);
640 CREATE INDEX fk_user_badge_badge ON user_badge (badge_id);
642 /******************** Add Table: user_favorite_questions ************************/
644 /* Build Table Structure */
645 CREATE TABLE user_favorite_questions
647 id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
648 user_id INTEGER NOT NULL,
649 question_id INTEGER NOT NULL
650 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
652 /* Table Items: user_favorite_questions */
654 /* Add Indexes for: user_favorite_questions */
655 CREATE INDEX fk_user_favorite_questions_auth_user ON user_favorite_questions (user_id);
656 CREATE INDEX fk_user_favorite_questions_question ON user_favorite_questions (question_id);
658 /******************** Add Table: vote ************************/
660 /* Build Table Structure */
663 id INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
664 content_type_id INTEGER NOT NULL,
665 object_id INTEGER UNSIGNED NOT NULL,
666 user_id INTEGER NOT NULL,
667 vote SMALLINT NOT NULL,
668 voted_at DATETIME NOT NULL
669 ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
671 /* Table Items: vote */
673 /* Add Indexes for: vote */
674 CREATE UNIQUE INDEX content_type_id ON vote (content_type_id, object_id, user_id);
675 CREATE INDEX vote_content_type_id ON vote (content_type_id);
676 CREATE INDEX vote_user_id ON vote (user_id);
679 /************ Add Foreign Keys to Database ***************/
680 /*-----------------------------------------------------------
681 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:
682 fk_auth_group_permissions_auth_group may require an index on table: auth_group_permissions, column: group_id
683 fk_auth_user_groups_auth_user may require an index on table: auth_user_groups, column: user_id
684 fk_auth_user_user_permissions_auth_user may require an index on table: auth_user_user_permissions, column: user_id
685 fk_question_tags_question may require an index on table: question_tags, column: question_id
686 -----------------------------------------------------------
689 /************ Foreign Key: fk_activity_auth_user ***************/
690 ALTER TABLE activity ADD CONSTRAINT fk_activity_auth_user
691 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
693 /************ Foreign Key: deleted_by_id_refs_id_192b0170 ***************/
694 ALTER TABLE answer ADD CONSTRAINT deleted_by_id_refs_id_192b0170
695 FOREIGN KEY (deleted_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
697 /************ Foreign Key: fk_answer_auth_user ***************/
698 ALTER TABLE answer ADD CONSTRAINT fk_answer_auth_user
699 FOREIGN KEY (author_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
701 /************ Foreign Key: fk_answer_question ***************/
702 ALTER TABLE answer ADD CONSTRAINT fk_answer_question
703 FOREIGN KEY (question_id) REFERENCES question (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
705 /************ Foreign Key: last_edited_by_id_refs_id_192b0170 ***************/
706 ALTER TABLE answer ADD CONSTRAINT last_edited_by_id_refs_id_192b0170
707 FOREIGN KEY (last_edited_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
709 /************ Foreign Key: locked_by_id_refs_id_192b0170 ***************/
710 ALTER TABLE answer ADD CONSTRAINT locked_by_id_refs_id_192b0170
711 FOREIGN KEY (locked_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
713 /************ Foreign Key: fk_answer_revision_auth_user ***************/
714 ALTER TABLE answer_revision ADD CONSTRAINT fk_answer_revision_auth_user
715 FOREIGN KEY (author_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
717 /************ Foreign Key: fk_auth_group_permissions_auth_group ***************/
718 ALTER TABLE auth_group_permissions ADD CONSTRAINT fk_auth_group_permissions_auth_group
719 FOREIGN KEY (group_id) REFERENCES auth_group (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
721 /************ Foreign Key: fk_auth_group_permissions_auth_permission ***************/
722 ALTER TABLE auth_group_permissions ADD CONSTRAINT fk_auth_group_permissions_auth_permission
723 FOREIGN KEY (permission_id) REFERENCES auth_permission (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
725 /************ Foreign Key: fk_auth_message_auth_user ***************/
726 ALTER TABLE auth_message ADD CONSTRAINT fk_auth_message_auth_user
727 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
729 /************ Foreign Key: fk_auth_permission_django_content_type ***************/
730 ALTER TABLE auth_permission ADD CONSTRAINT fk_auth_permission_django_content_type
731 FOREIGN KEY (content_type_id) REFERENCES django_content_type (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
733 /************ Foreign Key: fk_auth_user_groups_auth_group ***************/
734 ALTER TABLE auth_user_groups ADD CONSTRAINT fk_auth_user_groups_auth_group
735 FOREIGN KEY (group_id) REFERENCES auth_group (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
737 /************ Foreign Key: fk_auth_user_groups_auth_user ***************/
738 ALTER TABLE auth_user_groups ADD CONSTRAINT fk_auth_user_groups_auth_user
739 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
741 /************ Foreign Key: fk_auth_user_user_permissions_auth_permission ***************/
742 ALTER TABLE auth_user_user_permissions ADD CONSTRAINT fk_auth_user_user_permissions_auth_permission
743 FOREIGN KEY (permission_id) REFERENCES auth_permission (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
745 /************ Foreign Key: fk_auth_user_user_permissions_auth_user ***************/
746 ALTER TABLE auth_user_user_permissions ADD CONSTRAINT fk_auth_user_user_permissions_auth_user
747 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
749 /************ Foreign Key: fk_award_auth_user ***************/
750 ALTER TABLE award ADD CONSTRAINT fk_award_auth_user
751 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
753 /************ Foreign Key: fk_award_badge ***************/
754 ALTER TABLE award ADD CONSTRAINT fk_award_badge
755 FOREIGN KEY (badge_id) REFERENCES badge (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
757 /************ Foreign Key: fk_books_auth_user ***************/
758 ALTER TABLE book ADD CONSTRAINT fk_books_auth_user
759 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
761 /************ Foreign Key: fk_book_author_info_auth_user ***************/
762 ALTER TABLE book_author_info ADD CONSTRAINT fk_book_author_info_auth_user
763 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
765 /************ Foreign Key: fk_book_author_rss_auth_user ***************/
766 ALTER TABLE book_author_rss ADD CONSTRAINT fk_book_author_rss_auth_user
767 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
769 /************ Foreign Key: fk_book_question_book ***************/
770 ALTER TABLE book_question ADD CONSTRAINT fk_book_question_book
771 FOREIGN KEY (book_id) REFERENCES book (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
773 /************ Foreign Key: fk_book_question_question ***************/
774 ALTER TABLE book_question ADD CONSTRAINT fk_book_question_question
775 FOREIGN KEY (question_id) REFERENCES question (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
777 /************ Foreign Key: fk_comment_auth_user ***************/
778 ALTER TABLE `comment` ADD CONSTRAINT fk_comment_auth_user
779 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
781 /************ Foreign Key: fk_comment_django_content_type ***************/
782 ALTER TABLE `comment` ADD CONSTRAINT fk_comment_django_content_type
783 FOREIGN KEY (content_type_id) REFERENCES django_content_type (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
785 /************ Foreign Key: fk_django_admin_log_auth_user ***************/
786 ALTER TABLE django_admin_log ADD CONSTRAINT fk_django_admin_log_auth_user
787 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
789 /************ Foreign Key: fk_django_admin_log_django_content_type ***************/
790 ALTER TABLE django_admin_log ADD CONSTRAINT fk_django_admin_log_django_content_type
791 FOREIGN KEY (content_type_id) REFERENCES django_content_type (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
793 /************ Foreign Key: fk_django_authopenid_userassociation_auth_user ***************/
794 ALTER TABLE django_authopenid_userassociation ADD CONSTRAINT fk_django_authopenid_userassociation_auth_user
795 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
797 /************ Foreign Key: fk_django_authopenid_userpasswordqueue_auth_user ***************/
798 ALTER TABLE django_authopenid_userpasswordqueue ADD CONSTRAINT fk_django_authopenid_userpasswordqueue_auth_user
799 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
801 /************ Foreign Key: fk_favorite_question_auth_user ***************/
802 ALTER TABLE favorite_question ADD CONSTRAINT fk_favorite_question_auth_user
803 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
805 /************ Foreign Key: fk_favorite_question_question ***************/
806 ALTER TABLE favorite_question ADD CONSTRAINT fk_favorite_question_question
807 FOREIGN KEY (question_id) REFERENCES question (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
809 /************ Foreign Key: fk_flagged_item_auth_user ***************/
810 ALTER TABLE flagged_item ADD CONSTRAINT fk_flagged_item_auth_user
811 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
813 /************ Foreign Key: fk_flagged_item_django_content_type ***************/
814 ALTER TABLE flagged_item ADD CONSTRAINT fk_flagged_item_django_content_type
815 FOREIGN KEY (content_type_id) REFERENCES django_content_type (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
817 /************ Foreign Key: closed_by_id_refs_id_56e9d00c ***************/
818 ALTER TABLE question ADD CONSTRAINT closed_by_id_refs_id_56e9d00c
819 FOREIGN KEY (closed_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
821 /************ Foreign Key: deleted_by_id_refs_id_56e9d00c ***************/
822 ALTER TABLE question ADD CONSTRAINT deleted_by_id_refs_id_56e9d00c
823 FOREIGN KEY (deleted_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
825 /************ Foreign Key: fk_question_auth_user ***************/
826 ALTER TABLE question ADD CONSTRAINT fk_question_auth_user
827 FOREIGN KEY (author_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
829 /************ Foreign Key: last_activity_by_id_refs_id_56e9d00c ***************/
830 ALTER TABLE question ADD CONSTRAINT last_activity_by_id_refs_id_56e9d00c
831 FOREIGN KEY (last_activity_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
833 /************ Foreign Key: last_edited_by_id_refs_id_56e9d00c ***************/
834 ALTER TABLE question ADD CONSTRAINT last_edited_by_id_refs_id_56e9d00c
835 FOREIGN KEY (last_edited_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
837 /************ Foreign Key: locked_by_id_refs_id_56e9d00c ***************/
838 ALTER TABLE question ADD CONSTRAINT locked_by_id_refs_id_56e9d00c
839 FOREIGN KEY (locked_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
841 /************ Foreign Key: fk_question_revision_auth_user ***************/
842 ALTER TABLE question_revision ADD CONSTRAINT fk_question_revision_auth_user
843 FOREIGN KEY (author_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
845 /************ Foreign Key: fk_question_revision_question ***************/
846 ALTER TABLE question_revision ADD CONSTRAINT fk_question_revision_question
847 FOREIGN KEY (question_id) REFERENCES question (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
849 /************ Foreign Key: fk_question_tags_question ***************/
850 ALTER TABLE question_tags ADD CONSTRAINT fk_question_tags_question
851 FOREIGN KEY (question_id) REFERENCES question (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
853 /************ Foreign Key: fk_question_tags_tag ***************/
854 ALTER TABLE question_tags ADD CONSTRAINT fk_question_tags_tag
855 FOREIGN KEY (tag_id) REFERENCES tag (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
857 /************ Foreign Key: fk_repute_auth_user ***************/
858 ALTER TABLE repute ADD CONSTRAINT fk_repute_auth_user
859 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
861 /************ Foreign Key: fk_repute_question ***************/
862 ALTER TABLE repute ADD CONSTRAINT fk_repute_question
863 FOREIGN KEY (question_id) REFERENCES question (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
865 /************ Foreign Key: fk_tag_auth_user ***************/
866 ALTER TABLE tag ADD CONSTRAINT fk_tag_auth_user
867 FOREIGN KEY (created_by_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
869 /************ Foreign Key: fk_user_badge_auth_user ***************/
870 ALTER TABLE user_badge ADD CONSTRAINT fk_user_badge_auth_user
871 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
873 /************ Foreign Key: fk_user_badge_badge ***************/
874 ALTER TABLE user_badge ADD CONSTRAINT fk_user_badge_badge
875 FOREIGN KEY (badge_id) REFERENCES badge (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
877 /************ Foreign Key: fk_user_favorite_questions_auth_user ***************/
878 ALTER TABLE user_favorite_questions ADD CONSTRAINT fk_user_favorite_questions_auth_user
879 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
881 /************ Foreign Key: fk_user_favorite_questions_question ***************/
882 ALTER TABLE user_favorite_questions ADD CONSTRAINT fk_user_favorite_questions_question
883 FOREIGN KEY (question_id) REFERENCES question (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
885 /************ Foreign Key: fk_vote_auth_user ***************/
886 ALTER TABLE vote ADD CONSTRAINT fk_vote_auth_user
887 FOREIGN KEY (user_id) REFERENCES auth_user (id) ON UPDATE NO ACTION ON DELETE NO ACTION;
889 /************ Foreign Key: fk_vote_django_content_type ***************/
890 ALTER TABLE vote ADD CONSTRAINT fk_vote_django_content_type
891 FOREIGN KEY (content_type_id) REFERENCES django_content_type (id) ON UPDATE NO ACTION ON DELETE NO ACTION;