Database Versioning

We recently added database versioning. Until now, the database was unversioned. When running upgrade.php, we would do all of the steps necessary to upgrade the DB from the earliest release of WP to the latest, regardless of what release of WP generated the DB being upgraded. To accomplish this, the upgrade code had to ensure that every action it performed worked against all versions of the WP DB and produced the same results no matter how many times upgrade.php was called. This could be a pain since we had to ensure that every upgrade action could recognize and not step on its own work when being called for the second, third, and fourth times. With the addition of a database version, we can do the work once and skip it on subsequent calls to upgrade.php. This makes the upgrade code easier to write and makes upgrade.php run faster. For example, 1.2 had some problems with double slashing quotes. Code in the upgrade went through the entire DB and fixed these double slashed quotes. This is an expensive operation that was run every time upgrade.php was called, even when upgrading from later releases that did not have the problem. Now we check the database version and skip that step if we aren’t upgrading from a 1.2 or earlier database. If you run upgrade.php against an up-to-date DB, upgrade simply returns immediately and does not touch the DB. A simple change that was overdue.

3 thoughts on “Database Versioning

  1. Pingback: AjaxBlog

Leave a Reply