Updates
Piwik\
Updates
Base class for update scripts.
Update scripts perform version updates for Matomo (formerly Piwik) core or individual plugins. They can run SQL queries and/or PHP code to update an environment to a newer version.
To create a new update script, create a class that extends Updates. Name the class and file
after the version, eg, class Updates_3_0_0 and 3.0.0.php. Override the getMigrationQueries()
method if you need to run SQL queries. Override the doUpdate() method to do other types
of updating, eg, to activate/deactivate plugins or create files.
Methods
The abstract class defines the following methods:
getMigrations()— Return migrations to be executed in this update.doUpdate()— Perform the incremental version update.
getMigrations()
Return migrations to be executed in this update.
Migrations should be defined here, instead of in doUpdate(), since this method is used to display a preview
of which migrations and database queries an update will run. If you execute migrations directly in doUpdate(),
they won't be displayed to the user.
Signature
It accepts the following parameter(s):
$updater(Updater) —
It returns a
Migration[]value.
doUpdate()
Perform the incremental version update.
This method should perform all updating logic. If you define migrations in an overridden getMigrations()
method, you must call Updater::executeMigrations() here.
See \Piwik\Plugins\ExamplePlugin\Updates\Updates_0_0_2 for an example.
Signature
It accepts the following parameter(s):
$updater(Updater) —
It does not return anything or a mixed result.