MediaWiki REL1_34
SqliteUpdater.php
Go to the documentation of this file.
1<?php
25
33
34 protected function getCoreUpdateList() {
35 return [
36 [ 'disableContentHandlerUseDB' ],
37
38 // 1.14
39 [ 'addField', 'site_stats', 'ss_active_users', 'patch-ss_active_users.sql' ],
40 [ 'doActiveUsersInit' ],
41 [ 'addField', 'ipblocks', 'ipb_allow_usertalk', 'patch-ipb_allow_usertalk.sql' ],
42 [ 'sqliteInitialIndexes' ],
43
44 // 1.15
45 [ 'addTable', 'change_tag', 'patch-change_tag.sql' ],
46
47 // 1.16
48 [ 'addTable', 'user_properties', 'patch-user_properties.sql' ],
49 [ 'addTable', 'log_search', 'patch-log_search.sql' ],
50 [ 'ifNoActorTable', '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 [ 'ifNoActorTable', 'doLogUsertextPopulation' ],
53 [ 'doLogSearchPopulation' ],
54 [ 'addTable', 'l10n_cache', 'patch-l10n_cache.sql' ],
55 [ 'dropIndex', 'change_tag', 'ct_rc_id', 'patch-change_tag-indexes.sql' ],
56 [ 'addField', 'redirect', 'rd_interwiki', 'patch-rd_interwiki.sql' ],
57 [ 'sqliteSetupSearchindex' ],
58
59 // 1.17
60 [ 'addTable', 'iwlinks', 'patch-iwlinks.sql' ],
61 [ 'addIndex', 'iwlinks', 'iwl_prefix_title_from', 'patch-rename-iwl_prefix.sql' ],
62 [ 'addField', 'updatelog', 'ul_value', 'patch-ul_value.sql' ],
63 [ 'addField', 'interwiki', 'iw_api', 'patch-iw_api_and_wikiid.sql' ],
64 [ 'dropIndex', 'iwlinks', 'iwl_prefix', 'patch-kill-iwl_prefix.sql' ],
65 [ 'addField', 'categorylinks', 'cl_collation', 'patch-categorylinks-better-collation.sql' ],
66 [ 'addTable', 'module_deps', 'patch-module_deps.sql' ],
67 [ 'dropIndex', 'archive', 'ar_page_revid', 'patch-archive_kill_ar_page_revid.sql' ],
68 [ 'addIndexIfNoneExist',
69 'archive', [ 'ar_revid', 'ar_revid_uniq' ], 'patch-archive_ar_revid.sql' ],
70
71 // 1.18
72 [ 'addIndex', 'user', 'user_email', 'patch-user_email_index.sql' ],
73 [ 'addTable', 'uploadstash', 'patch-uploadstash.sql' ],
74 [ 'addTable', 'user_former_groups', 'patch-user_former_groups.sql' ],
75
76 // 1.19
77 [ 'doMigrateUserOptions' ],
78 [ 'dropField', 'user', 'user_options', 'patch-drop-user_options.sql' ],
79 [ 'addField', 'revision', 'rev_sha1', 'patch-rev_sha1.sql' ],
80 [ 'addField', 'archive', 'ar_sha1', 'patch-ar_sha1.sql' ],
81 [ 'addIndex', 'page', 'page_redirect_namespace_len',
82 'patch-page_redirect_namespace_len.sql' ],
83 [ 'addField', 'uploadstash', 'us_chunk_inx', 'patch-uploadstash_chunk.sql' ],
84 [ 'addfield', 'job', 'job_timestamp', 'patch-jobs-add-timestamp.sql' ],
85
86 // 1.20
87 [ 'addIndex', 'revision', 'page_user_timestamp', 'patch-revision-user-page-index.sql' ],
88 [ 'addField', 'ipblocks', 'ipb_parent_block_id', 'patch-ipb-parent-block-id.sql' ],
89 [ 'addIndex', 'ipblocks', 'ipb_parent_block_id', 'patch-ipb-parent-block-id-index.sql' ],
90 [ 'dropField', 'category', 'cat_hidden', 'patch-cat_hidden.sql' ],
91
92 // 1.21
93 [ 'addField', 'revision', 'rev_content_format', 'patch-revision-rev_content_format.sql' ],
94 [ 'addField', 'revision', 'rev_content_model', 'patch-revision-rev_content_model.sql' ],
95 [ 'addField', 'archive', 'ar_content_format', 'patch-archive-ar_content_format.sql' ],
96 [ 'addField', 'archive', 'ar_content_model', 'patch-archive-ar_content_model.sql' ],
97 [ 'addField', 'page', 'page_content_model', 'patch-page-page_content_model.sql' ],
98 [ 'enableContentHandlerUseDB' ],
99
100 [ 'dropField', 'site_stats', 'ss_admins', 'patch-drop-ss_admins.sql' ],
101 [ 'dropField', 'recentchanges', 'rc_moved_to_title', 'patch-rc_moved.sql' ],
102 [ 'addTable', 'sites', 'patch-sites.sql' ],
103 [ 'addField', 'filearchive', 'fa_sha1', 'patch-fa_sha1.sql' ],
104 [ 'addField', 'job', 'job_token', 'patch-job_token.sql' ],
105 [ 'addField', 'job', 'job_attempts', 'patch-job_attempts.sql' ],
106 [ 'doEnableProfiling' ],
107 [ 'addField', 'uploadstash', 'us_props', 'patch-uploadstash-us_props.sql' ],
108 [ 'modifyField', 'user_groups', 'ug_group', 'patch-ug_group-length-increase-255.sql' ],
109 [ 'modifyField', 'user_former_groups', 'ufg_group',
110 'patch-ufg_group-length-increase-255.sql' ],
111 [ 'addIndex', 'page_props', 'pp_propname_page',
112 'patch-page_props-propname-page-index.sql' ],
113 [ 'addIndex', 'image', 'img_media_mime', 'patch-img_media_mime-index.sql' ],
114
115 // 1.22
116 [ 'addIndex', 'iwlinks', 'iwl_prefix_from_title', 'patch-iwlinks-from-title-index.sql' ],
117 [ 'addField', 'archive', 'ar_id', 'patch-archive-ar_id.sql' ],
118 [ 'addField', 'externallinks', 'el_id', 'patch-externallinks-el_id.sql' ],
119
120 // 1.23
121 [ 'addField', 'recentchanges', 'rc_source', 'patch-rc_source.sql' ],
122 [ 'ifNoActorTable', 'addIndex', 'logging', 'log_user_text_type_time',
123 'patch-logging_user_text_type_time_index.sql' ],
124 [ 'ifNoActorTable', 'addIndex', 'logging', 'log_user_text_time',
125 'patch-logging_user_text_time_index.sql' ],
126 [ 'addField', 'page', 'page_links_updated', 'patch-page_links_updated.sql' ],
127 [ 'addField', 'user', 'user_password_expires', 'patch-user_password_expire.sql' ],
128
129 // 1.24
130 [ 'addField', 'page_props', 'pp_sortkey', 'patch-pp_sortkey.sql' ],
131 [ 'dropField', 'recentchanges', 'rc_cur_time', 'patch-drop-rc_cur_time.sql' ],
132 [ 'addIndex', 'watchlist', 'wl_user_notificationtimestamp',
133 'patch-watchlist-user-notificationtimestamp-index.sql' ],
134 [ 'addField', 'page', 'page_lang', 'patch-page-page_lang.sql' ],
135 [ 'addField', 'pagelinks', 'pl_from_namespace', 'patch-pl_from_namespace.sql' ],
136 [ 'addField', 'templatelinks', 'tl_from_namespace', 'patch-tl_from_namespace.sql' ],
137 [ 'addField', 'imagelinks', 'il_from_namespace', 'patch-il_from_namespace.sql' ],
138
139 // 1.25
140 [ 'dropTable', 'hitcounter' ],
141 [ 'dropField', 'site_stats', 'ss_total_views', 'patch-drop-ss_total_views.sql' ],
142 [ 'dropField', 'page', 'page_counter', 'patch-drop-page_counter.sql' ],
143 [ 'modifyField', 'filearchive', 'fa_deleted_reason', 'patch-editsummary-length.sql' ],
144
145 // 1.27
146 [ 'dropTable', 'msg_resource_links' ],
147 [ 'dropTable', 'msg_resource' ],
148 [ 'addTable', 'bot_passwords', 'patch-bot_passwords.sql' ],
149 [ 'addField', 'watchlist', 'wl_id', 'patch-watchlist-wl_id.sql' ],
150 [ 'dropIndex', 'categorylinks', 'cl_collation', 'patch-kill-cl_collation_index.sql' ],
151 [ 'addIndex', 'categorylinks', 'cl_collation_ext',
152 'patch-add-cl_collation_ext_index.sql' ],
153 [ 'doCollationUpdate' ],
154
155 // 1.28
156 [ 'addIndex', 'recentchanges', 'rc_name_type_patrolled_timestamp',
157 'patch-add-rc_name_type_patrolled_timestamp_index.sql' ],
158 [ 'addField', 'change_tag', 'ct_id', 'patch-change_tag-ct_id.sql' ],
159
160 // 1.29
161 [ 'addField', 'externallinks', 'el_index_60', 'patch-externallinks-el_index_60.sql' ],
162 [ 'addField', 'user_groups', 'ug_expiry', 'patch-user_groups-ug_expiry.sql' ],
163 [ 'ifNoActorTable', 'addIndex', 'image', 'img_user_timestamp', 'patch-image-user-index-2.sql' ],
164
165 // 1.30
166 [ 'modifyField', 'image', 'img_media_type', 'patch-add-3d.sql' ],
167 [ 'addTable', 'ip_changes', 'patch-ip_changes.sql' ],
168 [ 'renameIndex', 'categorylinks', 'cl_from', 'PRIMARY', false,
169 'patch-categorylinks-fix-pk.sql' ],
170 [ 'renameIndex', 'templatelinks', 'tl_from', 'PRIMARY', false,
171 'patch-templatelinks-fix-pk.sql' ],
172 [ 'renameIndex', 'pagelinks', 'pl_from', 'PRIMARY', false, 'patch-pagelinks-fix-pk.sql' ],
173 [ 'renameIndex', 'text', 'old_id', 'PRIMARY', false, 'patch-text-fix-pk.sql' ],
174 [ 'renameIndex', 'imagelinks', 'il_from', 'PRIMARY', false, 'patch-imagelinks-fix-pk.sql' ],
175 [ 'renameIndex', 'iwlinks', 'iwl_from', 'PRIMARY', false, 'patch-iwlinks-fix-pk.sql' ],
176 [ 'renameIndex', 'langlinks', 'll_from', 'PRIMARY', false, 'patch-langlinks-fix-pk.sql' ],
177 [ 'renameIndex', 'log_search', 'ls_field_val', 'PRIMARY', false, 'patch-log_search-fix-pk.sql' ],
178 [ 'renameIndex', 'module_deps', 'md_module_skin', 'PRIMARY', false,
179 'patch-module_deps-fix-pk.sql' ],
180 [ 'renameIndex', 'objectcache', 'keyname', 'PRIMARY', false, 'patch-objectcache-fix-pk.sql' ],
181 [ 'renameIndex', 'querycache_info', 'qci_type', 'PRIMARY', false,
182 'patch-querycache_info-fix-pk.sql' ],
183 [ 'renameIndex', 'site_stats', 'ss_row_id', 'PRIMARY', false, 'patch-site_stats-fix-pk.sql' ],
184 [ 'renameIndex', 'user_former_groups', 'ufg_user_group', 'PRIMARY', false,
185 'patch-user_former_groups-fix-pk.sql' ],
186 [ 'renameIndex', 'user_properties', 'user_properties_user_property', 'PRIMARY', false,
187 'patch-user_properties-fix-pk.sql' ],
188 [ 'addTable', 'comment', 'patch-comment-table.sql' ],
189 [ 'addTable', 'revision_comment_temp', 'patch-revision_comment_temp-table.sql' ],
190 // image_comment_temp is no longer needed when upgrading to MW 1.31 or newer,
191 // as it is dropped later in the update process as part of 'migrateImageCommentTemp'.
192 // File kept on disk and the updater entry here for historical purposes.
193 // [ 'addTable', 'image_comment_temp', 'patch-image_comment_temp-table.sql' ],
194 [ 'addField', 'archive', 'ar_comment_id', 'patch-archive-ar_comment_id.sql' ],
195 [ 'modifyField', 'image', 'img_description', 'patch-image-img_description-default.sql' ],
196 [ 'addField', 'ipblocks', 'ipb_reason_id', 'patch-ipblocks-ipb_reason_id.sql' ],
197 [ 'addField', 'logging', 'log_comment_id', 'patch-logging-log_comment_id.sql' ],
198 [ 'addField', 'oldimage', 'oi_description_id', 'patch-oldimage-oi_description_id.sql' ],
199 [ 'addField', 'protected_titles', 'pt_reason_id', 'patch-protected_titles-pt_reason_id.sql' ],
200 [ 'addField', 'recentchanges', 'rc_comment_id', 'patch-recentchanges-rc_comment_id.sql' ],
201 [ 'modifyField', 'revision', 'rev_comment', 'patch-revision-rev_comment-default.sql' ],
202
203 // This field was added in 1.31, but is put here so it can be used by 'migrateComments'
204 [ 'addField', 'image', 'img_description_id', 'patch-image-img_description_id.sql' ],
205 [ 'addField', 'filearchive', 'fa_description_id', 'patch-filearchive-fa_description_id.sql' ],
206
207 [ 'migrateComments' ],
208 [ 'renameIndex', 'l10n_cache', 'lc_lang_key', 'PRIMARY', false,
209 'patch-l10n_cache-primary-key.sql' ],
210
211 // 1.31
212 [ 'addTable', 'content', 'patch-content.sql' ],
213 [ 'addTable', 'content_models', 'patch-content_models.sql' ],
214 [ 'addTable', 'slots', 'patch-slots.sql' ],
215 [ 'addField', 'slots', 'slot_origin', 'patch-slot-origin.sql' ],
216 [ 'addTable', 'slot_roles', 'patch-slot_roles.sql' ],
217 [ 'migrateArchiveText' ],
218 [ 'addTable', 'actor', 'patch-actor-table.sql' ],
219 [ 'addField', 'archive', 'ar_actor', 'patch-archive-ar_actor.sql' ],
220 [ 'addTable', 'revision_actor_temp', 'patch-revision_actor_temp-table.sql' ],
221 [ 'addField', 'ipblocks', 'ipb_by_actor', 'patch-ipblocks-ipb_by_actor.sql' ],
222 [ 'addField', 'image', 'img_actor', 'patch-image-img_actor.sql' ],
223 [ 'addField', 'oldimage', 'oi_actor', 'patch-oldimage-oi_actor.sql' ],
224 [ 'addField', 'filearchive', 'fa_actor', 'patch-filearchive-fa_actor.sql' ],
225 [ 'addField', 'recentchanges', 'rc_actor', 'patch-recentchanges-rc_actor.sql' ],
226 [ 'addField', 'logging', 'log_actor', 'patch-logging-log_actor.sql' ],
227 [ 'migrateActors' ],
228 [ 'modifyField', 'revision', 'rev_text_id', 'patch-rev_text_id-default.sql' ],
229 [ 'modifyTable', 'site_stats', 'patch-site_stats-modify.sql' ],
230 [ 'populateArchiveRevId' ],
231 [ 'addIndex', 'recentchanges', 'rc_namespace_title_timestamp',
232 'patch-recentchanges-nttindex.sql' ],
233
234 // 1.32
235 [ 'addTable', 'change_tag_def', 'patch-change_tag_def.sql' ],
236 [ 'populateExternallinksIndex60' ],
237 [ 'modifyfield', 'externallinks', 'el_index_60',
238 'patch-externallinks-el_index_60-drop-default.sql' ],
239 [ 'runMaintenance', DeduplicateArchiveRevId::class, 'maintenance/deduplicateArchiveRevId.php' ],
240 [ 'addField', 'change_tag', 'ct_tag_id', 'patch-change_tag-tag_id.sql' ],
241 [ 'addIndex', 'archive', 'ar_revid_uniq', 'patch-archive-ar_rev_id-unique.sql' ],
242 [ 'populateContentTables' ],
243 [ 'addIndex', 'logging', 'log_type_action', 'patch-logging-log-type-action-index.sql' ],
244 [ 'dropIndex', 'logging', 'type_action', 'patch-logging-drop-type-action-index.sql' ],
245 [ 'renameIndex', 'interwiki', 'iw_prefix', 'PRIMARY', false, 'patch-interwiki-fix-pk.sql' ],
246 [ 'renameIndex', 'page_props', 'pp_page_propname', 'PRIMARY', false,
247 'patch-page_props-fix-pk.sql' ],
248 [ 'renameIndex', 'protected_titles', 'pt_namespace_title', 'PRIMARY', false,
249 'patch-protected_titles-fix-pk.sql' ],
250 [ 'renameIndex', 'site_identifiers', 'site_ids_type', 'PRIMARY', false,
251 'patch-site_identifiers-fix-pk.sql' ],
252 [ 'addIndex', 'recentchanges', 'rc_this_oldid', 'patch-recentchanges-rc_this_oldid-index.sql' ],
253 [ 'dropTable', 'transcache' ],
254 [ 'runMaintenance', PopulateChangeTagDef::class, 'maintenance/populateChangeTagDef.php' ],
255 [ 'addIndex', 'change_tag', 'change_tag_rc_tag_id',
256 'patch-change_tag-change_tag_rc_tag_id.sql' ],
257 [ 'addField', 'ipblocks', 'ipb_sitewide', 'patch-ipb_sitewide.sql' ],
258 [ 'addTable', 'ipblocks_restrictions', 'patch-ipblocks_restrictions-table.sql' ],
259 [ 'migrateImageCommentTemp' ],
260
261 // 1.33
262 [ 'dropField', 'change_tag', 'ct_tag', 'patch-drop-ct_tag.sql' ],
263 [ 'dropTable', 'valid_tag' ],
264 [ 'dropTable', 'tag_summary' ],
265 [ 'dropField', 'archive', 'ar_comment', 'patch-archive-drop-ar_comment.sql' ],
266 [ 'dropField', 'ipblocks', 'ipb_reason', 'patch-ipblocks-drop-ipb_reason.sql' ],
267 [ 'dropField', 'image', 'img_description', 'patch-image-drop-img_description.sql' ],
268 [ 'dropField', 'oldimage', 'oi_description', 'patch-oldimage-drop-oi_description.sql' ],
269 [ 'dropField', 'filearchive', 'fa_description', 'patch-filearchive-drop-fa_description.sql' ],
270 [ 'dropField', 'recentchanges', 'rc_comment', 'patch-recentchanges-drop-rc_comment.sql' ],
271 [ 'dropField', 'logging', 'log_comment', 'patch-logging-drop-log_comment.sql' ],
272 [ 'dropField', 'protected_titles', 'pt_reason', 'patch-protected_titles-drop-pt_reason.sql' ],
273
274 // 1.34
275 [ 'dropField', 'archive', 'ar_user', 'patch-archive-drop-ar_user.sql' ],
276 [ 'dropField', 'ipblocks', 'ipb_by', 'patch-ipblocks-drop-ipb_by.sql' ],
277 [ 'dropField', 'image', 'img_user', 'patch-image-drop-img_user.sql' ],
278 [ 'dropField', 'oldimage', 'oi_user', 'patch-oldimage-drop-oi_user.sql' ],
279 [ 'dropField', 'filearchive', 'fa_user', 'patch-filearchive-drop-fa_user.sql' ],
280 [ 'dropField', 'recentchanges', 'rc_user', 'patch-recentchanges-drop-rc_user.sql' ],
281 [ 'dropField', 'logging', 'log_user', 'patch-logging-drop-log_user.sql' ],
282 ];
283 }
284
285 protected function sqliteInitialIndexes() {
286 // initial-indexes.sql fails if the indexes are already present,
287 // so we perform a quick check if our database is newer.
288 if ( $this->updateRowExists( 'initial_indexes' ) ||
289 $this->db->indexExists( 'user', 'user_name', __METHOD__ )
290 ) {
291 $this->output( "...have initial indexes\n" );
292
293 return;
294 }
295 $this->applyPatch( 'initial-indexes.sql', false, "Adding initial indexes" );
296 }
297
298 protected function sqliteSetupSearchindex() {
299 $module = DatabaseSqlite::getFulltextSearchModule();
300 $fts3tTable = $this->updateRowExists( 'fts3' );
301 if ( $fts3tTable && !$module ) {
302 $this->applyPatch(
303 'searchindex-no-fts.sql',
304 false,
305 'PHP is missing FTS3 support, downgrading tables'
306 );
307 } elseif ( !$fts3tTable && $module == 'FTS3' ) {
308 $this->applyPatch( 'searchindex-fts3.sql', false, "Adding FTS3 search capabilities" );
309 } else {
310 $this->output( "...fulltext search table appears to be in order.\n" );
311 }
312 }
313}
Class for handling database updates.
updateRowExists( $key)
Helper function: check if the given key is present in the updatelog table.
output( $str)
Output some text.
applyPatch( $path, $isFullPath=false, $msg=null)
Applies a SQL patch.
Class for handling updates to Sqlite databases.
getCoreUpdateList()
Get an array of updates to perform on the database.