* simplified file description header or load.php
[lhc/web/wiklou.git] / maintenance / tables.sql
index a139280..2661b84 100644 (file)
@@ -417,6 +417,7 @@ CREATE TABLE /*_*/archive (
 
 CREATE INDEX /*i*/name_title_timestamp ON /*_*/archive (ar_namespace,ar_title,ar_timestamp);
 CREATE INDEX /*i*/ar_usertext_timestamp ON /*_*/archive (ar_user_text,ar_timestamp);
+CREATE INDEX /*i*/ar_page_revid ON /*_*/archive (ar_namespace, ar_title, ar_rev_id);
 
 
 --
@@ -489,29 +490,48 @@ CREATE TABLE /*_*/categorylinks (
   -- all such pages are in namespace 14 (NS_CATEGORY).
   cl_to varchar(255) binary NOT NULL default '',
   
-  -- The title of the linking page, or an optional override
-  -- to determine sort order. Sorting is by binary order, which
-  -- isn't always ideal, but collations seem to be an exciting
-  -- and dangerous new world in MySQL... The sortkey is updated
-  -- if no override exists and cl_from is renamed.
-  --
-  -- 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 '',
+  -- A binary string obtained by applying a sortkey generation algorithm
+  -- (Language::convertToSortkey()) to page_title, or cl_sortkey_prefix . "\0"
+  -- . page_title if cl_sortkey_prefix is nonempty.
+  cl_sortkey varbinary(255) NOT NULL default '',
+
+  -- A prefix for the raw sortkey manually specified by the user, either via
+  -- [[Category:Foo|prefix]] or {{defaultsort:prefix}}.  If nonempty, it's
+  -- concatenated with a null followed by the page title before the sortkey
+  -- conversion algorithm is run.  We store this so that we can update
+  -- collations without reparsing all pages.
+  cl_sortkey_prefix varchar(255) 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
+  cl_timestamp timestamp NOT NULL,
+
+  -- Stores $wgCategoryCollation at the time cl_sortkey was generated.  This
+  -- can be used to install new collation versions, tracking which rows are not
+  -- yet updated.  '' means no collation, this is a legacy row that needs to be
+  -- updated by updateCollation.php.  In the future, it might be possible to
+  -- specify different collations per category.
+  cl_collation varbinary(32) NOT NULL default '',
+
+  -- Stores whether cl_from is a category, file, or other page, so we can
+  -- paginate the three categories separately.  This never has to be updated
+  -- after the page is created, since none of these page types can be moved to
+  -- any other.
+  cl_type ENUM('page', 'subcat', 'file') NOT NULL default 'page'
 ) /*$wgDBTableOptions*/;
 
 CREATE UNIQUE INDEX /*i*/cl_from ON /*_*/categorylinks (cl_from,cl_to);
 
--- We always sort within a given category...
-CREATE INDEX /*i*/cl_sortkey ON /*_*/categorylinks (cl_to,cl_sortkey,cl_from);
+-- We always sort within a given category, and within a given type.  FIXME:
+-- Formerly this index didn't cover cl_type (since that didn't exist), so old
+-- callers won't be using an index: fix this?
+CREATE INDEX /*i*/cl_sortkey ON /*_*/categorylinks (cl_to,cl_type,cl_sortkey,cl_from);
 
 -- Not really used?
 CREATE INDEX /*i*/cl_timestamp ON /*_*/categorylinks (cl_to,cl_timestamp);
 
+-- For finding rows with outdated collation
+CREATE INDEX /*i*/cl_collation ON /*_*/categorylinks (cl_collation);
 
 -- 
 -- Track all existing categories.  Something is a category if 1) it has an en-
@@ -580,7 +600,7 @@ CREATE INDEX /*i*/el_index ON /*_*/externallinks (el_index(60));
 --
 CREATE TABLE /*_*/external_user (
   -- Foreign key to user_id
-  eu_wiki_id int unsigned NOT NULL PRIMARY KEY,
+  eu_local_id int unsigned NOT NULL PRIMARY KEY,
 
   -- Some opaque identifier provided by the external database
   eu_external_id varchar(255) binary NOT NULL
@@ -607,6 +627,24 @@ CREATE UNIQUE INDEX /*i*/ll_from ON /*_*/langlinks (ll_from, ll_lang);
 CREATE INDEX /*i*/ll_lang ON /*_*/langlinks (ll_lang, ll_title);
 
 
+-- 
+-- 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 '',
+
+  -- Title of the target, including namespace
+  iwl_title varchar(255) binary NOT NULL default ''
+) /*$wgDBTableOptions*/;
+
+CREATE UNIQUE INDEX /*i*/iwl_from ON /*_*/iwlinks (iwl_from, iwl_prefix, iwl_title);
+CREATE UNIQUE INDEX /*i*/iwl_prefix_title_from ON /*_*/iwlinks (iwl_prefix, iwl_title, iwl_from);
+
+
 --
 -- Contains a single row with some aggregate info
 -- on the state of the site.
