2 require_once( "commandLine.inc" );
5 * Why yes, this *is* another special-purpose Wikimedia maintenance script!
6 * Should be fixed up and generalized.
9 if ( count( $args ) != 2 ) {
10 wfDie( "Rename external storage dbs and leave a new one...\n" .
11 "Usage: php renamewiki.php <olddb> <newdb>\n" );
14 list( $from, $to ) = $args;
16 echo "Renaming blob tables in ES from $from to $to...\n";
17 echo "Sleeping 5 seconds...";
21 # Initialise external storage
22 if ( is_array( $wgDefaultExternalStore ) ) {
23 $stores = $wgDefaultExternalStore;
24 } elseif ( $wgDefaultExternalStore ) {
25 $stores = array( $wgDefaultExternalStore );
29 if ( count( $stores ) ) {
30 require_once( 'ExternalStoreDB.php' );
31 print "Initialising external storage $store...\n";
32 global $wgDBuser, $wgDBpassword, $wgExternalServers;
33 foreach ( $stores as $storeURL ) {
35 if ( !preg_match( '!^DB://(.*)$!', $storeURL, $m ) ) {
42 $wgExternalServers[$cluster][0]['user'] = $wgDBuser;
43 $wgExternalServers[$cluster][0]['password'] = $wgDBpassword;
45 $store = new ExternalStoreDB
;
46 $extdb =& $store->getMaster( $cluster );
47 $extdb->query( "SET table_type=InnoDB" );
48 $extdb->query( "CREATE DATABASE {$to}" );
49 $extdb->query( "ALTER TABLE {$from}.blobs RENAME TO {$to}.blobs" );
50 $extdb->selectDB( $to );
51 dbsource( "$maintenance/storage/blobs.sql", $extdb );
52 $extdb->immediateCommit();