Drupal - reseting the hook_update_n status of a module

Setting it to 0 should work. system_schema() says the value should be:

-1 if the module is not installed (its tables do not exist); 0 or the largest N of the module's hook_update_N() function that has either been run or existed when the module was first installed.


FYI, in Drupal 8, the system table has been removed, and this information is now stored in the key_value table.

UPDATE key_value SET value='i:8000;' WHERE collection = 'system.schema' AND name = 'module_name';

(As noted above, the actual value should be less than the hook_update_N() you want to repeat, but higher than or matching the last update that does not need to be repeated.)


I did this so much that I ended up writing a drush module to roll back the update version in the system table. Called "uroll" for update rollback.

https://github.com/danshumaker/drush-uroll

Usage: drush uroll --module=mycustommodule --version=5

It's super simple but I use it all the time. This combined with a database backup reload script allows you to rinse and repeat when writing update functions.

Hopefully helpful to you. Good luck.