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