I wanted to add columns to my module schema, I added an update hook hook_update_6031 however when I go to the update.php script my module isn't listed at all, not even as "no updates". Do I have to provide some hook to have my module be listed? I can't seem to find any documentation on how to write updates other than the function documentation for hook_update or looking at some other module code.


Some things to check:

  • Is your update function placed in [modulename].module or in [modulename].install? It should be in the install file.
  • Is the function really called hook_update_6031? in that case, replace 'hook' with the name of your module. For instance, an update function for the comment module could be called comment_update_6003.

If the above does not help, please update your question with the code of your update function. Also check the value in the schema_version column in the system table for your module - for the [modulename]_update_6031 function, it must not be less than 6031, but not -1.

  • haha, apparently I did name it hook_update, I changed it and it works fine. – ameer Jun 15 '11 at 21:12
  • Glad I could help. I think every Drupal developer makes that mistake at least once :-) – marcvangend Jun 15 '11 at 21:20
  • 2
    Also important, always make your module name lower case only. Update functions aren't detected for modules with upper case characters in them, although other hooks are. – Berdir Jun 16 '11 at 0:21
  • @Berdir that's interesting, I didn't know that. Is there a good reason for this behavior? – marcvangend Jun 16 '11 at 8:45
  • Yes. Calling functions is case insensitive, so hooks work. But update functions are detected by manually looking at defined functions: api.drupal.org/api/drupal/includes--install.inc/function/… – Berdir Jun 16 '11 at 11:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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