http://www.mediawiki.org/wiki/Special:Code/MediaWiki/97842

Revision: 97842
Author:   asher
Date:     2011-09-22 19:35:45 +0000 (Thu, 22 Sep 2011)
Log Message:
-----------
1.18wmf1-2 migration for liquidthreads

Added Paths:
-----------
    branches/wmf/1.18wmf1/maintenance/ums_conversation.sql
    branches/wmf/1.18wmf1/maintenance/upgrade-1.18wmf1-2.php

Added: branches/wmf/1.18wmf1/maintenance/ums_conversation.sql
===================================================================
--- branches/wmf/1.18wmf1/maintenance/ums_conversation.sql                      
        (rev 0)
+++ branches/wmf/1.18wmf1/maintenance/ums_conversation.sql      2011-09-22 
19:35:45 UTC (rev 97842)
@@ -0,0 +1,10 @@
+-- ums_conversation
+-- Adds and populates the ums_conversation field, along with relevant indices.
+ALTER TABLE /*_*/user_message_state ADD COLUMN ums_conversation int(8) 
unsigned NOT NULL DEFAULT 0;
+
+CREATE INDEX /*i*/ums_user_conversation ON /*_*/user_message_state 
(ums_user,ums_conversation);
+DROP INDEX /*i*/ums_read ON /*_*/user_message_state;
+
+UPDATE /*_*/user_message_state, /*_*/thread
+SET /*_*/user_message_state.ums_conversation = if(/*_*/thread.thread_ancestor, 
/*_*/thread.thread_ancestor, /*_*/thread.thread_id)
+WHERE ums_conversation = 0 AND /*_*/thread.thread_id = 
/*_*/user_message_state.ums_thread;

Added: branches/wmf/1.18wmf1/maintenance/upgrade-1.18wmf1-2.php
===================================================================
--- branches/wmf/1.18wmf1/maintenance/upgrade-1.18wmf1-2.php                    
        (rev 0)
+++ branches/wmf/1.18wmf1/maintenance/upgrade-1.18wmf1-2.php    2011-09-22 
19:35:45 UTC (rev 97842)
@@ -0,0 +1,94 @@
+<?php
+
+require( dirname( __FILE__ ) . '/commandLine.inc' );
+
+doAllSchemaChanges();
+
+function doAllSchemaChanges() {
+       global $wgLBFactoryConf, $wgConf;
+
+       $sectionLoads = $wgLBFactoryConf['sectionLoads'];
+       $sectionsByDB = $wgLBFactoryConf['sectionsByDB'];
+       $rootPass = trim( wfShellExec( '/home/wikipedia/bin/mysql_root_pass' ) 
);
+
+       // Compile wiki lists
+       $wikisBySection = array();
+       foreach ( $wgConf->getLocalDatabases() as $wiki ) {
+               if ( isset( $sectionsByDB[$wiki] ) ) {
+                       $wikisBySection[$sectionsByDB[$wiki]][] = $wiki;
+               } else {
+                       $wikisBySection['DEFAULT'][] = $wiki;
+               }
+       }
+
+       // Do the upgrades
+       foreach ( $sectionLoads as $section => $loads ) {
+               $master = true;
+               foreach ( $loads as $server => $load ) {
+                       if ( $master ) {
+                               echo "Skipping $section master $server\n";
+                               $master = false;
+                               continue;
+                       }
+
+                       $db = new DatabaseMysql(
+                               $server,
+                               'root',
+                               $rootPass,
+                               false, /* dbName */
+                               0, /* flags, no transactions */
+                               '' /* prefix */
+                       );
+
+                       foreach ( $wikisBySection[$section] as $wiki ) {
+                               $db->selectDB( $wiki );
+                               upgradeWiki( $db );
+                               while ( $db->getLag() > 10 ) {
+                                       echo "Waiting for $server to catch up 
to master.\n";
+                                       sleep( 60 );
+                               }
+                       }
+               }
+       }
+
+       echo "All done (except masters).\n";
+}
+
+function upgradeWiki( $db ) {
+       $wiki = $db->getDBname();
+       $server = $db->getServer();
+
+       $upgradeLogRow = $db->selectRow( 'updatelog',
+               'ul_key',
+               array( 'ul_key' => '1.18wmf1-2' ),
+               __FUNCTION__ );
+       if ( $upgradeLogRow ) {
+               echo $db->getDBname() . ": already done\n";
+               return;
+       }
+
+       echo "$server $wiki 1.18wmf1-2";
+       
+       if ( $wgConf->get( 'wmgUseLiquidThreads', $wiki ) ) {
+               echo " liquidthreads";
+               sourceUpgradeFile( $db, dirname( __FILE__ ) 
.'/ums_conversation.sql' );
+       } else {
+               echo " no-op";
+       }
+       
+       $db->insert( 'updatelog', 
+               array( 'ul_key' => '1.18wmf1-2' ),
+               __FUNCTION__ );
+       echo " ok\n";
+
+}
+
+function sourceUpgradeFile( $db, $file ) {
+       if ( !file_exists( $file ) ) {
+               echo "File missing: $file\n";
+               exit( 1 );
+       }
+       $db->sourceFile( $file );
+}
+
+


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to