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