# table field patch file (in maintenance/archives)
array( 'ipblocks', 'ipb_id', 'patch-ipblocks.sql' ),
array( 'ipblocks', 'ipb_expiry', 'patch-ipb_expiry.sql' ),
+ array( 'ipblocks', 'ipb_enable_autoblock', 'patch-ipb_optional_autoblock.sql' ),
array( 'recentchanges', 'rc_type', 'patch-rc_type.sql' ),
array( 'recentchanges', 'rc_ip', 'patch-rc_ip.sql' ),
array( 'recentchanges', 'rc_id', 'patch-rc_id.sql' ),
dbsource( archive( 'patch-recentchanges-utindex.sql' ) );
} else {
# Index seems to exist
- echo( "...seems to be ok\n" );
+ echo( "...index on ( rc_namespace, rc_user_text ) seems to be ok\n" );
+ }
+
+ #Add (rc_user_text, rc_timestamp) index [A. Garrett], November 2006
+ # See if we can find the index we want
+ $info = $wgDatabase->indexInfo( 'recentchanges', 'rc_user_text', __METHOD__ );
+ if( !$info ) {
+ # None, so create
+ echo( "...index on ( rc_user_text, rc_timestamp ) not found; creating\n" );
+ dbsource( archive( 'patch-rc_user_text-index.sql' ) );
+ } else {
+ # Index seems to exist
+ echo( "...index on ( rc_user_text, rc_timestamp ) seems to be ok\n" );
+ }
+}
+
+function index_has_field($table, $index, $field) {
+ global $wgDatabase;
+ echo( "Checking if $table index $index includes field $field...\n" );
+ $info = $wgDatabase->indexInfo( $table, $index, __METHOD__ );
+ if( $info ) {
+ foreach($info as $row) {
+ if($row->Column_name == $field) {
+ echo( "...index $index on table $table seems to be ok\n" );
+ return true;
+ }
+ }
+ }
+ echo( "...index $index on table $table has no field $field; adding\n" );
+ return false;
+}
+
+function do_backlinking_indices_update() {
+ echo( "Checking for backlinking indices...\n" );
+ if (!index_has_field('pagelinks', 'pl_namespace', 'pl_from') ||
+ !index_has_field('templatelinks', 'tl_namespace', 'tl_from') ||
+ !index_has_field('imagelinks', 'il_to', 'il_from'))
+ {
+ dbsource( archive( 'patch-backlinkindexes.sql' ) );
}
}
do_page_random_update(); flush();
do_rc_indices_update(); flush();
+
+ do_backlinking_indices_update(); flush();
initialiseMessages(); flush();
}
PGEND;
- $upgrade = str_replace( 'MWVERSION', $wgVersion, $upgrade );
+ } ## end version 1.7.1 upgrade
+ else if ($version == '1.8') {
+ $upgrade = <<<PGEND
+
+BEGIN;
- $res = $wgDatabase->query($upgrade);
+-- Tighten up restrictions on the revision table so we don't lose data:
+ALTER TABLE revision DROP CONSTRAINT revision_rev_user_fkey;
+ALTER TABLE revision ADD CONSTRAINT revision_rev_user_fkey
+ FOREIGN KEY (rev_user) REFERENCES mwuser(user_id) ON DELETE RESTRICT;
- } ## end version 1.7.1 upgrade
+-- New column for better password tracking:
+ALTER TABLE mwuser ADD user_newpass_time TIMESTAMPTZ;
+
+-- New column for autoblocking problem users
+ALTER TABLE ipblocks ADD ipb_enable_autoblock CHAR NOT NULL DEFAULT '1';
+
+-- Despite it's name, ipb_address does not necessarily contain IP addresses :)
+ALTER TABLE ipblocks ALTER ipb_address TYPE TEXT USING ipb_address::TEXT;
+
+-- New tables:
+CREATE TABLE redirect (
+ rd_from INTEGER NOT NULL REFERENCES page(page_id) ON DELETE CASCADE,
+ rd_namespace SMALLINT NOT NULL,
+ rd_title TEXT NOT NULL
+);
+CREATE INDEX redirect_ns_title ON redirect (rd_namespace,rd_title,rd_from);
+
+CREATE TABLE querycachetwo (
+ qcc_type TEXT NOT NULL,
+ qcc_value SMALLINT NOT NULL DEFAULT 0,
+ qcc_namespace INTEGER NOT NULL DEFAULT 0,
+ qcc_title TEXT NOT NULL DEFAULT '',
+ qcc_namespacetwo INTEGER NOT NULL DEFAULT 0,
+ qcc_titletwo TEXT NOT NULL DEFAULT ''
+);
+CREATE INDEX querycachetwo_type_value ON querycachetwo (qcc_type, qcc_value);
+CREATE INDEX querycachetwo_title ON querycachetwo (qcc_type,qcc_namespace,qcc_title);
+CREATE INDEX querycachetwo_titletwo ON querycachetwo (qcc_type,qcc_namespacetwo,qcc_titletwo);
+
+-- Note this upgrade
+INSERT INTO mediawiki_version (type,mw_version,notes)
+VALUES ('Upgrade','MWVERSION','Upgrade from older version 1.8');
+
+COMMIT;
+
+PGEND;
+
+ }
else {
- print "No updates needed\n";
+ print "No updates needed for version $version\n";
+ return;
}
+ $upgrade = str_replace( 'MWVERSION', $wgVersion, $upgrade );
+ $res = $wgDatabase->query($upgrade);
+
+
return;
}