upgrade-db.php
Upgrade the database.
- This script will abort on a production site.
- The release documentation will specify the required user (if any) to run this script.
- Run this from the command line using the command:
wp eval-file upgrade-db.php [--user={user_name}]
Tags
Table of Contents
Constants
- OPTION_NAME = 'pnet_db_version'
- DB version option name.
- REQUIRED_USER = 'devmaster'
- Required user name.
- REQUIRED_VERSION = '6.8.0'
- Required db version.
Functions
- is_production() : bool
- Check if this is a production site.
- is_upgrade_required() : bool
- Check if upgrade is required.
- is_correct_user() : bool
- Check if the correct user is running this script.
- upgrade_database() : void
- Upgrade the database.
- do_upgrades() : bool
- Perform the upgrades.
- set_word_count_metadata() : bool
- Set word count metadata for all posts.
- delete_jetpack_artefacts() : bool
- Remove Jetpack artefacts.
Constants
OPTION_NAME
DB version option name.
public
string
OPTION_NAME
= 'pnet_db_version'
Tags
REQUIRED_USER
Required user name.
public
string
REQUIRED_USER
= 'devmaster'
- If this is set, the upgrader will only run if the current user matches this name.
- Only set this if the upgrader calls functions that have user capability checks.
Tags
REQUIRED_VERSION
Required db version.
public
string
REQUIRED_VERSION
= '6.8.0'
- This MUST be set to the plugin version if upgrader is to run. Leave as a value less than the current version to skip upgrade.
Tags
Functions
is_production()
Check if this is a production site.
is_production() : bool
Tags
Return values
bool —True if this is a production site, false otherwise.
is_upgrade_required()
Check if upgrade is required.
is_upgrade_required() : bool
Tags
Return values
bool —True If stored version is less than the required version, false otherwise.
is_correct_user()
Check if the correct user is running this script.
is_correct_user() : bool
- If REQUIRED_USER is set, the upgrader will only run if the current user matches this name.
Tags
Return values
bool —True if the current user matches the required user, false otherwise.
upgrade_database()
Upgrade the database.
upgrade_database() : void
- Abort if this is a production site.
- Abort if upgrade is not needed.
- If REQUIRED_USER is set, the upgrader will only run if the current user matches this name.
- Delete this file after successful upgrade.
Tags
do_upgrades()
Perform the upgrades.
do_upgrades() : bool
- Call functions from here to perform the actual database upgrades.
- Bail if any function fails.
Tags
Return values
bool —True if upgrade was successful, false otherwise.
set_word_count_metadata()
Set word count metadata for all posts.
set_word_count_metadata() : bool
Tags
Return values
bool —True if successful, false otherwise.
delete_jetpack_artefacts()
Remove Jetpack artefacts.
delete_jetpack_artefacts() : bool
- Remove Jetpack comment metadata.
- Remove Jetpack post metadata.
Tags
Return values
bool —True if successful, false otherwise.