array( 'addTable', 'user_newtalk', 'patch-usernewtalk2.sql' ),
array( 'addTable', 'transcache', 'patch-transcache.sql' ),
array( 'addField', 'interwiki', 'iw_trans', 'patch-interwiki-trans.sql' ),
- array( 'addTable', 'trackbacks', 'patch-trackbacks.sql' ),
// 1.6
array( 'doWatchlistNull' ),
// 1.16
array( 'addTable', 'user_properties', 'patch-user_properties.sql' ),
array( 'addTable', 'log_search', 'patch-log_search.sql' ),
- array( 'doLogSearchPopulation' ),
array( 'addField', 'logging', 'log_user_text', 'patch-log_user_text.sql' ),
+ array( 'doLogUsertextPopulation' ), # listed separately from the previous update because 1.16 was released without this update
+ array( 'doLogSearchPopulation' ),
array( 'addTable', 'l10n_cache', 'patch-l10n_cache.sql' ),
array( 'addTable', 'external_user', 'patch-external_user.sql' ),
array( 'addIndex', 'log_search', 'ls_field_val', 'patch-log_search-rename-index.sql' ),
array( 'doUpdateTranscacheField' ),
array( 'renameEuWikiId' ),
array( 'doUpdateMimeMinorField' ),
- array( 'doPopulateRevLen' ),
// 1.17
array( 'addTable', 'iwlinks', 'patch-iwlinks.sql' ),
array( 'addIndex', 'iwlinks', 'iwl_prefix_title_from', 'patch-rename-iwl_prefix.sql' ),
- array( 'addField', 'updatelog', 'ul_value', 'patch-ul_value.sql' ),
+ array( 'addField', 'updatelog', 'ul_value', 'patch-ul_value.sql' ),
array( 'addField', 'interwiki', 'iw_api', 'patch-iw_api_and_wikiid.sql' ),
- array( 'dropIndex', 'iwlinks', 'iwl_prefix', 'patch-kill-iwl_prefix.sql' ),
- array( 'dropIndex', 'iwlinks', 'iwl_prefix_from_title', 'patch-kill-iwl_pft.sql' ),
- array( 'addField', 'categorylinks', 'cl_collation', 'patch-categorylinks-better-collation.sql' ),
+ array( 'dropIndex', 'iwlinks', 'iwl_prefix', 'patch-kill-iwl_prefix.sql' ),
+ array( 'dropIndex', 'iwlinks', 'iwl_prefix_from_title', 'patch-kill-iwl_pft.sql' ),
+ array( 'addField', 'categorylinks', 'cl_collation', 'patch-categorylinks-better-collation.sql' ),
array( 'doClFieldsUpdate' ),
array( 'doCollationUpdate' ),
array( 'addTable', 'msg_resource', 'patch-msg_resource.sql' ),
array( 'addTable', 'module_deps', 'patch-module_deps.sql' ),
+ array( 'dropIndex', 'archive', 'ar_page_revid', 'patch-archive_kill_ar_page_revid.sql' ),
+ array( 'addIndex', 'archive', 'ar_revid', 'patch-archive_ar_revid.sql' ),
+ array( 'doLangLinksLengthUpdate' ),
+
+ // 1.18
+ array( 'doUserNewTalkTimestampNotNull' ),
+ array( 'addIndex', 'user', 'user_email', 'patch-user_email_index.sql' ),
+ array( 'modifyField', 'user_properties', 'up_property', 'patch-up_property.sql' ),
+ array( 'addTable', 'uploadstash', 'patch-uploadstash.sql' ),
+ array( 'addTable', 'user_former_groups', 'patch-user_former_groups.sql'),
+
+ // 1.19
+ array( 'addIndex', 'logging', 'type_action', 'patch-logging-type-action-index.sql'),
+ array( 'doMigrateUserOptions' ),
+ array( 'dropField', 'user', 'user_options', 'patch-drop-user_options.sql' ),
+ array( 'addField', 'revision', 'rev_sha1', 'patch-rev_sha1.sql' ),
+ array( 'addField', 'archive', 'ar_sha1', 'patch-ar_sha1.sql' ),
+ array( 'addIndex', 'page', 'page_redirect_namespace_len', 'patch-page_redirect_namespace_len.sql' ),
+ array( 'modifyField', 'user_groups', 'ug_group', 'patch-ug_group-length-increase.sql' ),
+ array( 'addField', 'uploadstash', 'us_chunk_inx', 'patch-uploadstash_chunk.sql' ),
+ array( 'addfield', 'job', 'job_timestamp', 'patch-jobs-add-timestamp.sql' ),
+
+ // 1.20
+ // content model stuff for WikiData
+ array( 'addField', 'revision', 'rev_content_format', 'patch-revision-rev_content_format.sql' ),
+ array( 'addField', 'revision', 'rev_content_model', 'patch-revision-rev_content_model.sql' ),
+ array( 'addField', 'archive', 'ar_content_format', 'patch-archive-ar_content_format.sql' ),
+ array( 'addField', 'archive', 'ar_content_model', 'patch-archive-ar_content_model.sql' ),
+ array( 'addField', 'page', 'page_content_model', 'patch-page-page_content_model.sql' ),
+ array( 'modifyField', 'user_former_groups', 'ufg_group', 'patch-ufg_group-length-increase.sql' ),
+
+ // 1.20
+ array( 'addTable', 'config', 'patch-config.sql' ),
+ array( 'addIndex', 'revision', 'page_user_timestamp', 'patch-revision-user-page-index.sql' ),
);
}
$this->output( "...$table table has correct $field encoding.\n" );
} else {
$this->output( "Fixing $field encoding on $table table... " );
- $this->db->applyPatch( $patchFile );
- $this->output( "ok\n" );
+ $this->applyPatch( $patchFile );
+ $this->output( "done.\n" );
}
}
if ( $info ) {
foreach ( $info as $row ) {
if ( $row->Column_name == $field ) {
- $this->output( "...index $index on table $table includes field $field\n" );
+ $this->output( "...index $index on table $table includes field $field.\n" );
return true;
}
}
}
- $this->output( "...index $index on table $table has no field $field; adding\n" );
+ $this->output( "...index $index on table $table has no field $field; added.\n" );
return false;
}
protected function doInterwikiUpdate() {
global $IP;
- if ( $this->db->tableExists( "interwiki" ) ) {
+ if ( $this->db->tableExists( "interwiki", __METHOD__ ) ) {
$this->output( "...already have interwiki table\n" );
return;
}
$this->output( 'Creating interwiki table...' );
$this->applyPatch( 'patch-interwiki.sql' );
- $this->output( "ok\n" );
+ $this->output( "done.\n" );
$this->output( 'Adding default interwiki definitions...' );
$this->applyPatch( "$IP/maintenance/interwiki.sql", true );
- $this->output( "ok\n" );
+ $this->output( "done.\n" );
}
/**
*/
protected function doIndexUpdate() {
$meta = $this->db->fieldInfo( 'recentchanges', 'rc_timestamp' );
+ if ( $meta === false ) {
+ throw new MWException( 'Missing rc_timestamp field of recentchanges table. Should not happen.' );
+ }
if ( $meta->isMultipleKey() ) {
- $this->output( "...indexes seem up to 20031107 standards\n" );
+ $this->output( "...indexes seem up to 20031107 standards.\n" );
return;
}
$this->output( "Updating indexes to 20031107..." );
$this->applyPatch( 'patch-indexes.sql', true );
- $this->output( "ok\n" );
+ $this->output( "done.\n" );
}
protected function doOldLinksUpdate() {
$this->output( "Fixing ancient broken imagelinks table.\n" );
$this->output( "NOTE: you will have to run maintenance/refreshLinks.php after this.\n" );
$this->applyPatch( 'patch-fix-il_from.sql' );
- $this->output( "ok\n" );
+ $this->output( "done.\n" );
}
/**
$talk = $this->db->selectField( 'watchlist', 'count(*)', 'wl_namespace & 1', __METHOD__ );
$nontalk = $this->db->selectField( 'watchlist', 'count(*)', 'NOT (wl_namespace & 1)', __METHOD__ );
if ( $talk == $nontalk ) {
- $this->output( "...watchlist talk page rows already present\n" );
+ $this->output( "...watchlist talk page rows already present.\n" );
return;
}
'wl_title' => 'wl_title',
'wl_notificationtimestamp' => 'wl_notificationtimestamp'
), array( 'NOT (wl_namespace & 1)' ), __METHOD__, 'IGNORE' );
- $this->output( "ok\n" );
+ $this->output( "done.\n" );
}
function doSchemaRestructuring() {
- if ( $this->db->tableExists( 'page' ) ) {
+ if ( $this->db->tableExists( 'page', __METHOD__ ) ) {
$this->output( "...page table already exists.\n" );
return;
}
$this->output( wfTimestamp( TS_DB ) );
$this->output( "......<b>Found duplicate entries</b>\n" );
$this->output( sprintf( "<b> %-60s %3s %5s</b>\n", 'Title', 'NS', 'Count' ) );
+ $duplicate = array();
foreach ( $rows as $row ) {
if ( ! isset( $duplicate[$row->cur_namespace] ) ) {
$duplicate[$row->cur_namespace] = array();
$this->output( "......<b>Deleted</b> " . $this->db->affectedRows() . " records.\n" );
}
-
$this->output( wfTimestamp( TS_DB ) );
$this->output( "......Creating tables.\n" );
$this->db->query( "CREATE TABLE $page (
} else {
$this->output( "Promoting $field from $info->Type to int... " );
$this->db->query( "ALTER TABLE $tablename MODIFY $field int NOT NULL", __METHOD__ );
- $this->output( "ok\n" );
+ $this->output( "done.\n" );
}
}
}
protected function doPagelinksUpdate() {
- if ( $this->db->tableExists( 'pagelinks' ) ) {
+ if ( $this->db->tableExists( 'pagelinks', __METHOD__ ) ) {
$this->output( "...already have pagelinks table.\n" );
return;
}
$this->output( "Converting links and brokenlinks tables to pagelinks... " );
$this->applyPatch( 'patch-pagelinks.sql' );
- $this->output( "ok\n" );
+ $this->output( "done.\n" );
global $wgContLang;
foreach ( MWNamespace::getCanonicalNamespaces() as $ns => $name ) {
$likeprefix = str_replace( '_', '\\_', $prefix );
$sql = "UPDATE $pagelinks
- SET pl_namespace=$ns,
- pl_title=TRIM(LEADING '$prefix:' FROM pl_title)
- WHERE pl_namespace=0
- AND pl_title LIKE '$likeprefix:%'";
+ SET pl_namespace=$ns,
+ pl_title=TRIM(LEADING '$prefix:' FROM pl_title)
+ WHERE pl_namespace=0
+ AND pl_title LIKE '$likeprefix:%'";
$this->db->query( $sql, __METHOD__ );
- $this->output( "ok\n" );
+ $this->output( "done.\n" );
}
}
protected function doUserUniqueUpdate() {
- $duper = new UserDupes( $this->db );
+ $duper = new UserDupes( $this->db, array( $this, 'output' ) );
if ( $duper->hasUniqueIndex() ) {
$this->output( "...already have unique user_name index.\n" );
return;
}
$this->output( "Adding unique index on user_name... " );
$this->applyPatch( 'patch-user_nameindex.sql' );
- $this->output( "ok\n" );
+ $this->output( "done.\n" );
}
protected function doUserGroupsUpdate() {
- if ( $this->db->tableExists( 'user_groups' ) ) {
+ if ( $this->db->tableExists( 'user_groups', __METHOD__ ) ) {
$info = $this->db->fieldInfo( 'user_groups', 'ug_group' );
if ( $info->type() == 'int' ) {
$oldug = $this->db->tableName( 'user_groups' );
$newug = $this->db->tableName( 'user_groups_bogus' );
$this->output( "user_groups table exists but is in bogus intermediate format. Renaming to $newug... " );
$this->db->query( "ALTER TABLE $oldug RENAME TO $newug", __METHOD__ );
- $this->output( "ok\n" );
+ $this->output( "done.\n" );
$this->output( "Re-adding fresh user_groups table... " );
$this->applyPatch( 'patch-user_groups.sql' );
- $this->output( "ok\n" );
+ $this->output( "done.\n" );
$this->output( "***\n" );
$this->output( "*** WARNING: You will need to manually fix up user permissions in the user_groups\n" );
$this->output( "Adding user_groups table... " );
$this->applyPatch( 'patch-user_groups.sql' );
- $this->output( "ok\n" );
+ $this->output( "done.\n" );
- if ( !$this->db->tableExists( 'user_rights' ) ) {
- if ( $this->db->fieldExists( 'user', 'user_rights' ) ) {
+ if ( !$this->db->tableExists( 'user_rights', __METHOD__ ) ) {
+ if ( $this->db->fieldExists( 'user', 'user_rights', __METHOD__ ) ) {
$this->output( "Upgrading from a 1.3 or older database? Breaking out user_rights for conversion..." );
$this->db->applyPatch( 'patch-user_rights.sql' );
- $this->output( "ok\n" );
+ $this->output( "done.\n" );
} else {
$this->output( "*** WARNING: couldn't locate user_rights table or field for upgrade.\n" );
$this->output( "*** You may need to manually configure some sysops by manipulating\n" );
__METHOD__ );
}
}
- $this->output( "ok\n" );
+ $this->output( "done.\n" );
}
/**
$this->output( "Making wl_notificationtimestamp nullable... " );
$this->applyPatch( 'patch-watchlist-null.sql' );
- $this->output( "ok\n" );
+ $this->output( "done.\n" );
}
/**
$rows = $this->db->affectedRows();
if( $rows ) {
- $this->output( "Set page_random to a random value on $row rows where it was set to 0\n" );
+ $this->output( "Set page_random to a random value on $rows rows where it was set to 0\n" );
} else {
$this->output( "...no page_random rows needed to be set\n" );
}
}
protected function doTemplatelinksUpdate() {
- if ( $this->db->tableExists( 'templatelinks' ) ) {
+ if ( $this->db->tableExists( 'templatelinks', __METHOD__ ) ) {
$this->output( "...templatelinks table already exists\n" );
return;
}
foreach ( $res as $row ) {
$count = ( $count + 1 ) % 100;
if ( $count == 0 ) {
- wfWaitForSlaves( 10 );
+ wfWaitForSlaves();
}
$this->db->insert( 'templatelinks',
array(
* -- Andrew Garrett, January 2007.
*/
protected function doRestrictionsUpdate() {
- if ( $this->db->tableExists( 'page_restrictions' ) ) {
+ if ( $this->db->tableExists( 'page_restrictions', __METHOD__ ) ) {
$this->output( "...page_restrictions table already exists.\n" );
return;
}
$this->output( "Creating page_restrictions table..." );
$this->applyPatch( 'patch-page_restrictions.sql' );
$this->applyPatch( 'patch-page_restrictions_sortkey.sql' );
- $this->output( "ok\n" );
+ $this->output( "done.\n" );
$this->output( "Migrating old restrictions to new table...\n" );
$task = $this->maintenance->runChild( 'UpdateRestrictions' );
}
protected function doPopulateParentId() {
- if ( $this->updateRowExists( 'populate rev_parent_id' ) ) {
- $this->output( "...rev_parent_id column already populated.\n" );
- return;
- }
+ if ( !$this->updateRowExists( 'populate rev_parent_id' ) ) {
+ $this->output(
+ "Populating rev_parent_id fields, printing progress markers. For large\n" .
+ "databases, you may want to hit Ctrl-C and do this manually with\n" .
+ "maintenance/populateParentId.php.\n" );
- $task = $this->maintenance->runChild( 'PopulateParentId' );
- $task->execute();
+ $task = $this->maintenance->runChild( 'PopulateParentId' );
+ $task->execute();
+ }
}
protected function doMaybeProfilingMemoryUpdate() {
- if ( !$this->db->tableExists( 'profiling' ) ) {
+ if ( !$this->db->tableExists( 'profiling', __METHOD__ ) ) {
// Simply ignore
- } elseif ( $this->db->fieldExists( 'profiling', 'pf_memory' ) ) {
+ } elseif ( $this->db->fieldExists( 'profiling', 'pf_memory', __METHOD__ ) ) {
$this->output( "...profiling table has pf_memory field.\n" );
} else {
$this->output( "Adding pf_memory field to table profiling..." );
$this->applyPatch( 'patch-profiling-memory.sql' );
- $this->output( "ok\n" );
+ $this->output( "done.\n" );
}
}
protected function doFilearchiveIndicesUpdate() {
$info = $this->db->indexInfo( 'filearchive', 'fa_user_timestamp', __METHOD__ );
if ( !$info ) {
+ $this->output( "Updating filearchive indices..." );
$this->applyPatch( 'patch-filearchive-user-index.sql' );
- $this->output( "...filearchive indices updated\n" );
+ $this->output( "done.\n" );
}
}
$this->output( "Making pl_namespace, tl_namespace and il_to indices UNIQUE... " );
$this->applyPatch( 'patch-pl-tl-il-unique.sql' );
- $this->output( "ok\n" );
+ $this->output( "done.\n" );
}
protected function renameEuWikiId() {
- if ( $this->db->fieldExists( 'external_user', 'eu_local_id' ) ) {
+ if ( $this->db->fieldExists( 'external_user', 'eu_local_id', __METHOD__ ) ) {
$this->output( "...eu_wiki_id already renamed to eu_local_id.\n" );
return;
}
$this->output( "Renaming eu_wiki_id -> eu_local_id... " );
$this->applyPatch( 'patch-eu_local_id.sql' );
- $this->output( "ok\n" );
+ $this->output( "done.\n" );
}
protected function doUpdateMimeMinorField() {
$this->output( "Altering all *_mime_minor fields to 100 bytes in size ... " );
$this->applyPatch( 'patch-mime_minor_length.sql' );
- $this->output( "ok\n" );
- }
-
- protected function doPopulateRevLen() {
- if ( $this->updateRowExists( 'populate rev_len' ) ) {
- $this->output( "...rev_len column already populated.\n" );
- return;
- }
-
- $task = $this->maintenance->runChild( 'PopulateRevisionLength' );
- $task->execute();
+ $this->output( "done.\n" );
}
protected function doClFieldsUpdate() {
$this->applyPatch( 'patch-categorylinks-better-collation2.sql' );
$this->output( "done.\n" );
}
+
+ protected function doLangLinksLengthUpdate() {
+ $langlinks = $this->db->tableName( 'langlinks' );
+ $res = $this->db->query( "SHOW COLUMNS FROM $langlinks LIKE 'll_lang'" );
+ $row = $this->db->fetchObject( $res );
+
+ if ( $row && $row->Type == "varbinary(10)" ) {
+ $this->output( 'Updating length of ll_lang in langlinks...' );
+ $this->applyPatch( 'patch-langlinks-ll_lang-20.sql' );
+ $this->output( "done.\n" );
+ } else {
+ $this->output( "...ll_lang is up-to-date.\n" );
+ }
+ }
+
+ protected function doUserNewTalkTimestampNotNull() {
+ $info = $this->db->fieldInfo( 'user_newtalk', 'user_last_timestamp' );
+ if ( $info->isNullable() ) {
+ $this->output( "...user_last_timestamp is already nullable.\n" );
+ return;
+ }
+
+ $this->output( "Making user_last_timestamp nullable... " );
+ $this->applyPatch( 'patch-user-newtalk-timestamp-null.sql' );
+ $this->output( "done.\n" );
+ }
}