Where can I find the database changes between WordPress versions?

Given vX and vX+1, how do I find the difference between each versions database schema?

Related posts

Leave a Reply

1 comment

  1. In wp-admin/includes/upgrade.php are version specific functions for database upgrades. They include changes for the schema. Examples for 3.4.0 and 3.5.0:

    /**
     * Execute changes made in WordPress 3.4.
     *
     * @since 3.4.0
     */
    function upgrade_340() {
        global $wp_current_db_version, $wpdb;
    
        if ( $wp_current_db_version < 19798 ) {
            $wpdb->hide_errors();
            $wpdb->query( "ALTER TABLE $wpdb->options DROP COLUMN blog_id" );
            $wpdb->show_errors();
        }
    
        if ( $wp_current_db_version < 19799 ) {
            $wpdb->hide_errors();
            $wpdb->query("ALTER TABLE $wpdb->comments DROP INDEX comment_approved");
            $wpdb->show_errors();
        }
    
        if ( $wp_current_db_version < 20022 && is_main_site() && ! defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
            $wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key = 'themes_last_view'" );
        }
    
        if ( $wp_current_db_version < 20080 ) {
            if ( 'yes' == $wpdb->get_var( "SELECT autoload FROM $wpdb->options WHERE option_name = 'uninstall_plugins'" ) ) {
                $uninstall_plugins = get_option( 'uninstall_plugins' );
                delete_option( 'uninstall_plugins' );
                add_option( 'uninstall_plugins', $uninstall_plugins, null, 'no' );
            }
        }
    }
    
    /**
     * Execute changes made in WordPress 3.5.
     *
     * @since 3.5.0
     */
    function upgrade_350() {
        global $wp_current_db_version, $wpdb;
    
        if ( $wp_current_db_version < 22006 && $wpdb->get_var( "SELECT link_id FROM $wpdb->links LIMIT 1" ) )
            update_option( 'link_manager_enabled', 1 ); // Previously set to 0 by populate_options()
    
        if ( $wp_current_db_version < 21811 && is_main_site() && ! defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
            $meta_keys = array();
            foreach ( array_merge( get_post_types(), get_taxonomies() ) as $name ) {
                if ( false !== strpos( $name, '-' ) )
                $meta_keys[] = 'edit_' . str_replace( '-', '_', $name ) . '_per_page';
            }
            if ( $meta_keys ) {
                $meta_keys = implode( "', '", $meta_keys );
                $wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key IN ('$meta_keys')" );
            }
        }
    
        if ( $wp_current_db_version < 22422 && $term = get_term_by( 'slug', 'post-format-standard', 'post_format' ) )
            wp_delete_term( $term->term_id, 'post_format' );
    }
    

    The Codex has some additional information on the Database description page.