wp-cli / db-command

Performs basic database operations using credentials stored in wp-config.php.
MIT License
71 stars 59 forks source link

Command to force default WP indexes and collation #159

Closed ethanclevenger91 closed 1 year ago

ethanclevenger91 commented 4 years ago

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.

schlessera commented 3 years ago

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