Automated Upgrading
Add-ons can be automatically upgraded during the ExpressionEngine core upgrading process, if the user has opted to do so.
The upgrade.addon_name.php File
The upgrade.addon_name.php file allows your add-on to hook into the EE upgrade process to run code at various stages of the upgrade process.
For example:
upgrade.my_awesome_plugin.php
<?php
class My_awesome_plugin_upgrade {
public function upgrade($version)
{
if(version_compare($version, '3.0.0', '=')) {
// Run updates for upgrade to EE3
}
if(version_compare($version, '4.0.0', '=')) {
// Run updates for upgrade to EE3
}
}
}
The upgrade function is run at each minor version update of the ExpressionEngine process. If your add-on has an upgrade.addon_name.php
, where addon_name
is the snake_case name of your add-on, ExpressionEngine will automatically run the upgrade
function at each version update.
The add-on upgrade
function should accept a parameter $version
that will be the current stepped version in the ExpressionEngine update process.