ebfbaea967eeb5c932f0bf477a4272eb25e484dc
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 $maintenance = "$IP/maintenance";
23 # Initialise external storage
24 if ( is_array( $wgDefaultExternalStore ) ) {
25 $stores = $wgDefaultExternalStore;
26 } elseif ( $wgDefaultExternalStore ) {
27 $stores = array( $wgDefaultExternalStore );
31 if ( count( $stores ) ) {
32 require_once( 'ExternalStoreDB.php' );
33 print "Initialising external storage $store...\n";
34 global $wgDBuser, $wgDBpassword, $wgExternalServers;
35 foreach ( $stores as $storeURL ) {
37 if ( !preg_match( '!^DB://(.*)$!', $storeURL, $m ) ) {
44 $wgExternalServers[$cluster][0]['user'] = $wgDBuser;
45 $wgExternalServers[$cluster][0]['password'] = $wgDBpassword;
47 $store = new ExternalStoreDB
;
48 $extdb =& $store->getMaster( $cluster );
49 $extdb->query( "SET table_type=InnoDB" );
50 $extdb->query( "CREATE DATABASE {$to}" );
51 $extdb->query( "ALTER TABLE {$from}.blobs RENAME TO {$to}.blobs" );
52 $extdb->selectDB( $from );
53 dbsource( "$maintenance/storage/blobs.sql", $extdb );
54 $extdb->immediateCommit();