Mobile app version of vmapp.org
Login or Join
Speyer207

: How to create new tables in mediawki 1.25+? How is the hook set up to create new database tables when an extension is registered in MediaWiki 1.25+? The manual says Possibly the Hooks

@Speyer207

Posted in: #Mediawiki

How is the hook set up to create new database tables when an extension is registered in MediaWiki 1.25+?

The manual says


Possibly the Hooks section of extensions.json should be used...


What I tried

in MyExtension/extension.json

"Hooks": {
"LoadExtensionSchemaUpdate": [
"MyExtensionHooks::mySchemaUpdate"
]
}


in MyExtension/MyExtension.hooks.php

class MyExtensionHooks {
public static function mySchemaUpdate( DatabaseUpdater $updater ) {
$updater->addExtensionTable( 'newTable',
__DIR__ . '/table.sql' );
return true;
}
}


in MyExtension/table.sql

CREATE TABLE newTable (
newTableID int not null auto_increment,
primary key (newTableID)
);


I ran ../maintenance/update.php but no newTable was created.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Speyer207

2 Comments

Sorted by latest first Latest Oldest Best

 

@Tiffany637

Add this to your domain URL /mw-config/ and the update page will appear

10% popularity Vote Up Vote Down


 

@Reiling115

The hook is called LoadExtensionSchemaUpdates.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme