Surprisingly not. Instead, you need to use the following function which is run whenever the plugin is activated.
define( 'YOUR_PLUGIN_VERSION', '1.0.0' );
register_activation_hook( __FILE__, 'your_plugin_activation_function' );
function your_plugin_activation_function() {
// Do activation tasks here.
your_install_function();
your_upgrade_migration_function();
}
Run your install script.
function your_install_function() {
// Set the current version of the plugin in the db.
update_option( 'your_plugin_version', YOUR_PLUGIN_VERSION );
}
Then for each new version, you do a compare which basically performs your database migrations, etc.
function your_upgrade_migration_function() {
// Using a version prior to 1.1.1
if ( version_compare( YOUR_PLUGIN_VERSION, '1.1.1', '<' ) ) {
// Do upgrade things unique for this version.
}
// Using a version prior to 1.2.0
if ( version_compare( YOUR_PLUGIN_VERSION, '1.2.0', '<' ) ) {
// Do upgrade things unique for this version.
}
}