3 * Sqlite-specific updater.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
25 * Class for handling updates to Sqlite databases.
30 class SqliteUpdater
extends DatabaseUpdater
{
32 protected function getCoreUpdateList() {
35 array( 'addField', 'site_stats', 'ss_active_users', 'patch-ss_active_users.sql' ),
36 array( 'doActiveUsersInit' ),
37 array( 'addField', 'ipblocks', 'ipb_allow_usertalk', 'patch-ipb_allow_usertalk.sql' ),
38 array( 'sqliteInitialIndexes' ),
41 array( 'addTable', 'change_tag', 'patch-change_tag.sql' ),
42 array( 'addTable', 'tag_summary', 'patch-change_tag.sql' ),
43 array( 'addTable', 'valid_tag', 'patch-change_tag.sql' ),
46 array( 'addTable', 'user_properties', 'patch-user_properties.sql' ),
47 array( 'addTable', 'log_search', 'patch-log_search.sql' ),
48 array( 'addField', 'logging', 'log_user_text', 'patch-log_user_text.sql' ),
49 array( 'doLogUsertextPopulation' ), # listed separately from the previous update because 1.16 was released without this update
50 array( 'doLogSearchPopulation' ),
51 array( 'addTable', 'l10n_cache', 'patch-l10n_cache.sql' ),
52 array( 'addTable', 'external_user', 'patch-external_user.sql' ),
53 array( 'addIndex', 'log_search', 'ls_field_val', 'patch-log_search-rename-index.sql' ),
54 array( 'addIndex', 'change_tag', 'change_tag_rc_tag', 'patch-change_tag-indexes.sql' ),
55 array( 'addField', 'redirect', 'rd_interwiki', 'patch-rd_interwiki.sql' ),
56 array( 'doUpdateTranscacheField' ),
57 array( 'sqliteSetupSearchindex' ),
60 array( 'addTable', 'iwlinks', 'patch-iwlinks.sql' ),
61 array( 'addIndex', 'iwlinks', 'iwl_prefix_title_from', 'patch-rename-iwl_prefix.sql' ),
62 array( 'addField', 'updatelog', 'ul_value', 'patch-ul_value.sql' ),
63 array( 'addField', 'interwiki', 'iw_api', 'patch-iw_api_and_wikiid.sql' ),
64 array( 'dropIndex', 'iwlinks', 'iwl_prefix', 'patch-kill-iwl_prefix.sql' ),
65 array( 'dropIndex', 'iwlinks', 'iwl_prefix_from_title', 'patch-kill-iwl_pft.sql' ),
66 array( 'addField', 'categorylinks', 'cl_collation', 'patch-categorylinks-better-collation.sql' ),
67 array( 'doCollationUpdate' ),
68 array( 'addTable', 'msg_resource', 'patch-msg_resource.sql' ),
69 array( 'addTable', 'module_deps', 'patch-module_deps.sql' ),
70 array( 'dropIndex', 'archive', 'ar_page_revid', 'patch-archive_kill_ar_page_revid.sql' ),
71 array( 'addIndex', 'archive', 'ar_revid', 'patch-archive_ar_revid.sql' ),
74 array( 'addIndex', 'user', 'user_email', 'patch-user_email_index.sql' ),
75 array( 'addTable', 'uploadstash', 'patch-uploadstash.sql' ),
76 array( 'addTable', 'user_former_groups', 'patch-user_former_groups.sql'),
79 array( 'addIndex', 'logging', 'type_action', 'patch-logging-type-action-index.sql'),
80 array( 'doMigrateUserOptions' ),
81 array( 'dropField', 'user', 'user_options', 'patch-drop-user_options.sql' ),
82 array( 'addField', 'revision', 'rev_sha1', 'patch-rev_sha1.sql' ),
83 array( 'addField', 'archive', 'ar_sha1', 'patch-ar_sha1.sql' ),
84 array( 'addIndex', 'page', 'page_redirect_namespace_len', 'patch-page_redirect_namespace_len.sql' ),
85 array( 'modifyField', 'user_groups', 'ug_group', 'patch-ug_group-length-increase.sql' ),
86 array( 'addField', 'uploadstash', 'us_chunk_inx', 'patch-uploadstash_chunk.sql' ),
87 array( 'addfield', 'job', 'job_timestamp', 'patch-jobs-add-timestamp.sql' ),
88 array( 'modifyField', 'user_former_groups', 'ufg_group', 'patch-ug_group-length-increase.sql' ),
91 array( 'addTable', 'config', 'patch-config.sql' ),
92 array( 'addIndex', 'revision', 'page_user_timestamp', 'patch-revision-user-page-index.sql' ),
93 array( 'addField', 'ipblocks', 'ipb_parent_block_id', 'patch-ipb-parent-block-id.sql' ),
94 array( 'addIndex', 'ipblocks', 'ipb_parent_block_id', 'patch-ipb-parent-block-id-index.sql' ),
98 protected function sqliteInitialIndexes() {
99 // initial-indexes.sql fails if the indexes are already present, so we perform a quick check if our database is newer.
100 if ( $this->updateRowExists( 'initial_indexes' ) ||
$this->db
->indexExists( 'user', 'user_name', __METHOD__
) ) {
101 $this->output( "...have initial indexes\n" );
104 $this->output( "Adding initial indexes..." );
105 $this->applyPatch( 'initial-indexes.sql' );
106 $this->output( "done\n" );
109 protected function sqliteSetupSearchindex() {
110 $module = DatabaseSqlite
::getFulltextSearchModule();
111 $fts3tTable = $this->updateRowExists( 'fts3' );
112 if ( $fts3tTable && !$module ) {
113 $this->output( '...PHP is missing FTS3 support, downgrading tables...' );
114 $this->applyPatch( 'searchindex-no-fts.sql' );
115 $this->output( "done\n" );
116 } elseif ( !$fts3tTable && $module == 'FTS3' ) {
117 $this->output( '...adding FTS3 search capabilities...' );
118 $this->applyPatch( 'searchindex-fts3.sql' );
119 $this->output( "done\n" );
121 $this->output( "...fulltext search table appears to be in order.\n" );