summaryrefslogtreecommitdiff
path: root/maintenance/renamewiki.php
diff options
context:
space:
mode:
Diffstat (limited to 'maintenance/renamewiki.php')
-rw-r--r--maintenance/renamewiki.php60
1 files changed, 60 insertions, 0 deletions
diff --git a/maintenance/renamewiki.php b/maintenance/renamewiki.php
new file mode 100644
index 00000000..ebfbaea9
--- /dev/null
+++ b/maintenance/renamewiki.php
@@ -0,0 +1,60 @@
+<?php
+require_once( "commandLine.inc" );
+
+/**
+ * Why yes, this *is* another special-purpose Wikimedia maintenance script!
+ * Should be fixed up and generalized.
+ */
+
+if ( count( $args ) != 2 ) {
+ wfDie( "Rename external storage dbs and leave a new one...\n" .
+ "Usage: php renamewiki.php <olddb> <newdb>\n" );
+}
+
+list( $from, $to ) = $args;
+
+echo "Renaming blob tables in ES from $from to $to...\n";
+echo "Sleeping 5 seconds...";
+sleep(5);
+echo "\n";
+
+$maintenance = "$IP/maintenance";
+
+# 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( $from );
+ dbsource( "$maintenance/storage/blobs.sql", $extdb );
+ $extdb->immediateCommit();
+ }
+}
+
+echo "done.\n";
+
+?> \ No newline at end of file