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

Earnie Boyd earnie at users.sourceforge.net
Tue Oct 9 12:14:16 UTC 2007


Quoting Earl Miles <merlin at logrus.com>:

> Barry Jaspan wrote:
>> 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.
>
> Personally, I think this was a mistake.
>
> Not that the idea itself wasn't good, but module developers have 
> already started porting stuff over, and now there are no modules that 
> can simultaneously work with Drupal 6-beta1 and Drupal 6-beta2. This 
> is one of the things that can really frustrate module developers, and 
> I don't see a pressing need for this change. Yes, it was an error and 
> probably shouldn't have been this way, but it wasn't hurting 
> anything, either.
>

And .schema is self explanatory.  While .install is to be used only at 
install time at first glance (I know it is used during update as well). 
  Tools can be developed using just the .schema alone.

Earnie -- http://for-my-kids.com/
-- http://give-me-an-offer.com/



More information about the development mailing list