Index: branches/wmf/1.18wmf1/maintenance/schema-changes-1.18wmf1-1.sql |
— | — | @@ -0,0 +1,4 @@ |
| 2 | +-- patch-up_property.sql |
| 3 | +ALTER TABLE /*$wgDBprefix*/user_properties |
| 4 | + MODIFY up_property varbinary(255); |
| 5 | + |
Index: branches/wmf/1.18wmf1/maintenance/upgrade-1.18wmf1-1.php |
— | — | @@ -0,0 +1,109 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +require( dirname( __FILE__ ) . '/commandLine.inc' ); |
| 5 | + |
| 6 | +doAllSchemaChanges(); |
| 7 | + |
| 8 | +function doAllSchemaChanges() { |
| 9 | + global $wgLBFactoryConf, $wgConf; |
| 10 | + |
| 11 | + $sectionLoads = $wgLBFactoryConf['sectionLoads']; |
| 12 | + $sectionsByDB = $wgLBFactoryConf['sectionsByDB']; |
| 13 | + $rootPass = trim( wfShellExec( '/home/wikipedia/bin/mysql_root_pass' ) ); |
| 14 | + |
| 15 | + // Compile wiki lists |
| 16 | + $wikisBySection = array(); |
| 17 | + foreach ( $wgConf->getLocalDatabases() as $wiki ) { |
| 18 | + if ( isset( $sectionsByDB[$wiki] ) ) { |
| 19 | + $wikisBySection[$sectionsByDB[$wiki]][] = $wiki; |
| 20 | + } else { |
| 21 | + $wikisBySection['DEFAULT'][] = $wiki; |
| 22 | + } |
| 23 | + } |
| 24 | + |
| 25 | + // Do the upgrades |
| 26 | + foreach ( $sectionLoads as $section => $loads ) { |
| 27 | + $master = true; |
| 28 | + foreach ( $loads as $server => $load ) { |
| 29 | + if ( $master ) { |
| 30 | + echo "Skipping $section master $server\n"; |
| 31 | + $master = false; |
| 32 | + continue; |
| 33 | + } |
| 34 | + |
| 35 | + $db = new DatabaseMysql( |
| 36 | + $server, |
| 37 | + 'root', |
| 38 | + $rootPass, |
| 39 | + false, /* dbName */ |
| 40 | + 0, /* flags, no transactions */ |
| 41 | + '' /* prefix */ |
| 42 | + ); |
| 43 | + |
| 44 | + foreach ( $wikisBySection[$section] as $wiki ) { |
| 45 | + $db->selectDB( $wiki ); |
| 46 | + upgradeWiki( $db ); |
| 47 | + while ( $db->getLag() > 10 ) { |
| 48 | + echo "Waiting for $server to catch up to master.\n"; |
| 49 | + sleep( 60 ); |
| 50 | + } |
| 51 | + } |
| 52 | + } |
| 53 | + } |
| 54 | + |
| 55 | + echo "All done (except masters).\n"; |
| 56 | +} |
| 57 | + |
| 58 | +function upgradeWiki( $db ) { |
| 59 | + $wiki = $db->getDBname(); |
| 60 | + $server = $db->getServer(); |
| 61 | + |
| 62 | + $upgradeLogRow = $db->selectRow( 'updatelog', |
| 63 | + 'ul_key', |
| 64 | + array( 'ul_key' => '1.18wmf1-final' ), |
| 65 | + __FUNCTION__ ); |
| 66 | + if ( $upgradeLogRow ) { |
| 67 | + echo $db->getDBname() . ": already done\n"; |
| 68 | + return; |
| 69 | + } |
| 70 | + |
| 71 | + echo "$server $wiki 1.18wmf1-final"; |
| 72 | + |
| 73 | + sourceUpgradeFile( $db, dirname( __FILE__ ) .'/schema-changes-1.18wmf1-1.sql' ); |
| 74 | + |
| 75 | + if ( isFlaggedRevsWiki( $wiki ) ) { |
| 76 | + echo " FlaggedRevs"; |
| 77 | + sourceUpgradeFile( $db, dirname(__FILE__).'/../extensions/FlaggedRevs/schema/mysql/' . |
| 78 | + 'patch-fr_page_rev-index.sql' ); |
| 79 | + } |
| 80 | + |
| 81 | + if ( $db->fieldExists( 'article_feedback', 'aa_page_id' ) ) { |
| 82 | + echo " aa_page_id index"; |
| 83 | + sourceUpgradeFile( $db, dirname( __FILE__ ) . '/../extensions/ArticleFeedback/sql/AddArticleFeedbackPageIndex.sql' ); |
| 84 | + } |
| 85 | + |
| 86 | + $db->insert( 'updatelog', |
| 87 | + array( 'ul_key' => '1.18wmf1-final' ), |
| 88 | + __FUNCTION__ ); |
| 89 | + echo " ok\n"; |
| 90 | +} |
| 91 | + |
| 92 | +function isFlaggedRevsWiki( $wiki ) { |
| 93 | + static $dblist; |
| 94 | + global $IP; |
| 95 | + |
| 96 | + if ( $dblist === null ) { |
| 97 | + $dblist = array_map( 'trim', file( "$IP/../flaggedrevs.dblist" ) ); |
| 98 | + } |
| 99 | + return in_array( $wiki, $dblist ); |
| 100 | +} |
| 101 | + |
| 102 | +function sourceUpgradeFile( $db, $file ) { |
| 103 | + if ( !file_exists( $file ) ) { |
| 104 | + echo "File missing: $file\n"; |
| 105 | + exit( 1 ); |
| 106 | + } |
| 107 | + $db->sourceFile( $file ); |
| 108 | +} |
| 109 | + |
| 110 | + |