MediaWiki REL1_37
SqliteUpdater.php
Go to the documentation of this file.
1<?php
32
33 protected function getCoreUpdateList() {
34 return [
35 // 1.28
36 [ 'addIndex', 'recentchanges', 'rc_name_type_patrolled_timestamp',
37 'patch-add-rc_name_type_patrolled_timestamp_index.sql' ],
38 [ 'addField', 'change_tag', 'ct_id', 'patch-change_tag-ct_id.sql' ],
39
40 // 1.29
41 [ 'addField', 'externallinks', 'el_index_60', 'patch-externallinks-el_index_60.sql' ],
42 [ 'addField', 'user_groups', 'ug_expiry', 'patch-user_groups-ug_expiry.sql' ],
43 [ 'ifTableNotExists', 'actor',
44 'addIndex', 'image', 'img_user_timestamp', 'patch-image-user-index-2.sql' ],
45
46 // 1.30
47 [ 'modifyField', 'image', 'img_media_type', 'patch-add-3d.sql' ],
48 [ 'addTable', 'ip_changes', 'patch-ip_changes.sql' ],
49 [ 'renameIndex', 'categorylinks', 'cl_from', 'PRIMARY', false,
50 'patch-categorylinks-fix-pk.sql' ],
51 [ 'renameIndex', 'templatelinks', 'tl_from', 'PRIMARY', false,
52 'patch-templatelinks-fix-pk.sql' ],
53 [ 'renameIndex', 'pagelinks', 'pl_from', 'PRIMARY', false, 'patch-pagelinks-fix-pk.sql' ],
54 [ 'renameIndex', 'text', 'old_id', 'PRIMARY', false, 'patch-text-fix-pk.sql' ],
55 [ 'renameIndex', 'imagelinks', 'il_from', 'PRIMARY', false, 'patch-imagelinks-fix-pk.sql' ],
56 [ 'renameIndex', 'iwlinks', 'iwl_from', 'PRIMARY', false, 'patch-iwlinks-fix-pk.sql' ],
57 [ 'renameIndex', 'langlinks', 'll_from', 'PRIMARY', false, 'patch-langlinks-fix-pk.sql' ],
58 [ 'renameIndex', 'log_search', 'ls_field_val', 'PRIMARY', false, 'patch-log_search-fix-pk.sql' ],
59 [ 'renameIndex', 'module_deps', 'md_module_skin', 'PRIMARY', false,
60 'patch-module_deps-fix-pk.sql' ],
61 [ 'renameIndex', 'objectcache', 'keyname', 'PRIMARY', false, 'patch-objectcache-fix-pk.sql' ],
62 [ 'renameIndex', 'querycache_info', 'qci_type', 'PRIMARY', false,
63 'patch-querycache_info-fix-pk.sql' ],
64 [ 'renameIndex', 'site_stats', 'ss_row_id', 'PRIMARY', false, 'patch-site_stats-fix-pk.sql' ],
65 [ 'renameIndex', 'user_former_groups', 'ufg_user_group', 'PRIMARY', false,
66 'patch-user_former_groups-fix-pk.sql' ],
67 [ 'renameIndex', 'user_properties', 'user_properties_user_property', 'PRIMARY', false,
68 'patch-user_properties-fix-pk.sql' ],
69 [ 'addTable', 'comment', 'patch-comment-table.sql' ],
70 [ 'addTable', 'revision_comment_temp', 'patch-revision_comment_temp-table.sql' ],
71 [ 'addField', 'archive', 'ar_comment_id', 'patch-archive-ar_comment_id.sql' ],
72 [ 'modifyField', 'image', 'img_description', 'patch-image-img_description-default.sql' ],
73 [ 'addField', 'ipblocks', 'ipb_reason_id', 'patch-ipblocks-ipb_reason_id.sql' ],
74 [ 'addField', 'logging', 'log_comment_id', 'patch-logging-log_comment_id.sql' ],
75 [ 'addField', 'oldimage', 'oi_description_id', 'patch-oldimage-oi_description_id.sql' ],
76 [ 'addField', 'protected_titles', 'pt_reason_id', 'patch-protected_titles-pt_reason_id.sql' ],
77 [ 'addField', 'recentchanges', 'rc_comment_id', 'patch-recentchanges-rc_comment_id.sql' ],
78 [ 'modifyField', 'revision', 'rev_comment', 'patch-revision-rev_comment-default.sql' ],
79
80 // This field was added in 1.31, but is put here so it can be used by 'migrateComments'
81 [ 'addField', 'image', 'img_description_id', 'patch-image-img_description_id.sql' ],
82 [ 'addField', 'filearchive', 'fa_description_id', 'patch-filearchive-fa_description_id.sql' ],
83
84 [ 'migrateComments' ],
85 [ 'renameIndex', 'l10n_cache', 'lc_lang_key', 'PRIMARY', false,
86 'patch-l10n_cache-primary-key.sql' ],
87
88 // 1.31
89 [ 'addTable', 'content', 'patch-content.sql' ],
90 [ 'addTable', 'content_models', 'patch-content_models.sql' ],
91 [ 'addTable', 'slots', 'patch-slots.sql' ],
92 [ 'addField', 'slots', 'slot_origin', 'patch-slot-origin.sql' ],
93 [ 'addTable', 'slot_roles', 'patch-slot_roles.sql' ],
94 [ 'migrateArchiveText' ],
95 [ 'addTable', 'actor', 'patch-actor-table.sql' ],
96 [ 'addField', 'archive', 'ar_actor', 'patch-archive-ar_actor.sql' ],
97 [ 'addTable', 'revision_actor_temp', 'patch-revision_actor_temp-table.sql' ],
98 [ 'addField', 'ipblocks', 'ipb_by_actor', 'patch-ipblocks-ipb_by_actor.sql' ],
99 [ 'addField', 'image', 'img_actor', 'patch-image-img_actor.sql' ],
100 [ 'addField', 'oldimage', 'oi_actor', 'patch-oldimage-oi_actor.sql' ],
101 [ 'addField', 'filearchive', 'fa_actor', 'patch-filearchive-fa_actor.sql' ],
102 [ 'addField', 'recentchanges', 'rc_actor', 'patch-recentchanges-rc_actor.sql' ],
103 [ 'addField', 'logging', 'log_actor', 'patch-logging-log_actor.sql' ],
104 [ 'migrateActors' ],
105 [ 'modifyField', 'revision', 'rev_text_id', 'patch-rev_text_id-default.sql' ],
106 [ 'modifyTable', 'site_stats', 'patch-site_stats-modify.sql' ],
107 [ 'populateArchiveRevId' ],
108 [ 'addIndex', 'recentchanges', 'rc_namespace_title_timestamp',
109 'patch-recentchanges-nttindex.sql' ],
110
111 // 1.32
112 [ 'addTable', 'change_tag_def', 'patch-change_tag_def.sql' ],
113 [ 'populateExternallinksIndex60' ],
114 [ 'modifyfield', 'externallinks', 'el_index_60',
115 'patch-externallinks-el_index_60-drop-default.sql' ],
116 [ 'runMaintenance', DeduplicateArchiveRevId::class, 'maintenance/deduplicateArchiveRevId.php' ],
117 [ 'addField', 'change_tag', 'ct_tag_id', 'patch-change_tag-tag_id.sql' ],
118 [ 'addIndex', 'archive', 'ar_revid_uniq', 'patch-archive-ar_rev_id-unique.sql' ],
119 [ 'populateContentTables' ],
120 [ 'addIndex', 'logging', 'log_type_action', 'patch-logging-log-type-action-index.sql' ],
121 [ 'dropIndex', 'logging', 'type_action', 'patch-logging-drop-type-action-index.sql' ],
122 [ 'renameIndex', 'interwiki', 'iw_prefix', 'PRIMARY', false, 'patch-interwiki-fix-pk.sql' ],
123 [ 'renameIndex', 'page_props', 'pp_page_propname', 'PRIMARY', false,
124 'patch-page_props-fix-pk.sql' ],
125 [ 'renameIndex', 'protected_titles', 'pt_namespace_title', 'PRIMARY', false,
126 'patch-protected_titles-fix-pk.sql' ],
127 [ 'renameIndex', 'site_identifiers', 'site_ids_type', 'PRIMARY', false,
128 'patch-site_identifiers-fix-pk.sql' ],
129 [ 'addIndex', 'recentchanges', 'rc_this_oldid', 'patch-recentchanges-rc_this_oldid-index.sql' ],
130 [ 'dropTable', 'transcache' ],
131 [ 'runMaintenance', PopulateChangeTagDef::class, 'maintenance/populateChangeTagDef.php' ],
132 [ 'dropIndex', 'change_tag', 'change_tag_rc_tag', 'patch-change_tag-change_tag_rc_tag_id.sql' ],
133 [ 'addField', 'ipblocks', 'ipb_sitewide', 'patch-ipb_sitewide.sql' ],
134 [ 'addTable', 'ipblocks_restrictions', 'patch-ipblocks_restrictions-table.sql' ],
135 [ 'migrateImageCommentTemp' ],
136
137 // 1.33
138 [ 'dropField', 'change_tag', 'ct_tag', 'patch-drop-ct_tag.sql' ],
139 [ 'dropTable', 'valid_tag' ],
140 [ 'dropTable', 'tag_summary' ],
141 [ 'dropField', 'archive', 'ar_comment', 'patch-archive-drop-ar_comment.sql' ],
142 [ 'dropField', 'ipblocks', 'ipb_reason', 'patch-ipblocks-drop-ipb_reason.sql' ],
143 [ 'dropField', 'image', 'img_description', 'patch-image-drop-img_description.sql' ],
144 [ 'dropField', 'oldimage', 'oi_description', 'patch-oldimage-drop-oi_description.sql' ],
145 [ 'dropField', 'filearchive', 'fa_description', 'patch-filearchive-drop-fa_description.sql' ],
146 [ 'dropField', 'recentchanges', 'rc_comment', 'patch-recentchanges-drop-rc_comment.sql' ],
147 [ 'dropField', 'logging', 'log_comment', 'patch-logging-drop-log_comment.sql' ],
148 [ 'dropField', 'protected_titles', 'pt_reason', 'patch-protected_titles-drop-pt_reason.sql' ],
149
150 // 1.34
151 [ 'dropField', 'archive', 'ar_user', 'patch-archive-drop-ar_user.sql' ],
152 [ 'dropField', 'ipblocks', 'ipb_by', 'patch-ipblocks-drop-ipb_by.sql' ],
153 [ 'dropField', 'image', 'img_user', 'patch-image-drop-img_user.sql' ],
154 [ 'dropField', 'oldimage', 'oi_user', 'patch-oldimage-drop-oi_user.sql' ],
155 [ 'dropField', 'filearchive', 'fa_user', 'patch-filearchive-drop-fa_user.sql' ],
156 [ 'dropField', 'recentchanges', 'rc_user', 'patch-recentchanges-drop-rc_user.sql' ],
157 [ 'dropField', 'logging', 'log_user', 'patch-logging-drop-log_user.sql' ],
158
159 // 1.35
160 [ 'addTable', 'watchlist_expiry', 'patch-watchlist_expiry.sql' ],
161 [ 'modifyfield', 'filearchive', 'fa_actor', 'patch-filearchive-drop-fa_actor-DEFAULT.sql' ],
162 [ 'modifyfield', 'recentchanges', 'rc_actor', 'patch-recentchanges-drop-rc_actor-DEFAULT.sql' ],
163 [ 'modifyfield', 'logging', 'log_actor', 'patch-logging-drop-log_actor-DEFAULT.sql' ],
164 [ 'modifyField', 'page', 'page_restrictions', 'patch-page_restrictions-null.sql' ],
165 [ 'renameIndex', 'ipblocks', 'ipb_address', 'ipb_address_unique', false,
166 'patch-ipblocks-rename-ipb_address.sql' ],
167 [ 'addField', 'revision', 'rev_actor', 'patch-revision-actor-comment-MCR.sql' ],
168 [ 'dropField', 'archive', 'ar_text_id', 'patch-archive-MCR.sql' ],
169 [ 'doFixIpbAddressUniqueIndex' ],
170 [ 'modifyField', 'actor', 'actor_name', 'patch-actor-actor_name-varbinary.sql' ],
171
172 // 1.36
173 [ 'modifyField', 'content', 'content_id', 'patch-content-content_id-fix_not_null.sql' ],
174 [ 'modifyField', 'redirect', 'rd_title', 'patch-redirect-rd_title-varbinary.sql' ],
175 [ 'modifyField', 'pagelinks', 'pl_title', 'patch-pagelinks-pl_title-varbinary.sql' ],
176 [ 'modifyField', 'templatelinks', 'tl_title', 'patch-templatelinks-tl_title-varbinary.sql' ],
177 [ 'modifyField', 'imagelinks', 'il_to', 'patch-imagelinks-il_to-varbinary.sql' ],
178 [ 'modifyField', 'langlinks', 'll_title', 'patch-langlinks-ll_title-varbinary.sql' ],
179 [ 'modifyField', 'iwlinks', 'iwl_title', 'patch-iwlinks-iwl_title-varbinary.sql' ],
180 [ 'modifyField', 'category', 'cat_title', 'patch-category-cat_title-varbinary.sql' ],
181 [ 'modifyField', 'querycache', 'qc_title', 'patch-querycache-qc_title-varbinary.sql' ],
182 [ 'modifyField', 'querycachetwo', 'qcc_title', 'patch-querycachetwo-qcc_title-varbinary.sql' ],
183 [ 'modifyField', 'watchlist', 'wl_title', 'patch-watchlist-wl_title-varbinary.sql' ],
184 [ 'modifyField', 'protected_titles', 'pt_title', 'patch-protected_titles-pt_title-varbinary.sql' ],
185 [ 'modifyField', 'protected_titles', 'pt_expiry', 'patch-protected_titles-pt_expiry-drop-default.sql' ],
186 [ 'modifyField', 'ip_changes', 'ipc_rev_timestamp', 'patch-ip_changes-pc_rev_timestamp-drop-default.sql' ],
187 [ 'modifyField', 'revision_actor_temp', 'revactor_timestamp', 'patch-revactor_timestamp-drop-default.sql' ],
188 [ 'renameIndex', 'watchlist', 'namespace_title', 'wl_namespace_title', false,
189 'patch-watchlist-namespace_title-rename-index.sql' ],
190 [ 'modifyField', 'job', 'job_title', 'patch-job-job_title-varbinary.sql' ],
191 [ 'modifyField', 'slot_roles', 'role_id', 'patch-slot_roles-role_id-fix_not_null.sql' ],
192 [ 'modifyField', 'content_models', 'model_id', 'patch-content_models-model_id-fix_not_null.sql' ],
193 [ 'modifyField', 'categorylinks', 'cl_to', 'patch-categorylinks-cl_to-varbinary.sql' ],
194 [ 'modifyField', 'logging', 'log_title', 'patch-logging-log_title-varbinary.sql' ],
195 [ 'renameIndex', 'user_properties', 'user_properties_property', 'up_property', false,
196 'patch-user_properties-rename-index.sql' ],
197 [ 'renameIndex', 'sites', 'sites_global_key', 'site_global_key', false, 'patch-sites-rename-indexes.sql' ],
198 [ 'renameIndex', 'logging', 'type_time', 'log_type_time', false, 'patch-logging-rename-indexes.sql' ],
199 [ 'modifyField', 'filearchive', 'fa_name', 'patch-filearchive-fa_name.sql' ],
200 [ 'modifyField', 'oldimage', 'oi_name', 'patch-oldimage-oi_name-varbinary.sql' ],
201 [ 'modifyField', 'objectcache', 'exptime', 'patch-objectcache-exptime-notnull.sql' ],
202 [ 'modifyField', 'ipblocks', 'ipb_timestamp', 'patch-ipblocks-ipb_timestamp-drop-default.sql' ],
203 [ 'renameIndex', 'archive', 'name_title_timestamp', 'ar_name_title_timestamp', false,
204 'patch-archive-rename-name_title_timestamp-index.sql' ],
205 [ 'modifyField', 'image', 'img_name', 'patch-image-img_name-varbinary.sql' ],
206 [ 'renameIndex', 'site_identifiers', 'site_ids_key', 'si_key', false,
207 'patch-site_identifiers-rename-indexes.sql' ],
208 [ 'modifyField', 'recentchanges', 'rc_title', 'patch-recentchanges-rc_title-varbinary.sql' ],
209 [ 'renameIndex', 'recentchanges', 'new_name_timestamp', 'rc_new_name_timestamp', false,
210 'patch-recentchanges-rc_new_name_timestamp.sql' ],
211 [ 'modifyField', 'archive', 'ar_title', 'patch-archive-ar_title-varbinary.sql' ],
212 [ 'modifyField', 'page', 'page_title', 'patch-page-page_title-varbinary.sql' ],
213 [ 'modifyField', 'user', 'user_name', 'patch-user_table-updates.sql' ],
214
215 // 1.37
216 [ 'renameIndex', 'revision', 'page_timestamp', 'rev_page_timestamp', false,
217 'patch-revision-rename-index.sql' ],
218 [ 'addField', 'objectcache', 'modtoken', 'patch-objectcache-modtoken.sql' ],
219 [ 'modifyField', 'revision', 'rev_timestamp', 'patch-revision-rev_timestamp-drop-default.sql' ],
220 [ 'addIndex', 'oldimage', 'oi_timestamp', 'patch-oldimage-oi_timestamp.sql' ],
221 [ 'renameIndex', 'page', 'name_title', 'page_name_title', false,
222 'patch-page-rename-name_title-index.sql' ],
223 [ 'renameIndex', 'change_tag', 'change_tag_rc_tag_id', 'ct_rc_tag_id', false,
224 'patch-change_tag-rename-indexes.sql' ],
225 ];
226 }
227
236 protected function indexHasField( $table, $index, $field ) {
237 $info = $this->db->indexInfo( $table, $index, __METHOD__ );
238 if ( $info ) {
239 foreach ( $info as $column ) {
240 if ( $column == $field ) {
241 $this->output( "...index $index on table $table includes field $field.\n" );
242 return true;
243 }
244 }
245 }
246 $this->output( "...index $index on table $table has no field $field; added.\n" );
247
248 return false;
249 }
250
251 protected function doFixIpbAddressUniqueIndex() {
252 if ( !$this->indexHasField( 'ipblocks', 'ipb_address_unique', 'ipb_anon_only' ) ) {
253 $this->output( "...ipb_address_unique index up-to-date.\n" );
254 return;
255 }
256
257 $this->applyPatch(
258 'patch-ipblocks-fix-ipb_address_unique.sql',
259 false,
260 'Removing ipb_anon_only column from ipb_address_unique index'
261 );
262 }
263}
Class for handling database updates.
output( $str)
Output some text.
applyPatch( $path, $isFullPath=false, $msg=null)
Applies a SQL patch.
getCoreUpdateList()
Get an array of updates to perform on the database.
indexHasField( $table, $index, $field)
Check whether an index contain a field.