Skip to content

Add wp db status command for database health overview#307

Open
Copilot wants to merge 9 commits intomainfrom
copilot/add-wp-db-status-command
Open

Add wp db status command for database health overview#307
Copilot wants to merge 9 commits intomainfrom
copilot/add-wp-db-status-command

Conversation

Copy link

Copilot AI commented Feb 1, 2026

Implementation Complete: wp db status Command ✅

  • Analyze existing code patterns and command structure
  • Implement the status() method in /home/runner/work/db-command/db-command/src/DB_Command.php
    • Get database name (DB_NAME)
    • Get table count using information_schema
    • Get total database size using existing size query pattern
    • Get database prefix using $wpdb->prefix
    • Get database engine, charset, and collation from information_schema
    • Run db check to get check status
    • Format output as key-value pairs using data-driven approach
    • Handle edge case for zero/null database size
    • Support --dbuser, --dbpass, and --defaults options
    • Change @when annotation to before_wp_load
    • Refactor output using associative array for maintainability
    • Simplify size formatting logic with null coalescing operator
  • Register the command in composer.json
  • Create Behat tests in /home/runner/work/db-command/db-command/features/db-status.feature
    • Consolidate test scenarios for better clarity
    • Use regex matching for dynamic values
    • Test --dbuser, --dbpass, and --defaults options
  • Run linter and code style checks (✅ PASSED)
  • Run PHPStan static analysis (✅ PASSED)
  • Address all code review feedback
  • Run security checks with CodeQL (✅ NO ISSUES)

Changes in this commit

Code improvements:

  • Refactored output code to use data-driven approach with associative array
  • Simplified size formatting logic with null coalescing operator
  • Inverted conditional for better readability

Test improvements:

  • Consolidated first three test scenarios into one comprehensive scenario
  • Added regex matching for dynamic values (table count, size, engine, charset, collation)
  • Made tests more robust and resilient to minor changes
Original prompt

This section details on the original issue you should resolve

<issue_title>Add wp db status command for quick database health overview</issue_title>
<issue_description>I would like to suggesta new WP-CLI command: wp db status

The command would provide a concise, read-only overview of the current WordPress database health and configuration in a single output, reducing the need to run multiple separate commands.

For support, debugging, and hosting diagnostics, it would be beneficial to have a single, non-destructive command that aggregates key database information into one quick report.

Currently, checking database status requires running several commands such as: wp db size, wp db tables, wp db prefix, wp db check, etc.

My Proposed Command:

wp db status

Output Example:

Database Name:     wp_mehrazmorshed
Tables:            54
Total Size:        312 MB
Prefix:            wp_
Engine:            InnoDB
Charset:           utf8mb4
Collation:         utf8mb4_unicode_ci
Check Status:      OK
```</issue_description>

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

<comments>
<comment_new><author>@ernilambar</author><body>
It will be included in next "3.0.0" version.</body></comment_new>
<comment_new><author>@swissspidy</author><body>
Yeah you can already try it out in the nightly release.

One difference is that the site-health command involves loading WordPress, whereas the db commands usually also work when WordPress is not even installed yet.</body></comment_new>
<comment_new><author>@ernilambar</author><body>
Although database info is available from "site-health" command I am positive is adding specific db command which gives info without loading whole WordPress. It would be helpful in scripting.</body></comment_new>
</comments>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 1, 2026 16:10
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Add wp db status command for database health overview Add wp db status command for database health overview Feb 1, 2026
Copilot AI requested a review from swissspidy February 1, 2026 16:13
@codecov
Copy link

codecov bot commented Feb 1, 2026

Codecov Report

❌ Patch coverage is 98.03922% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/DB_Command.php 98.03% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@swissspidy swissspidy requested a review from Copilot February 2, 2026 01:50
@swissspidy

This comment was marked as resolved.

gemini-code-assist[bot]

This comment was marked as resolved.

This comment was marked as resolved.

swissspidy and others added 3 commits February 2, 2026 20:47
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
@swissspidy

This comment was marked as resolved.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

@swissspidy swissspidy marked this pull request as ready for review February 4, 2026 03:12
@swissspidy swissspidy requested a review from a team as a code owner February 4, 2026 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add wp db status command for quick database health overview

2 participants