1 -- Experimental table definitions for MySQL 4.1 and 5.0 with
2 -- explicit character set support. Not fully tested, may have
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
12 -- ------------------------------------------------------------
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.
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!)
25 -- Only the 'searchindex' table requires MyISAM due to the
26 -- requirement for fulltext index support, which is missing
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.
35 -- Historically TIMESTAMP fields were used, but abandoned
36 -- in early 2002 after a lot of trouble with the fields
39 -- The PostgreSQL backend uses DATETIME fields for timestamps,
40 -- and we will migrate the MySQL definitions at some point as
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.
53 -- The user table contains basic account information,
54 -- authentication keys, etc.
56 -- Some multi-wiki sites may share a single central user table
57 -- between separate wikis using the $wgSharedDB setting.
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
64 CREATE TABLE /*$wgDBprefix*/user (
65 user_id
int(5) unsigned
NOT NULL auto_increment
,
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 '',
74 -- Optional 'real name' to be displayed in credit listings
75 user_real_name
varchar(255) binary NOT NULL default '',
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 '',
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 '',
90 -- Note: email should be restricted, not public info.
91 -- Same with passwords.
92 user_email tinytext
NOT NULL default '',
94 -- Newline-separated list of name=value defining the user
96 user_options
blob NOT NULL default '',
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 '',
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 '',
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,
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,
119 -- Expiration date for the user_email_token
120 user_email_token_expires
CHAR(14) BINARY,
122 -- Timestamp of account registration.
123 -- Accounts predating this schema addition may contain NULL.
124 user_registration
CHAR(14) BINARY,
126 PRIMARY KEY user_id (user_id
),
127 UNIQUE INDEX user_name (user_name
),
128 INDEX (user_email_token
)
130 ) TYPE=InnoDB
, DEFAULT CHARSET
=utf8
;
133 -- User permissions have been broken out to a separate table;
134 -- this allows sites with a shared user table to have different
135 -- permissions assigned to a user in each project.
137 -- This table replaces the old user_rights field which used a
138 -- comma-separated blob.
140 CREATE TABLE /*$wgDBprefix*/user_groups (
142 ug_user
int(5) unsigned
NOT NULL default '0',
144 -- Group names are short symbolic string keys.
145 -- The set of group names is open-ended, though in practice
146 -- only some predefined ones are likely to be used.
148 -- At runtime $wgGroupPermissions will associate group keys
149 -- with particular permissions. A user will have the combined
150 -- permissions of any group they're explicitly in, plus
151 -- the implicit '*' and 'user' groups.
152 ug_group
char(16) NOT NULL default '',
154 PRIMARY KEY (ug_user
,ug_group
),
156 ) TYPE=InnoDB
, DEFAULT CHARSET
=utf8
;
158 -- Stores notifications of user talk page changes, for the display
159 -- of the "you have new messages" box
160 CREATE TABLE /*$wgDBprefix*/user_newtalk (
161 -- Key to user.user_id
162 user_id
int(5) NOT NULL default '0',
163 -- If the user is an anonymous user hir IP address is stored here
164 -- since the user_id of 0 is ambiguous
165 user_ip
varchar(40) NOT NULL default '',
166 INDEX user_id (user_id
),
167 INDEX user_ip (user_ip
)
168 ) TYPE=InnoDB
, DEFAULT CHARSET
=utf8
;
172 -- Core of the wiki: each page has an entry here which identifies
173 -- it by title and contains some essential metadata.
175 CREATE TABLE /*$wgDBprefix*/page (
176 -- Unique identifier number. The page_id will be preserved across
177 -- edits and rename operations, but not deletions and recreations.
178 page_id
int(8) unsigned
NOT NULL auto_increment
,
180 -- A page name is broken into a namespace and a title.
181 -- The namespace keys are UI-language-independent constants,
182 -- defined in includes/Defines.php
183 page_namespace
int NOT NULL,
185 -- The rest of the title, as text.
186 -- Spaces are transformed into underscores in title storage.
187 page_title
varchar(255) binary NOT NULL,
189 -- Comma-separated set of permission keys indicating who
190 -- can move or edit the page.
191 page_restrictions tinyblob
NOT NULL default '',
193 -- Number of times this page has been viewed.
194 page_counter
bigint(20) unsigned
NOT NULL default '0',
196 -- 1 indicates the article is a redirect.
197 page_is_redirect
tinyint(1) unsigned
NOT NULL default '0',
199 -- 1 indicates this is a new entry, with only one edit.
200 -- Not all pages with one edit are new pages.
201 page_is_new
tinyint(1) unsigned
NOT NULL default '0',
203 -- Random value between 0 and 1, used for Special:Randompage
204 page_random
real unsigned
NOT NULL,
206 -- This timestamp is updated whenever the page changes in
207 -- a way requiring it to be re-rendered, invalidating caches.
208 -- Aside from editing this includes permission changes,
209 -- creation or deletion of linked pages, and alteration
210 -- of contained templates.
211 page_touched
char(14) binary NOT NULL default '',
213 -- Handy key to revision.rev_id of the current revision.
214 -- This may be 0 during page creation, but that shouldn't
215 -- happen outside of a transaction... hopefully.
216 page_latest
int(8) unsigned
NOT NULL,
218 -- Uncompressed length in bytes of the page's current source text.
219 page_len
int(8) unsigned
NOT NULL,
221 PRIMARY KEY page_id (page_id
),
222 UNIQUE INDEX name_title (page_namespace
,page_title
),
224 -- Special-purpose indexes
228 ) TYPE=InnoDB
, DEFAULT CHARSET
=utf8
;
231 -- Every edit of a page creates also a revision row.
232 -- This stores metadata about the revision, and a reference
233 -- to the text storage backend.
235 CREATE TABLE /*$wgDBprefix*/revision (
236 rev_id
int(8) unsigned
NOT NULL auto_increment
,
238 -- Key to page_id. This should _never_ be invalid.
239 rev_page
int(8) unsigned
NOT NULL,
241 -- Key to text.old_id, where the actual bulk text is stored.
242 -- It's possible for multiple revisions to use the same text,
243 -- for instance revisions where only metadata is altered
244 -- or a rollback to a previous version.
245 rev_text_id
int(8) unsigned
NOT NULL,
247 -- Text comment summarizing the change.
248 -- This text is shown in the history and other changes lists,
249 -- rendered in a subset of wiki markup by Linker::formatComment()
250 rev_comment tinyblob
NOT NULL default '',
252 -- Key to user.user_id of the user who made this edit.
253 -- Stores 0 for anonymous edits and for some mass imports.
254 rev_user
int(5) unsigned
NOT NULL default '0',
256 -- Text username or IP address of the editor.
257 rev_user_text
varchar(255) binary NOT NULL default '',
260 rev_timestamp
char(14) binary NOT NULL default '',
262 -- Records whether the user marked the 'minor edit' checkbox.
263 -- Many automated edits are marked as minor.
264 rev_minor_edit
tinyint(1) unsigned
NOT NULL default '0',
266 -- Not yet used; reserved for future changes to the deletion system.
267 rev_deleted
tinyint(1) unsigned
NOT NULL default '0',
269 PRIMARY KEY rev_page_id (rev_page
, rev_id
),
270 UNIQUE INDEX rev_id (rev_id
),
271 INDEX rev_timestamp (rev_timestamp
),
272 INDEX page_timestamp (rev_page
,rev_timestamp
),
273 INDEX user_timestamp (rev_user
,rev_timestamp
),
274 INDEX usertext_timestamp (rev_user_text
,rev_timestamp
)
276 ) TYPE=InnoDB
, DEFAULT CHARSET
=utf8
;
280 -- Holds text of individual page revisions.
282 -- Field names are a holdover from the 'old' revisions table in
283 -- MediaWiki 1.4 and earlier: an upgrade will transform that
284 -- table into the 'text' table to minimize unnecessary churning
285 -- and downtime. If upgrading, the other fields will be left unused.
287 CREATE TABLE /*$wgDBprefix*/text (
288 -- Unique text storage key number.
289 -- Note that the 'oldid' parameter used in URLs does *not*
290 -- refer to this number anymore, but to rev_id.
292 -- revision.rev_text_id is a key to this column
293 old_id
int(8) unsigned
NOT NULL auto_increment
,
295 -- Depending on the contents of the old_flags field, the text
296 -- may be convenient plain text, or it may be funkily encoded.
297 old_text mediumblob
NOT NULL default '',
299 -- Comma-separated list of flags:
300 -- gzip: text is compressed with PHP's gzdeflate() function.
301 -- utf8: text was stored as UTF-8.
302 -- If $wgLegacyEncoding option is on, rows *without* this flag
303 -- will be converted to UTF-8 transparently at load time.
304 -- object: text field contained a serialized PHP object.
305 -- The object either contains multiple versions compressed
306 -- together to achieve a better compression ratio, or it refers
307 -- to another row where the text can be found.
308 old_flags tinyblob
NOT NULL default '',
310 PRIMARY KEY old_id (old_id
)
312 ) TYPE=InnoDB
, DEFAULT CHARSET
=utf8
;
315 -- Holding area for deleted articles, which may be viewed
316 -- or restored by admins through the Special:Undelete interface.
317 -- The fields generally correspond to the page, revision, and text
318 -- fields, with several caveats.
320 CREATE TABLE /*$wgDBprefix*/archive (
321 ar_namespace
int NOT NULL default '0',
322 ar_title
varchar(255) binary NOT NULL default '',
324 -- Newly deleted pages will not store text in this table,
325 -- but will reference the separately existing text rows.
326 -- This field is retained for backwards compatibility,
327 -- so old archived pages will remain accessible after
328 -- upgrading from 1.4 to 1.5.
329 -- Text may be gzipped or otherwise funky.
330 ar_text mediumblob
NOT NULL default '',
332 -- Basic revision stuff...
333 ar_comment tinyblob
NOT NULL default '',
334 ar_user
int(5) unsigned
NOT NULL default '0',
335 ar_user_text
varchar(255) binary NOT NULL,
336 ar_timestamp
char(14) binary NOT NULL default '',
337 ar_minor_edit
tinyint(1) NOT NULL default '0',
340 ar_flags tinyblob
NOT NULL default '',
342 -- When revisions are deleted, their unique rev_id is stored
343 -- here so it can be retained after undeletion. This is necessary
344 -- to retain permalinks to given revisions after accidental delete
345 -- cycles or messy operations like history merges.
347 -- Old entries from 1.4 will be NULL here, and a new rev_id will
348 -- be created on undeletion for those revisions.
349 ar_rev_id
int(8) unsigned
,
351 -- For newly deleted revisions, this is the text.old_id key to the
352 -- actual stored text. To avoid breaking the block-compression scheme
353 -- and otherwise making storage changes harder, the actual text is
354 -- *not* deleted from the text table, merely hidden by removal of the
355 -- page and revision entries.
357 -- Old entries deleted under 1.2-1.4 will have NULL here, and their
358 -- ar_text and ar_flags fields will be used to create a new text
359 -- row upon undeletion.
360 ar_text_id
int(8) unsigned
,
362 KEY name_title_timestamp (ar_namespace
,ar_title
,ar_timestamp
)
364 ) TYPE=InnoDB
, DEFAULT CHARSET
=utf8
;
368 -- Track page-to-page hyperlinks within the wiki.
370 CREATE TABLE /*$wgDBprefix*/pagelinks (
371 -- Key to the page_id of the page containing the link.
372 pl_from
int(8) unsigned
NOT NULL default '0',
374 -- Key to page_namespace/page_title of the target page.
375 -- The target page may or may not exist, and due to renames
376 -- and deletions may refer to different page records as time
378 pl_namespace
int NOT NULL default '0',
379 pl_title
varchar(255) binary NOT NULL default '',
381 UNIQUE KEY pl_from(pl_from
,pl_namespace
,pl_title
),
382 KEY (pl_namespace
,pl_title
)
384 ) TYPE=InnoDB
, DEFAULT CHARSET
=utf8
;
388 -- Track template inclusions.
390 CREATE TABLE /*$wgDBprefix*/templatelinks (
391 -- Key to the page_id of the page containing the link.
392 tl_from
int(8) unsigned
NOT NULL default '0',
394 -- Key to page_namespace/page_title of the target page.
395 -- The target page may or may not exist, and due to renames
396 -- and deletions may refer to different page records as time
398 tl_namespace
int NOT NULL default '0',
399 tl_title
varchar(255) binary NOT NULL default '',
401 UNIQUE KEY tl_from(tl_from
,tl_namespace
,tl_title
),
402 KEY (tl_namespace
,tl_title
)
404 ) TYPE=InnoDB
, DEFAULT CHARSET
=utf8
;
408 -- Track links to images *used inline*
409 -- We don't distinguish live from broken links here, so
410 -- they do not need to be changed on upload/removal.
412 CREATE TABLE /*$wgDBprefix*/imagelinks (
413 -- Key to page_id of the page containing the image / media link.
414 il_from
int(8) unsigned
NOT NULL default '0',
416 -- Filename of target image.
417 -- This is also the page_title of the file's description page;
418 -- all such pages are in namespace 6 (NS_IMAGE).
419 il_to
varchar(255) binary NOT NULL default '',
421 UNIQUE KEY il_from(il_from
,il_to
),
424 ) TYPE=InnoDB
, DEFAULT CHARSET
=utf8
;
427 -- Track category inclusions *used inline*
428 -- This tracks a single level of category membership
429 -- (folksonomic tagging, really).
431 CREATE TABLE /*$wgDBprefix*/categorylinks (
432 -- Key to page_id of the page defined as a category member.
433 cl_from
int(8) unsigned
NOT NULL default '0',
435 -- Name of the category.
436 -- This is also the page_title of the category's description page;
437 -- all such pages are in namespace 14 (NS_CATEGORY).
438 cl_to
varchar(255) binary NOT NULL default '',
440 -- The title of the linking page, or an optional override
441 -- to determine sort order. Sorting is by binary order, which
442 -- isn't always ideal, but collations seem to be an exciting
443 -- and dangerous new world in MySQL...
445 -- For MySQL 4.1+ with charset set to utf8, the sort key *index*
446 -- needs cut to be smaller than 1024 bytes (at 3 bytes per char).
447 -- To sort properly on the shorter key, this field needs to be
448 -- the same shortness.
449 cl_sortkey
varchar(86) binary NOT NULL default '',
451 -- This isn't really used at present. Provided for an optional
452 -- sorting method by approximate addition time.
453 cl_timestamp
timestamp NOT NULL,
455 UNIQUE KEY cl_from(cl_from
,cl_to
),
457 -- We always sort within a given category...
458 KEY cl_sortkey(cl_to
,cl_sortkey
),
461 KEY cl_timestamp(cl_to
,cl_timestamp
)
463 ) TYPE=InnoDB
, DEFAULT CHARSET
=utf8
;
466 -- Track links to external URLs
468 CREATE TABLE /*$wgDBprefix*/externallinks (
469 -- page_id of the referring page
470 el_from
int(8) unsigned
NOT NULL default '0',
473 el_to
blob NOT NULL default '',
475 -- In the case of HTTP URLs, this is the URL with any username or password
476 -- removed, and with the labels in the hostname reversed and converted to
477 -- lower case. An extra dot is added to allow for matching of either
478 -- example.com or *.example.com in a single scan.
480 -- http://user:password@sub.example.com/page.html
482 -- http://com.example.sub./page.html
483 -- which allows for fast searching for all pages under example.com with the
485 -- WHERE el_index LIKE 'http://com.example.%'
486 el_index
blob NOT NULL default '',
488 KEY (el_from
, el_to(40)),
489 KEY (el_to(60), el_from
),
491 ) TYPE=InnoDB
, DEFAULT CHARSET
=utf8
;
494 -- Contains a single row with some aggregate info
495 -- on the state of the site.
497 CREATE TABLE /*$wgDBprefix*/site_stats (
498 -- The single row should contain 1 here.
499 ss_row_id
int(8) unsigned
NOT NULL,
501 -- Total number of page views, if hit counters are enabled.
502 ss_total_views
bigint(20) unsigned
default '0',
504 -- Total number of edits performed.
505 ss_total_edits
bigint(20) unsigned
default '0',
507 -- An approximate count of pages matching the following criteria:
510 -- * contains the text '[['
511 -- See Article::isCountable() in includes/Article.php
512 ss_good_articles
bigint(20) unsigned
default '0',
514 -- Total pages, theoretically equal to SELECT COUNT(*) FROM page; except faster
515 ss_total_pages
bigint(20) default '-1',
517 -- Number of users, theoretically equal to SELECT COUNT(*) FROM user;
518 ss_users
bigint(20) default '-1',
520 -- Deprecated, no longer updated as of 1.5
521 ss_admins
int(10) default '-1',
523 UNIQUE KEY ss_row_id (ss_row_id
)
528 -- Stores an ID for every time any article is visited;
529 -- depending on $wgHitcounterUpdateFreq, it is
530 -- periodically cleared and the page_counter column
531 -- in the page table updated for the all articles
532 -- that have been visited.)
534 CREATE TABLE /*$wgDBprefix*/hitcounter (
535 hc_id
INTEGER UNSIGNED
NOT NULL
536 ) TYPE=HEAP MAX_ROWS
=25000;
540 -- The internet is full of jerks, alas. Sometimes it's handy
541 -- to block a vandal or troll account.
543 CREATE TABLE /*$wgDBprefix*/ipblocks (
544 -- Primary key, introduced for privacy.
545 ipb_id
int(8) NOT NULL auto_increment
,
547 -- Blocked IP address in dotted-quad form or user name.
548 ipb_address
varchar(40) binary NOT NULL default '',
550 -- Blocked user ID or 0 for IP blocks.
551 ipb_user
int(8) unsigned
NOT NULL default '0',
553 -- User ID who made the block.
554 ipb_by
int(8) unsigned
NOT NULL default '0',
556 -- Text comment made by blocker.
557 ipb_reason tinyblob
NOT NULL default '',
559 -- Creation (or refresh) date in standard YMDHMS form.
560 -- IP blocks expire automatically.
561 ipb_timestamp
char(14) binary NOT NULL default '',
563 -- Indicates that the IP address was banned because a banned
564 -- user accessed a page through it. If this is 1, ipb_address
565 -- will be hidden, and the block identified by block ID number.
566 ipb_auto
tinyint(1) NOT NULL default '0',
568 -- Time at which the block will expire.
569 ipb_expiry
char(14) binary NOT NULL default '',
571 -- Start and end of an address range, in hexadecimal
572 -- Size chosen to allow IPv6
573 ipb_range_start
varchar(32) NOT NULL default '',
574 ipb_range_end
varchar(32) NOT NULL default '',
576 PRIMARY KEY ipb_id (ipb_id
),
577 INDEX ipb_address (ipb_address
),
578 INDEX ipb_user (ipb_user
),
579 INDEX ipb_range (ipb_range_start(8), ipb_range_end(8))
581 ) TYPE=InnoDB
, DEFAULT CHARSET
=utf8
;
585 -- Uploaded images and other files.
587 CREATE TABLE /*$wgDBprefix*/image (
589 -- This is also the title of the associated description page,
590 -- which will be in namespace 6 (NS_IMAGE).
591 img_name
varchar(255) binary NOT NULL default '',
593 -- File size in bytes.
594 img_size
int(8) unsigned
NOT NULL default '0',
596 -- For images, size in pixels.
597 img_width
int(5) NOT NULL default '0',
598 img_height
int(5) NOT NULL default '0',
600 -- Extracted EXIF metadata stored as a serialized PHP array.
601 img_metadata mediumblob
NOT NULL,
603 -- For images, bits per pixel if known.
604 img_bits
int(3) NOT NULL default '0',
606 -- Media type as defined by the MEDIATYPE_xxx constants
607 img_media_type
ENUM("UNKNOWN", "BITMAP", "DRAWING", "AUDIO", "VIDEO", "MULTIMEDIA", "OFFICE", "TEXT", "EXECUTABLE", "ARCHIVE") default NULL,
609 -- major part of a MIME media type as defined by IANA
610 -- see http://www.iana.org/assignments/media-types/
611 img_major_mime
ENUM("unknown", "application", "audio", "image", "text", "video", "message", "model", "multipart") NOT NULL default "unknown",
613 -- minor part of a MIME media type as defined by IANA
614 -- the minor parts are not required to adher to any standard
615 -- but should be consistent throughout the database
616 -- see http://www.iana.org/assignments/media-types/
617 img_minor_mime
varchar(32) NOT NULL default "unknown",
619 -- Description field as entered by the uploader.
620 -- This is displayed in image upload history and logs.
621 img_description tinyblob
NOT NULL default '',
623 -- user_id and user_name of uploader.
624 img_user
int(5) unsigned
NOT NULL default '0',
625 img_user_text
varchar(255) binary NOT NULL default '',
627 -- Time of the upload.
628 img_timestamp
char(14) binary NOT NULL default '',
630 PRIMARY KEY img_name (img_name
),
632 -- Used by Special:Imagelist for sort-by-size
633 INDEX img_size (img_size
),
635 -- Used by Special:Newimages and Special:Imagelist
636 INDEX img_timestamp (img_timestamp
)
638 ) TYPE=InnoDB
, DEFAULT CHARSET
=utf8
;
641 -- Previous revisions of uploaded files.
642 -- Awkwardly, image rows have to be moved into
643 -- this table at re-upload time.
645 CREATE TABLE /*$wgDBprefix*/oldimage (
646 -- Base filename: key to image.img_name
647 oi_name
varchar(255) binary NOT NULL default '',
649 -- Filename of the archived file.
650 -- This is generally a timestamp and '!' prepended to the base name.
651 oi_archive_name
varchar(255) binary NOT NULL default '',
653 -- Other fields as in image...
654 oi_size
int(8) unsigned
NOT NULL default 0,
655 oi_width
int(5) NOT NULL default 0,
656 oi_height
int(5) NOT NULL default 0,
657 oi_bits
int(3) NOT NULL default 0,
658 oi_description tinyblob
NOT NULL default '',
659 oi_user
int(5) unsigned
NOT NULL default '0',
660 oi_user_text
varchar(255) binary NOT NULL default '',
661 oi_timestamp
char(14) binary NOT NULL default '',
663 INDEX oi_name (oi_name(10))
665 ) TYPE=InnoDB
, DEFAULT CHARSET
=utf8
;
669 -- Primarily a summary table for Special:Recentchanges,
670 -- this table contains some additional info on edits from
671 -- the last few days, see Article::editUpdates()
673 CREATE TABLE /*$wgDBprefix*/recentchanges (
674 rc_id
int(8) NOT NULL auto_increment
,
675 rc_timestamp
varchar(14) binary NOT NULL default '',
676 rc_cur_time
varchar(14) binary NOT NULL default '',
679 rc_user
int(10) unsigned
NOT NULL default '0',
680 rc_user_text
varchar(255) binary NOT NULL default '',
682 -- When pages are renamed, their RC entries do _not_ change.
683 rc_namespace
int NOT NULL default '0',
684 rc_title
varchar(255) binary NOT NULL default '',
687 rc_comment
varchar(255) binary NOT NULL default '',
688 rc_minor
tinyint(3) unsigned
NOT NULL default '0',
690 -- Edits by user accounts with the 'bot' rights key are
691 -- marked with a 1 here, and will be hidden from the
693 rc_bot
tinyint(3) unsigned
NOT NULL default '0',
695 rc_new
tinyint(3) unsigned
NOT NULL default '0',
697 -- Key to page_id (was cur_id prior to 1.5).
698 -- This will keep links working after moves while
699 -- retaining the at-the-time name in the changes list.
700 rc_cur_id
int(10) unsigned
NOT NULL default '0',
702 -- rev_id of the given revision
703 rc_this_oldid
int(10) unsigned
NOT NULL default '0',
705 -- rev_id of the prior revision, for generating diff links.
706 rc_last_oldid
int(10) unsigned
NOT NULL default '0',
708 -- These may no longer be used, with the new move log.
709 rc_type
tinyint(3) unsigned
NOT NULL default '0',
710 rc_moved_to_ns
tinyint(3) unsigned
NOT NULL default '0',
711 rc_moved_to_title
varchar(255) binary NOT NULL default '',
713 -- If the Recent Changes Patrol option is enabled,
714 -- users may mark edits as having been reviewed to
715 -- remove a warning flag on the RC list.
716 -- A value of 1 indicates the page has been reviewed.
717 rc_patrolled
tinyint(3) unsigned
NOT NULL default '0',
719 -- Recorded IP address the edit was made from, if the
720 -- $wgPutIPinRC option is enabled.
721 rc_ip
char(15) NOT NULL default '',
723 PRIMARY KEY rc_id (rc_id
),
724 INDEX rc_timestamp (rc_timestamp
),
725 INDEX rc_namespace_title (rc_namespace
, rc_title
),
726 INDEX rc_cur_id (rc_cur_id
),
727 INDEX new_name_timestamp(rc_new
,rc_namespace
,rc_timestamp
),
730 ) TYPE=InnoDB
, DEFAULT CHARSET
=utf8
;
732 CREATE TABLE /*$wgDBprefix*/watchlist (
733 -- Key to user.user_id
734 wl_user
int(5) unsigned
NOT NULL,
736 -- Key to page_namespace/page_title
737 -- Note that users may watch pages which do not exist yet,
738 -- or existed in the past but have been deleted.
739 wl_namespace
int NOT NULL default '0',
740 wl_title
varchar(255) binary NOT NULL default '',
742 -- Timestamp when user was last sent a notification e-mail;
743 -- cleared when the user visits the page.
744 wl_notificationtimestamp
varchar(14) binary,
746 UNIQUE KEY (wl_user
, wl_namespace
, wl_title
),
747 KEY namespace_title (wl_namespace
,wl_title
)
749 ) TYPE=InnoDB
, DEFAULT CHARSET
=utf8
;
753 -- Used by the math module to keep track
754 -- of previously-rendered items.
756 CREATE TABLE /*$wgDBprefix*/math (
757 -- Binary MD5 hash of the latex fragment, used as an identifier key.
758 math_inputhash
varbinary(16) NOT NULL,
760 -- Not sure what this is, exactly...
761 math_outputhash
varbinary(16) NOT NULL,
763 -- texvc reports how well it thinks the HTML conversion worked;
764 -- if it's a low level the PNG rendering may be preferred.
765 math_html_conservativeness
tinyint(1) NOT NULL,
767 -- HTML output from texvc, if any
770 -- MathML output from texvc, if any
773 UNIQUE KEY math_inputhash (math_inputhash
)
775 ) TYPE=InnoDB
, DEFAULT CHARSET
=utf8
;
778 -- When using the default MySQL search backend, page titles
779 -- and text are munged to strip markup, do Unicode case folding,
780 -- and prepare the result for MySQL's fulltext index.
782 -- This table must be MyISAM; InnoDB does not support the needed
785 CREATE TABLE /*$wgDBprefix*/searchindex (
787 si_page
int(8) unsigned
NOT NULL,
789 -- Munged version of title
790 si_title
varchar(255) NOT NULL default '',
792 -- Munged version of body text
793 si_text mediumtext
NOT NULL default '',
795 UNIQUE KEY (si_page
),
796 FULLTEXT
si_title (si_title
),
797 FULLTEXT
si_text (si_text
)
799 ) TYPE=MyISAM
, DEFAULT CHARSET
=utf8
;
802 -- Recognized interwiki link prefixes
804 CREATE TABLE /*$wgDBprefix*/interwiki (
805 -- The interwiki prefix, (e.g. "Meatball", or the language prefix "de")
806 iw_prefix
char(32) NOT NULL,
808 -- The URL of the wiki, with "$1" as a placeholder for an article name.
809 -- Any spaces in the name will be transformed to underscores before
811 iw_url
char(127) NOT NULL,
813 -- A boolean value indicating whether the wiki is in this project
814 -- (used, for example, to detect redirect loops)
815 iw_local BOOL
NOT NULL,
817 -- Boolean value indicating whether interwiki transclusions are allowed.
818 iw_trans
TINYINT(1) NOT NULL DEFAULT 0,
820 UNIQUE KEY iw_prefix (iw_prefix
)
822 ) TYPE=InnoDB
, DEFAULT CHARSET
=utf8
;
825 -- Used for caching expensive grouped queries
827 CREATE TABLE /*$wgDBprefix*/querycache (
828 -- A key name, generally the base name of of the special page.
829 qc_type
char(32) NOT NULL,
831 -- Some sort of stored value. Sizes, counts...
832 qc_value
int(5) unsigned
NOT NULL default '0',
834 -- Target namespace+title
835 qc_namespace
int NOT NULL default '0',
836 qc_title
char(255) binary NOT NULL default '',
838 KEY (qc_type
,qc_value
)
840 ) TYPE=InnoDB
, DEFAULT CHARSET
=utf8
;
843 -- For a few generic cache operations if not using Memcached
845 CREATE TABLE /*$wgDBprefix*/objectcache (
846 keyname
char(255) binary not null default '',
849 unique key (keyname
),
852 ) TYPE=InnoDB
, DEFAULT CHARSET
=utf8
;
854 -- For article validation
855 CREATE TABLE /*$wgDBprefix*/validate (
856 val_user
int(11) NOT NULL default '0',
857 val_page
int(11) unsigned
NOT NULL default '0',
858 val_revision
int(11) unsigned
NOT NULL default '0',
859 val_type
int(11) unsigned
NOT NULL default '0',
860 val_value
int(11) default '0',
861 val_comment
varchar(255) NOT NULL default '',
862 val_ip
varchar(20) NOT NULL default '',
863 KEY val_user (val_user
,val_revision
)
864 ) TYPE=InnoDB
, DEFAULT CHARSET
=utf8
;
867 CREATE TABLE /*$wgDBprefix*/logging (
868 -- Symbolic keys for the general log type and the action type
869 -- within the log. The output format will be controlled by the
870 -- action field, but only the type controls categorization.
871 log_type
char(10) NOT NULL default '',
872 log_action
char(10) NOT NULL default '',
875 log_timestamp
char(14) NOT NULL default '19700101000000',
877 -- The user who performed this action; key to user_id
878 log_user
int unsigned
NOT NULL default 0,
880 -- Key to the page affected. Where a user is the target,
881 -- this will point to the user page.
882 log_namespace
int NOT NULL default 0,
883 log_title
varchar(255) binary NOT NULL default '',
885 -- Freeform text. Interpreted as edit history comments.
886 log_comment
varchar(255) NOT NULL default '',
888 -- LF separated list of miscellaneous parameters
889 log_params
blob NOT NULL default '',
891 KEY type_time (log_type
, log_timestamp
),
892 KEY user_time (log_user
, log_timestamp
),
893 KEY page_time (log_namespace
, log_title
, log_timestamp
)
895 ) TYPE=InnoDB
, DEFAULT CHARSET
=utf8
;
897 CREATE TABLE /*$wgDBprefix*/trackbacks (
898 tb_id
integer AUTO_INCREMENT
PRIMARY KEY,
899 tb_page
integer REFERENCES page(page_id
) ON DELETE CASCADE,
900 tb_title
varchar(255) NOT NULL,
901 tb_url
varchar(255) NOT NULL,
903 tb_name
varchar(255),
906 ) TYPE=InnoDB
, DEFAULT CHARSET
=utf8
;