Merge "Typo fix"
[mediawiki.git] / includes / installer / SqliteUpdater.php
blob28d8d66b1b700e5e4c1192e8e86471a8da6858e3
1 <?php
2 /**
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
20 * @file
21 * @ingroup Deployment
24 /**
25 * Class for handling updates to Sqlite databases.
27 * @ingroup Deployment
28 * @since 1.17
30 class SqliteUpdater extends DatabaseUpdater {
32 protected function getCoreUpdateList() {
33 return array(
34 // 1.14
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' ),
40 // 1.15
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' ),
45 // 1.16
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( 'addIndex', 'log_search', 'ls_field_val', 'patch-log_search-rename-index.sql' ),
53 array( 'addIndex', 'change_tag', 'change_tag_rc_tag', 'patch-change_tag-indexes.sql' ),
54 array( 'addField', 'redirect', 'rd_interwiki', 'patch-rd_interwiki.sql' ),
55 array( 'doUpdateTranscacheField' ),
56 array( 'sqliteSetupSearchindex' ),
58 // 1.17
59 array( 'addTable', 'iwlinks', 'patch-iwlinks.sql' ),
60 array( 'addIndex', 'iwlinks', 'iwl_prefix_title_from', 'patch-rename-iwl_prefix.sql' ),
61 array( 'addField', 'updatelog', 'ul_value', 'patch-ul_value.sql' ),
62 array( 'addField', 'interwiki', 'iw_api', 'patch-iw_api_and_wikiid.sql' ),
63 array( 'dropIndex', 'iwlinks', 'iwl_prefix', 'patch-kill-iwl_prefix.sql' ),
64 array( 'addField', 'categorylinks', 'cl_collation', 'patch-categorylinks-better-collation.sql' ),
65 array( 'doCollationUpdate' ),
66 array( 'addTable', 'msg_resource', 'patch-msg_resource.sql' ),
67 array( 'addTable', 'module_deps', 'patch-module_deps.sql' ),
68 array( 'dropIndex', 'archive', 'ar_page_revid', 'patch-archive_kill_ar_page_revid.sql' ),
69 array( 'addIndex', 'archive', 'ar_revid', 'patch-archive_ar_revid.sql' ),
71 // 1.18
72 array( 'addIndex', 'user', 'user_email', 'patch-user_email_index.sql' ),
73 array( 'addTable', 'uploadstash', 'patch-uploadstash.sql' ),
74 array( 'addTable', 'user_former_groups', 'patch-user_former_groups.sql'),
76 // 1.19
77 array( 'addIndex', 'logging', 'type_action', 'patch-logging-type-action-index.sql'),
78 array( 'doMigrateUserOptions' ),
79 array( 'dropField', 'user', 'user_options', 'patch-drop-user_options.sql' ),
80 array( 'addField', 'revision', 'rev_sha1', 'patch-rev_sha1.sql' ),
81 array( 'addField', 'archive', 'ar_sha1', 'patch-ar_sha1.sql' ),
82 array( 'addIndex', 'page', 'page_redirect_namespace_len', 'patch-page_redirect_namespace_len.sql' ),
83 array( 'addField', 'uploadstash', 'us_chunk_inx', 'patch-uploadstash_chunk.sql' ),
84 array( 'addfield', 'job', 'job_timestamp', 'patch-jobs-add-timestamp.sql' ),
86 // 1.20
87 array( 'addIndex', 'revision', 'page_user_timestamp', 'patch-revision-user-page-index.sql' ),
88 array( 'addField', 'ipblocks', 'ipb_parent_block_id', 'patch-ipb-parent-block-id.sql' ),
89 array( 'addIndex', 'ipblocks', 'ipb_parent_block_id', 'patch-ipb-parent-block-id-index.sql' ),
90 array( 'dropField', 'category', 'cat_hidden', 'patch-cat_hidden.sql' ),
92 // 1.21
93 array( 'addField', 'revision', 'rev_content_format', 'patch-revision-rev_content_format.sql' ),
94 array( 'addField', 'revision', 'rev_content_model', 'patch-revision-rev_content_model.sql' ),
95 array( 'addField', 'archive', 'ar_content_format', 'patch-archive-ar_content_format.sql' ),
96 array( 'addField', 'archive', 'ar_content_model', 'patch-archive-ar_content_model.sql' ),
97 array( 'addField', 'page', 'page_content_model', 'patch-page-page_content_model.sql' ),
99 array( 'dropField', 'site_stats', 'ss_admins', 'patch-drop-ss_admins.sql' ),
100 array( 'dropField', 'recentchanges', 'rc_moved_to_title', 'patch-rc_moved.sql' ),
101 array( 'addTable', 'sites', 'patch-sites.sql' ),
102 array( 'addField', 'filearchive', 'fa_sha1', 'patch-fa_sha1.sql' ),
103 array( 'addField', 'job', 'job_token', 'patch-job_token.sql' ),
104 array( 'addField', 'job', 'job_attempts', 'patch-job_attempts.sql' ),
105 array( 'doEnableProfiling' ),
106 array( 'addField', 'uploadstash', 'us_props', 'patch-uploadstash-us_props.sql' ),
107 array( 'modifyField', 'user_groups', 'ug_group', 'patch-ug_group-length-increase-255.sql' ),
108 array( 'modifyField', 'user_former_groups', 'ufg_group', 'patch-ufg_group-length-increase-255.sql' ),
109 array( 'addIndex', 'page_props', 'pp_propname_page', 'patch-page_props-propname-page-index.sql' ),
110 array( 'addIndex', 'image', 'img_media_mime', 'patch-img_media_mime-index.sql' ),
111 array( 'addIndex', 'iwlinks', 'iwl_prefix_from_title', 'patch-iwlinks-from-title-index.sql' ),
115 protected function sqliteInitialIndexes() {
116 // initial-indexes.sql fails if the indexes are already present, so we perform a quick check if our database is newer.
117 if ( $this->updateRowExists( 'initial_indexes' ) || $this->db->indexExists( 'user', 'user_name', __METHOD__ ) ) {
118 $this->output( "...have initial indexes\n" );
119 return;
121 $this->applyPatch( 'initial-indexes.sql', false, "Adding initial indexes" );
124 protected function sqliteSetupSearchindex() {
125 $module = DatabaseSqlite::getFulltextSearchModule();
126 $fts3tTable = $this->updateRowExists( 'fts3' );
127 if ( $fts3tTable && !$module ) {
128 $this->applyPatch( 'searchindex-no-fts.sql', false, 'PHP is missing FTS3 support, downgrading tables' );
129 } elseif ( !$fts3tTable && $module == 'FTS3' ) {
130 $this->applyPatch( 'searchindex-fts3.sql', false, "Adding FTS3 search capabilities" );
131 } else {
132 $this->output( "...fulltext search table appears to be in order.\n" );
136 protected function doEnableProfiling() {
137 global $wgProfileToDatabase;
138 if ( $wgProfileToDatabase === true && ! $this->db->tableExists( 'profiling', __METHOD__ ) ) {
139 $this->applyPatch( 'patch-profiling.sql', false, 'Add profiling table' );