[development] hook_schema() now in .install, not .schema

Barry Jaspan barry at jaspan.org
Mon Oct 8 23:44:39 UTC 2007


Public service announcement:

Prior to http://drupal.org/node/150245, hook_schema() was always 
defined in a module's .schema file.  There was never any good reason 
for it to be there.  The bad reason was "to avoid parsing the extra 
code in .install."  However, the results of hook_schema() are cached 
so the functions only have to be called when modules are 
enabled/disabled or when CCK type structures change.  This is very 
rare and parsing the .install files only on those occasions is not a 
performance issue.

Now, hook_schema() must be defined in .install.  The good reason for 
this is that it makes much more sense to have the schema definition 
and the schema update functions in the same place.  It will make bugs 
of the "changed hook_schema() without a hook_update_N() or vice 
versa" sort less likely.  And it is where God intended hook_schema() 
to be (says the atheist).

If this had been an actual emergency, your mail server would already 
have crashed.

Thanks,

Barry



More information about the development mailing list