MediaWiki  master
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-actor-comment-MCR.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  [ 'modifyField', 'revision', 'rev_text_id', 'patch-rev_text_id-default.sql' ],
58  [ 'modifyTable', 'site_stats', 'patch-site_stats-modify.sql' ],
59  [ 'populateArchiveRevId' ],
60  [ 'addIndex', 'recentchanges', 'rc_namespace_title_timestamp',
61  'patch-recentchanges-nttindex.sql' ],
62 
63  // 1.32
64  [ 'addTable', 'change_tag_def', 'patch-change_tag_def.sql' ],
65  [ 'populateExternallinksIndex60' ],
66  [ 'modifyfield', 'externallinks', 'el_index_60',
67  'patch-externallinks-el_index_60-drop-default.sql' ],
68  [ 'runMaintenance', DeduplicateArchiveRevId::class, 'maintenance/deduplicateArchiveRevId.php' ],
69  [ 'addField', 'change_tag', 'ct_tag_id', 'patch-change_tag-tag_id.sql' ],
70  [ 'addIndex', 'archive', 'ar_revid_uniq', 'patch-archive-ar_rev_id-unique.sql' ],
71  [ 'populateContentTables' ],
72  [ 'addIndex', 'logging', 'log_type_action', 'patch-logging-log-type-action-index.sql' ],
73  [ 'dropIndex', 'logging', 'type_action', 'patch-logging-drop-type-action-index.sql' ],
74  [ 'renameIndex', 'interwiki', 'iw_prefix', 'PRIMARY', false, 'patch-interwiki-fix-pk.sql' ],
75  [ 'renameIndex', 'page_props', 'pp_page_propname', 'PRIMARY', false,
76  'patch-page_props-fix-pk.sql' ],
77  [ 'renameIndex', 'protected_titles', 'pt_namespace_title', 'PRIMARY', false,
78  'patch-protected_titles-fix-pk.sql' ],
79  [ 'renameIndex', 'site_identifiers', 'site_ids_type', 'PRIMARY', false,
80  'patch-site_identifiers-fix-pk.sql' ],
81  [ 'addIndex', 'recentchanges', 'rc_this_oldid', 'patch-recentchanges-rc_this_oldid-index.sql' ],
82  [ 'dropTable', 'transcache' ],
83  [ 'runMaintenance', PopulateChangeTagDef::class, 'maintenance/populateChangeTagDef.php' ],
84  [ 'dropIndex', 'change_tag', 'change_tag_rc_tag', 'patch-change_tag-change_tag_rc_tag_id.sql' ],
85  [ 'addField', 'ipblocks', 'ipb_sitewide', 'patch-ipb_sitewide.sql' ],
86  [ 'addTable', 'ipblocks_restrictions', 'patch-ipblocks_restrictions-table.sql' ],
87  [ 'migrateImageCommentTemp' ],
88 
89  // 1.33
90  [ 'dropField', 'change_tag', 'ct_tag', 'patch-drop-ct_tag.sql' ],
91  [ 'dropTable', 'valid_tag' ],
92  [ 'dropTable', 'tag_summary' ],
93  [ 'dropField', 'archive', 'ar_comment', 'patch-archive-drop-ar_comment.sql' ],
94  [ 'dropField', 'ipblocks', 'ipb_reason', 'patch-ipblocks-drop-ipb_reason.sql' ],
95  [ 'dropField', 'image', 'img_description', 'patch-image-drop-img_description.sql' ],
96  [ 'dropField', 'oldimage', 'oi_description', 'patch-oldimage-drop-oi_description.sql' ],
97  [ 'dropField', 'filearchive', 'fa_description', 'patch-filearchive-drop-fa_description.sql' ],
98  [ 'dropField', 'recentchanges', 'rc_comment', 'patch-recentchanges-drop-rc_comment.sql' ],
99  [ 'dropField', 'logging', 'log_comment', 'patch-logging-drop-log_comment.sql' ],
100  [ 'dropField', 'protected_titles', 'pt_reason', 'patch-protected_titles-drop-pt_reason.sql' ],
101 
102  // 1.34
103  [ 'dropField', 'archive', 'ar_user', 'patch-archive-drop-ar_user.sql' ],
104  [ 'dropField', 'ipblocks', 'ipb_by', 'patch-ipblocks-drop-ipb_by.sql' ],
105  [ 'dropField', 'image', 'img_user', 'patch-image-drop-img_user.sql' ],
106  [ 'dropField', 'oldimage', 'oi_user', 'patch-oldimage-drop-oi_user.sql' ],
107  [ 'dropField', 'filearchive', 'fa_user', 'patch-filearchive-drop-fa_user.sql' ],
108  [ 'dropField', 'recentchanges', 'rc_user', 'patch-recentchanges-drop-rc_user.sql' ],
109  [ 'dropField', 'logging', 'log_user', 'patch-logging-drop-log_user.sql' ],
110 
111  // 1.35
112  [ 'addTable', 'watchlist_expiry', 'patch-watchlist_expiry.sql' ],
113  [ 'modifyfield', 'filearchive', 'fa_actor', 'patch-filearchive-drop-fa_actor-DEFAULT.sql' ],
114  [ 'modifyfield', 'recentchanges', 'rc_actor', 'patch-recentchanges-drop-rc_actor-DEFAULT.sql' ],
115  [ 'modifyfield', 'logging', 'log_actor', 'patch-logging-drop-log_actor-DEFAULT.sql' ],
116  [ 'modifyField', 'page', 'page_restrictions', 'patch-page_restrictions-null.sql' ],
117  [ 'renameIndex', 'ipblocks', 'ipb_address', 'ipb_address_unique', false,
118  'patch-ipblocks-rename-ipb_address.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, 'maintenance/migrateRevisionActorTemp.php' ],
192  [ 'dropTable', 'revision_actor_temp' ],
193  [ 'runMaintenance', UpdateRestrictions::class, 'maintenance/updateRestrictions.php' ],
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  ];
198  }
199 
208  protected function indexHasField( $table, $index, $field ) {
209  $info = $this->db->indexInfo( $table, $index, __METHOD__ );
210  if ( $info ) {
211  foreach ( $info as $column ) {
212  if ( $column == $field ) {
213  $this->output( "...index $index on table $table includes field $field.\n" );
214  return true;
215  }
216  }
217  }
218  $this->output( "...index $index on table $table has no field $field; added.\n" );
219 
220  return false;
221  }
222 
223  protected function doFixIpbAddressUniqueIndex() {
224  if ( !$this->indexHasField( 'ipblocks', 'ipb_address_unique', 'ipb_anon_only' ) ) {
225  $this->output( "...ipb_address_unique index up-to-date.\n" );
226  return;
227  }
228 
229  $this->applyPatch(
230  'patch-ipblocks-fix-ipb_address_unique.sql',
231  false,
232  'Removing ipb_anon_only column from ipb_address_unique index'
233  );
234  }
235 }
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.