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 -- This is a shared schema file used for both MySQL and SQLite installs.
7 -- For more documentation on the database schema, see
8 -- https://www.mediawiki.org/wiki/Manual:Database_layout
12 -- If possible, create tables as InnoDB to benefit from the
13 -- superior resiliency against crashes and ability to read
14 -- during writes (and write during reads!)
16 -- Only the 'searchindex' table requires MyISAM due to the
17 -- requirement for fulltext index support, which is missing
21 -- The MySQL table backend for MediaWiki currently uses
22 -- 14-character BINARY or VARBINARY fields to store timestamps.
23 -- The format is YYYYMMDDHHMMSS, which is derived from the
24 -- text format of MySQL's TIMESTAMP fields.
26 -- Historically TIMESTAMP fields were used, but abandoned
27 -- in early 2002 after a lot of trouble with the fields
30 -- The Postgres backend uses TIMESTAMPTZ fields for timestamps,
31 -- and we will migrate the MySQL definitions at some point as
35 -- The /*_*/ comments in this and other files are
36 -- replaced with the defined table prefix by the installer
37 -- and updater scripts. If you are installing or running
38 -- updates manually, you will need to manually insert the
39 -- table prefix if any when running these scripts.
44 -- The user table contains basic account information,
45 -- authentication keys, etc.
47 -- Some multi-wiki sites may share a single central user table
48 -- between separate wikis using the $wgSharedDB setting.
50 -- Note that when a external authentication plugin is used,
51 -- user table entries still need to be created to store
52 -- preferences and to key tracking information in the other
55 CREATE TABLE /*_*/user (
56 user_id
int unsigned
NOT NULL PRIMARY KEY AUTO_INCREMENT
,
58 -- Usernames must be unique, must not be in the form of
59 -- an IP address. _Shouldn't_ allow slashes or case
60 -- conflicts. Spaces are allowed, and are _not_ converted
61 -- to underscores like titles. See the User::newFromName() for
62 -- the specific tests that usernames have to pass.
63 user_name
varchar(255) binary NOT NULL default '',
65 -- Optional 'real name' to be displayed in credit listings
66 user_real_name
varchar(255) binary NOT NULL default '',
68 -- Password hashes, see User::crypt() and User::comparePasswords()
69 -- in User.php for the algorithm
70 user_password tinyblob
NOT NULL,
72 -- When using 'mail me a new password', a random
73 -- password is generated and the hash stored here.
74 -- The previous password is left in place until
75 -- someone actually logs in with the new password,
76 -- at which point the hash is moved to user_password
77 -- and the old password is invalidated.
78 user_newpassword tinyblob
NOT NULL,
80 -- Timestamp of the last time when a new password was
81 -- sent, for throttling and expiring purposes
82 -- Emailed passwords will expire $wgNewPasswordExpiry
83 -- (a week) after being set. If user_newpass_time is NULL
84 -- (eg. created by mail) it doesn't expire.
85 user_newpass_time
binary(14),
87 -- Note: email should be restricted, not public info.
88 -- Same with passwords.
89 user_email tinytext
NOT NULL,
91 -- If the browser sends an If-Modified-Since header, a 304 response is
92 -- suppressed if the value in this field for the current user is later than
93 -- the value in the IMS header. That is, this field is an invalidation timestamp
94 -- for the browser cache of logged-in users. Among other things, it is used
95 -- to prevent pages generated for a previously logged in user from being
96 -- displayed after a session expiry followed by a fresh login.
97 user_touched
binary(14) NOT NULL default '',
99 -- A pseudorandomly generated value that is stored in
100 -- a cookie when the "remember password" feature is
101 -- used (previously, a hash of the password was used, but
102 -- this was vulnerable to cookie-stealing attacks)
103 user_token
binary(32) NOT NULL default '',
105 -- Initially NULL; when a user's e-mail address has been
106 -- validated by returning with a mailed token, this is
107 -- set to the current timestamp.
108 user_email_authenticated
binary(14),
110 -- Randomly generated token created when the e-mail address
111 -- is set and a confirmation test mail sent.
112 user_email_token
binary(32),
114 -- Expiration date for the user_email_token
115 user_email_token_expires
binary(14),
117 -- Timestamp of account registration.
118 -- Accounts predating this schema addition may contain NULL.
119 user_registration
binary(14),
121 -- Count of edits and edit-like actions.
123 -- *NOT* intended to be an accurate copy of COUNT(*) WHERE rev_user=user_id
124 -- May contain NULL for old accounts if batch-update scripts haven't been
125 -- run, as well as listing deleted edits and other myriad ways it could be
128 -- Meant primarily for heuristic checks to give an impression of whether
129 -- the account has been used much.
133 -- Expiration date for user password.
134 user_password_expires
varbinary(14) DEFAULT NULL
136 ) /*$wgDBTableOptions*/;
138 CREATE UNIQUE INDEX /*i*/user_name
ON /*_*/user (user_name
);
139 CREATE INDEX /*i*/user_email_token
ON /*_*/user (user_email_token
);
140 CREATE INDEX /*i*/user_email
ON /*_*/user (user_email(50));
144 -- The "actor" table associates user names or IP addresses with integers for
145 -- the benefit of other tables that need to refer to either logged-in or
146 -- logged-out users. If something can only ever be done by logged-in users, it
147 -- can refer to the user table directly.
149 CREATE TABLE /*_*/actor (
150 -- Unique ID to identify each actor
151 actor_id
bigint unsigned
NOT NULL PRIMARY KEY AUTO_INCREMENT
,
153 -- Key to user.user_id, or NULL for anonymous edits.
154 actor_user
int unsigned
,
156 -- Text username or IP address
157 actor_name
varchar(255) binary NOT NULL
158 ) /*$wgDBTableOptions*/;
160 -- User IDs and names must be unique.
161 CREATE UNIQUE INDEX /*i*/actor_user
ON /*_*/actor (actor_user
);
162 CREATE UNIQUE INDEX /*i*/actor_name
ON /*_*/actor (actor_name
);
166 -- User permissions have been broken out to a separate table;
167 -- this allows sites with a shared user table to have different
168 -- permissions assigned to a user in each project.
170 -- This table replaces the old user_rights field which used a
171 -- comma-separated blob.
173 CREATE TABLE /*_*/user_groups (
175 ug_user
int unsigned
NOT NULL default 0,
177 -- Group names are short symbolic string keys.
178 -- The set of group names is open-ended, though in practice
179 -- only some predefined ones are likely to be used.
181 -- At runtime $wgGroupPermissions will associate group keys
182 -- with particular permissions. A user will have the combined
183 -- permissions of any group they're explicitly in, plus
184 -- the implicit '*' and 'user' groups.
185 ug_group
varbinary(255) NOT NULL default '',
187 -- Time at which the user group membership will expire. Set to
188 -- NULL for a non-expiring (infinite) membership.
189 ug_expiry
varbinary(14) NULL default NULL,
191 PRIMARY KEY (ug_user
, ug_group
)
192 ) /*$wgDBTableOptions*/;
194 CREATE INDEX /*i*/ug_group
ON /*_*/user_groups (ug_group
);
195 CREATE INDEX /*i*/ug_expiry
ON /*_*/user_groups (ug_expiry
);
197 -- Stores the groups the user has once belonged to.
198 -- The user may still belong to these groups (check user_groups).
199 -- Users are not autopromoted to groups from which they were removed.
200 CREATE TABLE /*_*/user_former_groups (
202 ufg_user
int unsigned
NOT NULL default 0,
203 ufg_group
varbinary(255) NOT NULL default '',
204 PRIMARY KEY (ufg_user
,ufg_group
)
205 ) /*$wgDBTableOptions*/;
208 -- Stores notifications of user talk page changes, for the display
209 -- of the "you have new messages" box
211 CREATE TABLE /*_*/user_newtalk (
212 -- Key to user.user_id
213 user_id
int unsigned
NOT NULL default 0,
214 -- If the user is an anonymous user their IP address is stored here
215 -- since the user_id of 0 is ambiguous
216 user_ip
varbinary(40) NOT NULL default '',
217 -- The highest timestamp of revisions of the talk page viewed
219 user_last_timestamp
varbinary(14) NULL default NULL
220 ) /*$wgDBTableOptions*/;
222 -- Indexes renamed for SQLite in 1.14
223 CREATE INDEX /*i*/un_user_id
ON /*_*/user_newtalk (user_id
);
224 CREATE INDEX /*i*/un_user_ip
ON /*_*/user_newtalk (user_ip
);
228 -- User preferences and perhaps other fun stuff. :)
229 -- Replaces the old user.user_options blob, with a couple nice properties:
231 -- 1) We only store non-default settings, so changes to the defaults
232 -- are now reflected for everybody, not just new accounts.
233 -- 2) We can more easily do bulk lookups, statistics, or modifications of
234 -- saved options since it's a sane table structure.
236 CREATE TABLE /*_*/user_properties (
237 -- Foreign key to user.user_id
238 up_user
int unsigned
NOT NULL,
240 -- Name of the option being saved. This is indexed for bulk lookup.
241 up_property
varbinary(255) NOT NULL,
243 -- Property value as a string.
245 PRIMARY KEY (up_user
,up_property
)
246 ) /*$wgDBTableOptions*/;
248 CREATE INDEX /*i*/user_properties_property
ON /*_*/user_properties (up_property
);
251 -- This table contains a user's bot passwords: passwords that allow access to
252 -- the account via the API with limited rights.
254 CREATE TABLE /*_*/bot_passwords (
255 -- User ID obtained from CentralIdLookup.
256 bp_user
int unsigned
NOT NULL,
258 -- Application identifier
259 bp_app_id
varbinary(32) NOT NULL,
261 -- Password hashes, like user.user_password
262 bp_password tinyblob
NOT NULL,
264 -- Like user.user_token
265 bp_token
binary(32) NOT NULL default '',
267 -- JSON blob for MWRestrictions
268 bp_restrictions
blob NOT NULL,
270 -- Grants allowed to the account when authenticated with this bot-password
271 bp_grants
blob NOT NULL,
273 PRIMARY KEY ( bp_user
, bp_app_id
)
274 ) /*$wgDBTableOptions*/;
277 -- Core of the wiki: each page has an entry here which identifies
278 -- it by title and contains some essential metadata.
280 CREATE TABLE /*_*/page (
281 -- Unique identifier number. The page_id will be preserved across
282 -- edits and rename operations, but not deletions and recreations.
283 page_id
int unsigned
NOT NULL PRIMARY KEY AUTO_INCREMENT
,
285 -- A page name is broken into a namespace and a title.
286 -- The namespace keys are UI-language-independent constants,
287 -- defined in includes/Defines.php
288 page_namespace
int NOT NULL,
290 -- The rest of the title, as text.
291 -- Spaces are transformed into underscores in title storage.
292 page_title
varchar(255) binary NOT NULL,
294 -- Comma-separated set of permission keys indicating who
295 -- can move or edit the page.
296 page_restrictions tinyblob
NOT NULL,
298 -- 1 indicates the article is a redirect.
299 page_is_redirect tinyint unsigned
NOT NULL default 0,
301 -- 1 indicates this is a new entry, with only one edit.
302 -- Not all pages with one edit are new pages.
303 page_is_new tinyint unsigned
NOT NULL default 0,
305 -- Random value between 0 and 1, used for Special:Randompage
306 page_random
real unsigned
NOT NULL,
308 -- This timestamp is updated whenever the page changes in
309 -- a way requiring it to be re-rendered, invalidating caches.
310 -- Aside from editing this includes permission changes,
311 -- creation or deletion of linked pages, and alteration
312 -- of contained templates.
313 page_touched
binary(14) NOT NULL default '',
315 -- This timestamp is updated whenever a page is re-parsed and
316 -- it has all the link tracking tables updated for it. This is
317 -- useful for de-duplicating expensive backlink update jobs.
318 page_links_updated
varbinary(14) NULL default NULL,
320 -- Handy key to revision.rev_id of the current revision.
321 -- This may be 0 during page creation, but that shouldn't
322 -- happen outside of a transaction... hopefully.
323 page_latest
int unsigned
NOT NULL,
325 -- Uncompressed length in bytes of the page's current source text.
326 page_len
int unsigned
NOT NULL,
328 -- content model, see CONTENT_MODEL_XXX constants
329 page_content_model
varbinary(32) DEFAULT NULL,
331 -- Page content language
332 page_lang
varbinary(35) DEFAULT NULL
333 ) /*$wgDBTableOptions*/;
335 -- The title index. Care must be taken to always specify a namespace when
336 -- by title, so that the index is used. Even listing all known namespaces
337 -- with IN() is better than omitting page_namespace from the WHERE clause.
338 CREATE UNIQUE INDEX /*i*/name_title
ON /*_*/page (page_namespace
,page_title
);
340 -- The index for Special:Random
341 CREATE INDEX /*i*/page_random
ON /*_*/page (page_random
);
343 -- Questionable utility, used by ProofreadPage, possibly DynamicPageList.
344 -- ApiQueryAllPages unconditionally filters on namespace and so hopefully does
346 CREATE INDEX /*i*/page_len
ON /*_*/page (page_len
);
348 -- The index for Special:Shortpages and Special:Longpages. Also SiteStats::articles()
349 -- in 'comma' counting mode, MessageCache::loadFromDB().
350 CREATE INDEX /*i*/page_redirect_namespace_len
ON /*_*/page (page_is_redirect
, page_namespace
, page_len
);
353 -- Every edit of a page creates also a revision row.
354 -- This stores metadata about the revision, and a reference
355 -- to the text storage backend.
357 CREATE TABLE /*_*/revision (
358 -- Unique ID to identify each revision
359 rev_id
int unsigned
NOT NULL PRIMARY KEY AUTO_INCREMENT
,
361 -- Key to page_id. This should _never_ be invalid.
362 rev_page
int unsigned
NOT NULL,
364 -- Key to text.old_id, where the actual bulk text is stored.
365 -- It's possible for multiple revisions to use the same text,
366 -- for instance revisions where only metadata is altered
367 -- or a rollback to a previous version.
368 -- @deprecated since 1.31. If rows in the slots table with slot_revision_id = rev_id
369 -- exist, this field should be ignored (and may be 0) in favor of the
370 -- corresponding data from the slots and content tables
371 rev_text_id
int unsigned
NOT NULL default 0,
373 -- Text comment summarizing the change. Deprecated in favor of
374 -- revision_comment_temp.revcomment_comment_id.
375 rev_comment
varbinary(767) NOT NULL default '',
377 -- Key to user.user_id of the user who made this edit.
378 -- Stores 0 for anonymous edits and for some mass imports.
379 -- Deprecated in favor of revision_actor_temp.revactor_actor.
380 rev_user
int unsigned
NOT NULL default 0,
382 -- Text username or IP address of the editor.
383 -- Deprecated in favor of revision_actor_temp.revactor_actor.
384 rev_user_text
varchar(255) binary NOT NULL default '',
386 -- Timestamp of when revision was created
387 rev_timestamp
binary(14) NOT NULL default '',
389 -- Records whether the user marked the 'minor edit' checkbox.
390 -- Many automated edits are marked as minor.
391 rev_minor_edit tinyint unsigned
NOT NULL default 0,
393 -- Restrictions on who can access this revision
394 rev_deleted tinyint unsigned
NOT NULL default 0,
396 -- Length of this revision in bytes
397 rev_len
int unsigned
,
399 -- Key to revision.rev_id
400 -- This field is used to add support for a tree structure (The Adjacency List Model)
401 rev_parent_id
int unsigned
default NULL,
403 -- SHA-1 text content hash in base-36
404 rev_sha1
varbinary(32) NOT NULL default '',
406 -- content model, see CONTENT_MODEL_XXX constants
407 -- @deprecated since 1.31. If rows in the slots table with slot_revision_id = rev_id
408 -- exist, this field should be ignored (and may be NULL) in favor of the
409 -- corresponding data from the slots and content tables
410 rev_content_model
varbinary(32) DEFAULT NULL,
412 -- content format, see CONTENT_FORMAT_XXX constants
413 -- @deprecated since 1.31. If rows in the slots table with slot_revision_id = rev_id
414 -- exist, this field should be ignored (and may be NULL).
415 rev_content_format
varbinary(64) DEFAULT NULL
417 ) /*$wgDBTableOptions*/ MAX_ROWS
=10000000 AVG_ROW_LENGTH
=1024;
418 -- In case tables are created as MyISAM, use row hints for MySQL <5.0 to avoid 4GB limit
420 -- The index is proposed for removal, do not use it in new code: T163532.
421 -- Used for ordering revisions within a page by rev_id, which is usually
422 -- incorrect, since rev_timestamp is normally the correct order. It can also
423 -- be used by dumpBackup.php, if a page and rev_id range is specified.
424 CREATE INDEX /*i*/rev_page_id
ON /*_*/revision (rev_page
, rev_id
);
426 -- Used by ApiQueryAllRevisions
427 CREATE INDEX /*i*/rev_timestamp
ON /*_*/revision (rev_timestamp
);
430 CREATE INDEX /*i*/page_timestamp
ON /*_*/revision (rev_page
,rev_timestamp
);
432 -- Logged-in user contributions index
433 CREATE INDEX /*i*/user_timestamp
ON /*_*/revision (rev_user
,rev_timestamp
);
435 -- Anonymous user countributions index
436 CREATE INDEX /*i*/usertext_timestamp
ON /*_*/revision (rev_user_text
,rev_timestamp
);
438 -- Credits index. This is scanned in order to compile credits lists for pages,
439 -- in ApiQueryContributors. Also for ApiQueryRevisions if rvuser is specified
440 -- and is a logged-in user.
441 CREATE INDEX /*i*/page_user_timestamp
ON /*_*/revision (rev_page
,rev_user
,rev_timestamp
);
444 -- Temporary table to avoid blocking on an alter of revision.
446 -- On large wikis like the English Wikipedia, altering the revision table is a
447 -- months-long process. This table is being created to avoid such an alter, and
448 -- will be merged back into revision in the future.
450 CREATE TABLE /*_*/revision_comment_temp (
452 revcomment_rev
int unsigned
NOT NULL,
454 revcomment_comment_id
bigint unsigned
NOT NULL,
455 PRIMARY KEY (revcomment_rev
, revcomment_comment_id
)
456 ) /*$wgDBTableOptions*/;
458 CREATE UNIQUE INDEX /*i*/revcomment_rev
ON /*_*/revision_comment_temp (revcomment_rev
);
461 -- Temporary table to avoid blocking on an alter of revision.
463 -- On large wikis like the English Wikipedia, altering the revision table is a
464 -- months-long process. This table is being created to avoid such an alter, and
465 -- will be merged back into revision in the future.
467 CREATE TABLE /*_*/revision_actor_temp (
469 revactor_rev
int unsigned
NOT NULL,
471 revactor_actor
bigint unsigned
NOT NULL,
472 -- Copy fields from revision for indexes
473 revactor_timestamp
binary(14) NOT NULL default '',
474 revactor_page
int unsigned
NOT NULL,
475 PRIMARY KEY (revactor_rev
, revactor_actor
)
476 ) /*$wgDBTableOptions*/;
478 CREATE UNIQUE INDEX /*i*/revactor_rev
ON /*_*/revision_actor_temp (revactor_rev
);
479 -- Match future indexes on revision
480 CREATE INDEX /*i*/actor_timestamp
ON /*_*/revision_actor_temp (revactor_actor
,revactor_timestamp
);
481 CREATE INDEX /*i*/page_actor_timestamp
ON /*_*/revision_actor_temp (revactor_page
,revactor_actor
,revactor_timestamp
);
484 -- Every time an edit by a logged out user is saved,
485 -- a row is created in ip_changes. This stores
486 -- the IP as a hex representation so that we can more
487 -- easily find edits within an IP range.
489 CREATE TABLE /*_*/ip_changes (
490 -- Foreign key to the revision table, also serves as the unique primary key
491 ipc_rev_id
int unsigned
NOT NULL PRIMARY KEY DEFAULT '0',
493 -- The timestamp of the revision
494 ipc_rev_timestamp
binary(14) NOT NULL DEFAULT '',
496 -- Hex representation of the IP address, as returned by IP::toHex()
497 -- For IPv4 it will resemble: ABCD1234
498 -- For IPv6: v6-ABCD1234000000000000000000000000
499 -- BETWEEN is then used to identify revisions within a given range
500 ipc_hex
varbinary(35) NOT NULL DEFAULT ''
502 ) /*$wgDBTableOptions*/;
504 CREATE INDEX /*i*/ipc_rev_timestamp
ON /*_*/ip_changes (ipc_rev_timestamp
);
505 CREATE INDEX /*i*/ipc_hex_time
ON /*_*/ip_changes (ipc_hex
,ipc_rev_timestamp
);
508 -- Holds text of individual page revisions.
510 -- Field names are a holdover from the 'old' revisions table in
511 -- MediaWiki 1.4 and earlier: an upgrade will transform that
512 -- table into the 'text' table to minimize unnecessary churning
513 -- and downtime. If upgrading, the other fields will be left unused.
515 CREATE TABLE /*_*/text (
516 -- Unique text storage key number.
517 -- Note that the 'oldid' parameter used in URLs does *not*
518 -- refer to this number anymore, but to rev_id.
520 -- revision.rev_text_id is a key to this column
521 old_id
int unsigned
NOT NULL PRIMARY KEY AUTO_INCREMENT
,
523 -- Depending on the contents of the old_flags field, the text
524 -- may be convenient plain text, or it may be funkily encoded.
525 old_text mediumblob
NOT NULL,
527 -- Comma-separated list of flags:
528 -- gzip: text is compressed with PHP's gzdeflate() function.
529 -- utf-8: text was stored as UTF-8.
530 -- If $wgLegacyEncoding option is on, rows *without* this flag
531 -- will be converted to UTF-8 transparently at load time. Note
532 -- that due to a bug in a maintenance script, this flag may
533 -- have been stored as 'utf8' in some cases (T18841).
534 -- object: text field contained a serialized PHP object.
535 -- The object either contains multiple versions compressed
536 -- together to achieve a better compression ratio, or it refers
537 -- to another row where the text can be found.
538 -- external: text was stored in an external location specified by old_text.
539 -- Any additional flags apply to the data stored at that URL, not
540 -- the URL itself. The 'object' flag is *not* set for URLs of the
541 -- form 'DB://cluster/id/itemid', because the external storage
542 -- system itself decompresses these.
543 old_flags tinyblob
NOT NULL
544 ) /*$wgDBTableOptions*/ MAX_ROWS
=10000000 AVG_ROW_LENGTH
=10240;
545 -- In case tables are created as MyISAM, use row hints for MySQL <5.0 to avoid 4GB limit
549 -- Edits, blocks, and other actions typically have a textual comment describing
550 -- the action. They are stored here to reduce the size of the main tables, and
551 -- to allow for deduplication.
553 -- Deduplication is currently best-effort to avoid locking on inserts that
554 -- would be required for strict deduplication. There MAY be multiple rows with
555 -- the same comment_text and comment_data.
557 CREATE TABLE /*_*/comment (
558 -- Unique ID to identify each comment
559 comment_id
bigint unsigned
NOT NULL PRIMARY KEY AUTO_INCREMENT
,
561 -- Hash of comment_text and comment_data, for deduplication
562 comment_hash
INT NOT NULL,
564 -- Text comment summarizing the change.
565 -- This text is shown in the history and other changes lists,
566 -- rendered in a subset of wiki markup by Linker::formatComment()
567 -- Size limits are enforced at the application level, and should
568 -- take care to crop UTF-8 strings appropriately.
569 comment_text
BLOB NOT NULL,
571 -- JSON data, intended for localizing auto-generated comments.
572 -- This holds structured data that is intended to be used to provide
573 -- localized versions of automatically-generated comments. When not empty,
574 -- comment_text should be the generated comment localized using the wiki's
577 ) /*$wgDBTableOptions*/;
578 -- Index used for deduplication.
579 CREATE INDEX /*i*/comment_hash
ON /*_*/comment (comment_hash
);
583 -- Archive area for deleted pages and their revisions.
584 -- These may be viewed (and restored) by admins through the Special:Undelete interface.
586 CREATE TABLE /*_*/archive (
588 ar_id
int unsigned
NOT NULL PRIMARY KEY AUTO_INCREMENT
,
590 -- Copied from page_namespace
591 ar_namespace
int NOT NULL default 0,
592 -- Copied from page_title
593 ar_title
varchar(255) binary NOT NULL default '',
595 -- Basic revision stuff...
596 ar_comment_id
bigint unsigned
NOT NULL,
597 ar_actor
bigint unsigned
NOT NULL,
598 ar_timestamp
binary(14) NOT NULL default '',
599 ar_minor_edit tinyint
NOT NULL default 0,
601 -- Copied from rev_id.
603 -- @since 1.5 Entries from 1.4 will be NULL here. When restoring
604 -- archive rows from before 1.5, a new rev_id is created.
605 ar_rev_id
int unsigned
NOT NULL,
607 -- Copied from rev_text_id, references text.old_id.
608 -- To avoid breaking the block-compression scheme and otherwise making
609 -- storage changes harder, the actual text is *not* deleted from the
610 -- text storage. Instead, it is merely hidden from public view, by removal
611 -- of the page and revision entries.
613 -- @deprecated since 1.31. If rows in the slots table with slot_revision_id = ar_rev_id
614 -- exist, this field should be ignored (and may be 0) in favor of the
615 -- corresponding data from the slots and content tables
616 ar_text_id
int unsigned
NOT NULL DEFAULT 0,
618 -- Copied from rev_deleted. Although this may be raised during deletion.
619 -- Users with the "suppressrevision" right may "archive" and "suppress"
620 -- content in a single action.
622 ar_deleted tinyint unsigned
NOT NULL default 0,
624 -- Copied from rev_len, length of this revision in bytes.
628 -- Copied from page_id. Restoration will attempt to use this as page ID if
629 -- no current page with the same name exists. Otherwise, the revisions will
630 -- be restored under the current page. Can be used for manual undeletion by
631 -- developers if multiple pages by the same name were archived.
633 -- @since 1.11 Older entries will have NULL.
634 ar_page_id
int unsigned
,
636 -- Copied from rev_parent_id.
638 ar_parent_id
int unsigned
default NULL,
640 -- Copied from rev_sha1, SHA-1 text content hash in base-36
642 ar_sha1
varbinary(32) NOT NULL default '',
644 -- Copied from rev_content_model, see CONTENT_MODEL_XXX constants
646 -- @deprecated since 1.31. If rows in the slots table with slot_revision_id = ar_rev_id
647 -- exist, this field should be ignored (and may be NULL) in favor of the
648 -- corresponding data from the slots and content tables
649 ar_content_model
varbinary(32) DEFAULT NULL,
651 -- Copied from rev_content_format, see CONTENT_FORMAT_XXX constants
653 -- @deprecated since 1.31. If rows in the slots table with slot_revision_id = ar_rev_id
654 -- exist, this field should be ignored (and may be NULL).
655 ar_content_format
varbinary(64) DEFAULT NULL
656 ) /*$wgDBTableOptions*/;
658 -- Index for Special:Undelete to page through deleted revisions
659 CREATE INDEX /*i*/name_title_timestamp
ON /*_*/archive (ar_namespace
,ar_title
,ar_timestamp
);
661 -- Index for Special:DeletedContributions
662 CREATE INDEX /*i*/ar_actor_timestamp
ON /*_*/archive (ar_actor
,ar_timestamp
);
664 -- Index for linking archive rows with tables that normally link with revision
665 -- rows, such as change_tag.
666 CREATE UNIQUE INDEX /*i*/ar_revid_uniq
ON /*_*/archive (ar_rev_id
);
669 -- Slots represent an n:m relation between revisions and content objects.
670 -- A content object can have a specific "role" in one or more revisions.
671 -- Each revision can have multiple content objects, each having a different role.
673 CREATE TABLE /*_*/slots (
675 -- reference to rev_id or ar_rev_id
676 slot_revision_id
bigint unsigned
NOT NULL,
678 -- reference to role_id
679 slot_role_id
smallint unsigned
NOT NULL,
681 -- reference to content_id
682 slot_content_id
bigint unsigned
NOT NULL,
684 -- The revision ID of the revision that originated the slot's content.
685 -- To find revisions that changed slots, look for slot_origin = slot_revision_id.
686 -- TODO: Is that actually true? Rollback seems to violate it by setting
687 -- slot_origin to an older rev_id. Undeletions could result in the same situation.
688 slot_origin
bigint unsigned
NOT NULL,
690 PRIMARY KEY ( slot_revision_id
, slot_role_id
)
691 ) /*$wgDBTableOptions*/;
693 -- Index for finding revisions that modified a specific slot
694 CREATE INDEX /*i*/slot_revision_origin_role
ON /*_*/slots (slot_revision_id
, slot_origin
, slot_role_id
);
697 -- The content table represents content objects. It's primary purpose is to provide the necessary
698 -- meta-data for loading and interpreting a serialized data blob to create a content object.
700 CREATE TABLE /*_*/content (
702 -- ID of the content object
703 content_id
bigint unsigned
PRIMARY KEY AUTO_INCREMENT
,
705 -- Nominal size of the content object (not necessarily of the serialized blob)
706 content_size
int unsigned
NOT NULL,
708 -- Nominal hash of the content object (not necessarily of the serialized blob)
709 content_sha1
varbinary(32) NOT NULL,
711 -- reference to model_id. Note the content format isn't specified; it should
712 -- be assumed to be in the default format for the model unless auto-detected
714 content_model
smallint unsigned
NOT NULL,
716 -- URL-like address of the content blob
717 content_address
varbinary(255) NOT NULL
718 ) /*$wgDBTableOptions*/;
721 -- Normalization table for role names
723 CREATE TABLE /*_*/slot_roles (
724 role_id
smallint PRIMARY KEY AUTO_INCREMENT
,
725 role_name
varbinary(64) NOT NULL
726 ) /*$wgDBTableOptions*/;
728 -- Index for looking of the internal ID of for a name
729 CREATE UNIQUE INDEX /*i*/role_name
ON /*_*/slot_roles (role_name
);
732 -- Normalization table for content model names
734 CREATE TABLE /*_*/content_models (
735 model_id
smallint PRIMARY KEY AUTO_INCREMENT
,
736 model_name
varbinary(64) NOT NULL
737 ) /*$wgDBTableOptions*/;
739 -- Index for looking of the internal ID of for a name
740 CREATE UNIQUE INDEX /*i*/model_name
ON /*_*/content_models (model_name
);
743 -- Track page-to-page hyperlinks within the wiki.
745 CREATE TABLE /*_*/pagelinks (
746 -- Key to the page_id of the page containing the link.
747 pl_from
int unsigned
NOT NULL default 0,
748 -- Namespace for this page
749 pl_from_namespace
int NOT NULL default 0,
751 -- Key to page_namespace/page_title of the target page.
752 -- The target page may or may not exist, and due to renames
753 -- and deletions may refer to different page records as time
755 pl_namespace
int NOT NULL default 0,
756 pl_title
varchar(255) binary NOT NULL default '',
757 PRIMARY KEY (pl_from
,pl_namespace
,pl_title
)
758 ) /*$wgDBTableOptions*/;
760 -- Reverse index, for Special:Whatlinkshere
761 CREATE INDEX /*i*/pl_namespace
ON /*_*/pagelinks (pl_namespace
,pl_title
,pl_from
);
763 -- Index for Special:Whatlinkshere with namespace filter
764 CREATE INDEX /*i*/pl_backlinks_namespace
ON /*_*/pagelinks (pl_from_namespace
,pl_namespace
,pl_title
,pl_from
);
768 -- Track template inclusions.
770 CREATE TABLE /*_*/templatelinks (
771 -- Key to the page_id of the page containing the link.
772 tl_from
int unsigned
NOT NULL default 0,
773 -- Namespace for this page
774 tl_from_namespace
int NOT NULL default 0,
776 -- Key to page_namespace/page_title of the target page.
777 -- The target page may or may not exist, and due to renames
778 -- and deletions may refer to different page records as time
780 tl_namespace
int NOT NULL default 0,
781 tl_title
varchar(255) binary NOT NULL default '',
782 PRIMARY KEY (tl_from
,tl_namespace
,tl_title
)
783 ) /*$wgDBTableOptions*/;
785 -- Reverse index, for Special:Whatlinkshere
786 CREATE INDEX /*i*/tl_namespace
ON /*_*/templatelinks (tl_namespace
,tl_title
,tl_from
);
788 -- Index for Special:Whatlinkshere with namespace filter
789 CREATE INDEX /*i*/tl_backlinks_namespace
ON /*_*/templatelinks (tl_from_namespace
,tl_namespace
,tl_title
,tl_from
);
793 -- Track links to images *used inline*
794 -- We don't distinguish live from broken links here, so
795 -- they do not need to be changed on upload/removal.
797 CREATE TABLE /*_*/imagelinks (
798 -- Key to page_id of the page containing the image / media link.
799 il_from
int unsigned
NOT NULL default 0,
800 -- Namespace for this page
801 il_from_namespace
int NOT NULL default 0,
803 -- Filename of target image.
804 -- This is also the page_title of the file's description page;
805 -- all such pages are in namespace 6 (NS_FILE).
806 il_to
varchar(255) binary NOT NULL default '',
807 PRIMARY KEY (il_from
,il_to
)
808 ) /*$wgDBTableOptions*/;
810 -- Reverse index, for Special:Whatlinkshere and file description page local usage
811 CREATE INDEX /*i*/il_to
ON /*_*/imagelinks (il_to
,il_from
);
813 -- Index for Special:Whatlinkshere with namespace filter
814 CREATE INDEX /*i*/il_backlinks_namespace
ON /*_*/imagelinks (il_from_namespace
,il_to
,il_from
);
818 -- Track category inclusions *used inline*
819 -- This tracks a single level of category membership
821 CREATE TABLE /*_*/categorylinks (
822 -- Key to page_id of the page defined as a category member.
823 cl_from
int unsigned
NOT NULL default 0,
825 -- Name of the category.
826 -- This is also the page_title of the category's description page;
827 -- all such pages are in namespace 14 (NS_CATEGORY).
828 cl_to
varchar(255) binary NOT NULL default '',
830 -- A binary string obtained by applying a sortkey generation algorithm
831 -- (Collation::getSortKey()) to page_title, or cl_sortkey_prefix . "\n"
832 -- . page_title if cl_sortkey_prefix is nonempty.
833 cl_sortkey
varbinary(230) NOT NULL default '',
835 -- A prefix for the raw sortkey manually specified by the user, either via
836 -- [[Category:Foo|prefix]] or {{defaultsort:prefix}}. If nonempty, it's
837 -- concatenated with a line break followed by the page title before the sortkey
838 -- conversion algorithm is run. We store this so that we can update
839 -- collations without reparsing all pages.
840 -- Note: If you change the length of this field, you also need to change
841 -- code in LinksUpdate.php. See T27254.
842 cl_sortkey_prefix
varchar(255) binary NOT NULL default '',
844 -- This isn't really used at present. Provided for an optional
845 -- sorting method by approximate addition time.
846 cl_timestamp
timestamp NOT NULL,
848 -- Stores $wgCategoryCollation at the time cl_sortkey was generated. This
849 -- can be used to install new collation versions, tracking which rows are not
850 -- yet updated. '' means no collation, this is a legacy row that needs to be
851 -- updated by updateCollation.php. In the future, it might be possible to
852 -- specify different collations per category.
853 cl_collation
varbinary(32) NOT NULL default '',
855 -- Stores whether cl_from is a category, file, or other page, so we can
856 -- paginate the three categories separately. This never has to be updated
857 -- after the page is created, since none of these page types can be moved to
859 cl_type
ENUM('page', 'subcat', 'file') NOT NULL default 'page',
860 PRIMARY KEY (cl_from
,cl_to
)
861 ) /*$wgDBTableOptions*/;
864 -- We always sort within a given category, and within a given type. FIXME:
865 -- Formerly this index didn't cover cl_type (since that didn't exist), so old
866 -- callers won't be using an index: fix this?
867 CREATE INDEX /*i*/cl_sortkey
ON /*_*/categorylinks (cl_to
,cl_type
,cl_sortkey
,cl_from
);
869 -- Used by the API (and some extensions)
870 CREATE INDEX /*i*/cl_timestamp
ON /*_*/categorylinks (cl_to
,cl_timestamp
);
872 -- Used when updating collation (e.g. updateCollation.php)
873 CREATE INDEX /*i*/cl_collation_ext
ON /*_*/categorylinks (cl_collation
, cl_to
, cl_type
, cl_from
);
876 -- Track all existing categories. Something is a category if 1) it has an entry
877 -- somewhere in categorylinks, or 2) it has a description page. Categories
878 -- might not have corresponding pages, so they need to be tracked separately.
880 CREATE TABLE /*_*/category (
882 cat_id
int unsigned
NOT NULL PRIMARY KEY AUTO_INCREMENT
,
884 -- Name of the category, in the same form as page_title (with underscores).
885 -- If there is a category page corresponding to this category, by definition,
886 -- it has this name (in the Category namespace).
887 cat_title
varchar(255) binary NOT NULL,
889 -- The numbers of member pages (including categories and media), subcatego-
890 -- ries, and Image: namespace members, respectively. These are signed to
891 -- make underflow more obvious. We make the first number include the second
892 -- two for better sorting: subtracting for display is easy, adding for order-
894 cat_pages
int signed
NOT NULL default 0,
895 cat_subcats
int signed
NOT NULL default 0,
896 cat_files
int signed
NOT NULL default 0
897 ) /*$wgDBTableOptions*/;
899 CREATE UNIQUE INDEX /*i*/cat_title
ON /*_*/category (cat_title
);
901 -- For Special:Mostlinkedcategories
902 CREATE INDEX /*i*/cat_pages
ON /*_*/category (cat_pages
);
906 -- Track links to external URLs
908 CREATE TABLE /*_*/externallinks (
910 el_id
int unsigned
NOT NULL PRIMARY KEY AUTO_INCREMENT
,
912 -- page_id of the referring page
913 el_from
int unsigned
NOT NULL default 0,
918 -- In the case of HTTP URLs, this is the URL with any username or password
919 -- removed, and with the labels in the hostname reversed and converted to
920 -- lower case. An extra dot is added to allow for matching of either
921 -- example.com or *.example.com in a single scan.
923 -- http://user:password@sub.example.com/page.html
925 -- http://com.example.sub./page.html
926 -- which allows for fast searching for all pages under example.com with the
928 -- WHERE el_index LIKE 'http://com.example.%'
930 -- Note if you enable or disable PHP's intl extension, you'll need to run
931 -- maintenance/refreshExternallinksIndex.php to refresh this field.
932 el_index
blob NOT NULL,
934 -- This is el_index truncated to 60 bytes to allow for sortable queries that
935 -- aren't supported by a partial index.
936 el_index_60
varbinary(60) NOT NULL
937 ) /*$wgDBTableOptions*/;
939 -- Forward index, for page edit, save
940 CREATE INDEX /*i*/el_from
ON /*_*/externallinks (el_from
, el_to(40));
942 -- Index for Special:LinkSearch exact search
943 CREATE INDEX /*i*/el_to
ON /*_*/externallinks (el_to(60), el_from
);
945 -- For Special:LinkSearch wildcard search
946 CREATE INDEX /*i*/el_index
ON /*_*/externallinks (el_index(60));
948 -- For Special:LinkSearch wildcard search with efficient paging by el_id
949 CREATE INDEX /*i*/el_index_60
ON /*_*/externallinks (el_index_60
, el_id
);
950 CREATE INDEX /*i*/el_from_index_60
ON /*_*/externallinks (el_from
, el_index_60
, el_id
);
953 -- Track interlanguage links
955 CREATE TABLE /*_*/langlinks (
956 -- page_id of the referring page
957 ll_from
int unsigned
NOT NULL default 0,
959 -- Language code of the target
960 ll_lang
varbinary(20) NOT NULL default '',
962 -- Title of the target, including namespace
963 ll_title
varchar(255) binary NOT NULL default '',
964 PRIMARY KEY (ll_from
,ll_lang
)
965 ) /*$wgDBTableOptions*/;
967 -- Index for ApiQueryLangbacklinks
968 CREATE INDEX /*i*/ll_lang
ON /*_*/langlinks (ll_lang
, ll_title
);
972 -- Track inline interwiki links
974 CREATE TABLE /*_*/iwlinks (
975 -- page_id of the referring page
976 iwl_from
int unsigned
NOT NULL default 0,
978 -- Interwiki prefix code of the target
979 iwl_prefix
varbinary(20) NOT NULL default '',
981 -- Title of the target, including namespace
982 iwl_title
varchar(255) binary NOT NULL default '',
983 PRIMARY KEY (iwl_from
,iwl_prefix
,iwl_title
)
984 ) /*$wgDBTableOptions*/;
986 -- Index for ApiQueryIWBacklinks
987 CREATE INDEX /*i*/iwl_prefix_title_from
ON /*_*/iwlinks (iwl_prefix
, iwl_title
, iwl_from
);
989 -- Index for ApiQueryIWLinks
990 CREATE INDEX /*i*/iwl_prefix_from_title
ON /*_*/iwlinks (iwl_prefix
, iwl_from
, iwl_title
);
994 -- Contains a single row with some aggregate info
995 -- on the state of the site.
997 CREATE TABLE /*_*/site_stats (
998 -- The single row should contain 1 here.
999 ss_row_id
int unsigned
NOT NULL PRIMARY KEY,
1001 -- Total number of edits performed.
1002 ss_total_edits
bigint unsigned
default NULL,
1004 -- See SiteStatsInit::articles().
1005 ss_good_articles
bigint unsigned
default NULL,
1007 -- Total pages, theoretically equal to SELECT COUNT(*) FROM page.
1008 ss_total_pages
bigint unsigned
default NULL,
1010 -- Number of users, theoretically equal to SELECT COUNT(*) FROM user.
1011 ss_users
bigint unsigned
default NULL,
1013 -- Number of users that still edit.
1014 ss_active_users
bigint unsigned
default NULL,
1016 -- Number of images, equivalent to SELECT COUNT(*) FROM image.
1017 ss_images
bigint unsigned
default NULL
1018 ) /*$wgDBTableOptions*/;
1021 -- The internet is full of jerks, alas. Sometimes it's handy
1022 -- to block a vandal or troll account.
1024 CREATE TABLE /*_*/ipblocks (
1025 -- Primary key, introduced for privacy.
1026 ipb_id
int NOT NULL PRIMARY KEY AUTO_INCREMENT
,
1028 -- Blocked IP address in dotted-quad form or user name.
1029 ipb_address tinyblob
NOT NULL,
1031 -- Blocked user ID or 0 for IP blocks.
1032 ipb_user
int unsigned
NOT NULL default 0,
1034 -- Actor who made the block.
1035 ipb_by_actor
bigint unsigned
NOT NULL,
1037 -- Key to comment_id. Text comment made by blocker.
1038 ipb_reason_id
bigint unsigned
NOT NULL,
1040 -- Creation (or refresh) date in standard YMDHMS form.
1041 -- IP blocks expire automatically.
1042 ipb_timestamp
binary(14) NOT NULL default '',
1044 -- Indicates that the IP address was banned because a banned
1045 -- user accessed a page through it. If this is 1, ipb_address
1046 -- will be hidden, and the block identified by block ID number.
1047 ipb_auto bool
NOT NULL default 0,
1049 -- If set to 1, block applies only to logged-out users
1050 ipb_anon_only bool
NOT NULL default 0,
1052 -- Block prevents account creation from matching IP addresses
1053 ipb_create_account bool
NOT NULL default 1,
1055 -- Block triggers autoblocks
1056 ipb_enable_autoblock bool
NOT NULL default '1',
1058 -- Time at which the block will expire.
1059 -- May be "infinity"
1060 ipb_expiry
varbinary(14) NOT NULL default '',
1062 -- Start and end of an address range, in hexadecimal
1063 -- Size chosen to allow IPv6
1064 -- FIXME: these fields were originally blank for single-IP blocks,
1065 -- but now they are populated. No migration was ever done. They
1066 -- should be fixed to be blank again for such blocks (T51504).
1067 ipb_range_start tinyblob
NOT NULL,
1068 ipb_range_end tinyblob
NOT NULL,
1070 -- Flag for entries hidden from users and Sysops
1071 ipb_deleted bool
NOT NULL default 0,
1073 -- Block prevents user from accessing Special:Emailuser
1074 ipb_block_email bool
NOT NULL default 0,
1076 -- Block allows user to edit their own talk page
1077 ipb_allow_usertalk bool
NOT NULL default 0,
1079 -- ID of the block that caused this block to exist
1080 -- Autoblocks set this to the original block
1081 -- so that the original block being deleted also
1082 -- deletes the autoblocks
1083 ipb_parent_block_id
int default NULL,
1085 -- Block user from editing any page on the site (other than their own user
1087 ipb_sitewide bool
NOT NULL default 1
1089 ) /*$wgDBTableOptions*/;
1091 -- Unique index to support "user already blocked" messages
1092 -- Any new options which prevent collisions should be included
1093 CREATE UNIQUE INDEX /*i*/ipb_address
ON /*_*/ipblocks (ipb_address(255), ipb_user
, ipb_auto
, ipb_anon_only
);
1095 -- For querying whether a logged-in user is blocked
1096 CREATE INDEX /*i*/ipb_user
ON /*_*/ipblocks (ipb_user
);
1098 -- For querying whether an IP address is in any range
1099 CREATE INDEX /*i*/ipb_range
ON /*_*/ipblocks (ipb_range_start(8), ipb_range_end(8));
1101 -- Index for Special:BlockList
1102 CREATE INDEX /*i*/ipb_timestamp
ON /*_*/ipblocks (ipb_timestamp
);
1104 -- Index for table pruning
1105 CREATE INDEX /*i*/ipb_expiry
ON /*_*/ipblocks (ipb_expiry
);
1107 -- Index for removing autoblocks when a parent block is removed
1108 CREATE INDEX /*i*/ipb_parent_block_id
ON /*_*/ipblocks (ipb_parent_block_id
);
1111 -- Partial Block Restrictions
1113 CREATE TABLE /*_*/ipblocks_restrictions (
1115 -- The ipb_id from ipblocks
1116 ir_ipb_id
int NOT NULL,
1118 -- The restriction type id.
1119 ir_type
tinyint(1) NOT NULL,
1121 -- The restriction id that corrposponds to the type. Typically a Page ID or a
1123 ir_value
int NOT NULL,
1125 PRIMARY KEY (ir_ipb_id
, ir_type
, ir_value
)
1126 ) /*$wgDBTableOptions*/;
1128 -- Index to query restrictions by the page or namespace.
1129 CREATE INDEX /*i*/ir_type_value
ON /*_*/ipblocks_restrictions (ir_type
, ir_value
);
1132 -- Uploaded images and other files.
1134 CREATE TABLE /*_*/image (
1136 -- This is also the title of the associated description page,
1137 -- which will be in namespace 6 (NS_FILE).
1138 img_name
varchar(255) binary NOT NULL default '' PRIMARY KEY,
1140 -- File size in bytes.
1141 img_size
int unsigned
NOT NULL default 0,
1143 -- For images, size in pixels.
1144 img_width
int NOT NULL default 0,
1145 img_height
int NOT NULL default 0,
1147 -- Extracted Exif metadata stored as a serialized PHP array.
1148 img_metadata mediumblob
NOT NULL,
1150 -- For images, bits per pixel if known.
1151 img_bits
int NOT NULL default 0,
1153 -- Media type as defined by the MEDIATYPE_xxx constants
1154 img_media_type
ENUM("UNKNOWN", "BITMAP", "DRAWING", "AUDIO", "VIDEO", "MULTIMEDIA", "OFFICE", "TEXT", "EXECUTABLE", "ARCHIVE", "3D") default NULL,
1156 -- major part of a MIME media type as defined by IANA
1157 -- see https://www.iana.org/assignments/media-types/
1158 -- for "chemical" cf. http://dx.doi.org/10.1021/ci9803233 by the ACS
1159 img_major_mime
ENUM("unknown", "application", "audio", "image", "text", "video", "message", "model", "multipart", "chemical") NOT NULL default "unknown",
1161 -- minor part of a MIME media type as defined by IANA
1162 -- the minor parts are not required to adher to any standard
1163 -- but should be consistent throughout the database
1164 -- see https://www.iana.org/assignments/media-types/
1165 img_minor_mime
varbinary(100) NOT NULL default "unknown",
1167 -- Foreign key to comment table, which contains the description field as entered by the uploader.
1168 -- This is displayed in image upload history and logs.
1169 img_description_id
bigint unsigned
NOT NULL,
1171 -- actor_id of the uploader.
1172 img_actor
bigint unsigned
NOT NULL,
1174 -- Time of the upload.
1175 img_timestamp
varbinary(14) NOT NULL default '',
1177 -- SHA-1 content hash in base-36
1178 img_sha1
varbinary(32) NOT NULL default ''
1179 ) /*$wgDBTableOptions*/;
1181 -- Used by Special:Newimages and ApiQueryAllImages
1182 CREATE INDEX /*i*/img_actor_timestamp
ON /*_*/image (img_actor
,img_timestamp
);
1183 -- Used by Special:ListFiles for sort-by-size
1184 CREATE INDEX /*i*/img_size
ON /*_*/image (img_size
);
1185 -- Used by Special:Newimages and Special:ListFiles
1186 CREATE INDEX /*i*/img_timestamp
ON /*_*/image (img_timestamp
);
1187 -- Used in API and duplicate search
1188 CREATE INDEX /*i*/img_sha1
ON /*_*/image (img_sha1(10));
1189 -- Used to get media of one type
1190 CREATE INDEX /*i*/img_media_mime
ON /*_*/image (img_media_type
,img_major_mime
,img_minor_mime
);
1194 -- Previous revisions of uploaded files.
1195 -- Awkwardly, image rows have to be moved into
1196 -- this table at re-upload time.
1198 CREATE TABLE /*_*/oldimage (
1199 -- Base filename: key to image.img_name
1200 oi_name
varchar(255) binary NOT NULL default '',
1202 -- Filename of the archived file.
1203 -- This is generally a timestamp and '!' prepended to the base name.
1204 oi_archive_name
varchar(255) binary NOT NULL default '',
1206 -- Other fields as in image...
1207 oi_size
int unsigned
NOT NULL default 0,
1208 oi_width
int NOT NULL default 0,
1209 oi_height
int NOT NULL default 0,
1210 oi_bits
int NOT NULL default 0,
1211 oi_description_id
bigint unsigned
NOT NULL,
1212 oi_actor
bigint unsigned
NOT NULL,
1213 oi_timestamp
binary(14) NOT NULL default '',
1215 oi_metadata mediumblob
NOT NULL,
1216 oi_media_type
ENUM("UNKNOWN", "BITMAP", "DRAWING", "AUDIO", "VIDEO", "MULTIMEDIA", "OFFICE", "TEXT", "EXECUTABLE", "ARCHIVE", "3D") default NULL,
1217 oi_major_mime
ENUM("unknown", "application", "audio", "image", "text", "video", "message", "model", "multipart", "chemical") NOT NULL default "unknown",
1218 oi_minor_mime
varbinary(100) NOT NULL default "unknown",
1219 oi_deleted tinyint unsigned
NOT NULL default 0,
1220 oi_sha1
varbinary(32) NOT NULL default ''
1221 ) /*$wgDBTableOptions*/;
1223 CREATE INDEX /*i*/oi_actor_timestamp
ON /*_*/oldimage (oi_actor
,oi_timestamp
);
1224 CREATE INDEX /*i*/oi_name_timestamp
ON /*_*/oldimage (oi_name
,oi_timestamp
);
1225 -- oi_archive_name truncated to 14 to avoid key length overflow
1226 CREATE INDEX /*i*/oi_name_archive_name
ON /*_*/oldimage (oi_name
,oi_archive_name(14));
1227 CREATE INDEX /*i*/oi_sha1
ON /*_*/oldimage (oi_sha1(10));
1231 -- Record of deleted file data
1233 CREATE TABLE /*_*/filearchive (
1235 fa_id
int NOT NULL PRIMARY KEY AUTO_INCREMENT
,
1237 -- Original base filename; key to image.img_name, page.page_title, etc
1238 fa_name
varchar(255) binary NOT NULL default '',
1240 -- Filename of archived file, if an old revision
1241 fa_archive_name
varchar(255) binary default '',
1243 -- Which storage bin (directory tree or object store) the file data
1244 -- is stored in. Should be 'deleted' for files that have been deleted;
1245 -- any other bin is not yet in use.
1246 fa_storage_group
varbinary(16),
1248 -- SHA-1 of the file contents plus extension, used as a key for storage.
1249 -- eg 8f8a562add37052a1848ff7771a2c515db94baa9.jpg
1251 -- If NULL, the file was missing at deletion time or has been purged
1252 -- from the archival storage.
1253 fa_storage_key
varbinary(64) default '',
1255 -- Deletion information, if this file is deleted.
1256 fa_deleted_user
int,
1257 fa_deleted_timestamp
binary(14) default '',
1258 fa_deleted_reason_id
bigint unsigned
NOT NULL,
1260 -- Duped fields from image
1261 fa_size
int unsigned
default 0,
1262 fa_width
int default 0,
1263 fa_height
int default 0,
1264 fa_metadata mediumblob
,
1265 fa_bits
int default 0,
1266 fa_media_type
ENUM("UNKNOWN", "BITMAP", "DRAWING", "AUDIO", "VIDEO", "MULTIMEDIA", "OFFICE", "TEXT", "EXECUTABLE", "ARCHIVE", "3D") default NULL,
1267 fa_major_mime
ENUM("unknown", "application", "audio", "image", "text", "video", "message", "model", "multipart", "chemical") default "unknown",
1268 fa_minor_mime
varbinary(100) default "unknown",
1269 fa_description_id
bigint unsigned
NOT NULL,
1270 fa_actor
bigint unsigned
NOT NULL,
1271 fa_timestamp
binary(14) default '',
1273 -- Visibility of deleted revisions, bitfield
1274 fa_deleted tinyint unsigned
NOT NULL default 0,
1276 -- sha1 hash of file content
1277 fa_sha1
varbinary(32) NOT NULL default ''
1278 ) /*$wgDBTableOptions*/;
1280 -- pick out by image name
1281 CREATE INDEX /*i*/fa_name
ON /*_*/filearchive (fa_name
, fa_timestamp
);
1282 -- pick out dupe files
1283 CREATE INDEX /*i*/fa_storage_group
ON /*_*/filearchive (fa_storage_group
, fa_storage_key
);
1284 -- sort by deletion time
1285 CREATE INDEX /*i*/fa_deleted_timestamp
ON /*_*/filearchive (fa_deleted_timestamp
);
1287 CREATE INDEX /*i*/fa_actor_timestamp
ON /*_*/filearchive (fa_actor
,fa_timestamp
);
1288 -- find file by sha1, 10 bytes will be enough for hashes to be indexed
1289 CREATE INDEX /*i*/fa_sha1
ON /*_*/filearchive (fa_sha1(10));
1293 -- Store information about newly uploaded files before they're
1294 -- moved into the actual filestore
1296 CREATE TABLE /*_*/uploadstash (
1297 us_id
int unsigned
NOT NULL PRIMARY KEY AUTO_INCREMENT
,
1299 -- the user who uploaded the file.
1300 us_user
int unsigned
NOT NULL,
1302 -- file key. this is how applications actually search for the file.
1303 -- this might go away, or become the primary key.
1304 us_key
varchar(255) NOT NULL,
1306 -- the original path
1307 us_orig_path
varchar(255) NOT NULL,
1309 -- the temporary path at which the file is actually stored
1310 us_path
varchar(255) NOT NULL,
1312 -- which type of upload the file came from (sometimes)
1313 us_source_type
varchar(50),
1315 -- the date/time on which the file was added
1316 us_timestamp
varbinary(14) NOT NULL,
1318 us_status
varchar(50) NOT NULL,
1320 -- chunk counter starts at 0, current offset is stored in us_size
1321 us_chunk_inx
int unsigned
NULL,
1323 -- Serialized file properties from FSFile::getProps()
1326 -- file size in bytes
1327 us_size
int unsigned
NOT NULL,
1328 -- this hash comes from FSFile::getSha1Base36(), and is 31 characters
1329 us_sha1
varchar(31) NOT NULL,
1330 us_mime
varchar(255),
1331 -- Media type as defined by the MEDIATYPE_xxx constants, should duplicate definition in the image table
1332 us_media_type
ENUM("UNKNOWN", "BITMAP", "DRAWING", "AUDIO", "VIDEO", "MULTIMEDIA", "OFFICE", "TEXT", "EXECUTABLE", "ARCHIVE", "3D") default NULL,
1333 -- image-specific properties
1334 us_image_width
int unsigned
,
1335 us_image_height
int unsigned
,
1336 us_image_bits
smallint unsigned
1338 ) /*$wgDBTableOptions*/;
1340 -- sometimes there's a delete for all of a user's stuff.
1341 CREATE INDEX /*i*/us_user
ON /*_*/uploadstash (us_user
);
1342 -- pick out files by key, enforce key uniqueness
1343 CREATE UNIQUE INDEX /*i*/us_key
ON /*_*/uploadstash (us_key
);
1344 -- the abandoned upload cleanup script needs this
1345 CREATE INDEX /*i*/us_timestamp
ON /*_*/uploadstash (us_timestamp
);
1349 -- Primarily a summary table for Special:Recentchanges,
1350 -- this table contains some additional info on edits from
1351 -- the last few days, see Article::editUpdates()
1353 CREATE TABLE /*_*/recentchanges (
1354 rc_id
int NOT NULL PRIMARY KEY AUTO_INCREMENT
,
1355 rc_timestamp
varbinary(14) NOT NULL default '',
1358 rc_actor
bigint unsigned
NOT NULL,
1360 -- When pages are renamed, their RC entries do _not_ change.
1361 rc_namespace
int NOT NULL default 0,
1362 rc_title
varchar(255) binary NOT NULL default '',
1364 -- as in revision...
1365 rc_comment_id
bigint unsigned
NOT NULL,
1366 rc_minor tinyint unsigned
NOT NULL default 0,
1368 -- Edits by user accounts with the 'bot' rights key are
1369 -- marked with a 1 here, and will be hidden from the
1371 rc_bot tinyint unsigned
NOT NULL default 0,
1373 -- Set if this change corresponds to a page creation
1374 rc_new tinyint unsigned
NOT NULL default 0,
1376 -- Key to page_id (was cur_id prior to 1.5).
1377 -- This will keep links working after moves while
1378 -- retaining the at-the-time name in the changes list.
1379 rc_cur_id
int unsigned
NOT NULL default 0,
1381 -- rev_id of the given revision
1382 rc_this_oldid
int unsigned
NOT NULL default 0,
1384 -- rev_id of the prior revision, for generating diff links.
1385 rc_last_oldid
int unsigned
NOT NULL default 0,
1387 -- The type of change entry (RC_EDIT,RC_NEW,RC_LOG,RC_EXTERNAL)
1388 rc_type tinyint unsigned
NOT NULL default 0,
1390 -- The source of the change entry (replaces rc_type)
1391 -- default of '' is temporary, needed for initial migration
1392 rc_source
varchar(16) binary not null default '',
1394 -- If the Recent Changes Patrol option is enabled,
1395 -- users may mark edits as having been reviewed to
1396 -- remove a warning flag on the RC list.
1397 -- A value of 1 indicates the page has been reviewed.
1398 rc_patrolled tinyint unsigned
NOT NULL default 0,
1400 -- Recorded IP address the edit was made from, if the
1401 -- $wgPutIPinRC option is enabled.
1402 rc_ip
varbinary(40) NOT NULL default '',
1404 -- Text length in characters before
1405 -- and after the edit
1409 -- Visibility of recent changes items, bitfield
1410 rc_deleted tinyint unsigned
NOT NULL default 0,
1412 -- Value corresponding to log_id, specific log entries
1413 rc_logid
int unsigned
NOT NULL default 0,
1414 -- Store log type info here, or null
1415 rc_log_type
varbinary(255) NULL default NULL,
1416 -- Store log action or null
1417 rc_log_action
varbinary(255) NULL default NULL,
1420 ) /*$wgDBTableOptions*/;
1422 -- Special:Recentchanges
1423 CREATE INDEX /*i*/rc_timestamp
ON /*_*/recentchanges (rc_timestamp
);
1425 -- Special:Watchlist
1426 CREATE INDEX /*i*/rc_namespace_title_timestamp
ON /*_*/recentchanges (rc_namespace
, rc_title
, rc_timestamp
);
1428 -- Special:Recentchangeslinked when finding changes in pages linked from a page
1429 CREATE INDEX /*i*/rc_cur_id
ON /*_*/recentchanges (rc_cur_id
);
1432 CREATE INDEX /*i*/new_name_timestamp
ON /*_*/recentchanges (rc_new
,rc_namespace
,rc_timestamp
);
1434 -- Blank unless $wgPutIPinRC=true (false at WMF), possibly used by extensions,
1435 -- but mostly replaced by CheckUser.
1436 CREATE INDEX /*i*/rc_ip
ON /*_*/recentchanges (rc_ip
);
1438 -- Probably intended for Special:NewPages namespace filter
1439 CREATE INDEX /*i*/rc_ns_actor
ON /*_*/recentchanges (rc_namespace
, rc_actor
);
1441 -- SiteStats active user count, Special:ActiveUsers, Special:NewPages user filter
1442 CREATE INDEX /*i*/rc_actor
ON /*_*/recentchanges (rc_actor
, rc_timestamp
);
1444 -- ApiQueryRecentChanges (T140108)
1445 CREATE INDEX /*i*/rc_name_type_patrolled_timestamp
ON /*_*/recentchanges (rc_namespace
, rc_type
, rc_patrolled
, rc_timestamp
);
1447 -- Article.php and friends (T139012)
1448 CREATE INDEX /*i*/rc_this_oldid
ON /*_*/recentchanges (rc_this_oldid
);
1450 CREATE TABLE /*_*/watchlist (
1451 wl_id
int unsigned
NOT NULL PRIMARY KEY AUTO_INCREMENT
,
1452 -- Key to user.user_id
1453 wl_user
int unsigned
NOT NULL,
1455 -- Key to page_namespace/page_title
1456 -- Note that users may watch pages which do not exist yet,
1457 -- or existed in the past but have been deleted.
1458 wl_namespace
int NOT NULL default 0,
1459 wl_title
varchar(255) binary NOT NULL default '',
1461 -- Timestamp used to send notification e-mails and show "updated since last visit" markers on
1462 -- history and recent changes / watchlist. Set to NULL when the user visits the latest revision
1463 -- of the page, which means that they should be sent an e-mail on the next change.
1464 wl_notificationtimestamp
varbinary(14)
1466 ) /*$wgDBTableOptions*/;
1468 -- Special:Watchlist
1469 CREATE UNIQUE INDEX /*i*/wl_user
ON /*_*/watchlist (wl_user
, wl_namespace
, wl_title
);
1471 -- Special:Movepage (WatchedItemStore::duplicateEntry)
1472 CREATE INDEX /*i*/namespace_title
ON /*_*/watchlist (wl_namespace
, wl_title
);
1474 -- ApiQueryWatchlistRaw changed filter
1475 CREATE INDEX /*i*/wl_user_notificationtimestamp
ON /*_*/watchlist (wl_user
, wl_notificationtimestamp
);
1479 -- When using the default MySQL search backend, page titles
1480 -- and text are munged to strip markup, do Unicode case folding,
1481 -- and prepare the result for MySQL's fulltext index.
1483 -- This table must be MyISAM; InnoDB does not support the needed
1486 CREATE TABLE /*_*/searchindex (
1488 si_page
int unsigned
NOT NULL,
1490 -- Munged version of title
1491 si_title
varchar(255) NOT NULL default '',
1493 -- Munged version of body text
1494 si_text mediumtext
NOT NULL
1495 ) ENGINE
=MyISAM
DEFAULT CHARSET
=utf8
;
1497 CREATE UNIQUE INDEX /*i*/si_page
ON /*_*/searchindex (si_page
);
1498 CREATE FULLTEXT
INDEX /*i*/si_title
ON /*_*/searchindex (si_title
);
1499 CREATE FULLTEXT
INDEX /*i*/si_text
ON /*_*/searchindex (si_text
);
1503 -- Recognized interwiki link prefixes
1505 CREATE TABLE /*_*/interwiki (
1506 -- The interwiki prefix, (e.g. "Meatball", or the language prefix "de")
1507 iw_prefix
varchar(32) NOT NULL PRIMARY KEY,
1509 -- The URL of the wiki, with "$1" as a placeholder for an article name.
1510 -- Any spaces in the name will be transformed to underscores before
1512 iw_url
blob NOT NULL,
1514 -- The URL of the file api.php
1515 iw_api
blob NOT NULL,
1517 -- The name of the database (for a connection to be established with LBFactory::getMainLB( 'wikiid' ))
1518 iw_wikiid
varchar(64) NOT NULL,
1520 -- A boolean value indicating whether the wiki is in this project
1521 -- (used, for example, to detect redirect loops)
1522 iw_local bool
NOT NULL,
1524 -- Boolean value indicating whether interwiki transclusions are allowed.
1525 iw_trans tinyint
NOT NULL default 0
1526 ) /*$wgDBTableOptions*/;
1530 -- Used for caching expensive grouped queries
1532 CREATE TABLE /*_*/querycache (
1533 -- A key name, generally the base name of of the special page.
1534 qc_type
varbinary(32) NOT NULL,
1536 -- Some sort of stored value. Sizes, counts...
1537 qc_value
int unsigned
NOT NULL default 0,
1539 -- Target namespace+title
1540 qc_namespace
int NOT NULL default 0,
1541 qc_title
varchar(255) binary NOT NULL default ''
1542 ) /*$wgDBTableOptions*/;
1544 CREATE INDEX /*i*/qc_type
ON /*_*/querycache (qc_type
,qc_value
);
1548 -- For a few generic cache operations if not using Memcached
1550 CREATE TABLE /*_*/objectcache (
1551 keyname
varbinary(255) NOT NULL default '' PRIMARY KEY,
1554 ) /*$wgDBTableOptions*/;
1555 CREATE INDEX /*i*/exptime
ON /*_*/objectcache (exptime
);
1558 CREATE TABLE /*_*/logging (
1559 -- Log ID, for referring to this specific log entry, probably for deletion and such.
1560 log_id
int unsigned
NOT NULL PRIMARY KEY AUTO_INCREMENT
,
1562 -- Symbolic keys for the general log type and the action type
1563 -- within the log. The output format will be controlled by the
1564 -- action field, but only the type controls categorization.
1565 log_type
varbinary(32) NOT NULL default '',
1566 log_action
varbinary(32) NOT NULL default '',
1569 log_timestamp
binary(14) NOT NULL default '19700101000000',
1571 -- The actor who performed this action
1572 log_actor
bigint unsigned
NOT NULL,
1574 -- Key to the page affected. Where a user is the target,
1575 -- this will point to the user page.
1576 log_namespace
int NOT NULL default 0,
1577 log_title
varchar(255) binary NOT NULL default '',
1578 log_page
int unsigned
NULL,
1580 -- Key to comment_id. Comment summarizing the change.
1581 log_comment_id
bigint unsigned
NOT NULL,
1583 -- miscellaneous parameters:
1584 -- LF separated list (old system) or serialized PHP array (new system)
1585 log_params
blob NOT NULL,
1587 -- rev_deleted for logs
1588 log_deleted tinyint unsigned
NOT NULL default 0
1589 ) /*$wgDBTableOptions*/;
1591 -- Special:Log type filter
1592 CREATE INDEX /*i*/type_time
ON /*_*/logging (log_type
, log_timestamp
);
1594 -- Special:Log performer filter
1595 CREATE INDEX /*i*/actor_time
ON /*_*/logging (log_actor
, log_timestamp
);
1597 -- Special:Log title filter, log extract
1598 CREATE INDEX /*i*/page_time
ON /*_*/logging (log_namespace
, log_title
, log_timestamp
);
1600 -- Special:Log unfiltered
1601 CREATE INDEX /*i*/times
ON /*_*/logging (log_timestamp
);
1603 -- Special:Log filter by performer and type
1604 CREATE INDEX /*i*/log_actor_type_time
ON /*_*/logging (log_actor
, log_type
, log_timestamp
);
1606 -- Apparently just used for a few maintenance pages (findMissingFiles.php, Flow).
1607 -- Could be removed?
1608 CREATE INDEX /*i*/log_page_id_time
ON /*_*/logging (log_page
,log_timestamp
);
1610 -- Special:Log action filter
1611 CREATE INDEX /*i*/log_type_action
ON /*_*/logging (log_type
, log_action
, log_timestamp
);
1614 CREATE TABLE /*_*/log_search (
1615 -- The type of ID (rev ID, log ID, rev timestamp, username)
1616 ls_field
varbinary(32) NOT NULL,
1617 -- The value of the ID
1618 ls_value
varchar(255) NOT NULL,
1620 ls_log_id
int unsigned
NOT NULL default 0,
1621 PRIMARY KEY (ls_field
,ls_value
,ls_log_id
)
1622 ) /*$wgDBTableOptions*/;
1623 CREATE INDEX /*i*/ls_log_id
ON /*_*/log_search (ls_log_id
);
1626 -- Jobs performed by parallel apache threads or a command-line daemon
1627 CREATE TABLE /*_*/job (
1628 job_id
int unsigned
NOT NULL PRIMARY KEY AUTO_INCREMENT
,
1631 -- Limited to 60 to prevent key length overflow
1632 job_cmd
varbinary(60) NOT NULL default '',
1634 -- Namespace and title to act on
1635 -- Should be 0 and '' if the command does not operate on a title
1636 job_namespace
int NOT NULL,
1637 job_title
varchar(255) binary NOT NULL,
1639 -- Timestamp of when the job was inserted
1640 -- NULL for jobs added before addition of the timestamp
1641 job_timestamp
varbinary(14) NULL default NULL,
1643 -- Any other parameters to the command
1644 -- Stored as a PHP serialized array, or an empty string if there are no parameters
1645 job_params mediumblob
NOT NULL,
1647 -- Random, non-unique, number used for job acquisition (for lock concurrency)
1648 job_random
integer unsigned
NOT NULL default 0,
1650 -- The number of times this job has been locked
1651 job_attempts
integer unsigned
NOT NULL default 0,
1653 -- Field that conveys process locks on rows via process UUIDs
1654 job_token
varbinary(32) NOT NULL default '',
1656 -- Timestamp when the job was locked
1657 job_token_timestamp
varbinary(14) NULL default NULL,
1659 -- Base 36 SHA1 of the job parameters relevant to detecting duplicates
1660 job_sha1
varbinary(32) NOT NULL default ''
1661 ) /*$wgDBTableOptions*/;
1663 CREATE INDEX /*i*/job_sha1
ON /*_*/job (job_sha1
);
1664 CREATE INDEX /*i*/job_cmd_token
ON /*_*/job (job_cmd
,job_token
,job_random
);
1665 CREATE INDEX /*i*/job_cmd_token_id
ON /*_*/job (job_cmd
,job_token
,job_id
);
1666 CREATE INDEX /*i*/job_cmd
ON /*_*/job (job_cmd
, job_namespace
, job_title
, job_params(128));
1667 CREATE INDEX /*i*/job_timestamp
ON /*_*/job (job_timestamp
);
1670 -- Details of updates to cached special pages
1671 CREATE TABLE /*_*/querycache_info (
1672 -- Special page name
1673 -- Corresponds to a qc_type value
1674 qci_type
varbinary(32) NOT NULL default '' PRIMARY KEY,
1676 -- Timestamp of last update
1677 qci_timestamp
binary(14) NOT NULL default '19700101000000'
1678 ) /*$wgDBTableOptions*/;
1681 -- For each redirect, this table contains exactly one row defining its target
1682 CREATE TABLE /*_*/redirect (
1683 -- Key to the page_id of the redirect page
1684 rd_from
int unsigned
NOT NULL default 0 PRIMARY KEY,
1686 -- Key to page_namespace/page_title of the target page.
1687 -- The target page may or may not exist, and due to renames
1688 -- and deletions may refer to different page records as time
1690 rd_namespace
int NOT NULL default 0,
1691 rd_title
varchar(255) binary NOT NULL default '',
1692 rd_interwiki
varchar(32) default NULL,
1693 rd_fragment
varchar(255) binary default NULL
1694 ) /*$wgDBTableOptions*/;
1696 CREATE INDEX /*i*/rd_ns_title
ON /*_*/redirect (rd_namespace
,rd_title
,rd_from
);
1699 -- Used for caching expensive grouped queries that need two links (for example double-redirects)
1700 CREATE TABLE /*_*/querycachetwo (
1701 -- A key name, generally the base name of of the special page.
1702 qcc_type
varbinary(32) NOT NULL,
1704 -- Some sort of stored value. Sizes, counts...
1705 qcc_value
int unsigned
NOT NULL default 0,
1707 -- Target namespace+title
1708 qcc_namespace
int NOT NULL default 0,
1709 qcc_title
varchar(255) binary NOT NULL default '',
1711 -- Target namespace+title2
1712 qcc_namespacetwo
int NOT NULL default 0,
1713 qcc_titletwo
varchar(255) binary NOT NULL default ''
1714 ) /*$wgDBTableOptions*/;
1716 CREATE INDEX /*i*/qcc_type
ON /*_*/querycachetwo (qcc_type
,qcc_value
);
1717 CREATE INDEX /*i*/qcc_title
ON /*_*/querycachetwo (qcc_type
,qcc_namespace
,qcc_title
);
1718 CREATE INDEX /*i*/qcc_titletwo
ON /*_*/querycachetwo (qcc_type
,qcc_namespacetwo
,qcc_titletwo
);
1721 -- Used for storing page restrictions (i.e. protection levels)
1722 CREATE TABLE /*_*/page_restrictions (
1723 -- Field for an ID for this restrictions row (sort-key for Special:ProtectedPages)
1724 pr_id
int unsigned
NOT NULL PRIMARY KEY AUTO_INCREMENT
,
1725 -- Page to apply restrictions to (Foreign Key to page).
1726 pr_page
int NOT NULL,
1727 -- The protection type (edit, move, etc)
1728 pr_type
varbinary(60) NOT NULL,
1729 -- The protection level (Sysop, autoconfirmed, etc)
1730 pr_level
varbinary(60) NOT NULL,
1731 -- Whether or not to cascade the protection down to pages transcluded.
1732 pr_cascade tinyint
NOT NULL,
1733 -- Field for future support of per-user restriction.
1734 pr_user
int unsigned
NULL,
1735 -- Field for time-limited protection.
1736 pr_expiry
varbinary(14) NULL
1737 ) /*$wgDBTableOptions*/;
1739 CREATE UNIQUE INDEX /*i*/pr_pagetype
ON /*_*/page_restrictions (pr_page
,pr_type
);
1740 CREATE INDEX /*i*/pr_typelevel
ON /*_*/page_restrictions (pr_type
,pr_level
);
1741 CREATE INDEX /*i*/pr_level
ON /*_*/page_restrictions (pr_level
);
1742 CREATE INDEX /*i*/pr_cascade
ON /*_*/page_restrictions (pr_cascade
);
1745 -- Protected titles - nonexistent pages that have been protected
1746 CREATE TABLE /*_*/protected_titles (
1747 pt_namespace
int NOT NULL,
1748 pt_title
varchar(255) binary NOT NULL,
1749 pt_user
int unsigned
NOT NULL,
1750 pt_reason_id
bigint unsigned
NOT NULL,
1751 pt_timestamp
binary(14) NOT NULL,
1752 pt_expiry
varbinary(14) NOT NULL default '',
1753 pt_create_perm
varbinary(60) NOT NULL,
1755 PRIMARY KEY (pt_namespace
,pt_title
)
1756 ) /*$wgDBTableOptions*/;
1758 CREATE INDEX /*i*/pt_timestamp
ON /*_*/protected_titles (pt_timestamp
);
1761 -- Name/value pairs indexed by page_id
1762 CREATE TABLE /*_*/page_props (
1763 pp_page
int NOT NULL,
1764 pp_propname
varbinary(60) NOT NULL,
1765 pp_value
blob NOT NULL,
1766 pp_sortkey
float DEFAULT NULL,
1768 PRIMARY KEY (pp_page
,pp_propname
)
1769 ) /*$wgDBTableOptions*/;
1771 CREATE UNIQUE INDEX /*i*/pp_propname_page
ON /*_*/page_props (pp_propname
,pp_page
);
1772 CREATE UNIQUE INDEX /*i*/pp_propname_sortkey_page
ON /*_*/page_props (pp_propname
,pp_sortkey
,pp_page
);
1774 -- A table to log updates, one text key row per update.
1775 CREATE TABLE /*_*/updatelog (
1776 ul_key
varchar(255) NOT NULL PRIMARY KEY,
1778 ) /*$wgDBTableOptions*/;
1781 -- A table to track tags for revisions, logs and recent changes.
1782 CREATE TABLE /*_*/change_tag (
1783 ct_id
int unsigned
NOT NULL PRIMARY KEY AUTO_INCREMENT
,
1784 -- RCID for the change
1786 -- LOGID for the change
1787 ct_log_id
int unsigned
NULL,
1788 -- REVID for the change
1789 ct_rev_id
int unsigned
NULL,
1790 -- Parameters for the tag; used by some extensions
1791 ct_params
blob NULL,
1792 -- Foreign key to change_tag_def row
1793 ct_tag_id
int unsigned
NOT NULL
1794 ) /*$wgDBTableOptions*/;
1797 CREATE UNIQUE INDEX /*i*/change_tag_rc_tag_id
ON /*_*/change_tag (ct_rc_id
,ct_tag_id
);
1798 CREATE UNIQUE INDEX /*i*/change_tag_log_tag_id
ON /*_*/change_tag (ct_log_id
,ct_tag_id
);
1799 CREATE UNIQUE INDEX /*i*/change_tag_rev_tag_id
ON /*_*/change_tag (ct_rev_id
,ct_tag_id
);
1800 -- Covering index, so we can pull all the info only out of the index.
1801 CREATE INDEX /*i*/change_tag_tag_id_id
ON /*_*/change_tag (ct_tag_id
,ct_rc_id
,ct_rev_id
,ct_log_id
);
1804 -- Table for storing localisation data
1805 CREATE TABLE /*_*/l10n_cache (
1807 lc_lang
varbinary(32) NOT NULL,
1809 lc_key
varchar(255) NOT NULL,
1811 lc_value mediumblob
NOT NULL,
1812 PRIMARY KEY (lc_lang
, lc_key
)
1813 ) /*$wgDBTableOptions*/;
1815 -- Table caching which local files a module depends on that aren't
1816 -- registered directly, used for fast retrieval of file dependency.
1817 -- Currently only used for tracking images that CSS depends on
1818 CREATE TABLE /*_*/module_deps (
1820 md_module
varbinary(255) NOT NULL,
1821 -- Module context vary (includes skin and language; called "md_skin" for legacy reasons)
1822 md_skin
varbinary(32) NOT NULL,
1823 -- JSON blob with file dependencies
1824 md_deps mediumblob
NOT NULL,
1825 PRIMARY KEY (md_module
,md_skin
)
1826 ) /*$wgDBTableOptions*/;
1828 -- Holds all the sites known to the wiki.
1829 CREATE TABLE /*_*/sites (
1830 -- Numeric id of the site
1831 site_id
INT UNSIGNED
NOT NULL PRIMARY KEY AUTO_INCREMENT
,
1833 -- Global identifier for the site, ie 'enwiktionary'
1834 site_global_key
varbinary(32) NOT NULL,
1836 -- Type of the site, ie 'mediawiki'
1837 site_type
varbinary(32) NOT NULL,
1839 -- Group of the site, ie 'wikipedia'
1840 site_group
varbinary(32) NOT NULL,
1842 -- Source of the site data, ie 'local', 'wikidata', 'my-magical-repo'
1843 site_source
varbinary(32) NOT NULL,
1845 -- Language code of the sites primary language.
1846 site_language
varbinary(32) NOT NULL,
1848 -- Protocol of the site, ie 'http://', 'irc://', '//'
1849 -- This field is an index for lookups and is build from type specific data in site_data.
1850 site_protocol
varbinary(32) NOT NULL,
1852 -- Domain of the site in reverse order, ie 'org.mediawiki.www.'
1853 -- This field is an index for lookups and is build from type specific data in site_data.
1854 site_domain
VARCHAR(255) NOT NULL,
1856 -- Type dependent site data.
1857 site_data
BLOB NOT NULL,
1859 -- If site.tld/path/key:pageTitle should forward users to the page on
1860 -- the actual site, where "key" is the local identifier.
1861 site_forward bool
NOT NULL,
1863 -- Type dependent site config.
1864 -- For instance if template transclusion should be allowed if it's a MediaWiki.
1865 site_config
BLOB NOT NULL
1866 ) /*$wgDBTableOptions*/;
1868 CREATE UNIQUE INDEX /*i*/sites_global_key
ON /*_*/sites (site_global_key
);
1869 CREATE INDEX /*i*/sites_type
ON /*_*/sites (site_type
);
1870 CREATE INDEX /*i*/sites_group
ON /*_*/sites (site_group
);
1871 CREATE INDEX /*i*/sites_source
ON /*_*/sites (site_source
);
1872 CREATE INDEX /*i*/sites_language
ON /*_*/sites (site_language
);
1873 CREATE INDEX /*i*/sites_protocol
ON /*_*/sites (site_protocol
);
1874 CREATE INDEX /*i*/sites_domain
ON /*_*/sites (site_domain
);
1875 CREATE INDEX /*i*/sites_forward
ON /*_*/sites (site_forward
);
1877 -- Links local site identifiers to their corresponding site.
1878 CREATE TABLE /*_*/site_identifiers (
1879 -- Key on site.site_id
1880 si_site
INT UNSIGNED
NOT NULL,
1882 -- local key type, ie 'interwiki' or 'langlink'
1883 si_type
varbinary(32) NOT NULL,
1885 -- local key value, ie 'en' or 'wiktionary'
1886 si_key
varbinary(32) NOT NULL,
1888 PRIMARY KEY (si_type
, si_key
)
1889 ) /*$wgDBTableOptions*/;
1891 CREATE INDEX /*i*/site_ids_site
ON /*_*/site_identifiers (si_site
);
1892 CREATE INDEX /*i*/site_ids_key
ON /*_*/site_identifiers (si_key
);
1894 -- Table defining tag names for IDs. Also stores hit counts to avoid expensive queries on change_tag
1895 CREATE TABLE /*_*/change_tag_def (
1896 -- Numerical ID of the tag (ct_tag_id refers to this)
1897 ctd_id
int unsigned
NOT NULL PRIMARY KEY AUTO_INCREMENT
,
1898 -- Symbolic name of the tag (what would previously be put in ct_tag)
1899 ctd_name
varbinary(255) NOT NULL,
1900 -- Whether this tag was defined manually by a privileged user using Special:Tags
1901 ctd_user_defined
tinyint(1) NOT NULL,
1902 -- Number of times this tag was used
1903 ctd_count
bigint unsigned
NOT NULL default 0
1904 ) /*$wgDBTableOptions*/;
1906 CREATE UNIQUE INDEX /*i*/ctd_name
ON /*_*/change_tag_def (ctd_name
);
1907 CREATE INDEX /*i*/ctd_count
ON /*_*/change_tag_def (ctd_count
);
1908 CREATE INDEX /*i*/ctd_user_defined
ON /*_*/change_tag_def (ctd_user_defined
);
1910 -- vim: sw=2 sts=2 et