X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Finstaller%2FPostgresUpdater.php;h=499a2d6671328ca68c459137adeb06c211e22319;hb=987319a54adf9f6208534b5ac3b60d6f88bbf7e4;hp=a03c6c45205791b8ccc81afe53b7dc44e1354d37;hpb=cef84004edcfe8248b3c55b393088700783df86c;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/installer/PostgresUpdater.php b/includes/installer/PostgresUpdater.php index a03c6c4520..499a2d6671 100644 --- a/includes/installer/PostgresUpdater.php +++ b/includes/installer/PostgresUpdater.php @@ -2,6 +2,21 @@ /** * PostgreSQL-specific updater. * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * * @file * @ingroup Deployment */ @@ -97,6 +112,7 @@ class PostgresUpdater extends DatabaseUpdater { array( 'addPgField', 'ipblocks', 'ipb_create_account', 'SMALLINT NOT NULL DEFAULT 1' ), array( 'addPgField', 'ipblocks', 'ipb_deleted', 'SMALLINT NOT NULL DEFAULT 0' ), array( 'addPgField', 'ipblocks', 'ipb_enable_autoblock', 'SMALLINT NOT NULL DEFAULT 1' ), + array( 'addPgField', 'ipblocks', 'ipb_parent_block_id', 'INTEGER DEFAULT NULL REFERENCES ipblocks(ipb_id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED' ), array( 'addPgField', 'filearchive', 'fa_deleted', 'SMALLINT NOT NULL DEFAULT 0' ), array( 'addPgField', 'logging', 'log_deleted', 'SMALLINT NOT NULL DEFAULT 0' ), array( 'addPgField', 'logging', 'log_id', "INTEGER NOT NULL PRIMARY KEY DEFAULT nextval('logging_log_id_seq')" ), @@ -194,6 +210,7 @@ class PostgresUpdater extends DatabaseUpdater { # New indexes array( 'addPgIndex', 'archive', 'archive_user_text', '(ar_user_text)' ), array( 'addPgIndex', 'image', 'img_sha1', '(img_sha1)' ), + array( 'addPgIndex', 'ipblocks', 'ipb_parent_block_id', '(ipb_parent_block_id)' ), array( 'addPgIndex', 'oldimage', 'oi_sha1', '(oi_sha1)' ), array( 'addPgIndex', 'page', 'page_mediawiki_title', '(page_title) WHERE page_namespace = 8' ), array( 'addPgIndex', 'pagelinks', 'pagelinks_title', '(pl_title)' ), @@ -290,6 +307,7 @@ class PostgresUpdater extends DatabaseUpdater { array( 'changeFkeyDeferrable', 'imagelinks', 'il_from', 'page(page_id) ON DELETE CASCADE' ), array( 'changeFkeyDeferrable', 'ipblocks', 'ipb_by', 'mwuser(user_id) ON DELETE CASCADE' ), array( 'changeFkeyDeferrable', 'ipblocks', 'ipb_user', 'mwuser(user_id) ON DELETE SET NULL' ), + array( 'changeFkeyDeferrable', 'ipblocks', 'ipb_parent_block_id', 'ipblocks(ipb_id) ON DELETE SET NULL' ), array( 'changeFkeyDeferrable', 'langlinks', 'll_from', 'page(page_id) ON DELETE CASCADE' ), array( 'changeFkeyDeferrable', 'logging', 'log_user', 'mwuser(user_id) ON DELETE SET NULL' ), array( 'changeFkeyDeferrable', 'oldimage', 'oi_name', 'image(img_name) ON DELETE CASCADE ON UPDATE CASCADE' ), @@ -595,11 +613,11 @@ END; if ( $this->db->indexExists( $table, $index ) ) { $this->output( "...index '$index' on table '$table' already exists\n" ); } else { - $this->output( "Creating index '$index' on table '$table'\n" ); if ( preg_match( '/^\(/', $type ) ) { + $this->output( "Creating index '$index' on table '$table'\n" ); $this->db->query( "CREATE INDEX $index ON $table $type" ); } else { - $this->applyPatch( $type, true ); + $this->applyPatch( $type, true, "Creating index '$index' on table '$table'" ); } } } @@ -629,7 +647,6 @@ END; protected function convertArchive2() { if ( $this->db->tableExists( "archive2" ) ) { - $this->output( "Converting 'archive2' back to normal archive table\n" ); if ( $this->db->ruleExists( 'archive', 'archive_insert' ) ) { $this->output( "Dropping rule 'archive_insert'\n" ); $this->db->query( 'DROP RULE archive_insert ON archive' ); @@ -638,7 +655,7 @@ END; $this->output( "Dropping rule 'archive_delete'\n" ); $this->db->query( 'DROP RULE archive_delete ON archive' ); } - $this->applyPatch( 'patch-remove-archive2.sql' ); + $this->applyPatch( 'patch-remove-archive2.sql', false, "Converting 'archive2' back to normal archive table" ); } else { $this->output( "...obsolete table 'archive2' does not exist\n" ); } @@ -673,14 +690,13 @@ END; protected function checkPageDeletedTrigger() { if ( !$this->db->triggerExists( 'page', 'page_deleted' ) ) { - $this->output( "Adding function and trigger 'page_deleted' to table 'page'\n" ); - $this->applyPatch( 'patch-page_deleted.sql' ); + $this->applyPatch( 'patch-page_deleted.sql', false, "Adding function and trigger 'page_deleted' to table 'page'" ); } else { $this->output( "...table 'page' has 'page_deleted' trigger\n" ); } } - protected function dropIndex( $table, $index ) { + protected function dropIndex( $table, $index, $patch = '', $fullpath = false ) { if ( $this->db->indexExists( $table, $index ) ) { $this->output( "Dropping obsolete index '$index'\n" ); $this->db->query( "DROP INDEX \"". $index ."\"" ); @@ -709,35 +725,30 @@ END; if ( $this->fkeyDeltype( 'revision_rev_user_fkey' ) == 'r' ) { $this->output( "...constraint 'revision_rev_user_fkey' is ON DELETE RESTRICT\n" ); } else { - $this->output( "Changing constraint 'revision_rev_user_fkey' to ON DELETE RESTRICT\n" ); - $this->applyPatch( 'patch-revision_rev_user_fkey.sql' ); + $this->applyPatch( 'patch-revision_rev_user_fkey.sql', false, "Changing constraint 'revision_rev_user_fkey' to ON DELETE RESTRICT" ); } } protected function checkIwlPrefix() { if ( $this->db->indexExists( 'iwlinks', 'iwl_prefix' ) ) { - $this->output( "Replacing index 'iwl_prefix' with 'iwl_prefix_from_title'...\n" ); - $this->applyPatch( 'patch-rename-iwl_prefix.sql' ); + $this->applyPatch( 'patch-rename-iwl_prefix.sql', false, "Replacing index 'iwl_prefix' with 'iwl_prefix_from_title'" ); } } protected function addInterwikiType() { - $this->output( "Refreshing add_interwiki()...\n" ); - $this->applyPatch( 'patch-add_interwiki.sql' ); + $this->applyPatch( 'patch-add_interwiki.sql', false, "Refreshing add_interwiki()" ); } protected function tsearchFixes() { # Tweak the page_title tsearch2 trigger to filter out slashes # This is create or replace, so harmless to call if not needed - $this->output( "Refreshing ts2_page_title()...\n" ); - $this->applyPatch( 'patch-ts2pagetitle.sql' ); + $this->applyPatch( 'patch-ts2pagetitle.sql', false, "Refreshing ts2_page_title()" ); # If the server is 8.3 or higher, rewrite the tsearch2 triggers # in case they have the old 'default' versions # Gather version numbers in case we need them if ( $this->db->getServerVersion() >= 8.3 ) { - $this->output( "Rewriting tsearch2 triggers...\n" ); - $this->applyPatch( 'patch-tsearch2funcs.sql' ); + $this->applyPatch( 'patch-tsearch2funcs.sql', false, "Rewriting tsearch2 triggers" ); } } }