MediaWiki  master
MysqlUpdater.php
Go to the documentation of this file.
1 <?php
24 
33  protected function getCoreUpdateList() {
34  return [
35  // 1.29
36  [ 'addField', 'externallinks', 'el_index_60', 'patch-externallinks-el_index_60.sql' ],
37  [ 'dropIndex', 'user_groups', 'ug_user_group', 'patch-user_groups-primary-key.sql' ],
38  [ 'addField', 'user_groups', 'ug_expiry', 'patch-user_groups-ug_expiry.sql' ],
39  [ 'ifTableNotExists', 'actor',
40  'addIndex', 'image', 'img_user_timestamp', 'patch-image-user-index-2.sql' ],
41 
42  // 1.30
43  [ 'modifyField', 'image', 'img_media_type', 'patch-add-3d.sql' ],
44  [ 'addTable', 'ip_changes', 'patch-ip_changes.sql' ],
45  [ 'renameIndex', 'categorylinks', 'cl_from', 'PRIMARY', false,
46  'patch-categorylinks-fix-pk.sql' ],
47  [ 'renameIndex', 'templatelinks', 'tl_from', 'PRIMARY', false,
48  'patch-templatelinks-fix-pk.sql' ],
49  [ 'renameIndex', 'pagelinks', 'pl_from', 'PRIMARY', false, 'patch-pagelinks-fix-pk.sql' ],
50  [ 'renameIndex', 'text', 'old_id', 'PRIMARY', false, 'patch-text-fix-pk.sql' ],
51  [ 'renameIndex', 'imagelinks', 'il_from', 'PRIMARY', false, 'patch-imagelinks-fix-pk.sql' ],
52  [ 'renameIndex', 'iwlinks', 'iwl_from', 'PRIMARY', false, 'patch-iwlinks-fix-pk.sql' ],
53  [ 'renameIndex', 'langlinks', 'll_from', 'PRIMARY', false, 'patch-langlinks-fix-pk.sql' ],
54  [ 'renameIndex', 'log_search', 'ls_field_val', 'PRIMARY', false, 'patch-log_search-fix-pk.sql' ],
55  [ 'renameIndex', 'module_deps', 'md_module_skin', 'PRIMARY', false,
56  'patch-module_deps-fix-pk.sql' ],
57  [ 'renameIndex', 'objectcache', 'keyname', 'PRIMARY', false, 'patch-objectcache-fix-pk.sql' ],
58  [ 'renameIndex', 'querycache_info', 'qci_type', 'PRIMARY', false,
59  'patch-querycache_info-fix-pk.sql' ],
60  [ 'renameIndex', 'site_stats', 'ss_row_id', 'PRIMARY', false, 'patch-site_stats-fix-pk.sql' ],
61  [ 'renameIndex', 'user_former_groups', 'ufg_user_group', 'PRIMARY', false,
62  'patch-user_former_groups-fix-pk.sql' ],
63  [ 'renameIndex', 'user_properties', 'user_properties_user_property', 'PRIMARY', false,
64  'patch-user_properties-fix-pk.sql' ],
65  [ 'addTable', 'comment', 'patch-comment-table.sql' ],
66  [ 'addTable', 'revision_comment_temp', 'patch-revision_comment_temp-table.sql' ],
67  [ 'addField', 'archive', 'ar_comment_id', 'patch-archive-ar_comment_id.sql' ],
68  [ 'addField', 'filearchive', 'fa_description_id', 'patch-filearchive-fa_description_id.sql' ],
69  [ 'modifyField', 'image', 'img_description', 'patch-image-img_description-default.sql' ],
70  [ 'addField', 'ipblocks', 'ipb_reason_id', 'patch-ipblocks-ipb_reason_id.sql' ],
71  [ 'addField', 'logging', 'log_comment_id', 'patch-logging-log_comment_id.sql' ],
72  [ 'addField', 'oldimage', 'oi_description_id', 'patch-oldimage-oi_description_id.sql' ],
73  [ 'addField', 'protected_titles', 'pt_reason_id', 'patch-protected_titles-pt_reason_id.sql' ],
74  [ 'addField', 'recentchanges', 'rc_comment_id', 'patch-recentchanges-rc_comment_id.sql' ],
75  [ 'setDefault', 'revision', 'rev_comment', '' ],
76 
77  // This field was added in 1.31, but is put here so it can be used by 'migrateComments'
78  [ 'addField', 'image', 'img_description_id', 'patch-image-img_description_id.sql' ],
79 
80  [ 'migrateComments' ],
81  [ 'renameIndex', 'l10n_cache', 'lc_lang_key', 'PRIMARY', false,
82  'patch-l10n_cache-primary-key.sql' ],
83  [ 'doUnsignedSyncronisation' ],
84 
85  // 1.31
86  [ 'addTable', 'slots', 'patch-slots.sql' ],
87  [ 'addField', 'slots', 'slot_origin', 'patch-slot-origin.sql' ],
88  [ 'addTable', 'content', 'patch-content.sql' ],
89  [ 'addTable', 'slot_roles', 'patch-slot_roles.sql' ],
90  [ 'addTable', 'content_models', 'patch-content_models.sql' ],
91  [ 'migrateArchiveText' ],
92  [ 'addTable', 'actor', 'patch-actor-table.sql' ],
93  [ 'addTable', 'revision_actor_temp', 'patch-revision_actor_temp-table.sql' ],
94  [ 'addField', 'archive', 'ar_actor', 'patch-archive-ar_actor.sql' ],
95  [ 'addField', 'ipblocks', 'ipb_by_actor', 'patch-ipblocks-ipb_by_actor.sql' ],
96  [ 'addField', 'image', 'img_actor', 'patch-image-img_actor.sql' ],
97  [ 'addField', 'oldimage', 'oi_actor', 'patch-oldimage-oi_actor.sql' ],
98  [ 'addField', 'filearchive', 'fa_actor', 'patch-filearchive-fa_actor.sql' ],
99  [ 'addField', 'recentchanges', 'rc_actor', 'patch-recentchanges-rc_actor.sql' ],
100  [ 'addField', 'logging', 'log_actor', 'patch-logging-log_actor.sql' ],
101  [ 'migrateActors' ],
102 
103  // Adds a default value to the rev_text_id field to allow Multi Content
104  // Revisions migration to happen where rows will have to be added to the
105  // revision table with no rev_text_id.
106  [ 'setDefault', 'revision', 'rev_text_id', 0 ],
107  [ 'modifyTable', 'site_stats', 'patch-site_stats-modify.sql' ],
108  [ 'populateArchiveRevId' ],
109  [ 'addIndex', 'recentchanges', 'rc_namespace_title_timestamp',
110  'patch-recentchanges-nttindex.sql' ],
111 
112  // 1.32
113  [ 'addTable', 'change_tag_def', 'patch-change_tag_def.sql' ],
114  [ 'populateExternallinksIndex60' ],
115  [ 'dropDefault', 'externallinks', 'el_index_60' ],
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  [ 'modifyTable', 'job', 'patch-job-params-mediumblob.sql' ],
150 
151  // 1.34
152  [ 'dropIndex', 'archive', 'ar_usertext_timestamp',
153  'patch-drop-archive-ar_usertext_timestamp.sql' ],
154  [ 'dropIndex', 'archive', 'usertext_timestamp', 'patch-drop-archive-usertext_timestamp.sql' ],
155  [ 'dropField', 'archive', 'ar_user', 'patch-drop-archive-user-fields.sql' ],
156  [ 'dropField', 'ipblocks', 'ip_by', 'patch-drop-ipblocks-user-fields.sql' ],
157  [ 'dropIndex', 'image', 'img_user_timestamp', 'patch-drop-image-img_user_timestamp.sql' ],
158  [ 'dropField', 'image', 'img_user', 'patch-drop-image-user-fields.sql' ],
159  [ 'dropField', 'oldimage', 'oi_user', 'patch-drop-oldimage-user-fields.sql' ],
160  [ 'dropField', 'filearchive', 'fa_user', 'patch-drop-filearchive-user-fields.sql' ],
161  [ 'dropField', 'recentchanges', 'rc_user', 'patch-drop-recentchanges-user-fields.sql' ],
162  [ 'dropField', 'logging', 'log_user', 'patch-drop-logging-user-fields.sql' ],
163  [ 'addIndex', 'user_newtalk', 'un_user_ip', 'patch-rename-mysql-user_newtalk-indexes.sql' ],
164 
165  // 1.35
166  [ 'addTable', 'watchlist_expiry', 'patch-watchlist_expiry.sql' ],
167  [ 'modifyField', 'page', 'page_restrictions', 'patch-page_restrictions-null.sql' ],
168  [ 'renameIndex', 'ipblocks', 'ipb_address', 'ipb_address_unique', false,
169  'patch-ipblocks-rename-ipb_address.sql' ],
170  [ 'addField', 'revision', 'rev_actor', 'patch-revision-actor-comment-MCR.sql' ],
171  [ 'dropField', 'archive', 'ar_text_id', 'patch-archive-MCR.sql' ],
172  [ 'doLanguageLinksLengthSync' ],
173  [ 'doFixIpbAddressUniqueIndex' ],
174  [ 'modifyField', 'actor', 'actor_name', 'patch-actor-actor_name-varbinary.sql' ],
175  [ 'modifyField', 'sites', 'site_global_key', 'patch-sites-site_global_key.sql' ],
176  [ 'modifyField', 'iwlinks', 'iwl_prefix', 'patch-extend-iwlinks-iwl_prefix.sql' ],
177 
178  // 1.36
179  [ 'modifyField', 'redirect', 'rd_title', 'patch-redirect-rd_title-varbinary.sql' ],
180  [ 'modifyField', 'pagelinks', 'pl_title', 'patch-pagelinks-pl_title-varbinary.sql' ],
181  [ 'modifyField', 'templatelinks', 'tl_title', 'patch-templatelinks-tl_title-varbinary.sql' ],
182  [ 'modifyField', 'imagelinks', 'il_to', 'patch-imagelinks-il_to-varbinary.sql' ],
183  [ 'modifyField', 'langlinks', 'll_title', 'patch-langlinks-ll_title-varbinary.sql' ],
184  [ 'modifyField', 'iwlinks', 'iwl_title', 'patch-iwlinks-iwl_title-varbinary.sql' ],
185  [ 'modifyField', 'category', 'cat_title', 'patch-category-cat_title-varbinary.sql' ],
186  [ 'modifyField', 'querycache', 'qc_title', 'patch-querycache-qc_title-varbinary.sql' ],
187  [ 'modifyField', 'querycachetwo', 'qcc_title', 'patch-querycachetwo-qcc_title-varbinary.sql' ],
188  [ 'modifyField', 'watchlist', 'wl_title', 'patch-watchlist-wl_title-varbinary.sql' ],
189  [ 'modifyField', 'user_newtalk', 'user_last_timestamp',
190  'patch-user_newtalk-user_last_timestamp-binary.sql'
191  ],
192  [ 'modifyField', 'protected_titles', 'pt_title', 'patch-protected_titles-pt_title-varbinary.sql' ],
193  [ 'dropDefault', 'protected_titles', 'pt_expiry' ],
194  [ 'dropDefault', 'ip_changes', 'ipc_rev_timestamp' ],
195  [ 'dropDefault', 'revision_actor_temp', 'revactor_timestamp' ],
196  [ 'modifyField', 'ipblocks_restrictions', 'ir_type', 'patch-ipblocks_restrictions-ir_type.sql' ],
197  [ 'renameIndex', 'watchlist', 'namespace_title', 'wl_namespace_title', false,
198  'patch-watchlist-namespace_title-rename-index.sql' ],
199  [ 'modifyField', 'job', 'job_title', 'patch-job-job_title-varbinary.sql' ],
200  [ 'modifyField', 'job', 'job_timestamp', 'patch-job_job_timestamp.sql' ],
201  [ 'modifyField', 'job', 'job_token_timestamp', 'patch-job_job_token_timestamp.sql' ],
202  [ 'modifyField', 'watchlist', 'wl_notificationtimestamp', 'patch-watchlist-wl_notificationtimestamp.sql' ],
203  [ 'modifyField', 'slot_roles', 'role_id', 'patch-slot_roles-role_id.sql' ],
204  [ 'modifyField', 'content_models', 'model_id', 'patch-content_models-model_id.sql' ],
205  [ 'modifyField', 'categorylinks', 'cl_to', 'patch-categorylinks-cl_to-varbinary.sql' ],
206  [ 'modifyField', 'logging', 'log_title', 'patch-logging-log_title-varbinary.sql' ],
207  [ 'modifyField', 'uploadstash', 'us_timestamp', 'patch-uploadstash-us_timestamp.sql' ],
208  [ 'renameIndex', 'user_properties', 'user_properties_property', 'up_property', false,
209  'patch-user_properties-rename-index.sql' ],
210  [ 'renameIndex', 'sites', 'sites_global_key', 'site_global_key', false, 'patch-sites-rename-indexes.sql' ],
211  [ 'renameIndex', 'logging', 'type_time', 'log_type_time', false, 'patch-logging-rename-indexes.sql' ],
212  [ 'modifyField', 'filearchive', 'fa_name', 'patch-filearchive-fa_name.sql' ],
213  [ 'dropDefault', 'filearchive', 'fa_deleted_timestamp' ],
214  [ 'dropDefault', 'filearchive', 'fa_timestamp' ],
215  [ 'modifyField', 'oldimage', 'oi_name', 'patch-oldimage-oi_name-varbinary.sql' ],
216  [ 'dropDefault', 'oldimage', 'oi_timestamp' ],
217  [ 'modifyField', 'objectcache', 'exptime', 'patch-objectcache-exptime-notnull.sql' ],
218  [ 'dropDefault', 'ipblocks', 'ipb_timestamp' ],
219  [ 'dropDefault', 'ipblocks', 'ipb_expiry' ],
220  [ 'renameIndex', 'archive', 'name_title_timestamp', 'ar_name_title_timestamp', false,
221  'patch-archive-rename-name_title_timestamp-index.sql' ],
222  [ 'modifyField', 'image', 'img_name', 'patch-image-img_name-varbinary.sql' ],
223  [ 'dropDefault', 'image', 'img_timestamp' ],
224  [ 'modifyField', 'image', 'img_timestamp', 'patch-image-img_timestamp.sql' ],
225  [ 'renameIndex', 'site_identifiers', 'site_ids_key', 'si_key', false,
226  'patch-site_identifiers-rename-indexes.sql' ],
227  [ 'modifyField', 'recentchanges', 'rc_title', 'patch-recentchanges-rc_title-varbinary.sql' ],
228  [ 'dropDefault', 'recentchanges', 'rc_timestamp' ],
229  [ 'modifyField', 'recentchanges', 'rc_timestamp', 'patch-recentchanges-rc_timestamp.sql' ],
230  [ 'modifyField', 'recentchanges', 'rc_id', 'patch-recentchanges-rc_id.sql' ],
231  [ 'renameIndex', 'recentchanges', 'new_name_timestamp', 'rc_new_name_timestamp', false,
232  'patch-recentchanges-rc_new_name_timestamp.sql' ],
233  [ 'dropDefault', 'archive', 'ar_timestamp' ],
234  [ 'modifyField', 'archive', 'ar_title', 'patch-archive-ar_title-varbinary.sql' ],
235  [ 'modifyField', 'page', 'page_title', 'patch-page-page_title-varbinary.sql' ],
236  [ 'dropDefault', 'page', 'page_touched' ],
237  [ 'modifyField', 'user', 'user_name', 'patch-user_table-updates.sql' ],
238 
239  // 1.37
240  [ 'renameIndex', 'revision', 'page_timestamp', 'rev_page_timestamp', false,
241  'patch-revision-rename-index.sql' ],
242  [ 'addField', 'objectcache', 'modtoken', 'patch-objectcache-modtoken.sql' ],
243  [ 'dropDefault', 'revision', 'rev_timestamp' ],
244  [ 'addIndex', 'oldimage', 'oi_timestamp', 'patch-oldimage-oi_timestamp.sql' ],
245  [ 'renameIndex', 'page', 'name_title', 'page_name_title', false, 'patch-page-rename-name_title-index.sql' ],
246  [ 'renameIndex', 'change_tag', 'change_tag_rc_tag_id', 'ct_rc_tag_id', false,
247  'patch-change_tag-rename-indexes.sql' ],
248 
249  // 1.38
250  [ 'doConvertDjvuMetadata' ],
251  [ 'dropField', 'page_restrictions', 'pr_user', 'patch-drop-page_restrictions-pr_user.sql' ],
252  ];
253  }
254 
264  protected function checkBin( $table, $field, $patchFile ) {
265  if ( !$this->doTable( $table ) ) {
266  return true;
267  }
268 
270  $fieldInfo = $this->db->fieldInfo( $table, $field );
271  if ( $fieldInfo->isBinary() ) {
272  $this->output( "...$table table has correct $field encoding.\n" );
273  } else {
274  $this->applyPatch( $patchFile, false, "Fixing $field encoding on $table table" );
275  }
276  }
277 
286  protected function indexHasField( $table, $index, $field ) {
287  $info = $this->db->indexInfo( $table, $index, __METHOD__ );
288  if ( $info ) {
289  foreach ( $info as $row ) {
290  if ( $row->Column_name == $field ) {
291  $this->output( "...index $index on table $table includes field $field.\n" );
292  return true;
293  }
294  }
295  }
296  $this->output( "...index $index on table $table has no field $field; added.\n" );
297 
298  return false;
299  }
300 
301  protected function doLanguageLinksLengthSync() {
302  $sync = [
303  [ 'table' => 'l10n_cache', 'field' => 'lc_lang', 'file' => 'patch-l10n_cache-lc_lang-35.sql' ],
304  [ 'table' => 'langlinks', 'field' => 'll_lang', 'file' => 'patch-langlinks-ll_lang-35.sql' ],
305  [ 'table' => 'sites', 'field' => 'site_language', 'file' => 'patch-sites-site_language-35.sql' ],
306  ];
307 
308  foreach ( $sync as $s ) {
309  $table = $this->db->tableName( $s['table'] );
310  $field = $s['field'];
311  $res = $this->db->query( "SHOW COLUMNS FROM $table LIKE '$field'", __METHOD__ );
312  $row = $this->db->fetchObject( $res );
313 
314  if ( $row && $row->Type !== "varbinary(35)" ) {
315  $this->applyPatch(
316  $s['file'],
317  false,
318  "Updating length of $field in $table"
319  );
320  } else {
321  $this->output( "...$field is up-to-date.\n" );
322  }
323  }
324  }
325 
326  protected function doFixIpbAddressUniqueIndex() {
327  if ( !$this->doTable( 'ipblocks' ) ) {
328  return;
329  }
330 
331  if ( !$this->indexHasField( 'ipblocks', 'ipb_address_unique', 'ipb_anon_only' ) ) {
332  $this->output( "...ipb_address_unique index up-to-date.\n" );
333  return;
334  }
335 
336  $this->applyPatch(
337  'patch-ipblocks-fix-ipb_address_unique.sql',
338  false,
339  'Removing ipb_anon_only column from ipb_address_unique index'
340  );
341  }
342 
343  protected function doUnsignedSyncronisation() {
344  $sync = [
345  [ 'table' => 'bot_passwords', 'field' => 'bp_user', 'file' => 'patch-bot_passwords-bp_user-unsigned.sql' ],
346  [ 'table' => 'change_tag', 'field' => 'ct_log_id', 'file' => 'patch-change_tag-ct_log_id-unsigned.sql' ],
347  [ 'table' => 'change_tag', 'field' => 'ct_rev_id', 'file' => 'patch-change_tag-ct_rev_id-unsigned.sql' ],
348  [ 'table' => 'user_newtalk', 'field' => 'user_id', 'file' => 'patch-user_newtalk-user_id-unsigned.sql' ],
349  [ 'table' => 'user_properties', 'field' => 'up_user',
350  'file' => 'patch-user_properties-up_user-unsigned.sql' ],
351  [ 'table' => 'change_tag', 'field' => 'ct_rc_id', 'file' => 'patch-change_tag-ct_rc_id-unsigned.sql' ]
352  ];
353 
354  foreach ( $sync as $s ) {
355  if ( !$this->doTable( $s['table'] ) ) {
356  continue;
357  }
358 
359  $info = $this->db->fieldInfo( $s['table'], $s['field'] );
360  if ( $info === false ) {
361  continue;
362  }
363  $fullName = "{$s['table']}.{$s['field']}";
364  if ( $info->isUnsigned() ) {
365  $this->output( "...$fullName is already unsigned int.\n" );
366 
367  continue;
368  }
369 
370  $this->applyPatch(
371  $s['file'],
372  false,
373  "Making $fullName into an unsigned int"
374  );
375  }
376 
377  return true;
378  }
379 
380  public function getSchemaVars() {
381  global $wgDBTableOptions;
382 
383  $vars = [];
384  $vars['wgDBTableOptions'] = str_replace( 'TYPE', 'ENGINE', $wgDBTableOptions );
385  $vars['wgDBTableOptions'] = str_replace(
386  'CHARSET=mysql4',
387  'CHARSET=binary',
388  $vars['wgDBTableOptions']
389  );
390 
391  return $vars;
392  }
393 
401  protected function dropDefault( $table, $field ) {
402  $updateKey = "$table-$field-dropDefault";
403 
404  if ( $this->updateRowExists( $updateKey ) ) {
405  return;
406  }
407 
408  $info = $this->db->fieldInfo( $table, $field );
409  if ( $info && $info->defaultValue() !== false ) {
410  $this->output( "Removing '$table.$field' default value.\n" );
411  $table = $this->db->tableName( $table );
412  $ret = $this->db->query( "ALTER TABLE $table ALTER COLUMN $field DROP DEFAULT", __METHOD__ );
413 
414  if ( $ret ) {
415  $this->insertUpdateRow( $updateKey );
416  }
417  }
418  }
419 
428  protected function setDefault( $table, $field, $default ) {
429  $info = $this->db->fieldInfo( $table, $field );
430  if ( $info && $info->defaultValue() !== $default ) {
431  $this->output( "Changing '$table.$field' default value.\n" );
432  $table = $this->db->tableName( $table );
433  $this->db->query(
434  "ALTER TABLE $table ALTER COLUMN $field SET DEFAULT "
435  . $this->db->addQuotes( $default ), __METHOD__
436  );
437  }
438  }
439 
440 }
DatabaseUpdater\output
output( $str)
Output some text.
Definition: DatabaseUpdater.php:246
MysqlUpdater\checkBin
checkBin( $table, $field, $patchFile)
MW 1.4 betas were missing the 'binary' marker from logging.log_title, which caused a MySQL collation ...
Definition: MysqlUpdater.php:264
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
MysqlUpdater\doFixIpbAddressUniqueIndex
doFixIpbAddressUniqueIndex()
Definition: MysqlUpdater.php:326
DatabaseUpdater\doTable
doTable( $name)
Returns whether updates should be executed on the database table $name.
Definition: DatabaseUpdater.php:609
MysqlUpdater\getSchemaVars
getSchemaVars()
Get appropriate schema variables in the current database connection.
Definition: MysqlUpdater.php:380
$res
$res
Definition: testCompression.php:57
MysqlUpdater\doLanguageLinksLengthSync
doLanguageLinksLengthSync()
Definition: MysqlUpdater.php:301
MysqlUpdater\setDefault
setDefault( $table, $field, $default)
Set a default value for a field.
Definition: MysqlUpdater.php:428
MysqlUpdater\getCoreUpdateList
getCoreUpdateList()
Get an array of updates to perform on the database.
Definition: MysqlUpdater.php:33
Wikimedia\Rdbms\MySQLField
Definition: MySQLField.php:5
DatabaseUpdater\updateRowExists
updateRowExists( $key)
Helper function: check if the given key is present in the updatelog table.
Definition: DatabaseUpdater.php:553
$s
foreach( $mmfl['setupFiles'] as $fileName) if( $queue) if(empty( $mmfl['quiet'])) $s
Definition: mergeMessageFileList.php:206
MysqlUpdater\dropDefault
dropDefault( $table, $field)
Drop a default value from a field.
Definition: MysqlUpdater.php:401
$wgDBTableOptions
$wgDBTableOptions
MySQL table options to use during installation or update.
Definition: DefaultSettings.php:2172
MysqlUpdater\indexHasField
indexHasField( $table, $index, $field)
Check whether an index contain a field.
Definition: MysqlUpdater.php:286
MysqlUpdater\doUnsignedSyncronisation
doUnsignedSyncronisation()
Definition: MysqlUpdater.php:343
DatabaseUpdater\insertUpdateRow
insertUpdateRow( $key, $val=null)
Helper function: Add a key to the updatelog table.
Definition: DatabaseUpdater.php:578
MysqlUpdater
Definition: MysqlUpdater.php:32