2010-07-20 22:28:50 +00:00
|
|
|
<?php
|
2010-08-21 18:20:09 +00:00
|
|
|
/**
|
|
|
|
|
* Sqlite-specific updater.
|
|
|
|
|
*
|
2012-05-06 05:50:15 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
2010-08-21 18:20:09 +00:00
|
|
|
* @file
|
|
|
|
|
* @ingroup Deployment
|
|
|
|
|
*/
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-07-20 22:28:50 +00:00
|
|
|
/**
|
2010-07-29 18:36:39 +00:00
|
|
|
* Class for handling updates to Sqlite databases.
|
2010-12-16 11:20:39 +00:00
|
|
|
*
|
2010-07-29 18:36:39 +00:00
|
|
|
* @ingroup Deployment
|
|
|
|
|
* @since 1.17
|
2010-07-20 22:28:50 +00:00
|
|
|
*/
|
|
|
|
|
class SqliteUpdater extends DatabaseUpdater {
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-07-20 22:28:50 +00:00
|
|
|
protected function getCoreUpdateList() {
|
|
|
|
|
return array(
|
2010-08-15 18:13:23 +00:00
|
|
|
// 1.14
|
2013-10-23 12:16:03 +00:00
|
|
|
array( 'addField', 'site_stats', 'ss_active_users', 'patch-ss_active_users.sql' ),
|
2010-09-12 16:24:03 +00:00
|
|
|
array( 'doActiveUsersInit' ),
|
2013-10-23 12:16:03 +00:00
|
|
|
array( 'addField', 'ipblocks', 'ipb_allow_usertalk', 'patch-ipb_allow_usertalk.sql' ),
|
2010-09-11 09:49:57 +00:00
|
|
|
array( 'sqliteInitialIndexes' ),
|
2010-08-15 18:13:23 +00:00
|
|
|
|
|
|
|
|
// 1.15
|
2013-10-23 12:16:03 +00:00
|
|
|
array( 'addTable', 'change_tag', 'patch-change_tag.sql' ),
|
|
|
|
|
array( 'addTable', 'tag_summary', 'patch-tag_summary.sql' ),
|
|
|
|
|
array( 'addTable', 'valid_tag', 'patch-valid_tag.sql' ),
|
2010-08-15 18:13:23 +00:00
|
|
|
|
|
|
|
|
// 1.16
|
2013-10-23 12:16:03 +00:00
|
|
|
array( 'addTable', 'user_properties', 'patch-user_properties.sql' ),
|
|
|
|
|
array( 'addTable', 'log_search', 'patch-log_search.sql' ),
|
|
|
|
|
array( 'addField', 'logging', 'log_user_text', 'patch-log_user_text.sql' ),
|
|
|
|
|
# listed separately from the previous update because 1.16 was released without this update
|
|
|
|
|
array( 'doLogUsertextPopulation' ),
|
2011-02-19 11:49:14 +00:00
|
|
|
array( 'doLogSearchPopulation' ),
|
2013-10-23 12:16:03 +00:00
|
|
|
array( 'addTable', 'l10n_cache', 'patch-l10n_cache.sql' ),
|
|
|
|
|
array( 'addIndex', 'log_search', 'ls_field_val', 'patch-log_search-rename-index.sql' ),
|
|
|
|
|
array( 'addIndex', 'change_tag', 'change_tag_rc_tag', 'patch-change_tag-indexes.sql' ),
|
|
|
|
|
array( 'addField', 'redirect', 'rd_interwiki', 'patch-rd_interwiki.sql' ),
|
2010-09-12 16:24:03 +00:00
|
|
|
array( 'doUpdateTranscacheField' ),
|
2010-09-11 09:49:57 +00:00
|
|
|
array( 'sqliteSetupSearchindex' ),
|
2010-08-15 18:13:23 +00:00
|
|
|
|
|
|
|
|
// 1.17
|
2013-10-23 12:16:03 +00:00
|
|
|
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', 'interwiki', 'iw_api', 'patch-iw_api_and_wikiid.sql' ),
|
|
|
|
|
array( 'dropIndex', 'iwlinks', 'iwl_prefix', 'patch-kill-iwl_prefix.sql' ),
|
|
|
|
|
array( 'addField', 'categorylinks', 'cl_collation', 'patch-categorylinks-better-collation.sql' ),
|
2010-09-12 16:24:03 +00:00
|
|
|
array( 'doCollationUpdate' ),
|
2013-10-23 12:16:03 +00:00
|
|
|
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' ),
|
2011-05-16 23:22:51 +00:00
|
|
|
|
2011-06-15 17:57:00 +00:00
|
|
|
// 1.18
|
2013-10-23 12:16:03 +00:00
|
|
|
array( 'addIndex', 'user', 'user_email', 'patch-user_email_index.sql' ),
|
|
|
|
|
array( 'addTable', 'uploadstash', 'patch-uploadstash.sql' ),
|
|
|
|
|
array( 'addTable', 'user_former_groups', 'patch-user_former_groups.sql' ),
|
2011-07-24 18:55:57 +00:00
|
|
|
|
|
|
|
|
// 1.19
|
2013-10-23 12:16:03 +00:00
|
|
|
array( 'addIndex', 'logging', 'type_action', 'patch-logging-type-action-index.sql' ),
|
2011-09-28 18:08:48 +00:00
|
|
|
array( 'doMigrateUserOptions' ),
|
2013-10-23 12:16:03 +00:00
|
|
|
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( 'addField', 'uploadstash', 'us_chunk_inx', 'patch-uploadstash_chunk.sql' ),
|
|
|
|
|
array( 'addfield', 'job', 'job_timestamp', 'patch-jobs-add-timestamp.sql' ),
|
2012-02-09 01:21:02 +00:00
|
|
|
|
|
|
|
|
// 1.20
|
2012-03-06 00:10:36 +00:00
|
|
|
array( 'addIndex', 'revision', 'page_user_timestamp', 'patch-revision-user-page-index.sql' ),
|
2012-03-28 02:44:32 +00:00
|
|
|
array( 'addField', 'ipblocks', 'ipb_parent_block_id', 'patch-ipb-parent-block-id.sql' ),
|
|
|
|
|
array( 'addIndex', 'ipblocks', 'ipb_parent_block_id', 'patch-ipb-parent-block-id-index.sql' ),
|
2013-10-23 12:16:03 +00:00
|
|
|
array( 'dropField', 'category', 'cat_hidden', 'patch-cat_hidden.sql' ),
|
2012-04-26 11:24:13 +00:00
|
|
|
|
2012-10-05 13:03:24 +00:00
|
|
|
// 1.21
|
2012-10-08 15:26:11 +00:00
|
|
|
array( 'addField', 'revision', 'rev_content_format', 'patch-revision-rev_content_format.sql' ),
|
2013-10-23 12:16:03 +00:00
|
|
|
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( 'dropField', 'site_stats', 'ss_admins', 'patch-drop-ss_admins.sql' ),
|
2012-09-29 10:25:31 +00:00
|
|
|
array( 'dropField', 'recentchanges', 'rc_moved_to_title', 'patch-rc_moved.sql' ),
|
2013-10-23 12:16:03 +00:00
|
|
|
array( 'addTable', 'sites', 'patch-sites.sql' ),
|
|
|
|
|
array( 'addField', 'filearchive', 'fa_sha1', 'patch-fa_sha1.sql' ),
|
|
|
|
|
array( 'addField', 'job', 'job_token', 'patch-job_token.sql' ),
|
|
|
|
|
array( 'addField', 'job', 'job_attempts', 'patch-job_attempts.sql' ),
|
2012-10-07 12:15:57 +00:00
|
|
|
array( 'doEnableProfiling' ),
|
2013-10-23 12:16:03 +00:00
|
|
|
array( 'addField', 'uploadstash', 'us_props', 'patch-uploadstash-us_props.sql' ),
|
2013-01-02 20:20:22 +00:00
|
|
|
array( 'modifyField', 'user_groups', 'ug_group', 'patch-ug_group-length-increase-255.sql' ),
|
2013-10-23 12:16:03 +00:00
|
|
|
array( 'modifyField', 'user_former_groups', 'ufg_group',
|
|
|
|
|
'patch-ufg_group-length-increase-255.sql' ),
|
|
|
|
|
array( 'addIndex', 'page_props', 'pp_propname_page',
|
|
|
|
|
'patch-page_props-propname-page-index.sql' ),
|
2012-11-22 19:12:42 +00:00
|
|
|
array( 'addIndex', 'image', 'img_media_mime', 'patch-img_media_mime-index.sql' ),
|
2013-10-23 12:16:03 +00:00
|
|
|
array( 'addIndex', 'iwlinks', 'iwl_prefix_from_title', 'patch-iwlinks-from-title-index.sql' ),
|
2012-10-28 02:23:50 +00:00
|
|
|
array( 'addField', 'archive', 'ar_id', 'patch-archive-ar_id.sql' ),
|
|
|
|
|
array( 'addField', 'externallinks', 'el_id', 'patch-externallinks-el_id.sql' ),
|
2013-10-25 20:10:42 +00:00
|
|
|
|
|
|
|
|
// 1.22
|
|
|
|
|
array( 'addField', 'recentchanges', 'rc_source', 'patch-rc_source.sql' ),
|
2010-07-20 22:28:50 +00:00
|
|
|
);
|
|
|
|
|
}
|
2010-09-11 09:49:57 +00:00
|
|
|
|
|
|
|
|
protected function sqliteInitialIndexes() {
|
2013-10-23 12:16:03 +00:00
|
|
|
// initial-indexes.sql fails if the indexes are already present,
|
|
|
|
|
// so we perform a quick check if our database is newer.
|
|
|
|
|
if ( $this->updateRowExists( 'initial_indexes' ) ||
|
|
|
|
|
$this->db->indexExists( 'user', 'user_name', __METHOD__ )
|
|
|
|
|
) {
|
2010-10-01 15:11:06 +00:00
|
|
|
$this->output( "...have initial indexes\n" );
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2010-09-11 09:49:57 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2012-08-29 08:07:10 +00:00
|
|
|
$this->applyPatch( 'initial-indexes.sql', false, "Adding initial indexes" );
|
2010-09-11 09:49:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function sqliteSetupSearchindex() {
|
2011-04-11 17:16:41 +00:00
|
|
|
$module = DatabaseSqlite::getFulltextSearchModule();
|
2010-09-12 16:24:03 +00:00
|
|
|
$fts3tTable = $this->updateRowExists( 'fts3' );
|
2013-03-07 16:50:43 +00:00
|
|
|
if ( $fts3tTable && !$module ) {
|
2013-10-23 12:16:03 +00:00
|
|
|
$this->applyPatch(
|
|
|
|
|
'searchindex-no-fts.sql',
|
|
|
|
|
false,
|
|
|
|
|
'PHP is missing FTS3 support, downgrading tables'
|
|
|
|
|
);
|
2010-09-11 09:49:57 +00:00
|
|
|
} elseif ( !$fts3tTable && $module == 'FTS3' ) {
|
2012-08-29 08:07:10 +00:00
|
|
|
$this->applyPatch( 'searchindex-fts3.sql', false, "Adding FTS3 search capabilities" );
|
2010-09-11 09:49:57 +00:00
|
|
|
} else {
|
2010-10-01 15:11:06 +00:00
|
|
|
$this->output( "...fulltext search table appears to be in order.\n" );
|
2010-09-11 09:49:57 +00:00
|
|
|
}
|
|
|
|
|
}
|
2012-10-07 12:15:57 +00:00
|
|
|
|
|
|
|
|
protected function doEnableProfiling() {
|
|
|
|
|
global $wgProfileToDatabase;
|
2013-10-08 11:43:42 +00:00
|
|
|
if ( $wgProfileToDatabase === true && !$this->db->tableExists( 'profiling', __METHOD__ ) ) {
|
2012-10-07 12:15:57 +00:00
|
|
|
$this->applyPatch( 'patch-profiling.sql', false, 'Add profiling table' );
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-07-20 22:28:50 +00:00
|
|
|
}
|