-- Adds a user,timestamp index to the archive table
-- Used for browsing deleted contributions and renames
-ALTER TABLE /*$wgDBprefix*/archive
+ALTER TABLE /*$wgDBprefix*/archive
ADD INDEX usertext_timestamp ( ar_user_text , ar_timestamp );
---
+--
-- patch-backlinkindexes.sql
---
+--
-- Per bug 6440 / http://bugzilla.wikimedia.org/show_bug.cgi?id=6440
--
-- Improve performance of the "what links here"-type queries
---
+--
ALTER TABLE /*$wgDBprefix*/pagelinks
DROP INDEX pl_namespace,
ALTER TABLE /*$wgDBprefix*/templatelinks
DROP INDEX tl_namespace,
ADD INDEX tl_namespace(tl_namespace, tl_title, tl_from);
-
+
ALTER TABLE /*$wgDBprefix*/imagelinks
DROP INDEX il_to,
ADD INDEX il_to(il_to, il_from);
cat_files int signed NOT NULL default 0,
cat_hidden tinyint(1) unsigned NOT NULL default 0,
-
+
PRIMARY KEY (cat_id),
UNIQUE KEY (cat_title),
CREATE TABLE /*$wgDBprefix*/categorylinks (
-- Key to page_id of the page defined as a category member.
cl_from int unsigned NOT NULL default '0',
-
+
-- Name of the category.
-- This is also the page_title of the category's description page;
-- all such pages are in namespace 14 (NS_CATEGORY).
-- isn't always ideal, but collations seem to be an exciting
-- and dangerous new world in MySQL...
--
- -- Truncate so that the cl_sortkey key fits in 1000 bytes
+ -- Truncate so that the cl_sortkey key fits in 1000 bytes
-- (MyISAM 5 with server_character_set=utf8)
cl_sortkey varchar(70) binary NOT NULL default '',
-
+
-- This isn't really used at present. Provided for an optional
-- sorting method by approximate addition time.
cl_timestamp timestamp NOT NULL,
-
+
UNIQUE KEY cl_from(cl_from,cl_to),
-
+
-- This key is trouble. It's incomplete, AND it's too big
-- when collation is set to UTF-8. Bleeeacch!
KEY cl_sortkey(cl_to,cl_sortkey),
-
+
-- Not really used?
KEY cl_timestamp(cl_to,cl_timestamp)
---
+--
-- patch-categorylinksindex.sql
---
+--
-- Per bug 10280 / http://bugzilla.wikimedia.org/show_bug.cgi?id=10280
--
-- Improve enum continuation performance of the what pages belong to a category query
---
+--
ALTER TABLE /*$wgDBprefix*/categorylinks
DROP INDEX cl_sortkey,
el_from int(8) unsigned NOT NULL default '0',
el_to blob NOT NULL,
el_index blob NOT NULL,
-
+
KEY (el_from, el_to(40)),
KEY (el_to(60), el_from),
KEY (el_index(60))
-- Adding fa_deleted field for additional content suppression
-ALTER TABLE /*$wgDBprefix*/filearchive
+ALTER TABLE /*$wgDBprefix*/filearchive
ADD fa_deleted tinyint unsigned NOT NULL default '0';
-- Adding index to sort by uploader
-ALTER TABLE /*$wgDBprefix*/filearchive
+ALTER TABLE /*$wgDBprefix*/filearchive
ADD INDEX fa_user_timestamp (fa_user_text,fa_timestamp),
-- Remove useless, incomplete index
DROP INDEX fa_deleted_user;
CREATE TABLE /*$wgDBprefix*/filearchive (
-- Unique row id
fa_id int not null auto_increment,
-
+
-- Original base filename; key to image.img_name, page.page_title, etc
fa_name varchar(255) binary NOT NULL default '',
-
+
-- Filename of archived file, if an old revision
fa_archive_name varchar(255) binary default '',
-
+
-- Which storage bin (directory tree or object store) the file data
-- is stored in. Should be 'deleted' for files that have been deleted;
-- any other bin is not yet in use.
fa_storage_group varbinary(16),
-
+
-- SHA-1 of the file contents plus extension, used as a key for storage.
-- eg 8f8a562add37052a1848ff7771a2c515db94baa9.jpg
--
-- If NULL, the file was missing at deletion time or has been purged
-- from the archival storage.
fa_storage_key varbinary(64) default '',
-
+
-- Deletion information, if this file is deleted.
fa_deleted_user int,
fa_deleted_timestamp binary(14) default '',
fa_deleted_reason text,
-
+
-- Duped fields from image
fa_size int unsigned default '0',
fa_width int default '0',
fa_user int unsigned default '0',
fa_user_text varchar(255) binary default '',
fa_timestamp binary(14) default '',
-
+
PRIMARY KEY (fa_id),
INDEX (fa_name, fa_timestamp), -- pick out by image name
INDEX (fa_storage_group, fa_storage_key), -- pick out dupe files
--
--- hitcounter table is used to buffer page hits before they are periodically
+-- hitcounter table is used to buffer page hits before they are periodically
-- counted and added to the cur_counter column in the cur table.
-- December 2003
--
---
+--
-- image-user-index.sql
---
+--
-- Add user/timestamp index to current image versions
---
+--
ALTER TABLE /*$wgDBprefix*/image
ADD INDEX img_usertext_timestamp (img_user_text,img_timestamp);
ALTER TABLE /*$wgDBprefix*/image ADD (
-- Media type as defined by the MEDIATYPE_xxx constants
img_media_type ENUM("UNKNOWN", "BITMAP", "DRAWING", "AUDIO", "VIDEO", "MULTIMEDIA", "OFFICE", "TEXT", "EXECUTABLE", "ARCHIVE") default NULL,
-
+
-- major part of a MIME media type as defined by IANA
-- see http://www.iana.org/assignments/media-types/
img_major_mime ENUM("unknown", "application", "audio", "image", "text", "video", "message", "model", "multipart") NOT NULL default "unknown",
-
+
-- minor part of a MIME media type as defined by IANA
-- the minor parts are not required to adher to any standard
-- but should be consistent throughout the database
---
+--
-- patch-indexes.sql
---
+--
-- Fix up table indexes; new to stable release in November 2003
---
+--
ALTER TABLE IF EXISTS /*$wgDBprefix*/links
DROP INDEX l_from,
CREATE TABLE /*$wgDBprefix*/interwiki (
-- The interwiki prefix, (e.g. "Meatball", or the language prefix "de")
iw_prefix varchar(32) NOT NULL,
-
+
-- The URL of the wiki, with "$1" as a placeholder for an article name.
-- Any spaces in the name will be transformed to underscores before
-- insertion.
iw_url blob NOT NULL,
-
+
-- A boolean value indicating whether the wiki is in this project
-- (used, for example, to detect redirect loops)
iw_local BOOL NOT NULL,
-
+
UNIQUE KEY iw_prefix (iw_prefix)
) /*$wgDBTableOptions*/;
--- Add extra option fields to the ipblocks table, add some extra indexes,
--- convert infinity values in ipb_expiry to something that sorts better,
--- extend ipb_address and range fields, add a unique index for block conflict
+-- Add extra option fields to the ipblocks table, add some extra indexes,
+-- convert infinity values in ipb_expiry to something that sorts better,
+-- extend ipb_address and range fields, add a unique index for block conflict
-- detection.
--- Conflicts in the new unique index can be handled by creating a new
+-- Conflicts in the new unique index can be handled by creating a new
-- table and inserting into it instead of doing an ALTER TABLE.
ipb_expiry varbinary(14) NOT NULL default '',
ipb_range_start tinyblob NOT NULL,
ipb_range_end tinyblob NOT NULL,
-
+
PRIMARY KEY ipb_id (ipb_id),
UNIQUE INDEX ipb_address_unique (ipb_address(255), ipb_user, ipb_auto),
INDEX ipb_user (ipb_user),
) /*$wgDBTableOptions*/;
-INSERT IGNORE INTO /*$wgDBprefix*/ipblocks_newunique
- (ipb_id, ipb_address, ipb_user, ipb_by, ipb_reason, ipb_timestamp, ipb_auto, ipb_expiry, ipb_range_start, ipb_range_end, ipb_anon_only, ipb_create_account)
+INSERT IGNORE INTO /*$wgDBprefix*/ipblocks_newunique
+ (ipb_id, ipb_address, ipb_user, ipb_by, ipb_reason, ipb_timestamp, ipb_auto, ipb_expiry, ipb_range_start, ipb_range_end, ipb_anon_only, ipb_create_account)
SELECT ipb_id, ipb_address, ipb_user, ipb_by, ipb_reason, ipb_timestamp, ipb_auto, ipb_expiry, ipb_range_start, ipb_range_end, 0 , ipb_user=0
FROM /*$wgDBprefix*/ipblocks;
ALTER TABLE /*$wgDBprefix*/ipblocks
ADD ipb_by_text varchar(255) binary NOT NULL default '';
-UPDATE /*$wgDBprefix*/ipblocks
+UPDATE /*$wgDBprefix*/ipblocks
JOIN /*$wgDBprefix*/user ON ipb_by = user_id
SET ipb_by_text = user_name
WHERE ipb_by != 0;
\ No newline at end of file
-- Adding ipb_deleted field for hiding usernames
-ALTER TABLE /*$wgDBprefix*/ipblocks
+ALTER TABLE /*$wgDBprefix*/ipblocks
ADD ipb_deleted bool NOT NULL default 0;
-- Add the range handling fields
-ALTER TABLE /*$wgDBprefix*/ipblocks
+ALTER TABLE /*$wgDBprefix*/ipblocks
ADD ipb_range_start tinyblob NOT NULL default '',
ADD ipb_range_end tinyblob NOT NULL default '',
ADD INDEX ipb_range (ipb_range_start(8), ipb_range_end(8));
-- Initialise fields
-- Only range blocks match ipb_address LIKE '%/%', this fact is used in the code already
-UPDATE /*$wgDBprefix*/ipblocks
- SET
- ipb_range_start = LPAD(HEX(
+UPDATE /*$wgDBprefix*/ipblocks
+ SET
+ ipb_range_start = LPAD(HEX(
(SUBSTRING_INDEX(ipb_address, '.', 1) << 24)
+ (SUBSTRING_INDEX(SUBSTRING_INDEX(ipb_address, '.', 2), '.', -1) << 16)
+ (SUBSTRING_INDEX(SUBSTRING_INDEX(ipb_address, '.', 3), '.', -1) << 24)
+ (SUBSTRING_INDEX(SUBSTRING_INDEX(ipb_address, '/', 1), '.', -1)) ), 8, '0' ),
- ipb_range_end = LPAD(HEX(
+ ipb_range_end = LPAD(HEX(
(SUBSTRING_INDEX(ipb_address, '.', 1) << 24)
+ (SUBSTRING_INDEX(SUBSTRING_INDEX(ipb_address, '.', 2), '.', -1) << 16)
+ (SUBSTRING_INDEX(SUBSTRING_INDEX(ipb_address, '.', 3), '.', -1) << 24)
---
+--
-- Track inline interwiki links
--
CREATE TABLE /*_*/iwlinks (
-- page_id of the referring page
iwl_from int unsigned NOT NULL default 0,
-
+
-- Interwiki prefix code of the target
iwl_prefix varbinary(20) NOT NULL default '',
-- Jobs performed by parallel apache threads or a command-line daemon
CREATE TABLE /*_*/job (
job_id int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT,
-
+
-- Command name
-- Limited to 60 to prevent key length overflow
job_cmd varbinary(60) NOT NULL default '',
CREATE TABLE /*$wgDBprefix*/langlinks (
-- page_id of the referring page
ll_from int unsigned NOT NULL default '0',
-
+
-- Language code of the target
ll_lang varbinary(20) NOT NULL default '',
CREATE TABLE /*$wgDBprefix*/links (
-- Key to the page_id of the page containing the link.
l_from int unsigned NOT NULL default '0',
-
+
-- Key to the page_id of the link target.
-- An unfortunate consequence of this is that rename
-- operations require changing the links entries for
-- all links to the moved page.
l_to int unsigned NOT NULL default '0',
-
+
UNIQUE KEY l_from(l_from,l_to),
KEY (l_to)
CREATE TABLE /*$wgDBprefix*/brokenlinks (
-- Key to the page_id of the page containing the link.
bl_from int unsigned NOT NULL default '0',
-
+
-- Text of the target page title ("namesapce:title").
-- Unfortunately this doesn't split the namespace index
-- key and therefore can't easily be joined to anything.
CREATE TABLE /*$wgDBprefix*/imagelinks (
-- Key to page_id of the page containing the image / media link.
il_from int unsigned NOT NULL default '0',
-
+
-- Filename of target image.
-- This is also the page_title of the file's description page;
-- all such pages are in namespace 6 (NS_FILE).
il_to varchar(255) binary NOT NULL default '',
-
+
UNIQUE KEY il_from(il_from,il_to),
KEY (il_to)
-- Rename the primary unique index from PRIMARY to ls_field_val
-- This is for MySQL only and is necessary only for databases which were updated
-- between MW 1.16 development revisions r50567 and r51465.
-ALTER TABLE /*_*/log_search
- DROP PRIMARY KEY,
+ALTER TABLE /*_*/log_search
+ DROP PRIMARY KEY,
ADD UNIQUE INDEX ls_field_val (ls_field,ls_value,ls_log_id);
-ALTER TABLE /*$wgDBprefix*/logging
+ALTER TABLE /*$wgDBprefix*/logging
ADD log_user_text varchar(255) binary NOT NULL default '',
ADD log_page int unsigned NULL,
CHANGE log_type log_type varbinary(32) NOT NULL,
---
+--
-- patch-logging-times-index.sql
---
+--
-- Add a very humble index on logging times
---
+--
ALTER TABLE /*$wgDBprefix*/logging
ADD INDEX times (log_timestamp);
-- action field, but only the type controls categorization.
log_type varbinary(10) NOT NULL default '',
log_action varbinary(10) NOT NULL default '',
-
+
-- Timestamp. Duh.
log_timestamp binary(14) NOT NULL default '19700101000000',
-
+
-- The user who performed this action; key to user_id
log_user int unsigned NOT NULL default 0,
-
+
-- Key to the page affected. Where a user is the target,
-- this will point to the user page.
log_namespace int NOT NULL default 0,
log_title varchar(255) binary NOT NULL default '',
-
+
-- Freeform text. Interpreted as edit history comments.
log_comment varchar(255) NOT NULL default '',
-
+
-- LF separated list of miscellaneous parameters
log_params blob NOT NULL,
ALTER TABLE /*_*/image
MODIFY COLUMN img_minor_mime varbinary(100) NOT NULL default "unknown";
-
+
ALTER TABLE /*_*/oldimage
MODIFY COLUMN oi_minor_mime varbinary(100) NOT NULL default "unknown";
-
+
INSERT INTO /*_*/updatelog(ul_key) VALUES ('mime_minor_length');
CREATE TABLE /*_*/msg_resource (
-- Resource name
mr_resource varbinary(255) NOT NULL,
- -- Language code
+ -- Language code
mr_lang varbinary(32) NOT NULL,
-- JSON blob. This is an incomplete JSON object, i.e. without the wrapping {}
mr_blob mediumblob NOT NULL,
---
+--
-- patch-oi_metadata.sql
---
+--
-- Add data to allow for direct reference to old images
-- Some re-indexing here.
-- Old images can be included into pages effeciently now.
---
+--
ALTER TABLE /*$wgDBprefix*/oldimage
DROP INDEX oi_name,
---
+--
-- oldimage-user-index.sql
---
+--
-- Add user/timestamp index to old image versions
---
+--
ALTER TABLE /*$wgDBprefix*/oldimage
ADD INDEX oi_usertext_timestamp (oi_user_text,oi_timestamp);
--
-- Create the new pagelinks table to merge links and brokenlinks data,
-- and populate it.
---
+--
-- Unlike the old links and brokenlinks, these records will not need to be
-- altered when target pages are created, deleted, or renamed. This should
-- reduce the amount of severe database frustration that happens when widely-
CREATE TABLE /*$wgDBprefix*/pagelinks (
-- Key to the page_id of the page containing the link.
pl_from int unsigned NOT NULL default '0',
-
+
-- Key to page_namespace/page_title of the target page.
-- The target page may or may not exist, and due to renames
-- and deletions may refer to different page records as time
-- goes by.
pl_namespace int NOT NULL default '0',
pl_title varchar(255) binary NOT NULL default '',
-
+
UNIQUE KEY pl_from(pl_from,pl_namespace,pl_title),
KEY (pl_namespace,pl_title)
--
--- parsercache table, for cacheing complete parsed articles
+-- parsercache table, for cacheing complete parsed articles
-- before they are imbedded in the skin.
--
---
+--
-- patch-pl-tl-il-unique-index.sql
---
+--
-- Make reorderings of UNIQUE indices UNIQUE as well
DROP INDEX /*i*/pl_namespace ON /*_*/pagelinks;
CREATE TABLE /*$wgDBprefix*/querycache (
-- A key name, generally the base name of of the special page.
qc_type varbinary(32) NOT NULL,
-
+
-- Some sort of stored value. Sizes, counts...
qc_value int unsigned NOT NULL default '0',
-
+
-- Target namespace+title
qc_namespace int NOT NULL default '0',
qc_title varchar(255) binary NOT NULL default '',
-
+
KEY (qc_type,qc_value)
) /*$wgDBTableOptions*/;
CREATE TABLE /*$wgDBprefix*/querycachetwo (
-- A key name, generally the base name of of the special page.
qcc_type varbinary(32) NOT NULL,
-
+
-- Some sort of stored value. Sizes, counts...
qcc_value int unsigned NOT NULL default '0',
-
+
-- Target namespace+title
qcc_namespace int NOT NULL default '0',
qcc_title varchar(255) binary NOT NULL default '',
-
+
-- Target namespace+title2
qcc_namespacetwo int NOT NULL default '0',
qcc_titletwo varchar(255) binary NOT NULL default '',
-- Adding rc_deleted field for revisiondelete
-- Add rc_logid to match log_id
-ALTER TABLE /*$wgDBprefix*/recentchanges
+ALTER TABLE /*$wgDBprefix*/recentchanges
ADD rc_deleted tinyint unsigned NOT NULL default '0',
ADD rc_logid int unsigned NOT NULL default '0',
ADD rc_log_type varbinary(255) NULL default NULL,
-- Primary key in recentchanges
-ALTER TABLE /*$wgDBprefix*/recentchanges
+ALTER TABLE /*$wgDBprefix*/recentchanges
ADD rc_id int NOT NULL auto_increment,
ADD PRIMARY KEY rc_id (rc_id);
-- Adding the rc_ip field for logging of IP addresses in recentchanges
-ALTER TABLE /*$wgDBprefix*/recentchanges
+ALTER TABLE /*$wgDBprefix*/recentchanges
ADD rc_ip varbinary(40) NOT NULL default '',
ADD INDEX rc_ip (rc_ip);
--
-- Create the new redirect table.
-- For each redirect, this table contains exactly one row defining its target
---
+--
CREATE TABLE /*$wgDBprefix*/redirect (
-- Key to the page_id of the redirect page
rd_from int unsigned NOT NULL default '0',
---
+--
-- Recreates the iwl_prefix index for the iwlinks table
--
CREATE UNIQUE INDEX /*i*/iwl_prefix_title_from ON /*_*/iwlinks (iwl_prefix, iwl_title, iwl_from);
rev_minor_edit tinyint unsigned NOT NULL default '0',
rev_deleted tinyint unsigned NOT NULL default '0',
-
PRIMARY KEY rev_page_id (rev_page, rev_id),
UNIQUE INDEX rev_id (rev_id),
INDEX rev_timestamp (rev_timestamp),
-- old_id int(8) unsigned NOT NULL auto_increment,
-- old_text mediumtext NOT NULL,
-- old_flags tinyblob NOT NULL,
---
+--
-- PRIMARY KEY old_id (old_id)
-- );
CREATE TABLE /*$wgDBprefix*/searchindex (
-- Key to page_id
si_page int unsigned NOT NULL,
-
+
-- Munged version of title
si_title varchar(255) NOT NULL default '',
-
+
-- Munged version of body text
si_text mediumtext NOT NULL,
-
+
UNIQUE KEY (si_page)
) ENGINE=MyISAM;
CREATE TABLE /*$wgDBprefix*/templatelinks (
-- Key to the page_id of the page containing the link.
tl_from int unsigned NOT NULL default '0',
-
+
-- Key to page_namespace/page_title of the target page.
-- The target page may or may not exist, and due to renames
-- and deletions may refer to different page records as time
-- goes by.
tl_namespace int NOT NULL default '0',
tl_title varchar(255) binary NOT NULL default '',
-
+
UNIQUE KEY tl_from(tl_from,tl_namespace,tl_title),
KEY (tl_namespace,tl_title)
-
) /*$wgDBTableOptions*/;
create table /*$wgDBprefix*/testrun (
tr_id int not null auto_increment,
-
+
tr_date char(14) binary,
tr_mw_version blob,
tr_php_version blob,
tr_db_version blob,
tr_uname blob,
-
+
primary key (tr_id)
) engine=InnoDB;
ti_run int not null,
ti_name varchar(255),
ti_success bool,
-
+
unique key (ti_run, ti_name),
key (ti_run, ti_success),
-
+
foreign key (ti_run) references /*$wgDBprefix*/testrun(tr_id)
on delete cascade
) engine=InnoDB;
--
--- Store information about newly uploaded files before they're
+-- Store information about newly uploaded files before they're
-- moved into the actual filestore
--
CREATE TABLE /*_*/uploadstash (
us_id int unsigned NOT NULL PRIMARY KEY auto_increment,
-
+
-- the user who uploaded the file.
us_user int unsigned NOT NULL,
-- the original path
us_orig_path varchar(255) NOT NULL,
-
+
-- the temporary path at which the file is actually stored
us_path varchar(255) NOT NULL,
-
+
-- which type of upload the file came from (sometimes)
us_source_type varchar(50),
-
+
-- the date/time on which the file was added
us_timestamp varbinary(14) not null,
-
+
us_status varchar(50) not null,
-- file properties from File::getPropsFromPath. these may prove unnecessary.
us_image_width int unsigned,
us_image_height int unsigned,
us_image_bits smallint unsigned
-
) /*$wgDBTableOptions*/;
-- sometimes there's a delete for all of a user's stuff.
-- Add a 'real name' field where users can specify the name they want
-- used for author attribution or other places that real names matter.
-ALTER TABLE user
+ALTER TABLE user
ADD (user_real_name varchar(255) binary NOT NULL default '');
--- Stores the groups the user has once belonged to.
+-- Stores the groups the user has once belonged to.
-- The user may still belong these groups. Check user_groups.
CREATE TABLE /*_*/user_former_groups (
-- Key to user_id
CREATE TABLE /*$wgDBprefix*/user_groups (
-- Key to user_id
ug_user int unsigned NOT NULL default '0',
-
+
-- Group names are short symbolic string keys.
-- The set of group names is open-ended, though in practice
-- only some predefined ones are likely to be used.
-- permissions of any group they're explicitly in, plus
-- the implicit '*' and 'user' groups.
ug_group varbinary(16) NOT NULL default '',
-
+
PRIMARY KEY (ug_user,ug_group),
KEY (ug_group)
) /*$wgDBTableOptions*/;
CREATE TABLE /*_*/user_properties(
-- Foreign key to user.user_id
up_user int not null,
-
+
-- Name of the option being saved. This is indexed for bulk lookup.
up_property varbinary(32) not null,
-
+
-- Property value as a string.
up_value blob
) /*$wgDBTableOptions*/;
CREATE TABLE /*$wgDBprefix*/user_rights (
-- Key to user_id
ur_user int unsigned NOT NULL,
-
+
-- Comma-separated list of permission keys
ur_rights tinyblob NOT NULL,
-
+
UNIQUE KEY ur_user (ur_user)
) /*$wgDBTableOptions*/;