* Update ipblocks table in MySQL 5 table defs
[lhc/web/wiklou.git] / maintenance / mysql5 / tables.sql
1 -- Experimental table definitions for MySQL 4.1 and 5.0 with
2 -- explicit character set support. Not fully tested, may have
3 -- surprises!
4 --
5 -- TODO: Test various fields
6 -- TODO: Anything else need to be moved to VARBINARY and BLOB?
7 -- TODO: UCS-2 better than UTF-8?
8 -- TODO: Find out how to get 4-byte UTF-8 chars into MySQL...
9 -- An alternate UCS-2 that does UTF-16 conversion would work.
10 -- TODO: Work on collation usage
11
12 -- ------------------------------------------------------------
13
14 -- SQL to create the initial tables for the MediaWiki database.
15 -- This is read and executed by the install script; you should
16 -- not have to run it by itself unless doing a manual install.
17
18 --
19 -- General notes:
20 --
21 -- If possible, create tables as InnoDB to benefit from the
22 -- superior resiliency against crashes and ability to read
23 -- during writes (and write during reads!)
24 --
25 -- Only the 'searchindex' table requires MyISAM due to the
26 -- requirement for fulltext index support, which is missing
27 -- from InnoDB.
28 --
29 --
30 -- The MySQL table backend for MediaWiki currently uses
31 -- 14-character CHAR or VARCHAR fields to store timestamps.
32 -- The format is YYYYMMDDHHMMSS, which is derived from the
33 -- text format of MySQL's TIMESTAMP fields.
34 --
35 -- Historically TIMESTAMP fields were used, but abandoned
36 -- in early 2002 after a lot of trouble with the fields
37 -- auto-updating.
38 --
39 -- The PostgreSQL backend uses DATETIME fields for timestamps,
40 -- and we will migrate the MySQL definitions at some point as
41 -- well.
42 --
43 --
44 -- The /*$wgDBprefix*/ comments in this and other files are
45 -- replaced with the defined table prefix by the installer
46 -- and updater scripts. If you are installing or running
47 -- updates manually, you will need to manually insert the
48 -- table prefix if any when running these scripts.
49 --
50
51
52 --
53 -- The user table contains basic account information,
54 -- authentication keys, etc.
55 --
56 -- Some multi-wiki sites may share a single central user table
57 -- between separate wikis using the $wgSharedDB setting.
58 --
59 -- Note that when a external authentication plugin is used,
60 -- user table entries still need to be created to store
61 -- preferences and to key tracking information in the other
62 -- tables.
63 --
64 CREATE TABLE /*$wgDBprefix*/user (
65 user_id int(5) unsigned NOT NULL auto_increment,
66
67 -- Usernames must be unique, must not be in the form of
68 -- an IP address. _Shouldn't_ allow slashes or case
69 -- conflicts. Spaces are allowed, and are _not_ converted
70 -- to underscores like titles. See the User::newFromName() for
71 -- the specific tests that usernames have to pass.
72 user_name varchar(255) binary NOT NULL default '',
73
74 -- Optional 'real name' to be displayed in credit listings
75 user_real_name varchar(255) binary NOT NULL default '',
76
77 -- Password hashes, normally hashed like so:
78 -- MD5(CONCAT(user_id,'-',MD5(plaintext_password))), see
79 -- wfEncryptPassword() in GlobalFunctions.php
80 user_password tinyblob NOT NULL default '',
81
82 -- When using 'mail me a new password', a random
83 -- password is generated and the hash stored here.
84 -- The previous password is left in place until
85 -- someone actually logs in with the new password,
86 -- at which point the hash is moved to user_password
87 -- and the old password is invalidated.
88 user_newpassword tinyblob NOT NULL default '',
89
90 -- Note: email should be restricted, not public info.
91 -- Same with passwords.
92 user_email tinytext NOT NULL default '',
93
94 -- Newline-separated list of name=value defining the user
95 -- preferences
96 user_options blob NOT NULL default '',
97
98 -- This is a timestamp which is updated when a user
99 -- logs in, logs out, changes preferences, or performs
100 -- some other action requiring HTML cache invalidation
101 -- to ensure that the UI is updated.
102 user_touched char(14) binary NOT NULL default '',
103
104 -- A pseudorandomly generated value that is stored in
105 -- a cookie when the "remember password" feature is
106 -- used (previously, a hash of the password was used, but
107 -- this was vulnerable to cookie-stealing attacks)
108 user_token char(32) binary NOT NULL default '',
109
110 -- Initially NULL; when a user's e-mail address has been
111 -- validated by returning with a mailed token, this is
112 -- set to the current timestamp.
113 user_email_authenticated CHAR(14) BINARY,
114
115 -- Randomly generated token created when the e-mail address
116 -- is set and a confirmation test mail sent.
117 user_email_token CHAR(32) BINARY,
118
119 -- Expiration date for the user_email_token
120 user_email_token_expires CHAR(14) BINARY,
121
122 PRIMARY KEY user_id (user_id),
123 UNIQUE INDEX user_name (user_name),
124 INDEX (user_email_token)
125
126 ) TYPE=InnoDB, DEFAULT CHARSET=utf8;
127
128 --
129 -- User permissions have been broken out to a separate table;
130 -- this allows sites with a shared user table to have different
131 -- permissions assigned to a user in each project.
132 --
133 -- This table replaces the old user_rights field which used a
134 -- comma-separated blob.
135 --
136 CREATE TABLE /*$wgDBprefix*/user_groups (
137 -- Key to user_id
138 ug_user int(5) unsigned NOT NULL default '0',
139
140 -- Group names are short symbolic string keys.
141 -- The set of group names is open-ended, though in practice
142 -- only some predefined ones are likely to be used.
143 --
144 -- At runtime $wgGroupPermissions will associate group keys
145 -- with particular permissions. A user will have the combined
146 -- permissions of any group they're explicitly in, plus
147 -- the implicit '*' and 'user' groups.
148 ug_group char(16) NOT NULL default '',
149
150 PRIMARY KEY (ug_user,ug_group),
151 KEY (ug_group)
152 ) TYPE=InnoDB, DEFAULT CHARSET=utf8;
153
154 -- Stores notifications of user talk page changes, for the display
155 -- of the "you have new messages" box
156 CREATE TABLE /*$wgDBprefix*/user_newtalk (
157 -- Key to user.user_id
158 user_id int(5) NOT NULL default '0',
159 -- If the user is an anonymous user hir IP address is stored here
160 -- since the user_id of 0 is ambiguous
161 user_ip varchar(40) NOT NULL default '',
162 INDEX user_id (user_id),
163 INDEX user_ip (user_ip)
164 ) TYPE=InnoDB, DEFAULT CHARSET=utf8;
165
166
167 --
168 -- Core of the wiki: each page has an entry here which identifies
169 -- it by title and contains some essential metadata.
170 --
171 CREATE TABLE /*$wgDBprefix*/page (
172 -- Unique identifier number. The page_id will be preserved across
173 -- edits and rename operations, but not deletions and recreations.
174 page_id int(8) unsigned NOT NULL auto_increment,
175
176 -- A page name is broken into a namespace and a title.
177 -- The namespace keys are UI-language-independent constants,
178 -- defined in includes/Defines.php
179 page_namespace int NOT NULL,
180
181 -- The rest of the title, as text.
182 -- Spaces are transformed into underscores in title storage.
183 page_title varchar(255) binary NOT NULL,
184
185 -- Comma-separated set of permission keys indicating who
186 -- can move or edit the page.
187 page_restrictions tinyblob NOT NULL default '',
188
189 -- Number of times this page has been viewed.
190 page_counter bigint(20) unsigned NOT NULL default '0',
191
192 -- 1 indicates the article is a redirect.
193 page_is_redirect tinyint(1) unsigned NOT NULL default '0',
194
195 -- 1 indicates this is a new entry, with only one edit.
196 -- Not all pages with one edit are new pages.
197 page_is_new tinyint(1) unsigned NOT NULL default '0',
198
199 -- Random value between 0 and 1, used for Special:Randompage
200 page_random real unsigned NOT NULL,
201
202 -- This timestamp is updated whenever the page changes in
203 -- a way requiring it to be re-rendered, invalidating caches.
204 -- Aside from editing this includes permission changes,
205 -- creation or deletion of linked pages, and alteration
206 -- of contained templates.
207 page_touched char(14) binary NOT NULL default '',
208
209 -- Handy key to revision.rev_id of the current revision.
210 -- This may be 0 during page creation, but that shouldn't
211 -- happen outside of a transaction... hopefully.
212 page_latest int(8) unsigned NOT NULL,
213
214 -- Uncompressed length in bytes of the page's current source text.
215 page_len int(8) unsigned NOT NULL,
216
217 PRIMARY KEY page_id (page_id),
218 UNIQUE INDEX name_title (page_namespace,page_title),
219
220 -- Special-purpose indexes
221 INDEX (page_random),
222 INDEX (page_len)
223
224 ) TYPE=InnoDB, DEFAULT CHARSET=utf8;
225
226 --
227 -- Every edit of a page creates also a revision row.
228 -- This stores metadata about the revision, and a reference
229 -- to the text storage backend.
230 --
231 CREATE TABLE /*$wgDBprefix*/revision (
232 rev_id int(8) unsigned NOT NULL auto_increment,
233
234 -- Key to page_id. This should _never_ be invalid.
235 rev_page int(8) unsigned NOT NULL,
236
237 -- Key to text.old_id, where the actual bulk text is stored.
238 -- It's possible for multiple revisions to use the same text,
239 -- for instance revisions where only metadata is altered
240 -- or a rollback to a previous version.
241 rev_text_id int(8) unsigned NOT NULL,
242
243 -- Text comment summarizing the change.
244 -- This text is shown in the history and other changes lists,
245 -- rendered in a subset of wiki markup by Linker::formatComment()
246 rev_comment tinyblob NOT NULL default '',
247
248 -- Key to user.user_id of the user who made this edit.
249 -- Stores 0 for anonymous edits and for some mass imports.
250 rev_user int(5) unsigned NOT NULL default '0',
251
252 -- Text username or IP address of the editor.
253 rev_user_text varchar(255) binary NOT NULL default '',
254
255 -- Timestamp
256 rev_timestamp char(14) binary NOT NULL default '',
257
258 -- Records whether the user marked the 'minor edit' checkbox.
259 -- Many automated edits are marked as minor.
260 rev_minor_edit tinyint(1) unsigned NOT NULL default '0',
261
262 -- Not yet used; reserved for future changes to the deletion system.
263 rev_deleted tinyint(1) unsigned NOT NULL default '0',
264
265 PRIMARY KEY rev_page_id (rev_page, rev_id),
266 UNIQUE INDEX rev_id (rev_id),
267 INDEX rev_timestamp (rev_timestamp),
268 INDEX page_timestamp (rev_page,rev_timestamp),
269 INDEX user_timestamp (rev_user,rev_timestamp),
270 INDEX usertext_timestamp (rev_user_text,rev_timestamp)
271
272 ) TYPE=InnoDB, DEFAULT CHARSET=utf8;
273
274
275 --
276 -- Holds text of individual page revisions.
277 --
278 -- Field names are a holdover from the 'old' revisions table in
279 -- MediaWiki 1.4 and earlier: an upgrade will transform that
280 -- table into the 'text' table to minimize unnecessary churning
281 -- and downtime. If upgrading, the other fields will be left unused.
282 --
283 CREATE TABLE /*$wgDBprefix*/text (
284 -- Unique text storage key number.
285 -- Note that the 'oldid' parameter used in URLs does *not*
286 -- refer to this number anymore, but to rev_id.
287 --
288 -- revision.rev_text_id is a key to this column
289 old_id int(8) unsigned NOT NULL auto_increment,
290
291 -- Depending on the contents of the old_flags field, the text
292 -- may be convenient plain text, or it may be funkily encoded.
293 old_text mediumblob NOT NULL default '',
294
295 -- Comma-separated list of flags:
296 -- gzip: text is compressed with PHP's gzdeflate() function.
297 -- utf8: text was stored as UTF-8.
298 -- If $wgLegacyEncoding option is on, rows *without* this flag
299 -- will be converted to UTF-8 transparently at load time.
300 -- object: text field contained a serialized PHP object.
301 -- The object either contains multiple versions compressed
302 -- together to achieve a better compression ratio, or it refers
303 -- to another row where the text can be found.
304 old_flags tinyblob NOT NULL default '',
305
306 PRIMARY KEY old_id (old_id)
307
308 ) TYPE=InnoDB, DEFAULT CHARSET=utf8;
309
310 --
311 -- Holding area for deleted articles, which may be viewed
312 -- or restored by admins through the Special:Undelete interface.
313 -- The fields generally correspond to the page, revision, and text
314 -- fields, with several caveats.
315 --
316 CREATE TABLE /*$wgDBprefix*/archive (
317 ar_namespace int NOT NULL default '0',
318 ar_title varchar(255) binary NOT NULL default '',
319
320 -- Newly deleted pages will not store text in this table,
321 -- but will reference the separately existing text rows.
322 -- This field is retained for backwards compatibility,
323 -- so old archived pages will remain accessible after
324 -- upgrading from 1.4 to 1.5.
325 -- Text may be gzipped or otherwise funky.
326 ar_text mediumblob NOT NULL default '',
327
328 -- Basic revision stuff...
329 ar_comment tinyblob NOT NULL default '',
330 ar_user int(5) unsigned NOT NULL default '0',
331 ar_user_text varchar(255) binary NOT NULL,
332 ar_timestamp char(14) binary NOT NULL default '',
333 ar_minor_edit tinyint(1) NOT NULL default '0',
334
335 -- See ar_text note.
336 ar_flags tinyblob NOT NULL default '',
337
338 -- When revisions are deleted, their unique rev_id is stored
339 -- here so it can be retained after undeletion. This is necessary
340 -- to retain permalinks to given revisions after accidental delete
341 -- cycles or messy operations like history merges.
342 --
343 -- Old entries from 1.4 will be NULL here, and a new rev_id will
344 -- be created on undeletion for those revisions.
345 ar_rev_id int(8) unsigned,
346
347 -- For newly deleted revisions, this is the text.old_id key to the
348 -- actual stored text. To avoid breaking the block-compression scheme
349 -- and otherwise making storage changes harder, the actual text is
350 -- *not* deleted from the text table, merely hidden by removal of the
351 -- page and revision entries.
352 --
353 -- Old entries deleted under 1.2-1.4 will have NULL here, and their
354 -- ar_text and ar_flags fields will be used to create a new text
355 -- row upon undeletion.
356 ar_text_id int(8) unsigned,
357
358 KEY name_title_timestamp (ar_namespace,ar_title,ar_timestamp)
359
360 ) TYPE=InnoDB, DEFAULT CHARSET=utf8;
361
362
363 --
364 -- Track page-to-page hyperlinks within the wiki.
365 --
366 CREATE TABLE /*$wgDBprefix*/pagelinks (
367 -- Key to the page_id of the page containing the link.
368 pl_from int(8) unsigned NOT NULL default '0',
369
370 -- Key to page_namespace/page_title of the target page.
371 -- The target page may or may not exist, and due to renames
372 -- and deletions may refer to different page records as time
373 -- goes by.
374 pl_namespace int NOT NULL default '0',
375 pl_title varchar(255) binary NOT NULL default '',
376
377 UNIQUE KEY pl_from(pl_from,pl_namespace,pl_title),
378 KEY (pl_namespace,pl_title)
379
380 ) TYPE=InnoDB, DEFAULT CHARSET=utf8;
381
382
383 --
384 -- Track links to images *used inline*
385 -- We don't distinguish live from broken links here, so
386 -- they do not need to be changed on upload/removal.
387 --
388 CREATE TABLE /*$wgDBprefix*/imagelinks (
389 -- Key to page_id of the page containing the image / media link.
390 il_from int(8) unsigned NOT NULL default '0',
391
392 -- Filename of target image.
393 -- This is also the page_title of the file's description page;
394 -- all such pages are in namespace 6 (NS_IMAGE).
395 il_to varchar(255) binary NOT NULL default '',
396
397 UNIQUE KEY il_from(il_from,il_to),
398 KEY (il_to)
399
400 ) TYPE=InnoDB, DEFAULT CHARSET=utf8;
401
402 --
403 -- Track category inclusions *used inline*
404 -- This tracks a single level of category membership
405 -- (folksonomic tagging, really).
406 --
407 CREATE TABLE /*$wgDBprefix*/categorylinks (
408 -- Key to page_id of the page defined as a category member.
409 cl_from int(8) unsigned NOT NULL default '0',
410
411 -- Name of the category.
412 -- This is also the page_title of the category's description page;
413 -- all such pages are in namespace 14 (NS_CATEGORY).
414 cl_to varchar(255) binary NOT NULL default '',
415
416 -- The title of the linking page, or an optional override
417 -- to determine sort order. Sorting is by binary order, which
418 -- isn't always ideal, but collations seem to be an exciting
419 -- and dangerous new world in MySQL...
420 --
421 -- For MySQL 4.1+ with charset set to utf8, the sort key *index*
422 -- needs cut to be smaller than 1024 bytes (at 3 bytes per char).
423 -- To sort properly on the shorter key, this field needs to be
424 -- the same shortness.
425 cl_sortkey varchar(86) binary NOT NULL default '',
426
427 -- This isn't really used at present. Provided for an optional
428 -- sorting method by approximate addition time.
429 cl_timestamp timestamp NOT NULL,
430
431 UNIQUE KEY cl_from(cl_from,cl_to),
432
433 -- We always sort within a given category...
434 KEY cl_sortkey(cl_to,cl_sortkey),
435
436 -- Not really used?
437 KEY cl_timestamp(cl_to,cl_timestamp)
438
439 ) TYPE=InnoDB, DEFAULT CHARSET=utf8;
440
441 --
442 -- Contains a single row with some aggregate info
443 -- on the state of the site.
444 --
445 CREATE TABLE /*$wgDBprefix*/site_stats (
446 -- The single row should contain 1 here.
447 ss_row_id int(8) unsigned NOT NULL,
448
449 -- Total number of page views, if hit counters are enabled.
450 ss_total_views bigint(20) unsigned default '0',
451
452 -- Total number of edits performed.
453 ss_total_edits bigint(20) unsigned default '0',
454
455 -- An approximate count of pages matching the following criteria:
456 -- * in namespace 0
457 -- * not a redirect
458 -- * contains the text '[['
459 -- See Article::isCountable() in includes/Article.php
460 ss_good_articles bigint(20) unsigned default '0',
461
462 -- Total pages, theoretically equal to SELECT COUNT(*) FROM page; except faster
463 ss_total_pages bigint(20) default '-1',
464
465 -- Number of users, theoretically equal to SELECT COUNT(*) FROM user;
466 ss_users bigint(20) default '-1',
467
468 -- Deprecated, no longer updated as of 1.5
469 ss_admins int(10) default '-1',
470
471 UNIQUE KEY ss_row_id (ss_row_id)
472
473 ) TYPE=InnoDB;
474
475 --
476 -- Stores an ID for every time any article is visited;
477 -- depending on $wgHitcounterUpdateFreq, it is
478 -- periodically cleared and the page_counter column
479 -- in the page table updated for the all articles
480 -- that have been visited.)
481 --
482 CREATE TABLE /*$wgDBprefix*/hitcounter (
483 hc_id INTEGER UNSIGNED NOT NULL
484 ) TYPE=HEAP MAX_ROWS=25000;
485
486
487 --
488 -- The internet is full of jerks, alas. Sometimes it's handy
489 -- to block a vandal or troll account.
490 --
491 CREATE TABLE /*$wgDBprefix*/ipblocks (
492 -- Primary key, introduced for privacy.
493 ipb_id int(8) NOT NULL auto_increment,
494
495 -- Blocked IP address in dotted-quad form or user name.
496 ipb_address varchar(40) binary NOT NULL default '',
497
498 -- Blocked user ID or 0 for IP blocks.
499 ipb_user int(8) unsigned NOT NULL default '0',
500
501 -- User ID who made the block.
502 ipb_by int(8) unsigned NOT NULL default '0',
503
504 -- Text comment made by blocker.
505 ipb_reason tinyblob NOT NULL default '',
506
507 -- Creation (or refresh) date in standard YMDHMS form.
508 -- IP blocks expire automatically.
509 ipb_timestamp char(14) binary NOT NULL default '',
510
511 -- Indicates that the IP address was banned because a banned
512 -- user accessed a page through it. If this is 1, ipb_address
513 -- will be hidden, and the block identified by block ID number.
514 ipb_auto tinyint(1) NOT NULL default '0',
515
516 -- Time at which the block will expire.
517 ipb_expiry char(14) binary NOT NULL default '',
518
519 -- Start and end of an address range, in hexadecimal
520 -- Size chosen to allow IPv6
521 ipb_range_start varchar(32) NOT NULL default '',
522 ipb_range_end varchar(32) NOT NULL default '',
523
524 PRIMARY KEY ipb_id (ipb_id),
525 INDEX ipb_address (ipb_address),
526 INDEX ipb_user (ipb_user),
527 INDEX ipb_range (ipb_range_start(8), ipb_range_end(8))
528
529 ) TYPE=InnoDB, DEFAULT CHARSET=utf8;
530
531
532 --
533 -- Uploaded images and other files.
534 --
535 CREATE TABLE /*$wgDBprefix*/image (
536 -- Filename.
537 -- This is also the title of the associated description page,
538 -- which will be in namespace 6 (NS_IMAGE).
539 img_name varchar(255) binary NOT NULL default '',
540
541 -- File size in bytes.
542 img_size int(8) unsigned NOT NULL default '0',
543
544 -- For images, size in pixels.
545 img_width int(5) NOT NULL default '0',
546 img_height int(5) NOT NULL default '0',
547
548 -- Extracted EXIF metadata stored as a serialized PHP array.
549 img_metadata mediumblob NOT NULL,
550
551 -- For images, bits per pixel if known.
552 img_bits int(3) NOT NULL default '0',
553
554 -- Media type as defined by the MEDIATYPE_xxx constants
555 img_media_type ENUM("UNKNOWN", "BITMAP", "DRAWING", "AUDIO", "VIDEO", "MULTIMEDIA", "OFFICE", "TEXT", "EXECUTABLE", "ARCHIVE") default NULL,
556
557 -- major part of a MIME media type as defined by IANA
558 -- see http://www.iana.org/assignments/media-types/
559 img_major_mime ENUM("unknown", "application", "audio", "image", "text", "video", "message", "model", "multipart") NOT NULL default "unknown",
560
561 -- minor part of a MIME media type as defined by IANA
562 -- the minor parts are not required to adher to any standard
563 -- but should be consistent throughout the database
564 -- see http://www.iana.org/assignments/media-types/
565 img_minor_mime varchar(32) NOT NULL default "unknown",
566
567 -- Description field as entered by the uploader.
568 -- This is displayed in image upload history and logs.
569 img_description tinyblob NOT NULL default '',
570
571 -- user_id and user_name of uploader.
572 img_user int(5) unsigned NOT NULL default '0',
573 img_user_text varchar(255) binary NOT NULL default '',
574
575 -- Time of the upload.
576 img_timestamp char(14) binary NOT NULL default '',
577
578 PRIMARY KEY img_name (img_name),
579
580 -- Used by Special:Imagelist for sort-by-size
581 INDEX img_size (img_size),
582
583 -- Used by Special:Newimages and Special:Imagelist
584 INDEX img_timestamp (img_timestamp)
585
586 ) TYPE=InnoDB, DEFAULT CHARSET=utf8;
587
588 --
589 -- Previous revisions of uploaded files.
590 -- Awkwardly, image rows have to be moved into
591 -- this table at re-upload time.
592 --
593 CREATE TABLE /*$wgDBprefix*/oldimage (
594 -- Base filename: key to image.img_name
595 oi_name varchar(255) binary NOT NULL default '',
596
597 -- Filename of the archived file.
598 -- This is generally a timestamp and '!' prepended to the base name.
599 oi_archive_name varchar(255) binary NOT NULL default '',
600
601 -- Other fields as in image...
602 oi_size int(8) unsigned NOT NULL default 0,
603 oi_width int(5) NOT NULL default 0,
604 oi_height int(5) NOT NULL default 0,
605 oi_bits int(3) NOT NULL default 0,
606 oi_description tinyblob NOT NULL default '',
607 oi_user int(5) unsigned NOT NULL default '0',
608 oi_user_text varchar(255) binary NOT NULL default '',
609 oi_timestamp char(14) binary NOT NULL default '',
610
611 INDEX oi_name (oi_name(10))
612
613 ) TYPE=InnoDB, DEFAULT CHARSET=utf8;
614
615
616 --
617 -- Primarily a summary table for Special:Recentchanges,
618 -- this table contains some additional info on edits from
619 -- the last few days, see Article::editUpdates()
620 --
621 CREATE TABLE /*$wgDBprefix*/recentchanges (
622 rc_id int(8) NOT NULL auto_increment,
623 rc_timestamp varchar(14) binary NOT NULL default '',
624 rc_cur_time varchar(14) binary NOT NULL default '',
625
626 -- As in revision
627 rc_user int(10) unsigned NOT NULL default '0',
628 rc_user_text varchar(255) binary NOT NULL default '',
629
630 -- When pages are renamed, their RC entries do _not_ change.
631 rc_namespace int NOT NULL default '0',
632 rc_title varchar(255) binary NOT NULL default '',
633
634 -- as in revision...
635 rc_comment varchar(255) binary NOT NULL default '',
636 rc_minor tinyint(3) unsigned NOT NULL default '0',
637
638 -- Edits by user accounts with the 'bot' rights key are
639 -- marked with a 1 here, and will be hidden from the
640 -- default view.
641 rc_bot tinyint(3) unsigned NOT NULL default '0',
642
643 rc_new tinyint(3) unsigned NOT NULL default '0',
644
645 -- Key to page_id (was cur_id prior to 1.5).
646 -- This will keep links working after moves while
647 -- retaining the at-the-time name in the changes list.
648 rc_cur_id int(10) unsigned NOT NULL default '0',
649
650 -- rev_id of the given revision
651 rc_this_oldid int(10) unsigned NOT NULL default '0',
652
653 -- rev_id of the prior revision, for generating diff links.
654 rc_last_oldid int(10) unsigned NOT NULL default '0',
655
656 -- These may no longer be used, with the new move log.
657 rc_type tinyint(3) unsigned NOT NULL default '0',
658 rc_moved_to_ns tinyint(3) unsigned NOT NULL default '0',
659 rc_moved_to_title varchar(255) binary NOT NULL default '',
660
661 -- If the Recent Changes Patrol option is enabled,
662 -- users may mark edits as having been reviewed to
663 -- remove a warning flag on the RC list.
664 -- A value of 1 indicates the page has been reviewed.
665 rc_patrolled tinyint(3) unsigned NOT NULL default '0',
666
667 -- Recorded IP address the edit was made from, if the
668 -- $wgPutIPinRC option is enabled.
669 rc_ip char(15) NOT NULL default '',
670
671 PRIMARY KEY rc_id (rc_id),
672 INDEX rc_timestamp (rc_timestamp),
673 INDEX rc_namespace_title (rc_namespace, rc_title),
674 INDEX rc_cur_id (rc_cur_id),
675 INDEX new_name_timestamp(rc_new,rc_namespace,rc_timestamp),
676 INDEX rc_ip (rc_ip)
677
678 ) TYPE=InnoDB, DEFAULT CHARSET=utf8;
679
680 CREATE TABLE /*$wgDBprefix*/watchlist (
681 -- Key to user.user_id
682 wl_user int(5) unsigned NOT NULL,
683
684 -- Key to page_namespace/page_title
685 -- Note that users may watch pages which do not exist yet,
686 -- or existed in the past but have been deleted.
687 wl_namespace int NOT NULL default '0',
688 wl_title varchar(255) binary NOT NULL default '',
689
690 -- Timestamp when user was last sent a notification e-mail;
691 -- cleared when the user visits the page.
692 wl_notificationtimestamp varchar(14) binary,
693
694 UNIQUE KEY (wl_user, wl_namespace, wl_title),
695 KEY namespace_title (wl_namespace,wl_title)
696
697 ) TYPE=InnoDB, DEFAULT CHARSET=utf8;
698
699
700 --
701 -- Used by the math module to keep track
702 -- of previously-rendered items.
703 --
704 CREATE TABLE /*$wgDBprefix*/math (
705 -- Binary MD5 hash of the latex fragment, used as an identifier key.
706 math_inputhash varbinary(16) NOT NULL,
707
708 -- Not sure what this is, exactly...
709 math_outputhash varbinary(16) NOT NULL,
710
711 -- texvc reports how well it thinks the HTML conversion worked;
712 -- if it's a low level the PNG rendering may be preferred.
713 math_html_conservativeness tinyint(1) NOT NULL,
714
715 -- HTML output from texvc, if any
716 math_html text,
717
718 -- MathML output from texvc, if any
719 math_mathml text,
720
721 UNIQUE KEY math_inputhash (math_inputhash)
722
723 ) TYPE=InnoDB, DEFAULT CHARSET=utf8;
724
725 --
726 -- When using the default MySQL search backend, page titles
727 -- and text are munged to strip markup, do Unicode case folding,
728 -- and prepare the result for MySQL's fulltext index.
729 --
730 -- This table must be MyISAM; InnoDB does not support the needed
731 -- fulltext index.
732 --
733 CREATE TABLE /*$wgDBprefix*/searchindex (
734 -- Key to page_id
735 si_page int(8) unsigned NOT NULL,
736
737 -- Munged version of title
738 si_title varchar(255) NOT NULL default '',
739
740 -- Munged version of body text
741 si_text mediumtext NOT NULL default '',
742
743 UNIQUE KEY (si_page),
744 FULLTEXT si_title (si_title),
745 FULLTEXT si_text (si_text)
746
747 ) TYPE=MyISAM, DEFAULT CHARSET=utf8;
748
749 --
750 -- Recognized interwiki link prefixes
751 --
752 CREATE TABLE /*$wgDBprefix*/interwiki (
753 -- The interwiki prefix, (e.g. "Meatball", or the language prefix "de")
754 iw_prefix char(32) NOT NULL,
755
756 -- The URL of the wiki, with "$1" as a placeholder for an article name.
757 -- Any spaces in the name will be transformed to underscores before
758 -- insertion.
759 iw_url char(127) NOT NULL,
760
761 -- A boolean value indicating whether the wiki is in this project
762 -- (used, for example, to detect redirect loops)
763 iw_local BOOL NOT NULL,
764
765 -- Boolean value indicating whether interwiki transclusions are allowed.
766 iw_trans TINYINT(1) NOT NULL DEFAULT 0,
767
768 UNIQUE KEY iw_prefix (iw_prefix)
769
770 ) TYPE=InnoDB, DEFAULT CHARSET=utf8;
771
772 --
773 -- Used for caching expensive grouped queries
774 --
775 CREATE TABLE /*$wgDBprefix*/querycache (
776 -- A key name, generally the base name of of the special page.
777 qc_type char(32) NOT NULL,
778
779 -- Some sort of stored value. Sizes, counts...
780 qc_value int(5) unsigned NOT NULL default '0',
781
782 -- Target namespace+title
783 qc_namespace int NOT NULL default '0',
784 qc_title char(255) binary NOT NULL default '',
785
786 KEY (qc_type,qc_value)
787
788 ) TYPE=InnoDB, DEFAULT CHARSET=utf8;
789
790 --
791 -- For a few generic cache operations if not using Memcached
792 --
793 CREATE TABLE /*$wgDBprefix*/objectcache (
794 keyname char(255) binary not null default '',
795 value mediumblob,
796 exptime datetime,
797 unique key (keyname),
798 key (exptime)
799
800 ) TYPE=InnoDB, DEFAULT CHARSET=utf8;
801
802 -- For article validation
803 CREATE TABLE /*$wgDBprefix*/validate (
804 val_user int(11) NOT NULL default '0',
805 val_page int(11) unsigned NOT NULL default '0',
806 val_revision int(11) unsigned NOT NULL default '0',
807 val_type int(11) unsigned NOT NULL default '0',
808 val_value int(11) default '0',
809 val_comment varchar(255) NOT NULL default '',
810 val_ip varchar(20) NOT NULL default '',
811 KEY val_user (val_user,val_revision)
812 ) TYPE=InnoDB, DEFAULT CHARSET=utf8;
813
814
815 CREATE TABLE /*$wgDBprefix*/logging (
816 -- Symbolic keys for the general log type and the action type
817 -- within the log. The output format will be controlled by the
818 -- action field, but only the type controls categorization.
819 log_type char(10) NOT NULL default '',
820 log_action char(10) NOT NULL default '',
821
822 -- Timestamp. Duh.
823 log_timestamp char(14) NOT NULL default '19700101000000',
824
825 -- The user who performed this action; key to user_id
826 log_user int unsigned NOT NULL default 0,
827
828 -- Key to the page affected. Where a user is the target,
829 -- this will point to the user page.
830 log_namespace int NOT NULL default 0,
831 log_title varchar(255) binary NOT NULL default '',
832
833 -- Freeform text. Interpreted as edit history comments.
834 log_comment varchar(255) NOT NULL default '',
835
836 -- LF separated list of miscellaneous parameters
837 log_params blob NOT NULL default '',
838
839 KEY type_time (log_type, log_timestamp),
840 KEY user_time (log_user, log_timestamp),
841 KEY page_time (log_namespace, log_title, log_timestamp)
842
843 ) TYPE=InnoDB, DEFAULT CHARSET=utf8;
844
845 CREATE TABLE /*$wgDBprefix*/trackbacks (
846 tb_id integer AUTO_INCREMENT PRIMARY KEY,
847 tb_page integer REFERENCES page(page_id) ON DELETE CASCADE,
848 tb_title varchar(255) NOT NULL,
849 tb_url varchar(255) NOT NULL,
850 tb_ex text,
851 tb_name varchar(255),
852
853 INDEX (tb_page)
854 ) TYPE=InnoDB, DEFAULT CHARSET=utf8;