Localisation updates from http://translatewiki.net.
[mediawiki.git] / maintenance / cleanupAncientTables.php
blobdbc2e0d3d4e3bf61729b9dc3eceb6835af49108e
1 <?php
2 /**
3 * Cleans up old database tables, dropping old indexes and fields.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * @file
21 * @ingroup Maintenance
24 require_once( __DIR__ . '/Maintenance.php' );
26 /**
27 * Maintenance script to cleans up old database tables, dropping old indexes
28 * and fields.
30 * @ingroup Maintenance
32 class CleanupAncientTables extends Maintenance {
34 public function __construct() {
35 parent::__construct();
36 $this->mDescription = "Cleanup ancient tables and indexes";
37 $this->addOption( 'force', 'Actually run this script' );
40 public function execute() {
41 if( !$this->hasOption( 'force' ) ) {
42 $this->error( "This maintenance script will remove old columns and indexes.\n"
43 . "It is recommended to backup your database first, and ensure all your data has been migrated to newer tables\n"
44 . "If you want to continue, run this script again with the --force \n"
48 $db = wfGetDB( DB_MASTER );
49 $ancientTables = array(
50 'blobs', // 1.4
51 'brokenlinks', // 1.4
52 'cur', // 1.4
53 'ip_blocks_old', // Temporary in 1.6
54 'links', // 1.4
55 'linkscc', // 1.4
56 // 'math', // 1.18, but don't want to drop if math extension is enabled...
57 'old', // 1.4
58 'oldwatchlist', // pre 1.1?
59 'trackback', // 1.19
60 'user_rights', // 1.5
61 'validate', // 1.6
64 foreach( $ancientTables as $table ) {
65 if ( $db->tableExists( $table, __METHOD__ ) ) {
66 $this->output( "Dropping table $table..." );
67 $db->dropTable( $table, __METHOD__ );
68 $this->output( "done.\n" );
72 $this->output( "Cleaning up text table\n" );
74 $oldIndexes = array(
75 'old_namespace',
76 'old_timestamp',
77 'name_title_timestamp',
78 'user_timestamp',
79 'usertext_timestamp',
81 foreach( $oldIndexes as $index ) {
82 if ( $db->indexExists( 'text', $index, __METHOD__ ) ) {
83 $this->output( "Dropping index $index from the text table..." );
84 $db->query( "DROP INDEX " . $db->addIdentifierQuotes( $index )
85 . " ON " . $db->tableName( 'text' ) );
86 $this->output( "done.\n" );
90 $oldFields = array(
91 'old_namespace',
92 'old_title',
93 'old_comment',
94 'old_user',
95 'old_user_text',
96 'old_timestamp',
97 'old_minor_edit',
98 'inverse_timestamp',
100 foreach( $oldFields as $field ) {
101 if ( $db->fieldExists( 'text', $field, __METHOD__ ) ) {
102 $this->output( "Dropping the $field field from the text table..." );
103 $db->query( "ALTER TABLE " . $db->tableName( 'text' )
104 . " DROP COLUMN " . $db->addIdentifierQuotes( $field ) );
105 $this->output( "done.\n" );
108 $this->output( "Done!\n" );
112 $maintClass = "CleanupAncientTables";
113 require_once( RUN_MAINTENANCE_IF_MAIN );