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 comments to Database Versioning

  1. skippy says:

    Excellent addition!

  2. [...] Ryan also explains that some behind the scenes work is underway to really speed up how WordPress works: I worked behind the scenes on database versioning and a persistent object cache. Users don’t really care about these since they’re not visible, but the changes should result in a faster, leaner, and more vigorous WordPress. Honest. [...]

  3. AjaxBlog says:

    Using WordPress

    Much of the amazing work WordPress Developers and hackers are doing to make WordPress 1.6 be the best blogging tool around is being put through the hands of wordpress.com users. Yes, we live with the occassional snafu, but for the most part, we love th…