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

Command to force default WP indexes and collation

Open ethanclevenger91 opened this issue 4 years ago • 1 comments

Feature Request

Describe your use case and the problem you are facing

In WP 4.2, the WP database collation was updated and some indexes were updated. As laid out there, a portion of that was only done if your version of MySQL supported it. That article suggests that it would be attempted again during a future update process, but I can't find much info on that. It also points to a core function that can be used to attempt the update.

That function updates one table at a time and doesn't handle the index updates that need to go along with it. It also leaves the developer to handle edge cases like timeouts on large tables or whatever else may occur (things I've run into).

It'd be great to have a single WP-CLI command that more-or-less recreates that original update and ensures your database ends up in a state where it has WP's expected collation and indexes. Sort of like a WP-specific repair for your database.

I'm sure there may be plugins out there that do this, but to have something from the core team seems appropriate since it revolves around some core expectations.

Of course, this may have side-effects on a user's database so should be done with caution, though the same can be said of the wp db reset command. Not sure how/if it should handle custom tables.

And this may be worrying about nothing - I'm not entirely familiar with the implications of mismatching actual DB collation and what gets configured in my wp-config file.

ethanclevenger91 avatar Jan 08 '20 18:01 ethanclevenger91

As far as I know, that already works as intended when you use wp core update-db.

schlessera avatar Jul 26 '21 08:07 schlessera