MediaWiki REL1_39
SqliteUpdater.php
Go to the documentation of this file.
1<?php
32
33 protected function getCoreUpdateList() {
34 return [
35 // 1.35 but must come first
36 [ 'addField', 'revision', 'rev_actor', 'patch-revision-rev_actor.sql' ],
37
38 // 1.31
39 [ 'addField', 'image', 'img_description_id', 'patch-image-img_description_id.sql' ],
40 [ 'migrateComments' ],
41
42 [ 'addTable', 'content', 'patch-content.sql' ],
43 [ 'addTable', 'content_models', 'patch-content_models.sql' ],
44 [ 'addTable', 'slots', 'patch-slots.sql' ],
45 [ 'addField', 'slots', 'slot_origin', 'patch-slot-origin.sql' ],
46 [ 'addTable', 'slot_roles', 'patch-slot_roles.sql' ],
47 [ 'migrateArchiveText' ],
48 [ 'addTable', 'actor', 'patch-actor-table.sql' ],
49 [ 'addField', 'archive', 'ar_actor', 'patch-archive-ar_actor.sql' ],
50 [ 'addField', 'ipblocks', 'ipb_by_actor', 'patch-ipblocks-ipb_by_actor.sql' ],
51 [ 'addField', 'image', 'img_actor', 'patch-image-img_actor.sql' ],
52 [ 'addField', 'oldimage', 'oi_actor', 'patch-oldimage-oi_actor.sql' ],
53 [ 'addField', 'filearchive', 'fa_actor', 'patch-filearchive-fa_actor.sql' ],
54 [ 'addField', 'recentchanges', 'rc_actor', 'patch-recentchanges-rc_actor.sql' ],
55 [ 'addField', 'logging', 'log_actor', 'patch-logging-log_actor.sql' ],
56 [ 'migrateActors' ],
57 [ 'modifyTable', 'site_stats', 'patch-site_stats-modify.sql' ],
58 [ 'populateArchiveRevId' ],
59 [ 'addIndex', 'recentchanges', 'rc_namespace_title_timestamp',
60 'patch-recentchanges-nttindex.sql' ],
61
62 // 1.32
63 [ 'addTable', 'change_tag_def', 'patch-change_tag_def.sql' ],
64 [ 'populateExternallinksIndex60' ],
65 [ 'modifyfield', 'externallinks', 'el_index_60',
66 'patch-externallinks-el_index_60-drop-default.sql' ],
67 [ 'runMaintenance', DeduplicateArchiveRevId::class ],
68 [ 'addField', 'change_tag', 'ct_tag_id', 'patch-change_tag-tag_id.sql' ],
69 [ 'addIndex', 'archive', 'ar_revid_uniq', 'patch-archive-ar_rev_id-unique.sql' ],
70 [ 'populateContentTables' ],
71 [ 'addIndex', 'logging', 'log_type_action', 'patch-logging-log-type-action-index.sql' ],
72 [ 'dropIndex', 'logging', 'type_action', 'patch-logging-drop-type-action-index.sql' ],
73 [ 'renameIndex', 'interwiki', 'iw_prefix', 'PRIMARY', false, 'patch-interwiki-fix-pk.sql' ],
74 [ 'renameIndex', 'page_props', 'pp_page_propname', 'PRIMARY', false,
75 'patch-page_props-fix-pk.sql' ],
76 [ 'renameIndex', 'protected_titles', 'pt_namespace_title', 'PRIMARY', false,
77 'patch-protected_titles-fix-pk.sql' ],
78 [ 'renameIndex', 'site_identifiers', 'site_ids_type', 'PRIMARY', false,
79 'patch-site_identifiers-fix-pk.sql' ],
80 [ 'addIndex', 'recentchanges', 'rc_this_oldid', 'patch-recentchanges-rc_this_oldid-index.sql' ],
81 [ 'dropTable', 'transcache' ],
82 [ 'runMaintenance', PopulateChangeTagDef::class ],
83 [ 'dropIndex', 'change_tag', 'change_tag_rc_tag', 'patch-change_tag-change_tag_rc_tag_id.sql' ],
84 [ 'addField', 'ipblocks', 'ipb_sitewide', 'patch-ipb_sitewide.sql' ],
85 [ 'addTable', 'ipblocks_restrictions', 'patch-ipblocks_restrictions-table.sql' ],
86 [ 'migrateImageCommentTemp' ],
87
88 // 1.33
89 [ 'dropField', 'change_tag', 'ct_tag', 'patch-drop-ct_tag.sql' ],
90 [ 'dropTable', 'valid_tag' ],
91 [ 'dropTable', 'tag_summary' ],
92 [ 'dropField', 'archive', 'ar_comment', 'patch-archive-drop-ar_comment.sql' ],
93 [ 'dropField', 'ipblocks', 'ipb_reason', 'patch-ipblocks-drop-ipb_reason.sql' ],
94 [ 'dropField', 'image', 'img_description', 'patch-image-drop-img_description.sql' ],
95 [ 'dropField', 'oldimage', 'oi_description', 'patch-oldimage-drop-oi_description.sql' ],
96 [ 'dropField', 'filearchive', 'fa_description', 'patch-filearchive-drop-fa_description.sql' ],
97 [ 'dropField', 'recentchanges', 'rc_comment', 'patch-recentchanges-drop-rc_comment.sql' ],
98 [ 'dropField', 'logging', 'log_comment', 'patch-logging-drop-log_comment.sql' ],
99 [ 'dropField', 'protected_titles', 'pt_reason', 'patch-protected_titles-drop-pt_reason.sql' ],
100
101 // 1.34
102 [ 'dropField', 'archive', 'ar_user', 'patch-archive-drop-ar_user.sql' ],
103 [ 'dropField', 'ipblocks', 'ipb_by', 'patch-ipblocks-drop-ipb_by.sql' ],
104 [ 'dropField', 'image', 'img_user', 'patch-image-drop-img_user.sql' ],
105 [ 'dropField', 'oldimage', 'oi_user', 'patch-oldimage-drop-oi_user.sql' ],
106 [ 'dropField', 'filearchive', 'fa_user', 'patch-filearchive-drop-fa_user.sql' ],
107 [ 'dropField', 'recentchanges', 'rc_user', 'patch-recentchanges-drop-rc_user.sql' ],
108 [ 'dropField', 'logging', 'log_user', 'patch-logging-drop-log_user.sql' ],
109
110 // 1.35
111 [ 'addTable', 'watchlist_expiry', 'patch-watchlist_expiry.sql' ],
112 [ 'modifyfield', 'filearchive', 'fa_actor', 'patch-filearchive-drop-fa_actor-DEFAULT.sql' ],
113 [ 'modifyfield', 'recentchanges', 'rc_actor', 'patch-recentchanges-drop-rc_actor-DEFAULT.sql' ],
114 [ 'modifyfield', 'logging', 'log_actor', 'patch-logging-drop-log_actor-DEFAULT.sql' ],
115 [ 'modifyField', 'page', 'page_restrictions', 'patch-page_restrictions-null.sql' ],
116 [ 'renameIndex', 'ipblocks', 'ipb_address', 'ipb_address_unique', false,
117 'patch-ipblocks-rename-ipb_address.sql' ],
118 [ 'dropField', 'revision', 'rev_user', 'patch-revision-actor-comment-MCR.sql' ],
119 [ 'dropField', 'archive', 'ar_text_id', 'patch-archive-MCR.sql' ],
120 [ 'doFixIpbAddressUniqueIndex' ],
121 [ 'modifyField', 'actor', 'actor_name', 'patch-actor-actor_name-varbinary.sql' ],
122
123 // 1.36
124 [ 'modifyField', 'content', 'content_id', 'patch-content-content_id-fix_not_null.sql' ],
125 [ 'modifyField', 'redirect', 'rd_title', 'patch-redirect-rd_title-varbinary.sql' ],
126 [ 'modifyField', 'pagelinks', 'pl_title', 'patch-pagelinks-pl_title-varbinary.sql' ],
127 [ 'modifyField', 'templatelinks', 'tl_title', 'patch-templatelinks-tl_title-varbinary.sql' ],
128 [ 'modifyField', 'imagelinks', 'il_to', 'patch-imagelinks-il_to-varbinary.sql' ],
129 [ 'modifyField', 'langlinks', 'll_title', 'patch-langlinks-ll_title-varbinary.sql' ],
130 [ 'modifyField', 'iwlinks', 'iwl_title', 'patch-iwlinks-iwl_title-varbinary.sql' ],
131 [ 'modifyField', 'category', 'cat_title', 'patch-category-cat_title-varbinary.sql' ],
132 [ 'modifyField', 'querycache', 'qc_title', 'patch-querycache-qc_title-varbinary.sql' ],
133 [ 'modifyField', 'querycachetwo', 'qcc_title', 'patch-querycachetwo-qcc_title-varbinary.sql' ],
134 [ 'modifyField', 'watchlist', 'wl_title', 'patch-watchlist-wl_title-varbinary.sql' ],
135 [ 'modifyField', 'protected_titles', 'pt_title', 'patch-protected_titles-pt_title-varbinary.sql' ],
136 [ 'modifyField', 'protected_titles', 'pt_expiry', 'patch-protected_titles-pt_expiry-drop-default.sql' ],
137 [ 'modifyField', 'ip_changes', 'ipc_rev_timestamp', 'patch-ip_changes-pc_rev_timestamp-drop-default.sql' ],
138 [ 'renameIndex', 'watchlist', 'namespace_title', 'wl_namespace_title', false,
139 'patch-watchlist-namespace_title-rename-index.sql' ],
140 [ 'modifyField', 'job', 'job_title', 'patch-job-job_title-varbinary.sql' ],
141 [ 'modifyField', 'slot_roles', 'role_id', 'patch-slot_roles-role_id-fix_not_null.sql' ],
142 [ 'modifyField', 'content_models', 'model_id', 'patch-content_models-model_id-fix_not_null.sql' ],
143 [ 'modifyField', 'categorylinks', 'cl_to', 'patch-categorylinks-cl_to-varbinary.sql' ],
144 [ 'modifyField', 'logging', 'log_title', 'patch-logging-log_title-varbinary.sql' ],
145 [ 'renameIndex', 'user_properties', 'user_properties_property', 'up_property', false,
146 'patch-user_properties-rename-index.sql' ],
147 [ 'renameIndex', 'sites', 'sites_global_key', 'site_global_key', false, 'patch-sites-rename-indexes.sql' ],
148 [ 'renameIndex', 'logging', 'type_time', 'log_type_time', false, 'patch-logging-rename-indexes.sql' ],
149 [ 'modifyField', 'filearchive', 'fa_name', 'patch-filearchive-fa_name.sql' ],
150 [ 'modifyField', 'oldimage', 'oi_name', 'patch-oldimage-oi_name-varbinary.sql' ],
151 [ 'modifyField', 'objectcache', 'exptime', 'patch-objectcache-exptime-notnull.sql' ],
152 [ 'modifyField', 'ipblocks', 'ipb_timestamp', 'patch-ipblocks-ipb_timestamp-drop-default.sql' ],
153 [ 'renameIndex', 'archive', 'name_title_timestamp', 'ar_name_title_timestamp', false,
154 'patch-archive-rename-name_title_timestamp-index.sql' ],
155 [ 'modifyField', 'image', 'img_name', 'patch-image-img_name-varbinary.sql' ],
156 [ 'renameIndex', 'site_identifiers', 'site_ids_key', 'si_key', false,
157 'patch-site_identifiers-rename-indexes.sql' ],
158 [ 'modifyField', 'recentchanges', 'rc_title', 'patch-recentchanges-rc_title-varbinary.sql' ],
159 [ 'renameIndex', 'recentchanges', 'new_name_timestamp', 'rc_new_name_timestamp', false,
160 'patch-recentchanges-rc_new_name_timestamp.sql' ],
161 [ 'modifyField', 'archive', 'ar_title', 'patch-archive-ar_title-varbinary.sql' ],
162 [ 'modifyField', 'page', 'page_title', 'patch-page-page_title-varbinary.sql' ],
163 [ 'modifyField', 'user', 'user_name', 'patch-user_table-updates.sql' ],
164
165 // 1.37
166 [ 'renameIndex', 'revision', 'page_timestamp', 'rev_page_timestamp', false,
167 'patch-revision-rename-index.sql' ],
168 [ 'addField', 'objectcache', 'modtoken', 'patch-objectcache-modtoken.sql' ],
169 [ 'modifyField', 'revision', 'rev_timestamp', 'patch-revision-rev_timestamp-drop-default.sql' ],
170 [ 'addIndex', 'oldimage', 'oi_timestamp', 'patch-oldimage-oi_timestamp.sql' ],
171 [ 'renameIndex', 'page', 'name_title', 'page_name_title', false,
172 'patch-page-rename-name_title-index.sql' ],
173 [ 'renameIndex', 'change_tag', 'change_tag_rc_tag_id', 'ct_rc_tag_id', false,
174 'patch-change_tag-rename-indexes.sql' ],
175
176 // 1.38
177 [ 'doConvertDjvuMetadata' ],
178 [ 'dropField', 'page_restrictions', 'pr_user', 'patch-drop-page_restrictions-pr_user.sql' ],
179 [ 'addTable', 'linktarget', 'patch-linktarget.sql' ],
180 [ 'dropIndex', 'revision', 'rev_page_id', 'patch-drop-rev_page_id.sql' ],
181 [ 'modifyField', 'page_restrictions', 'pr_page', 'patch-page_restrictions-pr_page.sql' ],
182 [ 'modifyField', 'page_props', 'pp_page', 'patch-page_props-pp_page.sql' ],
183 [ 'modifyField', 'ipblocks_restrictions', 'ir_value', 'patch-ipblocks_restrictions-ir_value.sql' ],
184 [ 'addField', 'templatelinks', 'tl_target_id', 'patch-templatelinks-target_id.sql' ],
185
186 // 1.39
187 [ 'addTable', 'user_autocreate_serial', 'patch-user_autocreate_serial.sql' ],
188 [ 'modifyField', 'ipblocks_restrictions', 'ir_ipb_id', 'patch-ipblocks_restrictions-ir_ipb_id.sql' ],
189 [ 'modifyField', 'ipblocks', 'ipb_id', 'patch-ipblocks-ipb_id.sql' ],
190 [ 'modifyField', 'user', 'user_editcount', 'patch-user-user_editcount.sql' ],
191 [ 'runMaintenance', MigrateRevisionActorTemp::class ],
192 [ 'dropTable', 'revision_actor_temp' ],
193 [ 'runMaintenance', UpdateRestrictions::class ],
194 [ 'dropField', 'page', 'page_restrictions', 'patch-page-drop-page_restrictions.sql' ],
195 [ 'migrateTemplatelinks' ],
196 [ 'modifyField', 'templatelinks', 'tl_namespace', 'patch-templatelinks-tl_title-nullable.sql' ],
197 [ 'dropField', 'templatelinks', 'tl_title', 'patch-templatelinks-drop-tl_title.sql' ],
198 ];
199 }
200
209 protected function indexHasField( $table, $index, $field ) {
210 $info = $this->db->indexInfo( $table, $index, __METHOD__ );
211 if ( $info ) {
212 foreach ( $info as $column ) {
213 if ( $column == $field ) {
214 $this->output( "...index $index on table $table includes field $field.\n" );
215 return true;
216 }
217 }
218 }
219 $this->output( "...index $index on table $table has no field $field; added.\n" );
220
221 return false;
222 }
223
224 protected function doFixIpbAddressUniqueIndex() {
225 if ( !$this->indexHasField( 'ipblocks', 'ipb_address_unique', 'ipb_anon_only' ) ) {
226 $this->output( "...ipb_address_unique index up-to-date.\n" );
227 return;
228 }
229
230 $this->applyPatch(
231 'patch-ipblocks-fix-ipb_address_unique.sql',
232 false,
233 'Removing ipb_anon_only column from ipb_address_unique index'
234 );
235 }
236}
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.