split prefs-help-userdata to prefs-help-realname & prefs-help-email. Nds still need...
[lhc/web/wiklou.git] / maintenance / tables.sql
index 9926966..e930183 100644 (file)
@@ -104,7 +104,7 @@ CREATE TABLE /*$wgDBprefix*/user (
   user_email_token_expires CHAR(14) BINARY,
 
   PRIMARY KEY user_id (user_id),
-  INDEX user_name (user_name(10)),
+  UNIQUE INDEX user_name (user_name),
   INDEX (user_email_token)
 
 ) TYPE=InnoDB;
@@ -114,27 +114,35 @@ CREATE TABLE /*$wgDBprefix*/user (
 -- this allows sites with a shared user table to have different
 -- permissions assigned to a user in each project.
 --
--- TODO: de-blob this; it should be a property table
+-- This table replaces the old user_rights field which used a
+-- comma-separated blob.
 --
-CREATE TABLE /*$wgDBprefix*/user_rights (
+CREATE TABLE /*$wgDBprefix*/user_groups (
   -- Key to user_id
-  ur_user int(5) unsigned NOT NULL,
-  
-  -- Comma-separated list of permission keys
-  ur_rights tinyblob NOT NULL default '',
+  ug_user int(5) unsigned NOT NULL default '0',
   
-  UNIQUE KEY ur_user (ur_user)
-
+  -- 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.
+  --
+  -- At runtime $wgGroupPermissions will associate group keys
+  -- with particular permissions. A user will have the combined
+  -- permissions of any group they're explicitly in, plus
+  -- the implicit '*' and 'user' groups.
+  ug_group char(16) NOT NULL default '',
+  
+  PRIMARY KEY (ug_user,ug_group),
+  KEY (ug_group)
 ) TYPE=InnoDB;
 
--- The following table is no longer needed with Enotif >= 2.00
--- Entries for newtalk on user_talk page are handled like in the watchlist table
--- CREATE TABLE /*$wgDBprefix*/user_newtalk (
---  user_id int(5) NOT NULL default '0',
---  user_ip varchar(40) NOT NULL default '',
---  INDEX user_id (user_id),
---  INDEX user_ip (user_ip)
--- );
+-- Stores notifications of user talk page changes, for the display
+-- of the "you have new messages" box
+CREATE TABLE /*$wgDBprefix*/user_newtalk (
+ user_id int(5) NOT NULL default '0',
+ user_ip varchar(40) NOT NULL default '',
+ INDEX user_id (user_id),
+ INDEX user_ip (user_ip)
+);
 
 
 --
@@ -261,7 +269,7 @@ CREATE TABLE /*$wgDBprefix*/text (
   
   -- Depending on the contents of the old_flags field, the text
   -- may be convenient plain text, or it may be funkily encoded.
-  old_text mediumtext NOT NULL default '',
+  old_text mediumblob NOT NULL default '',
   
   -- Comma-separated list of flags:
   -- gzip: text is compressed with PHP's gzdeflate() function.
@@ -293,7 +301,8 @@ CREATE TABLE /*$wgDBprefix*/archive (
   -- This field is retained for backwards compatibility,
   -- so old archived pages will remain accessible after
   -- upgrading from 1.4 to 1.5.
-  ar_text mediumtext NOT NULL default '',
+  -- Text may be gzipped or otherwise funky.
+  ar_text mediumblob NOT NULL default '',
   
   -- Basic revision stuff...
   ar_comment tinyblob NOT NULL default '',
@@ -329,44 +338,26 @@ CREATE TABLE /*$wgDBprefix*/archive (
 
 ) TYPE=InnoDB;
 
+
 --
--- Track links within the wiki that do exist.
--- These rows must be removed when the target page is
--- deleted, and replaced with brokenlinks entries.
--- They must also be updated if a target page is renamed.
+-- Track page-to-page hyperlinks within the wiki.
 --
-CREATE TABLE /*$wgDBprefix*/links (
+CREATE TABLE /*$wgDBprefix*/pagelinks (
   -- Key to the page_id of the page containing the link.
-  l_from int(8) unsigned NOT NULL default '0',
+  pl_from int(8) 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(8) 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 l_from(l_from,l_to),
-  KEY (l_to)
+  UNIQUE KEY pl_from(pl_from,pl_namespace,pl_title),
+  KEY (pl_namespace,pl_title)
 
 ) TYPE=InnoDB;
 
---
--- Track links to pages that don't yet exist.
--- These rows must be removed when the target page
--- is created, and replaced with links table entries.
---
-CREATE TABLE /*$wgDBprefix*/brokenlinks (
-  -- Key to the page_id of the page containing the link.
-  bl_from int(8) 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.
-  bl_to varchar(255) binary NOT NULL default '',
-  UNIQUE KEY bl_from(bl_from,bl_to),
-  KEY (bl_to)
-
-) TYPE=InnoDB;
 
 --
 -- Track links to images *used inline*
@@ -405,7 +396,12 @@ CREATE TABLE /*$wgDBprefix*/categorylinks (
   -- 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...
-  cl_sortkey varchar(255) binary NOT NULL default '',
+  --
+  -- For MySQL 4.1+ with charset set to utf8, the sort key *index*
+  -- needs cut to be smaller than 1024 bytes (at 3 bytes per char).
+  -- To sort properly on the shorter key, this field needs to be
+  -- the same shortness.
+  cl_sortkey varchar(86) binary NOT NULL default '',
   
   -- This isn't really used at present. Provided for an optional
   -- sorting method by approximate addition time.
@@ -413,26 +409,14 @@ CREATE TABLE /*$wgDBprefix*/categorylinks (
   
   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(128)),
+  -- We always sort within a given category...
+  KEY cl_sortkey(cl_to,cl_sortkey),
   
   -- Not really used?
   KEY cl_timestamp(cl_to,cl_timestamp)
 
 ) TYPE=InnoDB;
 
---
--- Stores (possibly gzipped) serialized objects with
--- cache arrays to reduce database load slurping up
--- from links and brokenlinks.
---
-CREATE TABLE /*$wgDBprefix*/linkscc (
-  lcc_pageid INT UNSIGNED NOT NULL UNIQUE KEY,
-  lcc_cacheobj MEDIUMBLOB NOT NULL
-
-) TYPE=InnoDB;
-
 --
 -- Contains a single row with some aggregate info
 -- on the state of the site.
@@ -454,6 +438,15 @@ CREATE TABLE /*$wgDBprefix*/site_stats (
   -- See isCountable() in includes/Article.php
   ss_good_articles bigint(20) unsigned default '0',
   
+  -- Total pages, theoretically equal to SELECT COUNT(*) FROM page; except faster
+  ss_total_pages bigint(20) default -1,
+
+  -- Number of users, theoretically equal to SELECT COUNT(*) FROM user;
+  ss_users bigint(20) default -1,
+
+  -- Deprecated, no longer updated as of 1.5
+  ss_admins int(10) default -1,
+
   UNIQUE KEY ss_row_id (ss_row_id)
 
 ) TYPE=InnoDB;
@@ -461,8 +454,8 @@ CREATE TABLE /*$wgDBprefix*/site_stats (
 --
 -- Stores an ID for every time any article is visited;
 -- depending on $wgHitcounterUpdateFreq, it is
--- periodically cleared and the cur_counter column
--- in the cur table updated for the all articles
+-- periodically cleared and the page_counter column
+-- in the page table updated for the all articles
 -- that have been visited.)
 --
 CREATE TABLE /*$wgDBprefix*/hitcounter (
@@ -531,9 +524,18 @@ CREATE TABLE /*$wgDBprefix*/image (
   -- For images, bits per pixel if known.
   img_bits int(3)  NOT NULL default '0',
   
-  -- File type key returned by getimagesize().
-  -- See http://www.php.net/getimagesize for possible values.
-  img_type int(3)  NOT NULL default '0',
+  -- 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
+  -- see http://www.iana.org/assignments/media-types/
+  img_minor_mime varchar(32) NOT NULL default "unknown",
   
   -- Description field as entered by the uploader.
   -- This is displayed in image upload history and logs.
@@ -574,7 +576,6 @@ CREATE TABLE /*$wgDBprefix*/oldimage (
   oi_width int(5) NOT NULL default 0,
   oi_height int(5) NOT NULL default 0,
   oi_bits int(3) NOT NULL default 0,
-  oi_type int(3) NOT NULL default 0,
   oi_description tinyblob NOT NULL default '',
   oi_user int(5) unsigned NOT NULL default '0',
   oi_user_text varchar(255) binary NOT NULL default '',
@@ -735,6 +736,9 @@ CREATE TABLE /*$wgDBprefix*/interwiki (
   -- (used, for example, to detect redirect loops)
   iw_local BOOL NOT NULL,
   
+  -- Boolean value indicating whether interwiki transclusions are allowed.
+  iw_trans TINYINT(1) NOT NULL DEFAULT 0,
+  
   UNIQUE KEY iw_prefix (iw_prefix)
 
 ) TYPE=InnoDB;
@@ -777,6 +781,7 @@ CREATE TABLE /*$wgDBprefix*/validate (
   `val_type` int(11) unsigned NOT NULL default '0',
   `val_value` int(11) default '0',
   `val_comment` varchar(255) NOT NULL default '',
+  `val_ip` varchar(20) NOT NULL default '',
   KEY `val_user` (`val_user`,`val_revision`)
 ) TYPE=InnoDB;
 
@@ -816,19 +821,11 @@ CREATE TABLE /*$wgDBprefix*/logging (
 
 
 -- Hold group name and description
-CREATE TABLE /*$wgDBprefix*/groups (
-  gr_id int(5) unsigned NOT NULL auto_increment,
-  gr_name varchar(50) NOT NULL default '',
-  gr_description varchar(255) NOT NULL default '',
-  gr_rights tinyblob,
-  PRIMARY KEY  (gr_id)
-
-) TYPE=InnoDB;
-
--- Relation table between user and groups
-CREATE TABLE /*$wgDBprefix*/user_groups (
-       ug_user int(5) unsigned NOT NULL default '0',
-       ug_group int(5) unsigned NOT NULL default '0',
-       PRIMARY KEY  (ug_user,ug_group)
-
-) TYPE=InnoDB;
+--CREATE TABLE /*$wgDBprefix*/groups (
+--  gr_id int(5) unsigned NOT NULL auto_increment,
+--  gr_name varchar(50) NOT NULL default '',
+--  gr_description varchar(255) NOT NULL default '',
+--  gr_rights tinyblob,
+--  PRIMARY KEY  (gr_id)
+--
+--) TYPE=InnoDB;