Over the lifetime of a plugin, as it gets expanded to provide additional functionality, there may be a need to store more data than was originally intended in custom database tables. As you may know, WordPress itself makes regular changes to its own database structure during the upgrade process to store new information. To do this, it uses a simple function called
dbDelta, which we can also access from our plugin's code.
This recipe shows how to alter the previous table creation code to load the WordPress upgrade API and use the database upgrade function to add an extra field to the existing bug storage table.
You should have already followed the Creating new database tables recipe to have the creation code to modify. Alternatively, you can get the resulting code (
Chapter 8/ch8-bug-tracker/ch8-bug-tracker-v1-1.php) from the code bundle and rename the file