How best to handle database version dependence (from $wp_db_version)

I'm working on a plugin to speed up WordPress queries by adding / changing indexes on WordPress tables.

My question is this: should I make my plugin refuse to work if the database version in $wp_db_version is greater than what I've tested with? It's now at 49752.

It seems from wp-admin/includes/upgrade.php that the core team sometimes adds or changes indexes, but that they haven't done so since the 4-byte utfmb4 character set came along.

What's the core team discipline for updating the database version number? In the past, have database updates appeared in the beta releases? (Giving me a chance to test my stuff before the release goes live.)

Topic wordpress-version plugin-development database updates Wordpress

Category Web


I sorted this out. It looks like the core team rolls out new versions of the database with their beta program. So, it's plenty easy to get advance warning.

And, the database upgrades live in wp-admin/includes/upgrade.php.

There's a sequence of functions in there named things like upgrade_500, upgrade_560, upgrade_590. They're named for the WordPress version when they first become active: upgrade_560 is, for example, tied to version 5.6.

Working through those functions is like doing an archaeological dig. With each layer, you see what changed from the previous.

Database schema wise.

  • V4.2.0 database V 31351 handled the conversion to utfmb4 unicode, and introduced the prefix indexes like ALTER TABLE wp_usermeta DROP INDEX meta_key, ADD INDEX meta_key(meta_key(191)).
  • V5.6, database V 49572 no longer has the column wp_posts.post_category.
  • V5.6, database V 49752 has the most recent upgrades for 5.8.x. No schema changes from V 49572. (Careful typing those version numbers, they're almost the same.)
  • V5.9beta, database V 51917 has no schema changes from V 49572.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.