@@ -764,7 +802,7 @@ CREATE TABLE /*_*/image (
   -- the minor parts are not required to adher to any standard
   -- but should be consistent throughout the database
   -- see http://www.iana.org/assignments/media-types/
-  img_minor_mime varbinary(32) NOT NULL default "unknown",
+  img_minor_mime varbinary(100) NOT NULL default "unknown",
   
   -- Description field as entered by the uploader.
   -- This is displayed in image upload history and logs.
@@ -782,9 +820,9 @@ CREATE TABLE /*_*/image (
 ) /*$wgDBTableOptions*/;
 
 CREATE INDEX /*i*/img_usertext_timestamp ON /*_*/image (img_user_text,img_timestamp);
--- Used by Special:Imagelist for sort-by-size
+-- Used by Special:ListFiles for sort-by-size
 CREATE INDEX /*i*/img_size ON /*_*/image (img_size);
--- Used by Special:Newimages and Special:Imagelist
+-- Used by Special:Newimages and Special:ListFiles
 CREATE INDEX /*i*/img_timestamp ON /*_*/image (img_timestamp);
 -- Used in API and duplicate search
 CREATE INDEX /*i*/img_sha1 ON /*_*/image (img_sha1);
@@ -816,7 +854,7 @@ CREATE TABLE /*_*/oldimage (
   oi_metadata mediumblob NOT NULL,
   oi_media_type ENUM("UNKNOWN", "BITMAP", "DRAWING", "AUDIO", "VIDEO", "MULTIMEDIA", "OFFICE", "TEXT", "EXECUTABLE", "ARCHIVE") default NULL,
   oi_major_mime ENUM("unknown", "application", "audio", "image", "text", "video", "message", "model", "multipart") NOT NULL default "unknown",
-  oi_minor_mime varbinary(32) NOT NULL default "unknown",
+  oi_minor_mime varbinary(100) NOT NULL default "unknown",
   oi_deleted tinyint unsigned NOT NULL default 0,
   oi_sha1 varbinary(32) NOT NULL default ''
 ) /*$wgDBTableOptions*/;
@@ -866,7 +904,7 @@ CREATE TABLE /*_*/filearchive (
   fa_bits int default 0,
   fa_media_type ENUM("UNKNOWN", "BITMAP", "DRAWING", "AUDIO", "VIDEO", "MULTIMEDIA", "OFFICE", "TEXT", "EXECUTABLE", "ARCHIVE") default NULL,
   fa_major_mime ENUM("unknown", "application", "audio", "image", "text", "video", "message", "model", "multipart") default "unknown",
-  fa_minor_mime varbinary(32) default "unknown",
+  fa_minor_mime varbinary(100) default "unknown",
   fa_description tinyblob,
   fa_user int unsigned default 0,
   fa_user_text varchar(255) binary,
@@ -1049,6 +1087,12 @@ CREATE TABLE /*_*/interwiki (
   -- insertion.
   iw_url blob NOT NULL,
   
+  -- The URL of the file api.php
+  iw_api blob NOT NULL,
+
+  -- The name of the database (for a connection to be established with wfGetLB( 'wikiid' ))
+  iw_wikiid varchar(64) 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,
@@ -1095,7 +1139,7 @@ CREATE INDEX /*i*/exptime ON /*_*/objectcache (exptime);
 CREATE TABLE /*_*/transcache (
   tc_url varbinary(255) NOT NULL,
   tc_contents text,
-  tc_time int NOT NULL
+  tc_time binary(14) NOT NULL
 ) /*$wgDBTableOptions*/;
 
 CREATE UNIQUE INDEX /*i*/tc_url_idx ON /*_*/transcache (tc_url);
@@ -1185,7 +1229,7 @@ CREATE TABLE /*_*/job (
   job_params blob NOT NULL
 ) /*$wgDBTableOptions*/;
 
-CREATE INDEX /*i*/job_cmd ON /*_*/job (job_cmd, job_namespace, job_title);
+CREATE INDEX /*i*/job_cmd ON /*_*/job (job_cmd, job_namespace, job_title, job_params(128));
 
 
 -- Details of updates to cached special pages
@@ -1292,17 +1336,23 @@ CREATE UNIQUE INDEX /*i*/pp_page_propname ON /*_*/page_props (pp_page,pp_propnam
 
 -- A table to log updates, one text key row per update.
 CREATE TABLE /*_*/updatelog (
-  ul_key varchar(255) NOT NULL PRIMARY KEY
+  ul_key varchar(255) NOT NULL PRIMARY KEY,
+  ul_value blob
 ) /*$wgDBTableOptions*/;
 
 
 -- A table to track tags for revisions, logs and recent changes.
 CREATE TABLE /*_*/change_tag (
-  ct_rc_id int NULL, -- RCID for the change
-  ct_log_id int NULL, -- LOGID for the change
-  ct_rev_id int NULL, -- REVID for the change
-  ct_tag varchar(255) NOT NULL, -- Tag applied
-  ct_params blob NULL -- Parameters for the tag, presently unused.
+  -- RCID for the change
+  ct_rc_id int NULL,
+  -- LOGID for the change
+  ct_log_id int NULL,
+  -- REVID for the change
+  ct_rev_id int NULL,
+  -- Tag applied
+  ct_tag varchar(255) NOT NULL,
+  -- Parameters for the tag, presently unused
+  ct_params blob NULL
 ) /*$wgDBTableOptions*/;
 
 CREATE UNIQUE INDEX /*i*/change_tag_rc_tag ON /*_*/change_tag (ct_rc_id,ct_tag);
@@ -1315,10 +1365,14 @@ CREATE INDEX /*i*/change_tag_tag_id ON /*_*/change_tag (ct_tag,ct_rc_id,ct_rev_i
 -- Rollup table to pull a LIST of tags simply without ugly GROUP_CONCAT
 -- that only works on MySQL 4.1+
 CREATE TABLE /*_*/tag_summary (
-  ts_rc_id int NULL, -- RCID for the change
-  ts_log_id int NULL, -- LOGID for the change
-  ts_rev_id int NULL, -- REVID for the change
-  ts_tags blob NOT NULL -- Comma-separated list of tags.
+  -- RCID for the change  
+  ts_rc_id int NULL,
+  -- LOGID for the change
+  ts_log_id int NULL,
+  -- REVID for the change
+  ts_rev_id int NULL,
+  -- Comma-separated list of tags
+  ts_tags blob NOT NULL
 ) /*$wgDBTableOptions*/;
 
 CREATE UNIQUE INDEX /*i*/tag_summary_rc_id ON /*_*/tag_summary (ts_rc_id);
@@ -1341,4 +1395,38 @@ CREATE TABLE /*_*/l10n_cache (
 ) /*$wgDBTableOptions*/;
 CREATE INDEX /*i*/lc_lang_key ON /*_*/l10n_cache (lc_lang, lc_key);
 
+-- Table for storing JSON message blobs for the resource loader
+CREATE TABLE /*_*/msg_resource (
+  -- Resource name
+  mr_resource varchar(255) NOT NULL,
+  -- Language code 
+  mr_lang varbinary(32) NOT NULL,
+  -- JSON blob
+  mr_blob mediumblob NOT NULL,
+  -- Timestamp of last update
+  mr_timestamp binary(14) NOT NULL
+) /*$wgDBTableOptions*/;
+CREATE UNIQUE INDEX /*i*/mr_resource_lang ON /*_*/msg_resource (mr_resource, mr_lang);
+
+-- Table for administering which message is contained in which resource
+CREATE TABLE /*_*/msg_resource_links (
+  mrl_resource varchar(255) NOT NULL,
+  -- Message key
+  mrl_message varchar(255) NOT NULL
+) /*$wgDBTableOptions*/;
+CREATE UNIQUE INDEX /*i*/mrl_message_resource ON /*_*/msg_resource_links (mrl_message, mrl_resource);
+
+-- Table for tracking which local files a module depends on that aren't
+-- registered directly.
+-- Currently only used for tracking images that CSS depends on
+CREATE TABLE /*_*/module_deps (
+  -- Module name
+  md_module varchar(255) NOT NULL,
+  -- Skin name
+  md_skin varchar(32) NOT NULL,
+  -- JSON blob with file dependencies
+  md_deps mediumblob NOT NULL
+) /*$wgDBTableOptions*/;
+CREATE UNIQUE INDEX /*i*/md_module_skin ON /*_*/module_deps (md_module, md_skin);
+
 -- vim: sw=2 sts=2 et