Drupal - Why is hook_update_N not running?
Another reason why an update hook would not run is a mismatch between the update hook name and the major release number of the module (see .info file).
For example: the update hook mymodule_update_7001 does not run if the module version is 7.x.1.0. In such case you must rename the hook to mymodule_update_7101.
See the hook_update API documentation
Drupal stores which update hooks has been run as it only runs the update hooks once. If a specific update hook is not run, the most probable reasons is
- It has already been run
- An update hook that needs to be run before fails.
You can see in the system table all the modules enabled and the schema_version
shows which update has been run last.
I had an issue where I installed a new module, but the install failed. The schema_version remained at -1, which prevented further updates for that module. Setting the version to 0 fixed it.
For the curious, I moved the schema of an existing table to a new module. The failure happened when it couldn't create the existing table, which I expected. The module was enabled as expected, but I didn't realize that the schema_version didn't update.