From: Brion Vibber Date: Mon, 26 Mar 2007 22:05:06 +0000 (+0000) Subject: quickie script to move ES blob tables from one wiki name to another, leaving fresh... X-Git-Tag: 1.31.0-rc.0~53598 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/categories/modifier.php?a=commitdiff_plain;h=266b5237c12d09ddd4174a6b830b1b910ed6df0b;p=lhc%2Fweb%2Fwiklou.git quickie script to move ES blob tables from one wiki name to another, leaving fresh tables at the old name should be generalized --- diff --git a/maintenance/renamewiki.php b/maintenance/renamewiki.php new file mode 100644 index 0000000000..6a0cb586db --- /dev/null +++ b/maintenance/renamewiki.php @@ -0,0 +1,58 @@ + \n" ); +} + +list( $from, $to ) = $args; + +echo "Renaming blob tables in ES from $from to $to...\n"; +echo "Sleeping 5 seconds..."; +sleep(5); +echo "\n"; + +# Initialise external storage +if ( is_array( $wgDefaultExternalStore ) ) { + $stores = $wgDefaultExternalStore; +} elseif ( $wgDefaultExternalStore ) { + $stores = array( $wgDefaultExternalStore ); +} else { + $stores = array(); +} +if ( count( $stores ) ) { + require_once( 'ExternalStoreDB.php' ); + print "Initialising external storage $store...\n"; + global $wgDBuser, $wgDBpassword, $wgExternalServers; + foreach ( $stores as $storeURL ) { + $m = array(); + if ( !preg_match( '!^DB://(.*)$!', $storeURL, $m ) ) { + continue; + } + + $cluster = $m[1]; + + # Hack + $wgExternalServers[$cluster][0]['user'] = $wgDBuser; + $wgExternalServers[$cluster][0]['password'] = $wgDBpassword; + + $store = new ExternalStoreDB; + $extdb =& $store->getMaster( $cluster ); + $extdb->query( "SET table_type=InnoDB" ); + $extdb->query( "CREATE DATABASE {$to}" ); + $extdb->query( "ALTER TABLE {$from}.blobs RENAME TO {$to}.blobs" ); + $extdb->selectDB( $to ); + dbsource( "$maintenance/storage/blobs.sql", $extdb ); + $extdb->immediateCommit(); + } +} + +echo "done.\n"; + +?> \ No newline at end of file