Manual:Hooks/LoadExtensionSchemaUpdates

Usage
This hook allows extensions to do updates when the MediaWiki updater is run. Extensions can perform updates using this hook or a series of global variables.

Extension Updates Before MediaWiki Updates
This hook fires before MediaWiki internal updates are run. If the extension doesn't depend on MediaWiki updates, it can just do its thing when the hook fires.

Extension Updates After MediaWiki Updates
If the extension update needs to operate after the MediaWiki updates have run, it should instead modify some global variables. For simple add table, add index, modify table operations, the extension can add new entries to these global variables:

If the extension needs to do some arbitrary stuff aside from adding or modifying tables, it can add a new function to the $wgMysqlUpdates global variable which will then be run after all the MediaWiki updates have finished. Something like this: