| LoadExtensionSchemaUpdates | |
|---|---|
| Available fromversion 1.10.1 Fired when MediaWiki is updated to allow extensions to register updates for the database schema | |
| Define function: | publicstaticfunctiononLoadExtensionSchemaUpdates(DatabaseUpdater$updater){...} |
| Attach hook: | Inextension.json:{"Hooks":{"LoadExtensionSchemaUpdates":"MediaWiki\\Extension\\MyExtension\\Hooks::onLoadExtensionSchemaUpdates"}} |
| Called from: | File(s):installer/DatabaseUpdater.php Function(s):__construct |
| Interface: | LoadExtensionSchemaUpdatesHook.php |
For more information about attaching hooks, seeManual:Hooks.
For examples of extensions using this hook, seeCategory:LoadExtensionSchemaUpdates extensions.
DatabaseUpdater::addExtensionTable(),DatabaseUpdater::modifyExtensionField(), etc.
|
sql/ directory.php maintenance/run.php update script to update your wiki’s database with your extension’sLoadExtensionSchemaUpdates hook. See theupdate.php manual for more information.Extension registration was introduced in MW 1.25, and so the Hooks section ofextension.json should be used instead of$wgHooks.For example:
"Hooks":{"LoadExtensionSchemaUpdates":"MediaWiki\\Extension\\ExtensionName\\Hooks::onLoadExtensionSchemaUpdates"}
And inExtensionName/includes/Hooks.php:
namespaceMediaWiki\Extension\ExtensionName;useDatabaseUpdater;classHooks{publicstaticfunctiononLoadExtensionSchemaUpdates(DatabaseUpdater$updater){// Register an SQL patch for changing the field$updater->modifyExtensionField('tablename','name_of_field',__DIR__.'/sql/patch_file_changing_field.sql');}}
The code of the hook callback is the same as for earlier versions (see below).