How to Force Update Drupal 7 Database Rerun

Author:
phil
Created:
Thursday, May 02nd, 2013
Last Updated:
Thursday, May 02nd, 2013

Disclaimer: Accessing the information on this page means you agree to the Sites Terms of Service


Have you ever been in the middle of a database update with Drupal, only to get a wonderful PHP error, or some other error of sorts? Then when you go to run the database update again, there's nothing to update, leaving you wondering if it actually ever updated or not...

I've run into this more than once and for the most part, just left it the way it was and crossed my fingers in hopes that I wouldn't have a problem later.

Back in the Drupal 6 days, you could rerun a database update on a module, as much as you wanted but they did away with this ability in Drupal 7.

I finally ran into a situation where I needed to try a rerun of the Drupal 7 database update for Views on a site where I had LOTS of views and didn't feel like trying to export them all, uninstall views, reinstall it and then import all of the views... That got me digging and really not much came up in the way of a "sold fix" for explaining how to rerun or force a database update for Drupal 7.

Finally after some digging, I came across a drupal stack exchange post which led me in the right direction and inspired me to writeup this blog.

How To Force Database Update Drupal 7

If you're a SQL guru, take a look at that stack exchange post for the proper syntax. If you're like me and need the safety of phpMyAdmin, keep reading.

Long story short, you need to go into the system table, find the module you want updated and change the schema_version to an earlier version. Since you're on Drupal 7, I recommend changing it to 7000 which will be the very first update for that module, for D7. The stack exchange post says to set it to 0, but when I did this for views, a bug with views was showing me Drupal 6 updates as well which isn't good...

So, to fix it through phpMyAdmin:
(Instructions assume a somewhat newer version like 3.5)

First thing's first, BACKUP YOUR DATABASE! I won't be held responsible for flying cats and whining dogs...

1) Open phpMyAdmin
2) Click on your database so you can view all of the tables
3) Find the system table
4) Click "Browse"
5) Click "Search" up in the main links (Browse | Structure | SQL | Search | etc.)
6) For the name column, put the name of the module you want to force update in the "Value" textfield. If you know the exact match, leave the operator as "Like", otherwise if you want a broader search, change it to Like %...%.
7) Once the results post, click Edit
8) Change the schema_version to either 0 or 7000
9) Save (Click "Go")
10) Go run "update.php" on your website and it should now tell you there are x Pending Updates available.

Proceed with the normal database update procedure and that should do it!

Post Comment

Comments

have to bookmark this blog on my social media

Thank you so, so, SO much for posting this. I've been losing sleep over this disaster of a module update (organic groups) which failed in the middle of database updates due to PHP errors. This post is a life saver!