In my custom module's install file I have a hook_update_N function. Let's say it's mymodule_update_7100. However, I've noticed that I've done it wrong and I want to change a line of code within this function. Seeing as I've already run updb/update.php the changes won't be picked up and I'd have to rename it to either mymodule_update_7101 or create a new function after it with that name. I'd really rather not have to do this, so I was wondering if there's a variable that tells Drupal exactly what "version number" a module is currently at and whether I can reset it to trick it into allowing me to run the update script again.

The actual effect the function has had on the database isn't important because it's just generating a taxonomy term that I can easily delete through the front-end afterwards.

5 Answers 5


The schema_version column in the system table contains the version of the last successful update. Manipulate that value and you can re-test your update.

The name column is the machine name of the module, same as the info file is named.

This query will do the trick for you.

UPDATE system SET schema_version = XXXX WHERE name = 'name_of_module';

Drupal 7 core's install.inc has the function drupal_set_installed_schema_version($module, $version)


For Drupal 9 UpdateHookRegistry service (update.update_hook_registry) replaced functions in schema.inc according to New UpdateHookRegistry replaces functions in schema.inc

so now instead of drupal_set_installed_schema_version($module, $version) you can use \Drupal::service('update.update_hook_registry')->setInstalledVersion($module, $version)

Example using Drush:

drush eval '\Drupal::service("update.update_hook_registry")->setInstalledVersion("MODULE", "930N");
  • 1
    This is the right answer for any of the Symfonic Drupal versions (> version 7).
    – apotek
    Commented Jun 13 at 18:19

On drupal 8 it's in the table key_value under value where name is the name of your module.


Following on from the comment by @wranvaud for Ddrupal 8, the actual statement/command is db_update('key_value')->fields(array('value' => serialize(nnn)))->condition('collection', 'system.schema', '=')->condition('name', 'your_module', '=')->execute(); where nnnn is the schema version you want to revert to. The important bit is serialize because the value is a blob/binary field. This can be executed in a Devel module php form

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.