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() {
34 [ 'disableContentHandlerUseDB' ],
37 [ 'addField', 'site_stats', 'ss_active_users', 'patch-ss_active_users.sql' ],
38 [ 'doActiveUsersInit' ],
39 [ 'addField', 'ipblocks', 'ipb_allow_usertalk', 'patch-ipb_allow_usertalk.sql' ],
40 [ 'sqliteInitialIndexes' ],
43 [ 'addTable', 'change_tag', 'patch-change_tag.sql' ],
44 [ 'addTable', 'tag_summary', 'patch-tag_summary.sql' ],
45 [ 'addTable', 'valid_tag', 'patch-valid_tag.sql' ],
48 [ 'addTable', 'user_properties', 'patch-user_properties.sql' ],
49 [ 'addTable', 'log_search', 'patch-log_search.sql' ],
50 [ 'addField', 'logging', 'log_user_text', 'patch-log_user_text.sql' ],
51 # listed separately from the previous update because 1.16 was released without this update
52 [ 'doLogUsertextPopulation' ],
53 [ 'doLogSearchPopulation' ],
54 [ 'addTable', 'l10n_cache', 'patch-l10n_cache.sql' ],
55 [ 'addIndex', 'log_search', 'ls_field_val', 'patch-log_search-rename-index.sql' ],
56 [ 'addIndex', 'change_tag', 'change_tag_rc_tag', 'patch-change_tag-indexes.sql' ],
57 [ 'addField', 'redirect', 'rd_interwiki', 'patch-rd_interwiki.sql' ],
58 [ 'doUpdateTranscacheField' ],
59 [ 'sqliteSetupSearchindex' ],
62 [ 'addTable', 'iwlinks', 'patch-iwlinks.sql' ],
63 [ 'addIndex', 'iwlinks', 'iwl_prefix_title_from', 'patch-rename-iwl_prefix.sql' ],
64 [ 'addField', 'updatelog', 'ul_value', 'patch-ul_value.sql' ],
65 [ 'addField', 'interwiki', 'iw_api', 'patch-iw_api_and_wikiid.sql' ],
66 [ 'dropIndex', 'iwlinks', 'iwl_prefix', 'patch-kill-iwl_prefix.sql' ],
67 [ 'addField', 'categorylinks', 'cl_collation', 'patch-categorylinks-better-collation.sql' ],
68 [ 'addTable', 'module_deps', 'patch-module_deps.sql' ],
69 [ 'dropIndex', 'archive', 'ar_page_revid', 'patch-archive_kill_ar_page_revid.sql' ],
70 [ 'addIndex', 'archive', 'ar_revid', 'patch-archive_ar_revid.sql' ],
73 [ 'addIndex', 'user', 'user_email', 'patch-user_email_index.sql' ],
74 [ 'addTable', 'uploadstash', 'patch-uploadstash.sql' ],
75 [ 'addTable', 'user_former_groups', 'patch-user_former_groups.sql' ],
78 [ 'addIndex', 'logging', 'type_action', 'patch-logging-type-action-index.sql' ],
79 [ 'doMigrateUserOptions' ],
80 [ 'dropField', 'user', 'user_options', 'patch-drop-user_options.sql' ],
81 [ 'addField', 'revision', 'rev_sha1', 'patch-rev_sha1.sql' ],
82 [ 'addField', 'archive', 'ar_sha1', 'patch-ar_sha1.sql' ],
83 [ 'addIndex', 'page', 'page_redirect_namespace_len',
84 'patch-page_redirect_namespace_len.sql' ],
85 [ 'addField', 'uploadstash', 'us_chunk_inx', 'patch-uploadstash_chunk.sql' ],
86 [ 'addfield', 'job', 'job_timestamp', 'patch-jobs-add-timestamp.sql' ],
89 [ 'addIndex', 'revision', 'page_user_timestamp', 'patch-revision-user-page-index.sql' ],
90 [ 'addField', 'ipblocks', 'ipb_parent_block_id', 'patch-ipb-parent-block-id.sql' ],
91 [ 'addIndex', 'ipblocks', 'ipb_parent_block_id', 'patch-ipb-parent-block-id-index.sql' ],
92 [ 'dropField', 'category', 'cat_hidden', 'patch-cat_hidden.sql' ],
95 [ 'addField', 'revision', 'rev_content_format', 'patch-revision-rev_content_format.sql' ],
96 [ 'addField', 'revision', 'rev_content_model', 'patch-revision-rev_content_model.sql' ],
97 [ 'addField', 'archive', 'ar_content_format', 'patch-archive-ar_content_format.sql' ],
98 [ 'addField', 'archive', 'ar_content_model', 'patch-archive-ar_content_model.sql' ],
99 [ 'addField', 'page', 'page_content_model', 'patch-page-page_content_model.sql' ],
100 [ 'enableContentHandlerUseDB' ],
102 [ 'dropField', 'site_stats', 'ss_admins', 'patch-drop-ss_admins.sql' ],
103 [ 'dropField', 'recentchanges', 'rc_moved_to_title', 'patch-rc_moved.sql' ],
104 [ 'addTable', 'sites', 'patch-sites.sql' ],
105 [ 'addField', 'filearchive', 'fa_sha1', 'patch-fa_sha1.sql' ],
106 [ 'addField', 'job', 'job_token', 'patch-job_token.sql' ],
107 [ 'addField', 'job', 'job_attempts', 'patch-job_attempts.sql' ],
108 [ 'doEnableProfiling' ],
109 [ 'addField', 'uploadstash', 'us_props', 'patch-uploadstash-us_props.sql' ],
110 [ 'modifyField', 'user_groups', 'ug_group', 'patch-ug_group-length-increase-255.sql' ],
111 [ 'modifyField', 'user_former_groups', 'ufg_group',
112 'patch-ufg_group-length-increase-255.sql' ],
113 [ 'addIndex', 'page_props', 'pp_propname_page',
114 'patch-page_props-propname-page-index.sql' ],
115 [ 'addIndex', 'image', 'img_media_mime', 'patch-img_media_mime-index.sql' ],
118 [ 'addIndex', 'iwlinks', 'iwl_prefix_from_title', 'patch-iwlinks-from-title-index.sql' ],
119 [ 'addField', 'archive', 'ar_id', 'patch-archive-ar_id.sql' ],
120 [ 'addField', 'externallinks', 'el_id', 'patch-externallinks-el_id.sql' ],
123 [ 'addField', 'recentchanges', 'rc_source', 'patch-rc_source.sql' ],
124 [ 'addIndex', 'logging', 'log_user_text_type_time',
125 'patch-logging_user_text_type_time_index.sql' ],
126 [ 'addIndex', 'logging', 'log_user_text_time', 'patch-logging_user_text_time_index.sql' ],
127 [ 'addField', 'page', 'page_links_updated', 'patch-page_links_updated.sql' ],
128 [ 'addField', 'user', 'user_password_expires', 'patch-user_password_expire.sql' ],
131 [ 'addField', 'page_props', 'pp_sortkey', 'patch-pp_sortkey.sql' ],
132 [ 'dropField', 'recentchanges', 'rc_cur_time', 'patch-drop-rc_cur_time.sql' ],
133 [ 'addIndex', 'watchlist', 'wl_user_notificationtimestamp',
134 'patch-watchlist-user-notificationtimestamp-index.sql' ],
135 [ 'addField', 'page', 'page_lang', 'patch-page-page_lang.sql' ],
136 [ 'addField', 'pagelinks', 'pl_from_namespace', 'patch-pl_from_namespace.sql' ],
137 [ 'addField', 'templatelinks', 'tl_from_namespace', 'patch-tl_from_namespace.sql' ],
138 [ 'addField', 'imagelinks', 'il_from_namespace', 'patch-il_from_namespace.sql' ],
141 [ 'dropTable', 'hitcounter' ],
142 [ 'dropField', 'site_stats', 'ss_total_views', 'patch-drop-ss_total_views.sql' ],
143 [ 'dropField', 'page', 'page_counter', 'patch-drop-page_counter.sql' ],
144 [ 'modifyField', 'filearchive', 'fa_deleted_reason', 'patch-editsummary-length.sql' ],
147 [ 'dropTable', 'msg_resource_links' ],
148 [ 'dropTable', 'msg_resource' ],
149 [ 'addTable', 'bot_passwords', 'patch-bot_passwords.sql' ],
150 [ 'addField', 'watchlist', 'wl_id', 'patch-watchlist-wl_id.sql' ],
151 [ 'dropIndex', 'categorylinks', 'cl_collation', 'patch-kill-cl_collation_index.sql' ],
152 [ 'addIndex', 'categorylinks', 'cl_collation_ext',
153 'patch-add-cl_collation_ext_index.sql' ],
154 [ 'doCollationUpdate' ],
157 [ 'addIndex', 'recentchanges', 'rc_name_type_patrolled_timestamp',
158 'patch-add-rc_name_type_patrolled_timestamp_index.sql' ],
159 [ 'addField', 'change_tag', 'ct_id', 'patch-change_tag-ct_id.sql' ],
160 [ 'addField', 'tag_summary', 'ts_id', 'patch-tag_summary-ts_id.sql' ],
163 [ 'addField', 'externallinks', 'el_index_60', 'patch-externallinks-el_index_60.sql' ],
167 protected function sqliteInitialIndexes() {
168 // initial-indexes.sql fails if the indexes are already present,
169 // so we perform a quick check if our database is newer.
170 if ( $this->updateRowExists( 'initial_indexes' ) ||
171 $this->db
->indexExists( 'user', 'user_name', __METHOD__
)
173 $this->output( "...have initial indexes\n" );
177 $this->applyPatch( 'initial-indexes.sql', false, "Adding initial indexes" );
180 protected function sqliteSetupSearchindex() {
181 $module = DatabaseSqlite
::getFulltextSearchModule();
182 $fts3tTable = $this->updateRowExists( 'fts3' );
183 if ( $fts3tTable && !$module ) {
185 'searchindex-no-fts.sql',
187 'PHP is missing FTS3 support, downgrading tables'
189 } elseif ( !$fts3tTable && $module == 'FTS3' ) {
190 $this->applyPatch( 'searchindex-fts3.sql', false, "Adding FTS3 search capabilities" );
192 $this->output( "...fulltext search table appears to be in order.\n" );