From f5282178d2ca3491f0f70916cc08ad0bf03c81bf Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Fri, 9 Mar 2007 21:51:11 +0000 Subject: [PATCH] *Add bitfields to various tables for revisiondelete --- maintenance/archives/patch-ar_deleted.sql | 3 +++ maintenance/archives/patch-fa_deleted.sql | 3 +++ maintenance/archives/patch-ipb_deleted.sql | 3 +++ maintenance/archives/patch-log_deleted.sql | 3 +++ maintenance/archives/patch-rc_deleted.sql | 8 +++++++ maintenance/mysql5/tables-binary.sql | 23 ++++++++++++++++++++ maintenance/mysql5/tables.sql | 25 +++++++++++++++++++++- maintenance/postgres/tables.sql | 19 ++++++++++++---- maintenance/updaters.inc | 9 ++++++-- 9 files changed, 89 insertions(+), 7 deletions(-) create mode 100644 maintenance/archives/patch-ar_deleted.sql create mode 100644 maintenance/archives/patch-fa_deleted.sql create mode 100644 maintenance/archives/patch-ipb_deleted.sql create mode 100644 maintenance/archives/patch-log_deleted.sql create mode 100644 maintenance/archives/patch-rc_deleted.sql diff --git a/maintenance/archives/patch-ar_deleted.sql b/maintenance/archives/patch-ar_deleted.sql new file mode 100644 index 0000000000..8bf98eb11d --- /dev/null +++ b/maintenance/archives/patch-ar_deleted.sql @@ -0,0 +1,3 @@ +-- Adding ar_deleted field for revisiondelete +ALTER TABLE /*$wgDBprefix*/archive + ADD ar_deleted tinyint(1) unsigned NOT NULL default '0'; \ No newline at end of file diff --git a/maintenance/archives/patch-fa_deleted.sql b/maintenance/archives/patch-fa_deleted.sql new file mode 100644 index 0000000000..a74bf474a9 --- /dev/null +++ b/maintenance/archives/patch-fa_deleted.sql @@ -0,0 +1,3 @@ +-- Adding fa_deleted field for additional content suppression +ALTER TABLE /*$wgDBprefix*/filearchive + ADD fa_deleted tinyint(1) unsigned NOT NULL default '0'; \ No newline at end of file diff --git a/maintenance/archives/patch-ipb_deleted.sql b/maintenance/archives/patch-ipb_deleted.sql new file mode 100644 index 0000000000..743f4d1295 --- /dev/null +++ b/maintenance/archives/patch-ipb_deleted.sql @@ -0,0 +1,3 @@ +-- Adding ipb_deleted field for hiding usernames +ALTER TABLE /*$wgDBprefix*/ipblocks + ADD ipb_deleted bool NOT NULL default 0; \ No newline at end of file diff --git a/maintenance/archives/patch-log_deleted.sql b/maintenance/archives/patch-log_deleted.sql new file mode 100644 index 0000000000..a108144b8a --- /dev/null +++ b/maintenance/archives/patch-log_deleted.sql @@ -0,0 +1,3 @@ +-- Adding ar_deleted field for revisiondelete +ALTER TABLE /*$wgDBprefix*/logging + ADD log_deleted tinyint(1) unsigned NOT NULL default '0'; \ No newline at end of file diff --git a/maintenance/archives/patch-rc_deleted.sql b/maintenance/archives/patch-rc_deleted.sql new file mode 100644 index 0000000000..dc1ee387a2 --- /dev/null +++ b/maintenance/archives/patch-rc_deleted.sql @@ -0,0 +1,8 @@ +-- Adding rc_deleted field for revisiondelete +-- Add rc_logid to match log_id +ALTER TABLE /*$wgDBprefix*/recentchanges + ADD rc_deleted tinyint(1) unsigned NOT NULL default '0', + ADD rc_logid int(10) unsigned NOT NULL default '0', + ADD rc_log_type varchar(255) binary NULL default NULL, + ADD rc_log_action varchar(255) binary NULL default NULL, + ADD rc_params blob NOT NULL default '', \ No newline at end of file diff --git a/maintenance/mysql5/tables-binary.sql b/maintenance/mysql5/tables-binary.sql index e75e903f12..b04d90d728 100644 --- a/maintenance/mysql5/tables-binary.sql +++ b/maintenance/mysql5/tables-binary.sql @@ -392,6 +392,9 @@ CREATE TABLE /*$wgDBprefix*/archive ( -- row upon undeletion. ar_text_id int(8) unsigned, + -- rev_deleted for archives + ar_deleted tinyint(1) unsigned NOT NULL default '0', + KEY name_title_timestamp (ar_namespace,ar_title,ar_timestamp) ) ENGINE=InnoDB, DEFAULT CHARSET=binary; @@ -634,6 +637,8 @@ CREATE TABLE /*$wgDBprefix*/ipblocks ( -- Size chosen to allow IPv6 ipb_range_start tinyblob NOT NULL, ipb_range_end tinyblob NOT NULL, + -- Flag for entries hidden from users and Sysops + ipb_deleted bool NOT NULL default 0, PRIMARY KEY ipb_id (ipb_id), @@ -776,6 +781,9 @@ CREATE TABLE /*$wgDBprefix*/filearchive ( fa_user_text varchar(255) binary, fa_timestamp char(14) binary default '', + -- Visibility of deleted revisions, bitfield + fa_deleted tinyint(1) unsigned NOT NULL default '0', + 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 @@ -844,6 +852,18 @@ CREATE TABLE /*$wgDBprefix*/recentchanges ( rc_old_len int(10), rc_new_len int(10), + -- Visibility of deleted revisions, bitfield + rc_deleted tinyint(1) unsigned NOT NULL default '0', + + -- Value corresonding to log_id, specific log entries + rc_logid int(10) unsigned NOT NULL default '0', + -- Store log type info here, or null + rc_log_type varchar(255) binary NULL default NULL, + -- Store log action or null + rc_log_action varchar(255) binary NULL default NULL, + -- Log params + rc_params blob NOT NULL default '', + PRIMARY KEY rc_id (rc_id), INDEX rc_timestamp (rc_timestamp), INDEX rc_namespace_title (rc_namespace, rc_title), @@ -1010,6 +1030,9 @@ CREATE TABLE /*$wgDBprefix*/logging ( -- LF separated list of miscellaneous parameters log_params blob NOT NULL, + + -- rev_deleted for logs + log_deleted tinyint(1) unsigned NOT NULL default '0', KEY type_time (log_type, log_timestamp), KEY user_time (log_user, log_timestamp), diff --git a/maintenance/mysql5/tables.sql b/maintenance/mysql5/tables.sql index 8a8fed1ca0..ac9e8e57a7 100644 --- a/maintenance/mysql5/tables.sql +++ b/maintenance/mysql5/tables.sql @@ -383,6 +383,9 @@ CREATE TABLE /*$wgDBprefix*/archive ( -- row upon undeletion. ar_text_id int(8) unsigned, + -- rev_deleted for archives + ar_deleted tinyint(1) unsigned NOT NULL default '0', + KEY name_title_timestamp (ar_namespace,ar_title,ar_timestamp) ) ENGINE=InnoDB, DEFAULT CHARSET=utf8; @@ -625,6 +628,8 @@ CREATE TABLE /*$wgDBprefix*/ipblocks ( -- Size chosen to allow IPv6 ipb_range_start tinyblob NOT NULL, ipb_range_end tinyblob NOT NULL, + -- Flag for entries hidden from users and Sysops + ipb_deleted bool NOT NULL default 0, PRIMARY KEY ipb_id (ipb_id), @@ -753,6 +758,9 @@ CREATE TABLE /*$wgDBprefix*/filearchive ( fa_deleted_timestamp char(14) binary default '', fa_deleted_reason text, + -- Visibility of deleted revisions, bitfield + fa_deleted tinyint(1) unsigned NOT NULL default '0', + -- Duped fields from image fa_size int(8) unsigned default '0', fa_width int(5) default '0', @@ -829,12 +837,24 @@ CREATE TABLE /*$wgDBprefix*/recentchanges ( -- Recorded IP address the edit was made from, if the -- $wgPutIPinRC option is enabled. rc_ip char(15) NOT NULL default '', - + -- Text length in characters before -- and after the edit rc_old_len int(10), rc_new_len int(10), + -- Visibility of deleted revisions, bitfield + rc_deleted tinyint(1) unsigned NOT NULL default '0', + + -- Value corresonding to log_id, specific log entries + rc_logid int(10) unsigned NOT NULL default '0', + -- Store log type info here, or null + rc_log_type varchar(255) binary NULL default NULL, + -- Store log action or null + rc_log_action varchar(255) binary NULL default NULL, + -- Log params + rc_params blob NOT NULL default '', + PRIMARY KEY rc_id (rc_id), INDEX rc_timestamp (rc_timestamp), INDEX rc_namespace_title (rc_namespace, rc_title), @@ -1006,6 +1026,9 @@ CREATE TABLE /*$wgDBprefix*/logging ( KEY user_time (log_user, log_timestamp), KEY page_time (log_namespace, log_title, log_timestamp), KEY times (log_timestamp) + + -- rev_deleted for logs + log_deleted tinyint(1) unsigned NOT NULL default '0', ) ENGINE=InnoDB, DEFAULT CHARSET=utf8; diff --git a/maintenance/postgres/tables.sql b/maintenance/postgres/tables.sql index b8412ba474..fb53d872d7 100644 --- a/maintenance/postgres/tables.sql +++ b/maintenance/postgres/tables.sql @@ -113,7 +113,7 @@ CREATE TABLE pagecontent ( -- replaces reserved word 'text' CREATE SEQUENCE pr_id_val; CREATE TABLE page_restrictions ( - pr_id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('pr_id_val'), + pr_id INTEGER NOT NULL UNIQUE DEFAULT nextval('pr_id_val'), pr_page INTEGER NULL REFERENCES page (page_id) ON DELETE CASCADE, pr_type TEXT NOT NULL, pr_level TEXT NOT NULL, @@ -135,7 +135,8 @@ CREATE TABLE archive2 ( ar_minor_edit CHAR NOT NULL DEFAULT '0', ar_flags TEXT, ar_rev_id INTEGER, - ar_text_id INTEGER + ar_text_id INTEGER, + ar_deleted INTEGER NOT NULL DEFAULT '0', ); CREATE INDEX archive_name_title_timestamp ON archive2 (ar_namespace,ar_title,ar_timestamp); @@ -246,6 +247,7 @@ CREATE TABLE ipblocks ( ipb_expiry TIMESTAMPTZ NOT NULL, ipb_range_start TEXT, ipb_range_end TEXT + ipb_deleted INTEGER NOT NULL, DEFAULT '0', ); CREATE INDEX ipb_address ON ipblocks (ipb_address); CREATE INDEX ipb_user ON ipblocks (ipb_user); @@ -306,6 +308,7 @@ CREATE TABLE filearchive ( fa_user INTEGER NULL REFERENCES mwuser(user_id) ON DELETE SET NULL, fa_user_text TEXT NOT NULL, fa_timestamp TIMESTAMPTZ + fa_deleted INTEGER NOT NULL DEFAULT '0', ); CREATE INDEX fa_name_time ON filearchive (fa_name, fa_timestamp); CREATE INDEX fa_dupe ON filearchive (fa_storage_group, fa_storage_key); @@ -335,7 +338,12 @@ CREATE TABLE recentchanges ( rc_patrolled CHAR NOT NULL DEFAULT '0', rc_ip CIDR, rc_old_len INTEGER, - rc_new_len INTEGER + rc_new_len INTEGER, + rc_deleted INTEGER NOT NULL DEFAULT '0', + rc_logid INTEGER NOT NULL DEFAULT '0', + rc_log_type TEXT, + rc_log_action TEXT, + rc_params TEXT, ); CREATE INDEX rc_timestamp ON recentchanges (rc_timestamp); CREATE INDEX rc_namespace_title ON recentchanges (rc_namespace, rc_title); @@ -410,6 +418,7 @@ CREATE TABLE transcache ( ); +CREATE SEQUENCE log_log_id_seq; CREATE TABLE logging ( log_type TEXT NOT NULL, log_action TEXT NOT NULL, @@ -418,7 +427,9 @@ CREATE TABLE logging ( log_namespace SMALLINT NOT NULL, log_title TEXT NOT NULL, log_comment TEXT, - log_params TEXT + log_params TEXT, + log_deleted INTEGER NOT NULL DEFAULT '0', + log_id INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('log_log_id_seq'), ); CREATE INDEX logging_type_name ON logging (log_type, log_timestamp); CREATE INDEX logging_user_time ON logging (log_timestamp, log_user); diff --git a/maintenance/updaters.inc b/maintenance/updaters.inc index ca2da347b8..c65e4f328f 100644 --- a/maintenance/updaters.inc +++ b/maintenance/updaters.inc @@ -63,10 +63,15 @@ $wgNewFields = array( array( 'ipblocks', 'ipb_range_start', 'patch-ipb_range_start.sql' ), array( 'site_stats', 'ss_images', 'patch-ss_images.sql' ), array( 'ipblocks', 'ipb_anon_only', 'patch-ipb_anon_only.sql' ), - array( 'ipblocks', 'ipb_enable_autoblock', 'patch-ipb_optional_autoblock.sql' ), + array( 'ipblocks', 'ipb_enable_autoblock', 'patch-ipb_optional_autoblock.sql' ), array( 'user', 'user_newpass_time','patch-user_newpass_time.sql' ), array( 'user', 'user_editcount', 'patch-user_editcount.sql' ), - array( 'logging', 'log_id', 'patch-log_id.sql' ), + array( 'recentchanges', 'rc_deleted', 'patch-rc_deleted.sql' ), + array( 'logging', 'log_id', 'patch-log_id.sql' ), + array( 'logging', 'log_deleted', 'patch-log_deleted.sql' ), + array( 'archive', 'ar_deleted', 'patch-ar_deleted.sql' ), + array( 'ipblocks', 'ipb_deleted', 'patch-ipb_deleted.sql' ), + array( 'filearchive', 'fa_deleted', 'patch-fa_deleted.sql' ), array( 'page_restrictions', 'pr_id', 'patch-page_restrictions_sortkey.sql' ), array( 'revision', 'rev_len', 'patch-rev_len.sql' ), array( 'revision', 'rev_parent_id', 'patch-rev_parent_id.sql' ), -- 2.20.1