+function do_namespace_size() {
+ $tables = array(
+ 'page' => 'page',
+ 'archive' => 'ar',
+ 'recentchanges' => 'rc',
+ 'watchlist' => 'wl',
+ 'querycache' => 'qc',
+ 'logging' => 'log',
+ );
+ foreach( $tables as $table => $prefix ) {
+ do_namespace_size_on( $table, $prefix );
+ flush();
+ }
+}
+
+function do_namespace_size_on( $table, $prefix ) {
+ global $wgDatabase;
+ $field = $prefix . '_namespace';
+
+ $tablename = $wgDatabase->tableName( $table );
+ $result = $wgDatabase->query( "SHOW COLUMNS FROM $tablename LIKE '$field'" );
+ $info = $wgDatabase->fetchObject( $result );
+ $wgDatabase->freeResult( $result );
+
+ if( substr( $info->Type, 0, 3 ) == 'int' ) {
+ echo "...$field is already a full int ($info->Type).\n";
+ } else {
+ echo "Promoting $field from $info->Type to int... ";
+
+ $sql = "ALTER TABLE $tablename MODIFY $field int NOT NULL";
+ $wgDatabase->query( $sql );
+
+ echo "ok\n";
+ }
+}