Manual:Hooks/LoadExtensionSchemaUpdates

Summary

 * 1) Create your hook as indicated below.  Each examples shows how to setup the hook function.  However, if you have more than one schema update, you can put them in the same function.
 * 2) Make sure the hook has access to any necessary sql files
 * 3) Format the sql files correctly.  See the ArticleFeedbackv5 SQL, and the corresponding hooks file, for some examples.
 * 4) From the command line run the   script to update your wiki’s database with your extension’s   hook
 * 5) See the update.php manual for more information

To modify an existing field
To modify an existing field, put:

SQLite does not support some features of ALTER TABLE, such as renaming columns. Thus, work-arounds are necessary. See handling of  in Hooks.php and the accompanying files in the Echo extension.

To add a new index
To add a new index, put:

To add a new table
To add a new table, in the main file for your extension: The  file should contain the necessary   table definition.

To add a table and/or modify a field
If your extension has already added a table, but you need to modify a field in it for a new version, make the change in the sql file for the table (for people installing the extension after the change), then make a "patch" sql file to modify the field in the table (for people updating from an older version).

The  file should contain the necessary   statement to update old versions of the schema.

To add a new table
To add a new table, in the main file for your extension: The  file should contain the necessary   table definition.

To add a table and/or modify a field
If your extension has already added a table, but you need to modify a field in it for a new version, make the change in the sql file for the table (for people installing the extension after the change), then make a "patch" sql file to modify the field in the table (for people updating from an older version).

The  file should contain the necessary   statement to update old versions of the schema.

Note: Be very careful about the last member of the array being true. If you pass it an absolute path and nothing else, it will treat the path as relative to maintenance/archives and you will get all manner of errors.

<= 1.16 and >= 1.17 dual support
It is possible to provide support for both older versions of MediaWiki, and the current versions without much extra effort required

To add a new table
To add a new table, in the main file for your extension: The  file should contain the necessary   table definition. For an example, see the FlaggedRevs extension.

To add a table and/or modify a field
If your extension has already added a table, but you need to modify a field in it for a new version, make the change in the sql file for the table (for people installing the extension after the change), then make a "patch" sql file to modify the field in the table (for people updating from an older version).

The  file should contain the necessary   statement to update old versions of the schema.