core-command icon indicating copy to clipboard operation
core-command copied to clipboard

Add `wp core check-update-db` command

Open Copilot opened this issue 1 week ago • 3 comments

  • [x] Add check-update-db method to Core_Command class
  • [x] Implement logic to check if database update is needed (compare wp_db_version with current db_version)
  • [x] Add support for --network flag for multisite installations
  • [x] Add appropriate WP-CLI output messages
  • [x] Update composer.json to register the new command
  • [x] Create Behat feature tests for the new command
  • [x] Address PR feedback:
    • [x] Revert README.md (auto-generated file)
    • [x] Fix composer.json semver version range
    • [x] Fix code formatting alignment
  • [x] Request code review and security scan (both passed with no issues)

Summary

Successfully implemented wp core check-update-db command that checks whether a WordPress database update is needed. The command:

  • Returns exit code 1 when update is needed, 0 when database is up to date
  • Compares wp_db_version with current db_version option
  • Supports --network flag to check all sites in a multisite installation
  • Follows the same patterns as existing wp core check-update command
  • Includes comprehensive Behat tests for single site and multisite scenarios

All PR feedback has been addressed.

Original prompt

This section details on the original issue you should resolve

<issue_title>Improve DB update commands</issue_title> <issue_description>We currently have a command wp core update-db that sometimes needs to be run after an update of Core.

It would be great to have a mechanism to check whether an update is actually needed.

Also, both commands might make more sense as wp db ... commands, instead of wp core ... commands.

Suggestion:

wp db check-update     Checks for the need for WordPress database updates.
wp db update           Runs the WordPress database update procedure.

Related issue: https://github.com/wp-cli/wp-cli/issues/5085

cc @swissspidy </issue_description>

<agent_instructions>The new command should be wp core check-update-db, to align with wp core check-update</agent_instructions>

Comments on the Issue (you are @copilot in this section)

  • Fixes wp-cli/core-command#293

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot avatar Oct 29 '25 20:10 Copilot