MediaWiki  REL1_22
SqliteUpdater.php
Go to the documentation of this file.
00001 <?php
00030 class SqliteUpdater extends DatabaseUpdater {
00031 
00032     protected function getCoreUpdateList() {
00033         return array(
00034             // 1.14
00035             array( 'addField', 'site_stats', 'ss_active_users', 'patch-ss_active_users.sql' ),
00036             array( 'doActiveUsersInit' ),
00037             array( 'addField', 'ipblocks', 'ipb_allow_usertalk', 'patch-ipb_allow_usertalk.sql' ),
00038             array( 'sqliteInitialIndexes' ),
00039 
00040             // 1.15
00041             array( 'addTable', 'change_tag', 'patch-change_tag.sql' ),
00042             array( 'addTable', 'tag_summary', 'patch-tag_summary.sql' ),
00043             array( 'addTable', 'valid_tag', 'patch-valid_tag.sql' ),
00044 
00045             // 1.16
00046             array( 'addTable', 'user_properties', 'patch-user_properties.sql' ),
00047             array( 'addTable', 'log_search', 'patch-log_search.sql' ),
00048             array( 'addField', 'logging', 'log_user_text', 'patch-log_user_text.sql' ),
00049             # listed separately from the previous update because 1.16 was released without this update
00050             array( 'doLogUsertextPopulation' ),
00051             array( 'doLogSearchPopulation' ),
00052             array( 'addTable', 'l10n_cache', 'patch-l10n_cache.sql' ),
00053             array( 'addIndex', 'log_search', 'ls_field_val', 'patch-log_search-rename-index.sql' ),
00054             array( 'addIndex', 'change_tag', 'change_tag_rc_tag', 'patch-change_tag-indexes.sql' ),
00055             array( 'addField', 'redirect', 'rd_interwiki', 'patch-rd_interwiki.sql' ),
00056             array( 'doUpdateTranscacheField' ),
00057             array( 'sqliteSetupSearchindex' ),
00058 
00059             // 1.17
00060             array( 'addTable', 'iwlinks', 'patch-iwlinks.sql' ),
00061             array( 'addIndex', 'iwlinks', 'iwl_prefix_title_from', 'patch-rename-iwl_prefix.sql' ),
00062             array( 'addField', 'updatelog', 'ul_value', 'patch-ul_value.sql' ),
00063             array( 'addField', 'interwiki', 'iw_api', 'patch-iw_api_and_wikiid.sql' ),
00064             array( 'dropIndex', 'iwlinks', 'iwl_prefix', 'patch-kill-iwl_prefix.sql' ),
00065             array( 'addField', 'categorylinks', 'cl_collation', 'patch-categorylinks-better-collation.sql' ),
00066             array( 'doCollationUpdate' ),
00067             array( 'addTable', 'msg_resource', 'patch-msg_resource.sql' ),
00068             array( 'addTable', 'module_deps', 'patch-module_deps.sql' ),
00069             array( 'dropIndex', 'archive', 'ar_page_revid', 'patch-archive_kill_ar_page_revid.sql' ),
00070             array( 'addIndex', 'archive', 'ar_revid', 'patch-archive_ar_revid.sql' ),
00071 
00072             // 1.18
00073             array( 'addIndex', 'user', 'user_email', 'patch-user_email_index.sql' ),
00074             array( 'addTable', 'uploadstash', 'patch-uploadstash.sql' ),
00075             array( 'addTable', 'user_former_groups', 'patch-user_former_groups.sql' ),
00076 
00077             // 1.19
00078             array( 'addIndex', 'logging', 'type_action', 'patch-logging-type-action-index.sql' ),
00079             array( 'doMigrateUserOptions' ),
00080             array( 'dropField', 'user', 'user_options', 'patch-drop-user_options.sql' ),
00081             array( 'addField', 'revision', 'rev_sha1', 'patch-rev_sha1.sql' ),
00082             array( 'addField', 'archive', 'ar_sha1', 'patch-ar_sha1.sql' ),
00083             array( 'addIndex', 'page', 'page_redirect_namespace_len',
00084                 'patch-page_redirect_namespace_len.sql' ),
00085             array( 'addField', 'uploadstash', 'us_chunk_inx', 'patch-uploadstash_chunk.sql' ),
00086             array( 'addfield', 'job', 'job_timestamp', 'patch-jobs-add-timestamp.sql' ),
00087 
00088             // 1.20
00089             array( 'addIndex', 'revision', 'page_user_timestamp', 'patch-revision-user-page-index.sql' ),
00090             array( 'addField', 'ipblocks', 'ipb_parent_block_id', 'patch-ipb-parent-block-id.sql' ),
00091             array( 'addIndex', 'ipblocks', 'ipb_parent_block_id', 'patch-ipb-parent-block-id-index.sql' ),
00092             array( 'dropField', 'category', 'cat_hidden', 'patch-cat_hidden.sql' ),
00093 
00094             // 1.21
00095             array( 'addField', 'revision', 'rev_content_format', 'patch-revision-rev_content_format.sql' ),
00096             array( 'addField', 'revision', 'rev_content_model', 'patch-revision-rev_content_model.sql' ),
00097             array( 'addField', 'archive', 'ar_content_format', 'patch-archive-ar_content_format.sql' ),
00098             array( 'addField', 'archive', 'ar_content_model', 'patch-archive-ar_content_model.sql' ),
00099             array( 'addField', 'page', 'page_content_model', 'patch-page-page_content_model.sql' ),
00100             array( 'dropField', 'site_stats', 'ss_admins', 'patch-drop-ss_admins.sql' ),
00101             array( 'dropField', 'recentchanges', 'rc_moved_to_title', 'patch-rc_moved.sql' ),
00102             array( 'addTable', 'sites', 'patch-sites.sql' ),
00103             array( 'addField', 'filearchive', 'fa_sha1', 'patch-fa_sha1.sql' ),
00104             array( 'addField', 'job', 'job_token', 'patch-job_token.sql' ),
00105             array( 'addField', 'job', 'job_attempts', 'patch-job_attempts.sql' ),
00106             array( 'doEnableProfiling' ),
00107             array( 'addField', 'uploadstash', 'us_props', 'patch-uploadstash-us_props.sql' ),
00108             array( 'modifyField', 'user_groups', 'ug_group', 'patch-ug_group-length-increase-255.sql' ),
00109             array( 'modifyField', 'user_former_groups', 'ufg_group',
00110                 'patch-ufg_group-length-increase-255.sql' ),
00111             array( 'addIndex', 'page_props', 'pp_propname_page',
00112                 'patch-page_props-propname-page-index.sql' ),
00113             array( 'addIndex', 'image', 'img_media_mime', 'patch-img_media_mime-index.sql' ),
00114             array( 'addIndex', 'iwlinks', 'iwl_prefix_from_title', 'patch-iwlinks-from-title-index.sql' ),
00115             array( 'addField', 'archive', 'ar_id', 'patch-archive-ar_id.sql' ),
00116             array( 'addField', 'externallinks', 'el_id', 'patch-externallinks-el_id.sql' ),
00117         );
00118     }
00119 
00120     protected function sqliteInitialIndexes() {
00121         // initial-indexes.sql fails if the indexes are already present,
00122         // so we perform a quick check if our database is newer.
00123         if ( $this->updateRowExists( 'initial_indexes' ) ||
00124             $this->db->indexExists( 'user', 'user_name', __METHOD__ )
00125         ) {
00126             $this->output( "...have initial indexes\n" );
00127 
00128             return;
00129         }
00130         $this->applyPatch( 'initial-indexes.sql', false, "Adding initial indexes" );
00131     }
00132 
00133     protected function sqliteSetupSearchindex() {
00134         $module = DatabaseSqlite::getFulltextSearchModule();
00135         $fts3tTable = $this->updateRowExists( 'fts3' );
00136         if ( $fts3tTable && !$module ) {
00137             $this->applyPatch(
00138                 'searchindex-no-fts.sql',
00139                 false,
00140                 'PHP is missing FTS3 support, downgrading tables'
00141             );
00142         } elseif ( !$fts3tTable && $module == 'FTS3' ) {
00143             $this->applyPatch( 'searchindex-fts3.sql', false, "Adding FTS3 search capabilities" );
00144         } else {
00145             $this->output( "...fulltext search table appears to be in order.\n" );
00146         }
00147     }
00148 
00149     protected function doEnableProfiling() {
00150         global $wgProfileToDatabase;
00151         if ( $wgProfileToDatabase === true && !$this->db->tableExists( 'profiling', __METHOD__ ) ) {
00152             $this->applyPatch( 'patch-profiling.sql', false, 'Add profiling table' );
00153         }
00154     }
00155 }