- INDEX user_name (user_name(10))
-);
-
--- TODO: de-blob this; it should be a property table
-CREATE TABLE user_rights (
- user_id int(5) unsigned NOT NULL,
- user_rights tinyblob NOT NULL default '',
- UNIQUE KEY user_id (user_id)
-);
-
-CREATE TABLE 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)
-);
-
-CREATE TABLE cur (
- cur_id int(8) unsigned NOT NULL auto_increment,
- cur_namespace tinyint(2) unsigned NOT NULL default '0',
- cur_title varchar(255) binary NOT NULL default '',
- cur_text mediumtext NOT NULL default '',
- cur_comment tinyblob NOT NULL default '',
- cur_user int(5) unsigned NOT NULL default '0',
- cur_user_text varchar(255) binary NOT NULL default '',
- cur_timestamp char(14) binary NOT NULL default '',
- cur_restrictions tinyblob NOT NULL default '',
- cur_counter bigint(20) unsigned NOT NULL default '0',
- cur_is_redirect tinyint(1) unsigned NOT NULL default '0',
- cur_minor_edit tinyint(1) unsigned NOT NULL default '0',
- cur_is_new tinyint(1) unsigned NOT NULL default '0',
- cur_random real unsigned NOT NULL,
- cur_touched char(14) binary NOT NULL default '',
- inverse_timestamp char(14) binary NOT NULL default '',
- PRIMARY KEY cur_id (cur_id),
- UNIQUE INDEX name_title (cur_namespace,cur_title),
-
- -- Is this one necessary?
- INDEX cur_title (cur_title(20)),
-
- INDEX cur_timestamp (cur_timestamp),
- INDEX (cur_random),
- INDEX name_title_timestamp (cur_namespace,cur_title,inverse_timestamp),
- INDEX user_timestamp (cur_user,inverse_timestamp),
- INDEX usertext_timestamp (cur_user_text,inverse_timestamp),
- INDEX namespace_redirect_timestamp(cur_namespace,cur_is_redirect,cur_timestamp)
-);
-
-CREATE TABLE old (
+ UNIQUE INDEX user_name (user_name),
+ INDEX (user_email_token)
+
+) TYPE=InnoDB;
+
+--
+-- User permissions have been broken out to a separate table;
+-- this allows sites with a shared user table to have different
+-- permissions assigned to a user in each project.
+--
+-- This table replaces the old user_rights field which used a
+-- comma-separated blob.
+--
+CREATE TABLE /*$wgDBprefix*/user_groups (
+ -- Key to user_id
+ ug_user int(5) 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.
+ --
+ -- 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)
+-- );
+
+
+--
+-- Core of the wiki: each page has an entry here which identifies
+-- it by title and contains some essential metadata.
+--
+CREATE TABLE /*$wgDBprefix*/page (
+ -- Unique identifier number. The page_id will be preserved across
+ -- edits and rename operations, but not deletions and recreations.
+ page_id int(8) unsigned NOT NULL auto_increment,
+
+ -- A page name is broken into a namespace and a title.
+ -- The namespace keys are UI-language-independent constants,
+ -- defined in Namespace.php.
+ page_namespace int NOT NULL,
+
+ -- The rest of the title, as text.
+ -- Spaces are transformed into underscores in title storage.
+ page_title varchar(255) binary NOT NULL,
+
+ -- Comma-separated set of permission keys indicating who
+ -- can move or edit the page.
+ page_restrictions tinyblob NOT NULL default '',
+
+ -- Number of times this page has been viewed.
+ page_counter bigint(20) unsigned NOT NULL default '0',
+
+ -- 1 indicates the article is a redirect.
+ page_is_redirect tinyint(1) unsigned NOT NULL default '0',
+
+ -- 1 indicates this is a new entry, with only one edit.
+ -- Not all pages with one edit are new pages.
+ page_is_new tinyint(1) unsigned NOT NULL default '0',
+
+ -- Random value between 0 and 1, used for Special:Randompage
+ page_random real unsigned NOT NULL,
+
+ -- This timestamp is updated whenever the page changes in
+ -- a way requiring it to be re-rendered, invalidating caches.
+ -- Aside from editing this includes permission changes,
+ -- creation or deletion of linked pages, and alteration
+ -- of contained templates.
+ page_touched char(14) binary NOT NULL default '',
+
+ -- Handy key to revision.rev_id of the current revision.
+ -- This may be 0 during page creation, but that shouldn't
+ -- happen outside of a transaction... hopefully.
+ page_latest int(8) unsigned NOT NULL,
+
+ -- Uncompressed length in bytes of the page's current source text.
+ page_len int(8) unsigned NOT NULL,
+
+ PRIMARY KEY page_id (page_id),
+ UNIQUE INDEX name_title (page_namespace,page_title),
+
+ -- Special-purpose indexes
+ INDEX (page_random),
+ INDEX (page_len)
+
+) TYPE=InnoDB;
+
+--
+-- Every edit of a page creates also a revision row.
+-- This stores metadata about the revision, and a reference
+-- to the text storage backend.
+--
+CREATE TABLE /*$wgDBprefix*/revision (
+ rev_id int(8) unsigned NOT NULL auto_increment,
+
+ -- Key to page_id. This should _never_ be invalid.
+ rev_page int(8) unsigned NOT NULL,
+
+ -- Key to text.old_id, where the actual bulk text is stored.
+ -- It's possible for multiple revisions to use the same text,
+ -- for instance revisions where only metadata is altered
+ -- or a rollback to a previous version.
+ rev_text_id int(8) unsigned NOT NULL,
+
+ -- Text comment summarizing the change.
+ -- This text is shown in the history and other changes lists,
+ -- rendered in a subset of wiki markup.
+ rev_comment tinyblob NOT NULL default '',
+
+ -- Key to user_id of the user who made this edit.
+ -- Stores 0 for anonymous edits and for some mass imports.
+ rev_user int(5) unsigned NOT NULL default '0',
+
+ -- Text username or IP address of the editor.
+ rev_user_text varchar(255) binary NOT NULL default '',
+
+ -- Timestamp
+ rev_timestamp char(14) binary NOT NULL default '',
+
+ -- Records whether the user marked the 'minor edit' checkbox.
+ -- Many automated edits are marked as minor.
+ rev_minor_edit tinyint(1) unsigned NOT NULL default '0',
+
+ -- Not yet used; reserved for future changes to the deletion system.
+ rev_deleted tinyint(1) 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),
+ INDEX page_timestamp (rev_page,rev_timestamp),
+ INDEX user_timestamp (rev_user,rev_timestamp),
+ INDEX usertext_timestamp (rev_user_text,rev_timestamp)
+
+) TYPE=InnoDB;
+
+
+--
+-- Holds text of individual page revisions.
+--
+-- Field names are a holdover from the 'old' revisions table in
+-- MediaWiki 1.4 and earlier: an upgrade will transform that
+-- table into the 'text' table to minimize unnecessary churning
+-- and downtime. If upgrading, the other fields will be left unused.
+--
+CREATE TABLE /*$wgDBprefix*/text (
+ -- Unique text storage key number.
+ -- Note that the 'oldid' parameter used in URLs does *not*
+ -- refer to this number anymore, but to rev_id.