3 * Why yes, this *is* another special-purpose Wikimedia maintenance script!
4 * Should be fixed up and generalized.
10 require_once( "commandLine.inc" );
12 if ( count( $args ) != 2 ) {
13 wfDie( "Rename external storage dbs and leave a new one...\n" .
14 "Usage: php renamewiki.php <olddb> <newdb>\n" );
17 list( $from, $to ) = $args;
19 echo "Renaming blob tables in ES from $from to $to...\n";
20 echo "Sleeping 5 seconds...";
24 $maintenance = "$IP/maintenance";
26 # Initialise external storage
27 if ( is_array( $wgDefaultExternalStore ) ) {
28 $stores = $wgDefaultExternalStore;
29 } elseif ( $wgDefaultExternalStore ) {
30 $stores = array( $wgDefaultExternalStore );
34 if ( count( $stores ) ) {
35 require_once( 'ExternalStoreDB.php' );
36 print "Initialising external storage $store...\n";
37 global $wgDBuser, $wgDBpassword, $wgExternalServers;
38 foreach ( $stores as $storeURL ) {
40 if ( !preg_match( '!^DB://(.*)$!', $storeURL, $m ) ) {
47 $wgExternalServers[$cluster][0]['user'] = $wgDBuser;
48 $wgExternalServers[$cluster][0]['password'] = $wgDBpassword;
50 $store = new ExternalStoreDB
;
51 $extdb =& $store->getMaster( $cluster );
52 $extdb->query( "SET table_type=InnoDB" );
53 $extdb->query( "CREATE DATABASE {$to}" );
54 $extdb->query( "ALTER TABLE {$from}.blobs RENAME TO {$to}.blobs" );
55 $extdb->selectDB( $from );
56 dbsource( "$maintenance/storage/blobs.sql", $extdb );
57 $extdb->immediateCommit();