Events gone after upgrading? Read this!

Posted on January 5, 2012

I’ve just discovered a potential bug in WordPress that may prevent some users from upgrading properly from version 4 to 5.

Who This Affects

If your database table names contain any capitals then chances are this affects you. If not, or if your events are showing up fine in the admin area, ignore this post, it is not affecting you!


You are upgrading from version 4 to version 5 and you notice that your events have disappeared. You check your database XX_em_events table and notice that there is no collumn called post_id, then your database did not upgrade.

Why is this happening?

Events Manager uses a function called dbDelta, which detects if you already have a database table installed and updates the structure accordingly or creates a new one if it doesn’t exist. dbDelta does not check for capitalized database names, it converts the names to lowercase, which on some systems with some server setups may return a false negative, meaning dbDelta tries to create a new database table and fails since it exists, so no upgrade takes place.


I have reported this bug to the WordPress ticket system and provided a solution there. Here it is again along with EM-specific upgrade instructions:

You firstly need to edit a WordPress core file which is /wp-admin/includes/upgrade.php line 1471 (do a search/replace if you don’t have line numbering in a text editor). Change this:

$cqueries[trim( strtolower($matches[1]), '`' )] = $qry;


$cqueries[trim($matches[1], '`' )] = $qry;

Next, you should visit and find an input box named ‘dbem_version’, you should see a number greater than 5, set it to 4.9.

Finally, load up an EM admin page and wait whilst the upgrade goes through!


  1. That doesn’t work for me… dbem_version was set to 4.123 (or like that) :/

    • marcus says:

      if this doesn’t work, bring it up in the forums. This is specific to tables with capitals due to a WP bug.

      if it says 4.x and it doesn’t change that number at all, your issue is different.