Update: bugfix release b2v6 available.
Some conversations with Chow Kah Soon, who’s site is full of diversions from work , finally
convinced encouraged me to solve some small problems that were giving him big trouble. Chow Kah Soon is in the lucky, but rare, position of having over 20,000 unique daily visitors to his site, so he’s sort of my designated stress-tester.
After looking at the logs he shared with me, the table structure, and the queries in bsuite, it was pretty clear that I needed to make some changes to the indexes.
Instead of using a normal $wpdb query to make our table, there is a special function in WordPress that we’ll use that can create a table if it isn’t there, or change the structure if it doesn’t match the current table. This will come in very handy if we ever need to make changes to the MySQL structure in the future.
The function’s a little finicky, and it took me a couple minutes to realize that it was tripping up on the backtick quotes (`) I had wrapped around my table and field names. But with that out of the way, it solves the big problem of how to easily add indexes to existing tables. What it doesn’t solve, sadly, is how to delete existing indexes that aren’t in the new table definition.
With the dbDelta function implemented, I also finally got around to implementing an auto-install hook that creates or re-configs the tables upon plugin activation. Here’s the example from the docs:
…you simply have to use the path of your plugin relative to /wp-content/plugins. Eg: you have a plugin in /wp-content/plugins/wp-spamfilter/wp-spamfilter.php then you have to call add_action as following:
Yes, all of these updates will be released soon. I promise.