split prefs-help-userdata to prefs-help-realname & prefs-help-email. Nds still need...
[lhc/web/wiklou.git] / maintenance / tables.sql
index 00416f3..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,45 +338,6 @@ 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.
---
-CREATE TABLE /*$wgDBprefix*/links (
-  -- Key to the page_id of the page containing the link.
-  l_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',
-  
-  UNIQUE KEY l_from(l_from,l_to),
-  KEY (l_to)
-
-) 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 page-to-page hyperlinks within the wiki.
@@ -426,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.
@@ -434,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.
@@ -475,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;
@@ -482,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 (
@@ -764,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;
@@ -806,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;
 
@@ -845,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;