Merge "maintenance: Document secondary purpose of --server"
[lhc/web/wiklou.git] / maintenance / tables.sql
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.
4
5 -- This is a shared schema file used for both MySQL and SQLite installs.
6 --
7 -- For more documentation on the database schema, see
8 -- https://www.mediawiki.org/wiki/Manual:Database_layout
9 --
10 -- General notes:
11 --
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!)
15 --
16 -- Only the 'searchindex' table requires MyISAM due to the
17 -- requirement for fulltext index support, which is missing
18 -- from InnoDB.
19 --
20 --
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.
25 --
26 -- Historically TIMESTAMP fields were used, but abandoned
27 -- in early 2002 after a lot of trouble with the fields
28 -- auto-updating.
29 --
30 -- The Postgres backend uses TIMESTAMPTZ fields for timestamps,
31 -- and we will migrate the MySQL definitions at some point as
32 -- well.
33 --
34 --
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.
40 --
41
42
43 --
44 -- The user table contains basic account information,
45 -- authentication keys, etc.
46 --
47 -- Some multi-wiki sites may share a single central user table
48 -- between separate wikis using the $wgSharedDB setting.
49 --
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
53 -- tables.
54 --
55 CREATE TABLE /*_*/user (
56 user_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
57
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 '',
64
65 -- Optional 'real name' to be displayed in credit listings
66 user_real_name varchar(255) binary NOT NULL default '',
67
68 -- Password hashes, see User::crypt() and User::comparePasswords()
69 -- in User.php for the algorithm
70 user_password tinyblob NOT NULL,
71
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,
79
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),
86
87 -- Note: email should be restricted, not public info.
88 -- Same with passwords.
89 user_email tinytext NOT NULL,
90
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 '',
98
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 '',
104
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),
109
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),
113
114 -- Expiration date for the user_email_token
115 user_email_token_expires binary(14),
116
117 -- Timestamp of account registration.
118 -- Accounts predating this schema addition may contain NULL.
119 user_registration binary(14),
120
121 -- Count of edits and edit-like actions.
122 --
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
126 -- out of sync.
127 --
128 -- Meant primarily for heuristic checks to give an impression of whether
129 -- the account has been used much.
130 --
131 user_editcount int,
132
133 -- Expiration date for user password.
134 user_password_expires varbinary(14) DEFAULT NULL
135
136 ) /*$wgDBTableOptions*/;
137
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));
141
142
143 --
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.
148 --
149 CREATE TABLE /*_*/actor (
150 -- Unique ID to identify each actor
151 actor_id bigint unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
152
153 -- Key to user.user_id, or NULL for anonymous edits.
154 actor_user int unsigned,
155
156 -- Text username or IP address
157 actor_name varchar(255) binary NOT NULL
158 ) /*$wgDBTableOptions*/;
159
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);
163
164
165 --
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.
169 --
170 -- This table replaces the old user_rights field which used a
171 -- comma-separated blob.
172 --
173 CREATE TABLE /*_*/user_groups (
174 -- Key to user_id
175 ug_user int unsigned NOT NULL default 0,
176
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.
180 --
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 '',
186
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,
190
191 PRIMARY KEY (ug_user, ug_group)
192 ) /*$wgDBTableOptions*/;
193
194 CREATE INDEX /*i*/ug_group ON /*_*/user_groups (ug_group);
195 CREATE INDEX /*i*/ug_expiry ON /*_*/user_groups (ug_expiry);
196
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 (
201 -- Key to user_id
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*/;
206
207 --
208 -- Stores notifications of user talk page changes, for the display
209 -- of the "you have new messages" box
210 --
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
218 -- by this user
219 user_last_timestamp varbinary(14) NULL default NULL
220 ) /*$wgDBTableOptions*/;
221
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);
225
226
227 --
228 -- User preferences and perhaps other fun stuff. :)
229 -- Replaces the old user.user_options blob, with a couple nice properties:
230 --
231 -- 1) We only store non-default settings, so changes to the defauls
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.
235 --
236 CREATE TABLE /*_*/user_properties (
237 -- Foreign key to user.user_id
238 up_user int unsigned NOT NULL,
239
240 -- Name of the option being saved. This is indexed for bulk lookup.
241 up_property varbinary(255) NOT NULL,
242
243 -- Property value as a string.
244 up_value blob,
245 PRIMARY KEY (up_user,up_property)
246 ) /*$wgDBTableOptions*/;
247
248 CREATE INDEX /*i*/user_properties_property ON /*_*/user_properties (up_property);
249
250 --
251 -- This table contains a user's bot passwords: passwords that allow access to
252 -- the account via the API with limited rights.
253 --
254 CREATE TABLE /*_*/bot_passwords (
255 -- User ID obtained from CentralIdLookup.
256 bp_user int unsigned NOT NULL,
257
258 -- Application identifier
259 bp_app_id varbinary(32) NOT NULL,
260
261 -- Password hashes, like user.user_password
262 bp_password tinyblob NOT NULL,
263
264 -- Like user.user_token
265 bp_token binary(32) NOT NULL default '',
266
267 -- JSON blob for MWRestrictions
268 bp_restrictions blob NOT NULL,
269
270 -- Grants allowed to the account when authenticated with this bot-password
271 bp_grants blob NOT NULL,
272
273 PRIMARY KEY ( bp_user, bp_app_id )
274 ) /*$wgDBTableOptions*/;
275
276 --
277 -- Core of the wiki: each page has an entry here which identifies
278 -- it by title and contains some essential metadata.
279 --
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,
284
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,
289
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,
293
294 -- Comma-separated set of permission keys indicating who
295 -- can move or edit the page.
296 page_restrictions tinyblob NOT NULL,
297
298 -- 1 indicates the article is a redirect.
299 page_is_redirect tinyint unsigned NOT NULL default 0,
300
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,
304
305 -- Random value between 0 and 1, used for Special:Randompage
306 page_random real unsigned NOT NULL,
307
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 '',
314
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,
319
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,
324
325 -- Uncompressed length in bytes of the page's current source text.
326 page_len int unsigned NOT NULL,
327
328 -- content model, see CONTENT_MODEL_XXX constants
329 page_content_model varbinary(32) DEFAULT NULL,
330
331 -- Page content language
332 page_lang varbinary(35) DEFAULT NULL
333 ) /*$wgDBTableOptions*/;
334
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);
339
340 -- The index for Special:Random
341 CREATE INDEX /*i*/page_random ON /*_*/page (page_random);
342
343 -- Questionable utility, used by ProofreadPage, possibly DynamicPageList.
344 -- ApiQueryAllPages unconditionally filters on namespace and so hopefully does
345 -- not use it.
346 CREATE INDEX /*i*/page_len ON /*_*/page (page_len);
347
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);
351
352 --
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.
356 --
357 CREATE TABLE /*_*/revision (
358 -- Unique ID to identify each revision
359 rev_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
360
361 -- Key to page_id. This should _never_ be invalid.
362 rev_page int unsigned NOT NULL,
363
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,
372
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 '',
376
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,
381
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 '',
385
386 -- Timestamp of when revision was created
387 rev_timestamp binary(14) NOT NULL default '',
388
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,
392
393 -- Restrictions on who can access this revision
394 rev_deleted tinyint unsigned NOT NULL default 0,
395
396 -- Length of this revision in bytes
397 rev_len int unsigned,
398
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,
402
403 -- SHA-1 text content hash in base-36
404 rev_sha1 varbinary(32) NOT NULL default '',
405
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,
411
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
416
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
419
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);
425
426 -- Used by ApiQueryAllRevisions
427 CREATE INDEX /*i*/rev_timestamp ON /*_*/revision (rev_timestamp);
428
429 -- History index
430 CREATE INDEX /*i*/page_timestamp ON /*_*/revision (rev_page,rev_timestamp);
431
432 -- Logged-in user contributions index
433 CREATE INDEX /*i*/user_timestamp ON /*_*/revision (rev_user,rev_timestamp);
434
435 -- Anonymous user countributions index
436 CREATE INDEX /*i*/usertext_timestamp ON /*_*/revision (rev_user_text,rev_timestamp);
437
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);
442
443 --
444 -- Temporary table to avoid blocking on an alter of revision.
445 --
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.
449 --
450 CREATE TABLE /*_*/revision_comment_temp (
451 -- Key to rev_id
452 revcomment_rev int unsigned NOT NULL,
453 -- Key to comment_id
454 revcomment_comment_id bigint unsigned NOT NULL,
455 PRIMARY KEY (revcomment_rev, revcomment_comment_id)
456 ) /*$wgDBTableOptions*/;
457 -- Ensure uniqueness
458 CREATE UNIQUE INDEX /*i*/revcomment_rev ON /*_*/revision_comment_temp (revcomment_rev);
459
460 --
461 -- Temporary table to avoid blocking on an alter of revision.
462 --
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.
466 --
467 CREATE TABLE /*_*/revision_actor_temp (
468 -- Key to rev_id
469 revactor_rev int unsigned NOT NULL,
470 -- Key to actor_id
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*/;
477 -- Ensure uniqueness
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);
482
483 --
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.
488 --
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',
492
493 -- The timestamp of the revision
494 ipc_rev_timestamp binary(14) NOT NULL DEFAULT '',
495
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 ''
501
502 ) /*$wgDBTableOptions*/;
503
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);
506
507 --
508 -- Holds text of individual page revisions.
509 --
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.
514 --
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.
519 --
520 -- revision.rev_text_id is a key to this column
521 old_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
522
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,
526
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
546
547
548 --
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.
552 --
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.
556 --
557 CREATE TABLE /*_*/comment (
558 -- Unique ID to identify each comment
559 comment_id bigint unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
560
561 -- Hash of comment_text and comment_data, for deduplication
562 comment_hash INT NOT NULL,
563
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,
570
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
575 -- content language.
576 comment_data BLOB
577 ) /*$wgDBTableOptions*/;
578 -- Index used for deduplication.
579 CREATE INDEX /*i*/comment_hash ON /*_*/comment (comment_hash);
580
581
582 --
583 -- Archive area for deleted pages and their revisions.
584 -- These may be viewed (and restored) by admins through the Special:Undelete interface.
585 --
586 CREATE TABLE /*_*/archive (
587 -- Primary key
588 ar_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
589
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 '',
594
595 -- Copied from text.old_text, for pages deleted before MediaWiki 1.5.
596 -- This row may contain the raw revision text, possibly compressed.
597 -- Newer MediaWiki versions use ar_text_id instead.
598 -- This field is retained for backwards compatibility, so that
599 -- old archived pages will remain accessible.
600 -- See migrateArchiveText.php for migrating values to text storage.
601 ar_text mediumblob NOT NULL,
602
603 -- Basic revision stuff...
604 ar_comment varbinary(767) NOT NULL default '', -- Deprecated in favor of ar_comment_id
605 ar_comment_id bigint unsigned NOT NULL DEFAULT 0, -- ("DEFAULT 0" is temporary, signaling that ar_comment should be used)
606 ar_user int unsigned NOT NULL default 0, -- Deprecated in favor of ar_actor
607 ar_user_text varchar(255) binary NOT NULL DEFAULT '', -- Deprecated in favor of ar_actor
608 ar_actor bigint unsigned NOT NULL DEFAULT 0, -- ("DEFAULT 0" is temporary, signaling that ar_user/ar_user_text should be used)
609 ar_timestamp binary(14) NOT NULL default '',
610 ar_minor_edit tinyint NOT NULL default 0,
611
612 -- Copied from text.old_flags, for pages deleted before MediaWiki 1.5.
613 -- Otherwise empty string.
614 -- See also note for ar_text.
615 ar_flags tinyblob NOT NULL,
616
617 -- Copied from rev_id.
618 --
619 -- @since 1.5 Entries from 1.4 will be NULL here. When restoring
620 -- archive rows from before 1.5, a new rev_id is created.
621 ar_rev_id int unsigned NOT NULL,
622
623 -- Copied from rev_text_id, references text.old_id.
624 -- To avoid breaking the block-compression scheme and otherwise making
625 -- storage changes harder, the actual text is *not* deleted from the
626 -- text storage. Instead, it is merely hidden from public view, by removal
627 -- of the page and revision entries.
628 --
629 -- @since 1.5 Entries from 1.2-1.4 will have NULL here. When restoring
630 -- archive rows without this, ar_text and ar_flags are used instead.
631 -- @deprecated since 1.31. If rows in the slots table with slot_revision_id = ar_rev_id
632 -- exist, this field should be ignored (and may be NULL or 0) in favor of the
633 -- corresponding data from the slots and content tables
634 ar_text_id int unsigned,
635
636 -- Copied from rev_deleted. Although this may be raised during deletion.
637 -- Users with the "suppressrevision" right may "archive" and "suppress"
638 -- content in a single action.
639 -- @since 1.10
640 ar_deleted tinyint unsigned NOT NULL default 0,
641
642 -- Copied from rev_len, length of this revision in bytes.
643 -- @since 1.10
644 ar_len int unsigned,
645
646 -- Copied from page_id. Restoration will attempt to use this as page ID if
647 -- no current page with the same name exists. Otherwise, the revisions will
648 -- be restored under the current page. Can be used for manual undeletion by
649 -- developers if multiple pages by the same name were archived.
650 --
651 -- @since 1.11 Older entries will have NULL.
652 ar_page_id int unsigned,
653
654 -- Copied from rev_parent_id.
655 -- @since 1.13
656 ar_parent_id int unsigned default NULL,
657
658 -- Copied from rev_sha1, SHA-1 text content hash in base-36
659 -- @since 1.19
660 ar_sha1 varbinary(32) NOT NULL default '',
661
662 -- Copied from rev_content_model, see CONTENT_MODEL_XXX constants
663 -- @since 1.21
664 -- @deprecated since 1.31. If rows in the slots table with slot_revision_id = ar_rev_id
665 -- exist, this field should be ignored (and may be NULL) in favor of the
666 -- corresponding data from the slots and content tables
667 ar_content_model varbinary(32) DEFAULT NULL,
668
669 -- Copied from rev_content_format, see CONTENT_FORMAT_XXX constants
670 -- @since 1.21
671 -- @deprecated since 1.31. If rows in the slots table with slot_revision_id = ar_rev_id
672 -- exist, this field should be ignored (and may be NULL).
673 ar_content_format varbinary(64) DEFAULT NULL
674 ) /*$wgDBTableOptions*/;
675
676 -- Index for Special:Undelete to page through deleted revisions
677 CREATE INDEX /*i*/name_title_timestamp ON /*_*/archive (ar_namespace,ar_title,ar_timestamp);
678
679 -- Index for Special:DeletedContributions
680 CREATE INDEX /*i*/ar_usertext_timestamp ON /*_*/archive (ar_user_text,ar_timestamp);
681 CREATE INDEX /*i*/ar_actor_timestamp ON /*_*/archive (ar_actor,ar_timestamp);
682
683 -- Index for linking archive rows with tables that normally link with revision
684 -- rows, such as change_tag.
685 CREATE INDEX /*i*/ar_revid ON /*_*/archive (ar_rev_id);
686
687 --
688 -- Slots represent an n:m relation between revisions and content objects.
689 -- A content object can have a specific "role" in one or more revisions.
690 -- Each revision can have multiple content objects, each having a different role.
691 --
692 CREATE TABLE /*_*/slots (
693
694 -- reference to rev_id or ar_rev_id
695 slot_revision_id bigint unsigned NOT NULL,
696
697 -- reference to role_id
698 slot_role_id smallint unsigned NOT NULL,
699
700 -- reference to content_id
701 slot_content_id bigint unsigned NOT NULL,
702
703 -- The revision ID of the revision that originated the slot's content.
704 -- To find revisions that changed slots, look for slot_origin = slot_revision_id.
705 slot_origin bigint unsigned NOT NULL,
706
707 PRIMARY KEY ( slot_revision_id, slot_role_id )
708 ) /*$wgDBTableOptions*/;
709
710 -- Index for finding revisions that modified a specific slot
711 CREATE INDEX /*i*/slot_revision_origin_role ON /*_*/slots (slot_revision_id, slot_origin, slot_role_id);
712
713 --
714 -- The content table represents content objects. It's primary purpose is to provide the necessary
715 -- meta-data for loading and interpreting a serialized data blob to create a content object.
716 --
717 CREATE TABLE /*_*/content (
718
719 -- ID of the content object
720 content_id bigint unsigned PRIMARY KEY AUTO_INCREMENT,
721
722 -- Nominal size of the content object (not necessarily of the serialized blob)
723 content_size int unsigned NOT NULL,
724
725 -- Nominal hash of the content object (not necessarily of the serialized blob)
726 content_sha1 varbinary(32) NOT NULL,
727
728 -- reference to model_id. Note the content format isn't specified; it should
729 -- be assumed to be in the default format for the model unless auto-detected
730 -- otherwise.
731 content_model smallint unsigned NOT NULL,
732
733 -- URL-like address of the content blob
734 content_address varbinary(255) NOT NULL
735 ) /*$wgDBTableOptions*/;
736
737 --
738 -- Normalization table for role names
739 --
740 CREATE TABLE /*_*/slot_roles (
741 role_id smallint PRIMARY KEY AUTO_INCREMENT,
742 role_name varbinary(64) NOT NULL
743 ) /*$wgDBTableOptions*/;
744
745 -- Index for looking of the internal ID of for a name
746 CREATE UNIQUE INDEX /*i*/role_name ON /*_*/slot_roles (role_name);
747
748 --
749 -- Normalization table for content model names
750 --
751 CREATE TABLE /*_*/content_models (
752 model_id smallint PRIMARY KEY AUTO_INCREMENT,
753 model_name varbinary(64) NOT NULL
754 ) /*$wgDBTableOptions*/;
755
756 -- Index for looking of the internal ID of for a name
757 CREATE UNIQUE INDEX /*i*/model_name ON /*_*/content_models (model_name);
758
759 --
760 -- Track page-to-page hyperlinks within the wiki.
761 --
762 CREATE TABLE /*_*/pagelinks (
763 -- Key to the page_id of the page containing the link.
764 pl_from int unsigned NOT NULL default 0,
765 -- Namespace for this page
766 pl_from_namespace int NOT NULL default 0,
767
768 -- Key to page_namespace/page_title of the target page.
769 -- The target page may or may not exist, and due to renames
770 -- and deletions may refer to different page records as time
771 -- goes by.
772 pl_namespace int NOT NULL default 0,
773 pl_title varchar(255) binary NOT NULL default '',
774 PRIMARY KEY (pl_from,pl_namespace,pl_title)
775 ) /*$wgDBTableOptions*/;
776
777 -- Reverse index, for Special:Whatlinkshere
778 CREATE INDEX /*i*/pl_namespace ON /*_*/pagelinks (pl_namespace,pl_title,pl_from);
779
780 -- Index for Special:Whatlinkshere with namespace filter
781 CREATE INDEX /*i*/pl_backlinks_namespace ON /*_*/pagelinks (pl_from_namespace,pl_namespace,pl_title,pl_from);
782
783
784 --
785 -- Track template inclusions.
786 --
787 CREATE TABLE /*_*/templatelinks (
788 -- Key to the page_id of the page containing the link.
789 tl_from int unsigned NOT NULL default 0,
790 -- Namespace for this page
791 tl_from_namespace int NOT NULL default 0,
792
793 -- Key to page_namespace/page_title of the target page.
794 -- The target page may or may not exist, and due to renames
795 -- and deletions may refer to different page records as time
796 -- goes by.
797 tl_namespace int NOT NULL default 0,
798 tl_title varchar(255) binary NOT NULL default '',
799 PRIMARY KEY (tl_from,tl_namespace,tl_title)
800 ) /*$wgDBTableOptions*/;
801
802 -- Reverse index, for Special:Whatlinkshere
803 CREATE INDEX /*i*/tl_namespace ON /*_*/templatelinks (tl_namespace,tl_title,tl_from);
804
805 -- Index for Special:Whatlinkshere with namespace filter
806 CREATE INDEX /*i*/tl_backlinks_namespace ON /*_*/templatelinks (tl_from_namespace,tl_namespace,tl_title,tl_from);
807
808
809 --
810 -- Track links to images *used inline*
811 -- We don't distinguish live from broken links here, so
812 -- they do not need to be changed on upload/removal.
813 --
814 CREATE TABLE /*_*/imagelinks (
815 -- Key to page_id of the page containing the image / media link.
816 il_from int unsigned NOT NULL default 0,
817 -- Namespace for this page
818 il_from_namespace int NOT NULL default 0,
819
820 -- Filename of target image.
821 -- This is also the page_title of the file's description page;
822 -- all such pages are in namespace 6 (NS_FILE).
823 il_to varchar(255) binary NOT NULL default '',
824 PRIMARY KEY (il_from,il_to)
825 ) /*$wgDBTableOptions*/;
826
827 -- Reverse index, for Special:Whatlinkshere and file description page local usage
828 CREATE INDEX /*i*/il_to ON /*_*/imagelinks (il_to,il_from);
829
830 -- Index for Special:Whatlinkshere with namespace filter
831 CREATE INDEX /*i*/il_backlinks_namespace ON /*_*/imagelinks (il_from_namespace,il_to,il_from);
832
833
834 --
835 -- Track category inclusions *used inline*
836 -- This tracks a single level of category membership
837 --
838 CREATE TABLE /*_*/categorylinks (
839 -- Key to page_id of the page defined as a category member.
840 cl_from int unsigned NOT NULL default 0,
841
842 -- Name of the category.
843 -- This is also the page_title of the category's description page;
844 -- all such pages are in namespace 14 (NS_CATEGORY).
845 cl_to varchar(255) binary NOT NULL default '',
846
847 -- A binary string obtained by applying a sortkey generation algorithm
848 -- (Collation::getSortKey()) to page_title, or cl_sortkey_prefix . "\n"
849 -- . page_title if cl_sortkey_prefix is nonempty.
850 cl_sortkey varbinary(230) NOT NULL default '',
851
852 -- A prefix for the raw sortkey manually specified by the user, either via
853 -- [[Category:Foo|prefix]] or {{defaultsort:prefix}}. If nonempty, it's
854 -- concatenated with a line break followed by the page title before the sortkey
855 -- conversion algorithm is run. We store this so that we can update
856 -- collations without reparsing all pages.
857 -- Note: If you change the length of this field, you also need to change
858 -- code in LinksUpdate.php. See T27254.
859 cl_sortkey_prefix varchar(255) binary NOT NULL default '',
860
861 -- This isn't really used at present. Provided for an optional
862 -- sorting method by approximate addition time.
863 cl_timestamp timestamp NOT NULL,
864
865 -- Stores $wgCategoryCollation at the time cl_sortkey was generated. This
866 -- can be used to install new collation versions, tracking which rows are not
867 -- yet updated. '' means no collation, this is a legacy row that needs to be
868 -- updated by updateCollation.php. In the future, it might be possible to
869 -- specify different collations per category.
870 cl_collation varbinary(32) NOT NULL default '',
871
872 -- Stores whether cl_from is a category, file, or other page, so we can
873 -- paginate the three categories separately. This never has to be updated
874 -- after the page is created, since none of these page types can be moved to
875 -- any other.
876 cl_type ENUM('page', 'subcat', 'file') NOT NULL default 'page',
877 PRIMARY KEY (cl_from,cl_to)
878 ) /*$wgDBTableOptions*/;
879
880
881 -- We always sort within a given category, and within a given type. FIXME:
882 -- Formerly this index didn't cover cl_type (since that didn't exist), so old
883 -- callers won't be using an index: fix this?
884 CREATE INDEX /*i*/cl_sortkey ON /*_*/categorylinks (cl_to,cl_type,cl_sortkey,cl_from);
885
886 -- Used by the API (and some extensions)
887 CREATE INDEX /*i*/cl_timestamp ON /*_*/categorylinks (cl_to,cl_timestamp);
888
889 -- Used when updating collation (e.g. updateCollation.php)
890 CREATE INDEX /*i*/cl_collation_ext ON /*_*/categorylinks (cl_collation, cl_to, cl_type, cl_from);
891
892 --
893 -- Track all existing categories. Something is a category if 1) it has an entry
894 -- somewhere in categorylinks, or 2) it has a description page. Categories
895 -- might not have corresponding pages, so they need to be tracked separately.
896 --
897 CREATE TABLE /*_*/category (
898 -- Primary key
899 cat_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
900
901 -- Name of the category, in the same form as page_title (with underscores).
902 -- If there is a category page corresponding to this category, by definition,
903 -- it has this name (in the Category namespace).
904 cat_title varchar(255) binary NOT NULL,
905
906 -- The numbers of member pages (including categories and media), subcatego-
907 -- ries, and Image: namespace members, respectively. These are signed to
908 -- make underflow more obvious. We make the first number include the second
909 -- two for better sorting: subtracting for display is easy, adding for order-
910 -- ing is not.
911 cat_pages int signed NOT NULL default 0,
912 cat_subcats int signed NOT NULL default 0,
913 cat_files int signed NOT NULL default 0
914 ) /*$wgDBTableOptions*/;
915
916 CREATE UNIQUE INDEX /*i*/cat_title ON /*_*/category (cat_title);
917
918 -- For Special:Mostlinkedcategories
919 CREATE INDEX /*i*/cat_pages ON /*_*/category (cat_pages);
920
921
922 --
923 -- Track links to external URLs
924 --
925 CREATE TABLE /*_*/externallinks (
926 -- Primary key
927 el_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
928
929 -- page_id of the referring page
930 el_from int unsigned NOT NULL default 0,
931
932 -- The URL
933 el_to blob NOT NULL,
934
935 -- In the case of HTTP URLs, this is the URL with any username or password
936 -- removed, and with the labels in the hostname reversed and converted to
937 -- lower case. An extra dot is added to allow for matching of either
938 -- example.com or *.example.com in a single scan.
939 -- Example:
940 -- http://user:password@sub.example.com/page.html
941 -- becomes
942 -- http://com.example.sub./page.html
943 -- which allows for fast searching for all pages under example.com with the
944 -- clause:
945 -- WHERE el_index LIKE 'http://com.example.%'
946 el_index blob NOT NULL,
947
948 -- This is el_index truncated to 60 bytes to allow for sortable queries that
949 -- aren't supported by a partial index.
950 -- @todo Drop the default once this is deployed everywhere and code is populating it.
951 el_index_60 varbinary(60) NOT NULL default ''
952 ) /*$wgDBTableOptions*/;
953
954 -- Forward index, for page edit, save
955 CREATE INDEX /*i*/el_from ON /*_*/externallinks (el_from, el_to(40));
956
957 -- Index for Special:LinkSearch exact search
958 CREATE INDEX /*i*/el_to ON /*_*/externallinks (el_to(60), el_from);
959
960 -- For Special:LinkSearch wildcard search
961 CREATE INDEX /*i*/el_index ON /*_*/externallinks (el_index(60));
962
963 -- For Special:LinkSearch wildcard search with efficient paging by el_id
964 CREATE INDEX /*i*/el_index_60 ON /*_*/externallinks (el_index_60, el_id);
965 CREATE INDEX /*i*/el_from_index_60 ON /*_*/externallinks (el_from, el_index_60, el_id);
966
967 --
968 -- Track interlanguage links
969 --
970 CREATE TABLE /*_*/langlinks (
971 -- page_id of the referring page
972 ll_from int unsigned NOT NULL default 0,
973
974 -- Language code of the target
975 ll_lang varbinary(20) NOT NULL default '',
976
977 -- Title of the target, including namespace
978 ll_title varchar(255) binary NOT NULL default '',
979 PRIMARY KEY (ll_from,ll_lang)
980 ) /*$wgDBTableOptions*/;
981
982 -- Index for ApiQueryLangbacklinks
983 CREATE INDEX /*i*/ll_lang ON /*_*/langlinks (ll_lang, ll_title);
984
985
986 --
987 -- Track inline interwiki links
988 --
989 CREATE TABLE /*_*/iwlinks (
990 -- page_id of the referring page
991 iwl_from int unsigned NOT NULL default 0,
992
993 -- Interwiki prefix code of the target
994 iwl_prefix varbinary(20) NOT NULL default '',
995
996 -- Title of the target, including namespace
997 iwl_title varchar(255) binary NOT NULL default '',
998 PRIMARY KEY (iwl_from,iwl_prefix,iwl_title)
999 ) /*$wgDBTableOptions*/;
1000
1001 -- Index for ApiQueryIWBacklinks
1002 CREATE INDEX /*i*/iwl_prefix_title_from ON /*_*/iwlinks (iwl_prefix, iwl_title, iwl_from);
1003
1004 -- Index for ApiQueryIWLinks
1005 CREATE INDEX /*i*/iwl_prefix_from_title ON /*_*/iwlinks (iwl_prefix, iwl_from, iwl_title);
1006
1007
1008 --
1009 -- Contains a single row with some aggregate info
1010 -- on the state of the site.
1011 --
1012 CREATE TABLE /*_*/site_stats (
1013 -- The single row should contain 1 here.
1014 ss_row_id int unsigned NOT NULL PRIMARY KEY,
1015
1016 -- Total number of edits performed.
1017 ss_total_edits bigint unsigned default NULL,
1018
1019 -- See SiteStatsInit::articles().
1020 ss_good_articles bigint unsigned default NULL,
1021
1022 -- Total pages, theoretically equal to SELECT COUNT(*) FROM page.
1023 ss_total_pages bigint unsigned default NULL,
1024
1025 -- Number of users, theoretically equal to SELECT COUNT(*) FROM user.
1026 ss_users bigint unsigned default NULL,
1027
1028 -- Number of users that still edit.
1029 ss_active_users bigint unsigned default NULL,
1030
1031 -- Number of images, equivalent to SELECT COUNT(*) FROM image.
1032 ss_images bigint unsigned default NULL
1033 ) /*$wgDBTableOptions*/;
1034
1035 --
1036 -- The internet is full of jerks, alas. Sometimes it's handy
1037 -- to block a vandal or troll account.
1038 --
1039 CREATE TABLE /*_*/ipblocks (
1040 -- Primary key, introduced for privacy.
1041 ipb_id int NOT NULL PRIMARY KEY AUTO_INCREMENT,
1042
1043 -- Blocked IP address in dotted-quad form or user name.
1044 ipb_address tinyblob NOT NULL,
1045
1046 -- Blocked user ID or 0 for IP blocks.
1047 ipb_user int unsigned NOT NULL default 0,
1048
1049 -- User ID who made the block.
1050 ipb_by int unsigned NOT NULL default 0, -- Deprecated in favor of ipb_by_actor
1051
1052 -- User name of blocker
1053 ipb_by_text varchar(255) binary NOT NULL default '', -- Deprecated in favor of ipb_by_actor
1054
1055 -- Actor who made the block.
1056 ipb_by_actor bigint unsigned NOT NULL DEFAULT 0, -- ("DEFAULT 0" is temporary, signaling that ipb_by/ipb_by_text should be used)
1057
1058 -- Text comment made by blocker. Deprecated in favor of ipb_reason_id
1059 ipb_reason varbinary(767) NOT NULL default '',
1060
1061 -- Key to comment_id. Text comment made by blocker.
1062 -- ("DEFAULT 0" is temporary, signaling that ipb_reason should be used)
1063 ipb_reason_id bigint unsigned NOT NULL DEFAULT 0,
1064
1065 -- Creation (or refresh) date in standard YMDHMS form.
1066 -- IP blocks expire automatically.
1067 ipb_timestamp binary(14) NOT NULL default '',
1068
1069 -- Indicates that the IP address was banned because a banned
1070 -- user accessed a page through it. If this is 1, ipb_address
1071 -- will be hidden, and the block identified by block ID number.
1072 ipb_auto bool NOT NULL default 0,
1073
1074 -- If set to 1, block applies only to logged-out users
1075 ipb_anon_only bool NOT NULL default 0,
1076
1077 -- Block prevents account creation from matching IP addresses
1078 ipb_create_account bool NOT NULL default 1,
1079
1080 -- Block triggers autoblocks
1081 ipb_enable_autoblock bool NOT NULL default '1',
1082
1083 -- Time at which the block will expire.
1084 -- May be "infinity"
1085 ipb_expiry varbinary(14) NOT NULL default '',
1086
1087 -- Start and end of an address range, in hexadecimal
1088 -- Size chosen to allow IPv6
1089 -- FIXME: these fields were originally blank for single-IP blocks,
1090 -- but now they are populated. No migration was ever done. They
1091 -- should be fixed to be blank again for such blocks (T51504).
1092 ipb_range_start tinyblob NOT NULL,
1093 ipb_range_end tinyblob NOT NULL,
1094
1095 -- Flag for entries hidden from users and Sysops
1096 ipb_deleted bool NOT NULL default 0,
1097
1098 -- Block prevents user from accessing Special:Emailuser
1099 ipb_block_email bool NOT NULL default 0,
1100
1101 -- Block allows user to edit their own talk page
1102 ipb_allow_usertalk bool NOT NULL default 0,
1103
1104 -- ID of the block that caused this block to exist
1105 -- Autoblocks set this to the original block
1106 -- so that the original block being deleted also
1107 -- deletes the autoblocks
1108 ipb_parent_block_id int default NULL
1109
1110 ) /*$wgDBTableOptions*/;
1111
1112 -- Unique index to support "user already blocked" messages
1113 -- Any new options which prevent collisions should be included
1114 CREATE UNIQUE INDEX /*i*/ipb_address ON /*_*/ipblocks (ipb_address(255), ipb_user, ipb_auto, ipb_anon_only);
1115
1116 -- For querying whether a logged-in user is blocked
1117 CREATE INDEX /*i*/ipb_user ON /*_*/ipblocks (ipb_user);
1118
1119 -- For querying whether an IP address is in any range
1120 CREATE INDEX /*i*/ipb_range ON /*_*/ipblocks (ipb_range_start(8), ipb_range_end(8));
1121
1122 -- Index for Special:BlockList
1123 CREATE INDEX /*i*/ipb_timestamp ON /*_*/ipblocks (ipb_timestamp);
1124
1125 -- Index for table pruning
1126 CREATE INDEX /*i*/ipb_expiry ON /*_*/ipblocks (ipb_expiry);
1127
1128 -- Index for removing autoblocks when a parent block is removed
1129 CREATE INDEX /*i*/ipb_parent_block_id ON /*_*/ipblocks (ipb_parent_block_id);
1130
1131
1132 --
1133 -- Uploaded images and other files.
1134 --
1135 CREATE TABLE /*_*/image (
1136 -- Filename.
1137 -- This is also the title of the associated description page,
1138 -- which will be in namespace 6 (NS_FILE).
1139 img_name varchar(255) binary NOT NULL default '' PRIMARY KEY,
1140
1141 -- File size in bytes.
1142 img_size int unsigned NOT NULL default 0,
1143
1144 -- For images, size in pixels.
1145 img_width int NOT NULL default 0,
1146 img_height int NOT NULL default 0,
1147
1148 -- Extracted Exif metadata stored as a serialized PHP array.
1149 img_metadata mediumblob NOT NULL,
1150
1151 -- For images, bits per pixel if known.
1152 img_bits int NOT NULL default 0,
1153
1154 -- Media type as defined by the MEDIATYPE_xxx constants
1155 img_media_type ENUM("UNKNOWN", "BITMAP", "DRAWING", "AUDIO", "VIDEO", "MULTIMEDIA", "OFFICE", "TEXT", "EXECUTABLE", "ARCHIVE", "3D") default NULL,
1156
1157 -- major part of a MIME media type as defined by IANA
1158 -- see https://www.iana.org/assignments/media-types/
1159 -- for "chemical" cf. http://dx.doi.org/10.1021/ci9803233 by the ACS
1160 img_major_mime ENUM("unknown", "application", "audio", "image", "text", "video", "message", "model", "multipart", "chemical") NOT NULL default "unknown",
1161
1162 -- minor part of a MIME media type as defined by IANA
1163 -- the minor parts are not required to adher to any standard
1164 -- but should be consistent throughout the database
1165 -- see https://www.iana.org/assignments/media-types/
1166 img_minor_mime varbinary(100) NOT NULL default "unknown",
1167
1168 -- Description field as entered by the uploader.
1169 -- This is displayed in image upload history and logs.
1170 -- Deprecated in favor of img_description_id.
1171 img_description varbinary(767) NOT NULL default '',
1172
1173 img_description_id bigint unsigned NOT NULL DEFAULT 0, -- ("DEFAULT 0" is temporary, signaling that img_description should be used)
1174
1175 -- user_id and user_name of uploader.
1176 -- Deprecated in favor of img_actor.
1177 img_user int unsigned NOT NULL default 0,
1178 img_user_text varchar(255) binary NOT NULL DEFAULT '',
1179
1180 -- actor_id of the uploader.
1181 -- ("DEFAULT 0" is temporary, signaling that img_user/img_user_text should be used)
1182 img_actor bigint unsigned NOT NULL DEFAULT 0,
1183
1184 -- Time of the upload.
1185 img_timestamp varbinary(14) NOT NULL default '',
1186
1187 -- SHA-1 content hash in base-36
1188 img_sha1 varbinary(32) NOT NULL default ''
1189 ) /*$wgDBTableOptions*/;
1190
1191 -- Used by Special:Newimages and ApiQueryAllImages
1192 CREATE INDEX /*i*/img_user_timestamp ON /*_*/image (img_user,img_timestamp);
1193 CREATE INDEX /*i*/img_usertext_timestamp ON /*_*/image (img_user_text,img_timestamp);
1194 CREATE INDEX /*i*/img_actor_timestamp ON /*_*/image (img_actor,img_timestamp);
1195 -- Used by Special:ListFiles for sort-by-size
1196 CREATE INDEX /*i*/img_size ON /*_*/image (img_size);
1197 -- Used by Special:Newimages and Special:ListFiles
1198 CREATE INDEX /*i*/img_timestamp ON /*_*/image (img_timestamp);
1199 -- Used in API and duplicate search
1200 CREATE INDEX /*i*/img_sha1 ON /*_*/image (img_sha1(10));
1201 -- Used to get media of one type
1202 CREATE INDEX /*i*/img_media_mime ON /*_*/image (img_media_type,img_major_mime,img_minor_mime);
1203
1204 --
1205 -- Temporary table to avoid blocking on an alter of image.
1206 --
1207 -- On large wikis like Wikimedia Commons, altering the image table is a
1208 -- months-long process. This table is being created to avoid such an alter, and
1209 -- will be merged back into image in the future.
1210 --
1211 CREATE TABLE /*_*/image_comment_temp (
1212 -- Key to img_name (ugh)
1213 imgcomment_name varchar(255) binary NOT NULL,
1214 -- Key to comment_id
1215 imgcomment_description_id bigint unsigned NOT NULL,
1216 PRIMARY KEY (imgcomment_name, imgcomment_description_id)
1217 ) /*$wgDBTableOptions*/;
1218 -- Ensure uniqueness
1219 CREATE UNIQUE INDEX /*i*/imgcomment_name ON /*_*/image_comment_temp (imgcomment_name);
1220
1221
1222 --
1223 -- Previous revisions of uploaded files.
1224 -- Awkwardly, image rows have to be moved into
1225 -- this table at re-upload time.
1226 --
1227 CREATE TABLE /*_*/oldimage (
1228 -- Base filename: key to image.img_name
1229 oi_name varchar(255) binary NOT NULL default '',
1230
1231 -- Filename of the archived file.
1232 -- This is generally a timestamp and '!' prepended to the base name.
1233 oi_archive_name varchar(255) binary NOT NULL default '',
1234
1235 -- Other fields as in image...
1236 oi_size int unsigned NOT NULL default 0,
1237 oi_width int NOT NULL default 0,
1238 oi_height int NOT NULL default 0,
1239 oi_bits int NOT NULL default 0,
1240 oi_description varbinary(767) NOT NULL default '', -- Deprecated.
1241 oi_description_id bigint unsigned NOT NULL DEFAULT 0, -- ("DEFAULT 0" is temporary, signaling that oi_description should be used)
1242 oi_user int unsigned NOT NULL default 0, -- Deprecated in favor of oi_actor
1243 oi_user_text varchar(255) binary NOT NULL DEFAULT '', -- Deprecated in favor of oi_actor
1244 oi_actor bigint unsigned NOT NULL DEFAULT 0, -- ("DEFAULT 0" is temporary, signaling that oi_user/oi_user_text should be used)
1245 oi_timestamp binary(14) NOT NULL default '',
1246
1247 oi_metadata mediumblob NOT NULL,
1248 oi_media_type ENUM("UNKNOWN", "BITMAP", "DRAWING", "AUDIO", "VIDEO", "MULTIMEDIA", "OFFICE", "TEXT", "EXECUTABLE", "ARCHIVE", "3D") default NULL,
1249 oi_major_mime ENUM("unknown", "application", "audio", "image", "text", "video", "message", "model", "multipart", "chemical") NOT NULL default "unknown",
1250 oi_minor_mime varbinary(100) NOT NULL default "unknown",
1251 oi_deleted tinyint unsigned NOT NULL default 0,
1252 oi_sha1 varbinary(32) NOT NULL default ''
1253 ) /*$wgDBTableOptions*/;
1254
1255 CREATE INDEX /*i*/oi_usertext_timestamp ON /*_*/oldimage (oi_user_text,oi_timestamp);
1256 CREATE INDEX /*i*/oi_actor_timestamp ON /*_*/oldimage (oi_actor,oi_timestamp);
1257 CREATE INDEX /*i*/oi_name_timestamp ON /*_*/oldimage (oi_name,oi_timestamp);
1258 -- oi_archive_name truncated to 14 to avoid key length overflow
1259 CREATE INDEX /*i*/oi_name_archive_name ON /*_*/oldimage (oi_name,oi_archive_name(14));
1260 CREATE INDEX /*i*/oi_sha1 ON /*_*/oldimage (oi_sha1(10));
1261
1262
1263 --
1264 -- Record of deleted file data
1265 --
1266 CREATE TABLE /*_*/filearchive (
1267 -- Unique row id
1268 fa_id int NOT NULL PRIMARY KEY AUTO_INCREMENT,
1269
1270 -- Original base filename; key to image.img_name, page.page_title, etc
1271 fa_name varchar(255) binary NOT NULL default '',
1272
1273 -- Filename of archived file, if an old revision
1274 fa_archive_name varchar(255) binary default '',
1275
1276 -- Which storage bin (directory tree or object store) the file data
1277 -- is stored in. Should be 'deleted' for files that have been deleted;
1278 -- any other bin is not yet in use.
1279 fa_storage_group varbinary(16),
1280
1281 -- SHA-1 of the file contents plus extension, used as a key for storage.
1282 -- eg 8f8a562add37052a1848ff7771a2c515db94baa9.jpg
1283 --
1284 -- If NULL, the file was missing at deletion time or has been purged
1285 -- from the archival storage.
1286 fa_storage_key varbinary(64) default '',
1287
1288 -- Deletion information, if this file is deleted.
1289 fa_deleted_user int,
1290 fa_deleted_timestamp binary(14) default '',
1291 fa_deleted_reason varbinary(767) default '', -- Deprecated
1292 fa_deleted_reason_id bigint unsigned NOT NULL DEFAULT 0, -- ("DEFAULT 0" is temporary, signaling that fa_deleted_reason should be used)
1293
1294 -- Duped fields from image
1295 fa_size int unsigned default 0,
1296 fa_width int default 0,
1297 fa_height int default 0,
1298 fa_metadata mediumblob,
1299 fa_bits int default 0,
1300 fa_media_type ENUM("UNKNOWN", "BITMAP", "DRAWING", "AUDIO", "VIDEO", "MULTIMEDIA", "OFFICE", "TEXT", "EXECUTABLE", "ARCHIVE", "3D") default NULL,
1301 fa_major_mime ENUM("unknown", "application", "audio", "image", "text", "video", "message", "model", "multipart", "chemical") default "unknown",
1302 fa_minor_mime varbinary(100) default "unknown",
1303 fa_description varbinary(767) default '', -- Deprecated
1304 fa_description_id bigint unsigned NOT NULL DEFAULT 0, -- ("DEFAULT 0" is temporary, signaling that fa_description should be used)
1305 fa_user int unsigned default 0, -- Deprecated in favor of fa_actor
1306 fa_user_text varchar(255) binary DEFAULT '', -- Deprecated in favor of fa_actor
1307 fa_actor bigint unsigned NOT NULL DEFAULT 0, -- ("DEFAULT 0" is temporary, signaling that fa_user/fa_user_text should be used)
1308 fa_timestamp binary(14) default '',
1309
1310 -- Visibility of deleted revisions, bitfield
1311 fa_deleted tinyint unsigned NOT NULL default 0,
1312
1313 -- sha1 hash of file content
1314 fa_sha1 varbinary(32) NOT NULL default ''
1315 ) /*$wgDBTableOptions*/;
1316
1317 -- pick out by image name
1318 CREATE INDEX /*i*/fa_name ON /*_*/filearchive (fa_name, fa_timestamp);
1319 -- pick out dupe files
1320 CREATE INDEX /*i*/fa_storage_group ON /*_*/filearchive (fa_storage_group, fa_storage_key);
1321 -- sort by deletion time
1322 CREATE INDEX /*i*/fa_deleted_timestamp ON /*_*/filearchive (fa_deleted_timestamp);
1323 -- sort by uploader
1324 CREATE INDEX /*i*/fa_user_timestamp ON /*_*/filearchive (fa_user_text,fa_timestamp);
1325 CREATE INDEX /*i*/fa_actor_timestamp ON /*_*/filearchive (fa_actor,fa_timestamp);
1326 -- find file by sha1, 10 bytes will be enough for hashes to be indexed
1327 CREATE INDEX /*i*/fa_sha1 ON /*_*/filearchive (fa_sha1(10));
1328
1329
1330 --
1331 -- Store information about newly uploaded files before they're
1332 -- moved into the actual filestore
1333 --
1334 CREATE TABLE /*_*/uploadstash (
1335 us_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
1336
1337 -- the user who uploaded the file.
1338 us_user int unsigned NOT NULL,
1339
1340 -- file key. this is how applications actually search for the file.
1341 -- this might go away, or become the primary key.
1342 us_key varchar(255) NOT NULL,
1343
1344 -- the original path
1345 us_orig_path varchar(255) NOT NULL,
1346
1347 -- the temporary path at which the file is actually stored
1348 us_path varchar(255) NOT NULL,
1349
1350 -- which type of upload the file came from (sometimes)
1351 us_source_type varchar(50),
1352
1353 -- the date/time on which the file was added
1354 us_timestamp varbinary(14) NOT NULL,
1355
1356 us_status varchar(50) NOT NULL,
1357
1358 -- chunk counter starts at 0, current offset is stored in us_size
1359 us_chunk_inx int unsigned NULL,
1360
1361 -- Serialized file properties from FSFile::getProps()
1362 us_props blob,
1363
1364 -- file size in bytes
1365 us_size int unsigned NOT NULL,
1366 -- this hash comes from FSFile::getSha1Base36(), and is 31 characters
1367 us_sha1 varchar(31) NOT NULL,
1368 us_mime varchar(255),
1369 -- Media type as defined by the MEDIATYPE_xxx constants, should duplicate definition in the image table
1370 us_media_type ENUM("UNKNOWN", "BITMAP", "DRAWING", "AUDIO", "VIDEO", "MULTIMEDIA", "OFFICE", "TEXT", "EXECUTABLE", "ARCHIVE", "3D") default NULL,
1371 -- image-specific properties
1372 us_image_width int unsigned,
1373 us_image_height int unsigned,
1374 us_image_bits smallint unsigned
1375
1376 ) /*$wgDBTableOptions*/;
1377
1378 -- sometimes there's a delete for all of a user's stuff.
1379 CREATE INDEX /*i*/us_user ON /*_*/uploadstash (us_user);
1380 -- pick out files by key, enforce key uniqueness
1381 CREATE UNIQUE INDEX /*i*/us_key ON /*_*/uploadstash (us_key);
1382 -- the abandoned upload cleanup script needs this
1383 CREATE INDEX /*i*/us_timestamp ON /*_*/uploadstash (us_timestamp);
1384
1385
1386 --
1387 -- Primarily a summary table for Special:Recentchanges,
1388 -- this table contains some additional info on edits from
1389 -- the last few days, see Article::editUpdates()
1390 --
1391 CREATE TABLE /*_*/recentchanges (
1392 rc_id int NOT NULL PRIMARY KEY AUTO_INCREMENT,
1393 rc_timestamp varbinary(14) NOT NULL default '',
1394
1395 -- As in revision
1396 rc_user int unsigned NOT NULL default 0, -- Deprecated in favor of rc_actor
1397 rc_user_text varchar(255) binary NOT NULL DEFAULT '', -- Deprecated in favor of rc_actor
1398 rc_actor bigint unsigned NOT NULL DEFAULT 0, -- ("DEFAULT 0" is temporary, signaling that rc_user/rc_user_text should be used)
1399
1400 -- When pages are renamed, their RC entries do _not_ change.
1401 rc_namespace int NOT NULL default 0,
1402 rc_title varchar(255) binary NOT NULL default '',
1403
1404 -- as in revision...
1405 rc_comment varbinary(767) NOT NULL default '', -- Deprecated.
1406 rc_comment_id bigint unsigned NOT NULL DEFAULT 0, -- ("DEFAULT 0" is temporary, signaling that rc_comment should be used)
1407 rc_minor tinyint unsigned NOT NULL default 0,
1408
1409 -- Edits by user accounts with the 'bot' rights key are
1410 -- marked with a 1 here, and will be hidden from the
1411 -- default view.
1412 rc_bot tinyint unsigned NOT NULL default 0,
1413
1414 -- Set if this change corresponds to a page creation
1415 rc_new tinyint unsigned NOT NULL default 0,
1416
1417 -- Key to page_id (was cur_id prior to 1.5).
1418 -- This will keep links working after moves while
1419 -- retaining the at-the-time name in the changes list.
1420 rc_cur_id int unsigned NOT NULL default 0,
1421
1422 -- rev_id of the given revision
1423 rc_this_oldid int unsigned NOT NULL default 0,
1424
1425 -- rev_id of the prior revision, for generating diff links.
1426 rc_last_oldid int unsigned NOT NULL default 0,
1427
1428 -- The type of change entry (RC_EDIT,RC_NEW,RC_LOG,RC_EXTERNAL)
1429 rc_type tinyint unsigned NOT NULL default 0,
1430
1431 -- The source of the change entry (replaces rc_type)
1432 -- default of '' is temporary, needed for initial migration
1433 rc_source varchar(16) binary not null default '',
1434
1435 -- If the Recent Changes Patrol option is enabled,
1436 -- users may mark edits as having been reviewed to
1437 -- remove a warning flag on the RC list.
1438 -- A value of 1 indicates the page has been reviewed.
1439 rc_patrolled tinyint unsigned NOT NULL default 0,
1440
1441 -- Recorded IP address the edit was made from, if the
1442 -- $wgPutIPinRC option is enabled.
1443 rc_ip varbinary(40) NOT NULL default '',
1444
1445 -- Text length in characters before
1446 -- and after the edit
1447 rc_old_len int,
1448 rc_new_len int,
1449
1450 -- Visibility of recent changes items, bitfield
1451 rc_deleted tinyint unsigned NOT NULL default 0,
1452
1453 -- Value corresponding to log_id, specific log entries
1454 rc_logid int unsigned NOT NULL default 0,
1455 -- Store log type info here, or null
1456 rc_log_type varbinary(255) NULL default NULL,
1457 -- Store log action or null
1458 rc_log_action varbinary(255) NULL default NULL,
1459 -- Log params
1460 rc_params blob NULL
1461 ) /*$wgDBTableOptions*/;
1462
1463 -- Special:Recentchanges
1464 CREATE INDEX /*i*/rc_timestamp ON /*_*/recentchanges (rc_timestamp);
1465
1466 -- Special:Watchlist
1467 CREATE INDEX /*i*/rc_namespace_title_timestamp ON /*_*/recentchanges (rc_namespace, rc_title, rc_timestamp);
1468
1469 -- Special:Recentchangeslinked when finding changes in pages linked from a page
1470 CREATE INDEX /*i*/rc_cur_id ON /*_*/recentchanges (rc_cur_id);
1471
1472 -- Special:Newpages
1473 CREATE INDEX /*i*/new_name_timestamp ON /*_*/recentchanges (rc_new,rc_namespace,rc_timestamp);
1474
1475 -- Blank unless $wgPutIPinRC=true (false at WMF), possibly used by extensions,
1476 -- but mostly replaced by CheckUser.
1477 CREATE INDEX /*i*/rc_ip ON /*_*/recentchanges (rc_ip);
1478
1479 -- Probably intended for Special:NewPages namespace filter
1480 CREATE INDEX /*i*/rc_ns_usertext ON /*_*/recentchanges (rc_namespace, rc_user_text);
1481 CREATE INDEX /*i*/rc_ns_actor ON /*_*/recentchanges (rc_namespace, rc_actor);
1482
1483 -- SiteStats active user count, Special:ActiveUsers, Special:NewPages user filter
1484 CREATE INDEX /*i*/rc_user_text ON /*_*/recentchanges (rc_user_text, rc_timestamp);
1485 CREATE INDEX /*i*/rc_actor ON /*_*/recentchanges (rc_actor, rc_timestamp);
1486
1487 -- ApiQueryRecentChanges (T140108)
1488 CREATE INDEX /*i*/rc_name_type_patrolled_timestamp ON /*_*/recentchanges (rc_namespace, rc_type, rc_patrolled, rc_timestamp);
1489
1490
1491 CREATE TABLE /*_*/watchlist (
1492 wl_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
1493 -- Key to user.user_id
1494 wl_user int unsigned NOT NULL,
1495
1496 -- Key to page_namespace/page_title
1497 -- Note that users may watch pages which do not exist yet,
1498 -- or existed in the past but have been deleted.
1499 wl_namespace int NOT NULL default 0,
1500 wl_title varchar(255) binary NOT NULL default '',
1501
1502 -- Timestamp used to send notification e-mails and show "updated since last visit" markers on
1503 -- history and recent changes / watchlist. Set to NULL when the user visits the latest revision
1504 -- of the page, which means that they should be sent an e-mail on the next change.
1505 wl_notificationtimestamp varbinary(14)
1506
1507 ) /*$wgDBTableOptions*/;
1508
1509 -- Special:Watchlist
1510 CREATE UNIQUE INDEX /*i*/wl_user ON /*_*/watchlist (wl_user, wl_namespace, wl_title);
1511
1512 -- Special:Movepage (WatchedItemStore::duplicateEntry)
1513 CREATE INDEX /*i*/namespace_title ON /*_*/watchlist (wl_namespace, wl_title);
1514
1515 -- ApiQueryWatchlistRaw changed filter
1516 CREATE INDEX /*i*/wl_user_notificationtimestamp ON /*_*/watchlist (wl_user, wl_notificationtimestamp);
1517
1518
1519 --
1520 -- When using the default MySQL search backend, page titles
1521 -- and text are munged to strip markup, do Unicode case folding,
1522 -- and prepare the result for MySQL's fulltext index.
1523 --
1524 -- This table must be MyISAM; InnoDB does not support the needed
1525 -- fulltext index.
1526 --
1527 CREATE TABLE /*_*/searchindex (
1528 -- Key to page_id
1529 si_page int unsigned NOT NULL,
1530
1531 -- Munged version of title
1532 si_title varchar(255) NOT NULL default '',
1533
1534 -- Munged version of body text
1535 si_text mediumtext NOT NULL
1536 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
1537
1538 CREATE UNIQUE INDEX /*i*/si_page ON /*_*/searchindex (si_page);
1539 CREATE FULLTEXT INDEX /*i*/si_title ON /*_*/searchindex (si_title);
1540 CREATE FULLTEXT INDEX /*i*/si_text ON /*_*/searchindex (si_text);
1541
1542
1543 --
1544 -- Recognized interwiki link prefixes
1545 --
1546 CREATE TABLE /*_*/interwiki (
1547 -- The interwiki prefix, (e.g. "Meatball", or the language prefix "de")
1548 iw_prefix varchar(32) NOT NULL,
1549
1550 -- The URL of the wiki, with "$1" as a placeholder for an article name.
1551 -- Any spaces in the name will be transformed to underscores before
1552 -- insertion.
1553 iw_url blob NOT NULL,
1554
1555 -- The URL of the file api.php
1556 iw_api blob NOT NULL,
1557
1558 -- The name of the database (for a connection to be established with wfGetLB( 'wikiid' ))
1559 iw_wikiid varchar(64) NOT NULL,
1560
1561 -- A boolean value indicating whether the wiki is in this project
1562 -- (used, for example, to detect redirect loops)
1563 iw_local bool NOT NULL,
1564
1565 -- Boolean value indicating whether interwiki transclusions are allowed.
1566 iw_trans tinyint NOT NULL default 0
1567 ) /*$wgDBTableOptions*/;
1568
1569 CREATE UNIQUE INDEX /*i*/iw_prefix ON /*_*/interwiki (iw_prefix);
1570
1571
1572 --
1573 -- Used for caching expensive grouped queries
1574 --
1575 CREATE TABLE /*_*/querycache (
1576 -- A key name, generally the base name of of the special page.
1577 qc_type varbinary(32) NOT NULL,
1578
1579 -- Some sort of stored value. Sizes, counts...
1580 qc_value int unsigned NOT NULL default 0,
1581
1582 -- Target namespace+title
1583 qc_namespace int NOT NULL default 0,
1584 qc_title varchar(255) binary NOT NULL default ''
1585 ) /*$wgDBTableOptions*/;
1586
1587 CREATE INDEX /*i*/qc_type ON /*_*/querycache (qc_type,qc_value);
1588
1589
1590 --
1591 -- For a few generic cache operations if not using Memcached
1592 --
1593 CREATE TABLE /*_*/objectcache (
1594 keyname varbinary(255) NOT NULL default '' PRIMARY KEY,
1595 value mediumblob,
1596 exptime datetime
1597 ) /*$wgDBTableOptions*/;
1598 CREATE INDEX /*i*/exptime ON /*_*/objectcache (exptime);
1599
1600
1601 --
1602 -- Cache of interwiki transclusion
1603 --
1604 CREATE TABLE /*_*/transcache (
1605 tc_url varbinary(255) NOT NULL PRIMARY KEY,
1606 tc_contents text,
1607 tc_time binary(14) NOT NULL
1608 ) /*$wgDBTableOptions*/;
1609
1610
1611 CREATE TABLE /*_*/logging (
1612 -- Log ID, for referring to this specific log entry, probably for deletion and such.
1613 log_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
1614
1615 -- Symbolic keys for the general log type and the action type
1616 -- within the log. The output format will be controlled by the
1617 -- action field, but only the type controls categorization.
1618 log_type varbinary(32) NOT NULL default '',
1619 log_action varbinary(32) NOT NULL default '',
1620
1621 -- Timestamp. Duh.
1622 log_timestamp binary(14) NOT NULL default '19700101000000',
1623
1624 -- The user who performed this action; key to user_id
1625 log_user int unsigned NOT NULL default 0, -- Deprecated in favor of log_actor
1626
1627 -- Name of the user who performed this action
1628 log_user_text varchar(255) binary NOT NULL default '', -- Deprecated in favor of log_actor
1629
1630 -- The actor who performed this action
1631 log_actor bigint unsigned NOT NULL DEFAULT 0, -- ("DEFAULT 0" is temporary, signaling that log_user/log_user_text should be used)
1632
1633 -- Key to the page affected. Where a user is the target,
1634 -- this will point to the user page.
1635 log_namespace int NOT NULL default 0,
1636 log_title varchar(255) binary NOT NULL default '',
1637 log_page int unsigned NULL,
1638
1639 -- Freeform text. Interpreted as edit history comments.
1640 -- Deprecated in favor of log_comment_id.
1641 log_comment varbinary(767) NOT NULL default '',
1642
1643 -- Key to comment_id. Comment summarizing the change.
1644 -- ("DEFAULT 0" is temporary, signaling that log_comment should be used)
1645 log_comment_id bigint unsigned NOT NULL DEFAULT 0,
1646
1647 -- miscellaneous parameters:
1648 -- LF separated list (old system) or serialized PHP array (new system)
1649 log_params blob NOT NULL,
1650
1651 -- rev_deleted for logs
1652 log_deleted tinyint unsigned NOT NULL default 0
1653 ) /*$wgDBTableOptions*/;
1654
1655 -- Special:Log type filter
1656 CREATE INDEX /*i*/type_time ON /*_*/logging (log_type, log_timestamp);
1657
1658 -- Special:Log performer filter
1659 CREATE INDEX /*i*/user_time ON /*_*/logging (log_user, log_timestamp);
1660 CREATE INDEX /*i*/actor_time ON /*_*/logging (log_actor, log_timestamp);
1661
1662 -- Special:Log title filter, log extract
1663 CREATE INDEX /*i*/page_time ON /*_*/logging (log_namespace, log_title, log_timestamp);
1664
1665 -- Special:Log unfiltered
1666 CREATE INDEX /*i*/times ON /*_*/logging (log_timestamp);
1667
1668 -- Special:Log filter by performer and type
1669 CREATE INDEX /*i*/log_user_type_time ON /*_*/logging (log_user, log_type, log_timestamp);
1670 CREATE INDEX /*i*/log_actor_type_time ON /*_*/logging (log_actor, log_type, log_timestamp);
1671
1672 -- Apparently just used for a few maintenance pages (findMissingFiles.php, Flow).
1673 -- Could be removed?
1674 CREATE INDEX /*i*/log_page_id_time ON /*_*/logging (log_page,log_timestamp);
1675
1676 -- Special:Log action filter
1677 CREATE INDEX /*i*/type_action ON /*_*/logging (log_type, log_action, log_timestamp);
1678
1679 -- Special:Log filter by type and anonymous performer
1680 CREATE INDEX /*i*/log_user_text_type_time ON /*_*/logging (log_user_text, log_type, log_timestamp);
1681
1682 -- Special:Log filter by anonymous performer
1683 CREATE INDEX /*i*/log_user_text_time ON /*_*/logging (log_user_text, log_timestamp);
1684
1685
1686 CREATE TABLE /*_*/log_search (
1687 -- The type of ID (rev ID, log ID, rev timestamp, username)
1688 ls_field varbinary(32) NOT NULL,
1689 -- The value of the ID
1690 ls_value varchar(255) NOT NULL,
1691 -- Key to log_id
1692 ls_log_id int unsigned NOT NULL default 0,
1693 PRIMARY KEY (ls_field,ls_value,ls_log_id)
1694 ) /*$wgDBTableOptions*/;
1695 CREATE INDEX /*i*/ls_log_id ON /*_*/log_search (ls_log_id);
1696
1697
1698 -- Jobs performed by parallel apache threads or a command-line daemon
1699 CREATE TABLE /*_*/job (
1700 job_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
1701
1702 -- Command name
1703 -- Limited to 60 to prevent key length overflow
1704 job_cmd varbinary(60) NOT NULL default '',
1705
1706 -- Namespace and title to act on
1707 -- Should be 0 and '' if the command does not operate on a title
1708 job_namespace int NOT NULL,
1709 job_title varchar(255) binary NOT NULL,
1710
1711 -- Timestamp of when the job was inserted
1712 -- NULL for jobs added before addition of the timestamp
1713 job_timestamp varbinary(14) NULL default NULL,
1714
1715 -- Any other parameters to the command
1716 -- Stored as a PHP serialized array, or an empty string if there are no parameters
1717 job_params blob NOT NULL,
1718
1719 -- Random, non-unique, number used for job acquisition (for lock concurrency)
1720 job_random integer unsigned NOT NULL default 0,
1721
1722 -- The number of times this job has been locked
1723 job_attempts integer unsigned NOT NULL default 0,
1724
1725 -- Field that conveys process locks on rows via process UUIDs
1726 job_token varbinary(32) NOT NULL default '',
1727
1728 -- Timestamp when the job was locked
1729 job_token_timestamp varbinary(14) NULL default NULL,
1730
1731 -- Base 36 SHA1 of the job parameters relevant to detecting duplicates
1732 job_sha1 varbinary(32) NOT NULL default ''
1733 ) /*$wgDBTableOptions*/;
1734
1735 CREATE INDEX /*i*/job_sha1 ON /*_*/job (job_sha1);
1736 CREATE INDEX /*i*/job_cmd_token ON /*_*/job (job_cmd,job_token,job_random);
1737 CREATE INDEX /*i*/job_cmd_token_id ON /*_*/job (job_cmd,job_token,job_id);
1738 CREATE INDEX /*i*/job_cmd ON /*_*/job (job_cmd, job_namespace, job_title, job_params(128));
1739 CREATE INDEX /*i*/job_timestamp ON /*_*/job (job_timestamp);
1740
1741
1742 -- Details of updates to cached special pages
1743 CREATE TABLE /*_*/querycache_info (
1744 -- Special page name
1745 -- Corresponds to a qc_type value
1746 qci_type varbinary(32) NOT NULL default '' PRIMARY KEY,
1747
1748 -- Timestamp of last update
1749 qci_timestamp binary(14) NOT NULL default '19700101000000'
1750 ) /*$wgDBTableOptions*/;
1751
1752
1753 -- For each redirect, this table contains exactly one row defining its target
1754 CREATE TABLE /*_*/redirect (
1755 -- Key to the page_id of the redirect page
1756 rd_from int unsigned NOT NULL default 0 PRIMARY KEY,
1757
1758 -- Key to page_namespace/page_title of the target page.
1759 -- The target page may or may not exist, and due to renames
1760 -- and deletions may refer to different page records as time
1761 -- goes by.
1762 rd_namespace int NOT NULL default 0,
1763 rd_title varchar(255) binary NOT NULL default '',
1764 rd_interwiki varchar(32) default NULL,
1765 rd_fragment varchar(255) binary default NULL
1766 ) /*$wgDBTableOptions*/;
1767
1768 CREATE INDEX /*i*/rd_ns_title ON /*_*/redirect (rd_namespace,rd_title,rd_from);
1769
1770
1771 -- Used for caching expensive grouped queries that need two links (for example double-redirects)
1772 CREATE TABLE /*_*/querycachetwo (
1773 -- A key name, generally the base name of of the special page.
1774 qcc_type varbinary(32) NOT NULL,
1775
1776 -- Some sort of stored value. Sizes, counts...
1777 qcc_value int unsigned NOT NULL default 0,
1778
1779 -- Target namespace+title
1780 qcc_namespace int NOT NULL default 0,
1781 qcc_title varchar(255) binary NOT NULL default '',
1782
1783 -- Target namespace+title2
1784 qcc_namespacetwo int NOT NULL default 0,
1785 qcc_titletwo varchar(255) binary NOT NULL default ''
1786 ) /*$wgDBTableOptions*/;
1787
1788 CREATE INDEX /*i*/qcc_type ON /*_*/querycachetwo (qcc_type,qcc_value);
1789 CREATE INDEX /*i*/qcc_title ON /*_*/querycachetwo (qcc_type,qcc_namespace,qcc_title);
1790 CREATE INDEX /*i*/qcc_titletwo ON /*_*/querycachetwo (qcc_type,qcc_namespacetwo,qcc_titletwo);
1791
1792
1793 -- Used for storing page restrictions (i.e. protection levels)
1794 CREATE TABLE /*_*/page_restrictions (
1795 -- Field for an ID for this restrictions row (sort-key for Special:ProtectedPages)
1796 pr_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
1797 -- Page to apply restrictions to (Foreign Key to page).
1798 pr_page int NOT NULL,
1799 -- The protection type (edit, move, etc)
1800 pr_type varbinary(60) NOT NULL,
1801 -- The protection level (Sysop, autoconfirmed, etc)
1802 pr_level varbinary(60) NOT NULL,
1803 -- Whether or not to cascade the protection down to pages transcluded.
1804 pr_cascade tinyint NOT NULL,
1805 -- Field for future support of per-user restriction.
1806 pr_user int unsigned NULL,
1807 -- Field for time-limited protection.
1808 pr_expiry varbinary(14) NULL
1809 ) /*$wgDBTableOptions*/;
1810
1811 CREATE UNIQUE INDEX /*i*/pr_pagetype ON /*_*/page_restrictions (pr_page,pr_type);
1812 CREATE INDEX /*i*/pr_typelevel ON /*_*/page_restrictions (pr_type,pr_level);
1813 CREATE INDEX /*i*/pr_level ON /*_*/page_restrictions (pr_level);
1814 CREATE INDEX /*i*/pr_cascade ON /*_*/page_restrictions (pr_cascade);
1815
1816
1817 -- Protected titles - nonexistent pages that have been protected
1818 CREATE TABLE /*_*/protected_titles (
1819 pt_namespace int NOT NULL,
1820 pt_title varchar(255) binary NOT NULL,
1821 pt_user int unsigned NOT NULL,
1822 pt_reason varbinary(767) default '', -- Deprecated.
1823 pt_reason_id bigint unsigned NOT NULL DEFAULT 0, -- ("DEFAULT 0" is temporary, signaling that pt_reason should be used)
1824 pt_timestamp binary(14) NOT NULL,
1825 pt_expiry varbinary(14) NOT NULL default '',
1826 pt_create_perm varbinary(60) NOT NULL
1827 ) /*$wgDBTableOptions*/;
1828
1829 CREATE UNIQUE INDEX /*i*/pt_namespace_title ON /*_*/protected_titles (pt_namespace,pt_title);
1830 CREATE INDEX /*i*/pt_timestamp ON /*_*/protected_titles (pt_timestamp);
1831
1832
1833 -- Name/value pairs indexed by page_id
1834 CREATE TABLE /*_*/page_props (
1835 pp_page int NOT NULL,
1836 pp_propname varbinary(60) NOT NULL,
1837 pp_value blob NOT NULL,
1838 pp_sortkey float DEFAULT NULL
1839 ) /*$wgDBTableOptions*/;
1840
1841 CREATE UNIQUE INDEX /*i*/pp_page_propname ON /*_*/page_props (pp_page,pp_propname);
1842 CREATE UNIQUE INDEX /*i*/pp_propname_page ON /*_*/page_props (pp_propname,pp_page);
1843 CREATE UNIQUE INDEX /*i*/pp_propname_sortkey_page ON /*_*/page_props (pp_propname,pp_sortkey,pp_page);
1844
1845 -- A table to log updates, one text key row per update.
1846 CREATE TABLE /*_*/updatelog (
1847 ul_key varchar(255) NOT NULL PRIMARY KEY,
1848 ul_value blob
1849 ) /*$wgDBTableOptions*/;
1850
1851
1852 -- A table to track tags for revisions, logs and recent changes.
1853 CREATE TABLE /*_*/change_tag (
1854 ct_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
1855 -- RCID for the change
1856 ct_rc_id int NULL,
1857 -- LOGID for the change
1858 ct_log_id int unsigned NULL,
1859 -- REVID for the change
1860 ct_rev_id int unsigned NULL,
1861 -- Tag applied
1862 ct_tag varchar(255) NOT NULL,
1863 -- Parameters for the tag; used by some extensions
1864 ct_params blob NULL
1865 ) /*$wgDBTableOptions*/;
1866
1867 CREATE UNIQUE INDEX /*i*/change_tag_rc_tag ON /*_*/change_tag (ct_rc_id,ct_tag);
1868 CREATE UNIQUE INDEX /*i*/change_tag_log_tag ON /*_*/change_tag (ct_log_id,ct_tag);
1869 CREATE UNIQUE INDEX /*i*/change_tag_rev_tag ON /*_*/change_tag (ct_rev_id,ct_tag);
1870 -- Covering index, so we can pull all the info only out of the index.
1871 CREATE INDEX /*i*/change_tag_tag_id ON /*_*/change_tag (ct_tag,ct_rc_id,ct_rev_id,ct_log_id);
1872
1873
1874 -- Rollup table to pull a LIST of tags simply without ugly GROUP_CONCAT
1875 -- that only works on MySQL 4.1+
1876 CREATE TABLE /*_*/tag_summary (
1877 ts_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
1878 -- RCID for the change
1879 ts_rc_id int NULL,
1880 -- LOGID for the change
1881 ts_log_id int unsigned NULL,
1882 -- REVID for the change
1883 ts_rev_id int unsigned NULL,
1884 -- Comma-separated list of tags
1885 ts_tags blob NOT NULL
1886 ) /*$wgDBTableOptions*/;
1887
1888 CREATE UNIQUE INDEX /*i*/tag_summary_rc_id ON /*_*/tag_summary (ts_rc_id);
1889 CREATE UNIQUE INDEX /*i*/tag_summary_log_id ON /*_*/tag_summary (ts_log_id);
1890 CREATE UNIQUE INDEX /*i*/tag_summary_rev_id ON /*_*/tag_summary (ts_rev_id);
1891
1892
1893 CREATE TABLE /*_*/valid_tag (
1894 vt_tag varchar(255) NOT NULL PRIMARY KEY
1895 ) /*$wgDBTableOptions*/;
1896
1897 -- Table for storing localisation data
1898 CREATE TABLE /*_*/l10n_cache (
1899 -- Language code
1900 lc_lang varbinary(32) NOT NULL,
1901 -- Cache key
1902 lc_key varchar(255) NOT NULL,
1903 -- Value
1904 lc_value mediumblob NOT NULL,
1905 PRIMARY KEY (lc_lang, lc_key)
1906 ) /*$wgDBTableOptions*/;
1907
1908 -- Table caching which local files a module depends on that aren't
1909 -- registered directly, used for fast retrieval of file dependency.
1910 -- Currently only used for tracking images that CSS depends on
1911 CREATE TABLE /*_*/module_deps (
1912 -- Module name
1913 md_module varbinary(255) NOT NULL,
1914 -- Module context vary (includes skin and language; called "md_skin" for legacy reasons)
1915 md_skin varbinary(32) NOT NULL,
1916 -- JSON blob with file dependencies
1917 md_deps mediumblob NOT NULL,
1918 PRIMARY KEY (md_module,md_skin)
1919 ) /*$wgDBTableOptions*/;
1920
1921 -- Holds all the sites known to the wiki.
1922 CREATE TABLE /*_*/sites (
1923 -- Numeric id of the site
1924 site_id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
1925
1926 -- Global identifier for the site, ie 'enwiktionary'
1927 site_global_key varbinary(32) NOT NULL,
1928
1929 -- Type of the site, ie 'mediawiki'
1930 site_type varbinary(32) NOT NULL,
1931
1932 -- Group of the site, ie 'wikipedia'
1933 site_group varbinary(32) NOT NULL,
1934
1935 -- Source of the site data, ie 'local', 'wikidata', 'my-magical-repo'
1936 site_source varbinary(32) NOT NULL,
1937
1938 -- Language code of the sites primary language.
1939 site_language varbinary(32) NOT NULL,
1940
1941 -- Protocol of the site, ie 'http://', 'irc://', '//'
1942 -- This field is an index for lookups and is build from type specific data in site_data.
1943 site_protocol varbinary(32) NOT NULL,
1944
1945 -- Domain of the site in reverse order, ie 'org.mediawiki.www.'
1946 -- This field is an index for lookups and is build from type specific data in site_data.
1947 site_domain VARCHAR(255) NOT NULL,
1948
1949 -- Type dependent site data.
1950 site_data BLOB NOT NULL,
1951
1952 -- If site.tld/path/key:pageTitle should forward users to the page on
1953 -- the actual site, where "key" is the local identifier.
1954 site_forward bool NOT NULL,
1955
1956 -- Type dependent site config.
1957 -- For instance if template transclusion should be allowed if it's a MediaWiki.
1958 site_config BLOB NOT NULL
1959 ) /*$wgDBTableOptions*/;
1960
1961 CREATE UNIQUE INDEX /*i*/sites_global_key ON /*_*/sites (site_global_key);
1962 CREATE INDEX /*i*/sites_type ON /*_*/sites (site_type);
1963 CREATE INDEX /*i*/sites_group ON /*_*/sites (site_group);
1964 CREATE INDEX /*i*/sites_source ON /*_*/sites (site_source);
1965 CREATE INDEX /*i*/sites_language ON /*_*/sites (site_language);
1966 CREATE INDEX /*i*/sites_protocol ON /*_*/sites (site_protocol);
1967 CREATE INDEX /*i*/sites_domain ON /*_*/sites (site_domain);
1968 CREATE INDEX /*i*/sites_forward ON /*_*/sites (site_forward);
1969
1970 -- Links local site identifiers to their corresponding site.
1971 CREATE TABLE /*_*/site_identifiers (
1972 -- Key on site.site_id
1973 si_site INT UNSIGNED NOT NULL,
1974
1975 -- local key type, ie 'interwiki' or 'langlink'
1976 si_type varbinary(32) NOT NULL,
1977
1978 -- local key value, ie 'en' or 'wiktionary'
1979 si_key varbinary(32) NOT NULL
1980 ) /*$wgDBTableOptions*/;
1981
1982 CREATE UNIQUE INDEX /*i*/site_ids_type ON /*_*/site_identifiers (si_type, si_key);
1983 CREATE INDEX /*i*/site_ids_site ON /*_*/site_identifiers (si_site);
1984 CREATE INDEX /*i*/site_ids_key ON /*_*/site_identifiers (si_key);
1985
1986 -- vim: sw=2 sts=2 et