i'm developing a module and creating a .install file along with it. made some change in the table design so i decided to make one _update implementation here to test that functionality out. worked just fine. but i now go to install it on a different site, and when i do i have to manually run the module's update through the update.php script. i personally think that should be done automatically during the module's installation. any feedback on that? am i missing something perhaps? thanks!

Comments

rhyek’s picture

*bump*

dman’s picture

if you make a module, enable it, then continue to develop it (like by adding an install script) that will never happen.
Drupal noticed the module the first time and never looks again.

The latest devel.module has an option to manually run 'install' again on any module.

note update is not the same as hook_install.
On a new site, there is no call for update.

.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/

rhyek’s picture

i understand the _install hook only runs once in the lifetime of a module. if you want it run again you either use the devel module as you stated, or just delete the row in the system table of the db that corresponds to the module, drop the tables and enable the module for it to install.
my question is regarding updated modules. i keep adding _update hooks to my module as i develop it but the way drupal installs modules, i would have to move over all the _update hook instructions to the _install hook if i want the module to be up-do-date on a new install on a new site without the need of running update.php.
i believe on new installs, drupal should not only run _install but _update hooks as well without the need of running update.php manually.
if i understood this well, i'll probably move this over to a feature request thread or something.

dman’s picture

i would have to move over all the _update hook instructions to the _install hook if i want the module to be up-do-date on a new install on a new site without the need of running update.php.

You would and you should.
_install should be complete in itself - the end target.
_updates are incremental diffs and stuff.

When you install something, you shouldn't need to update it immediately. Looking at the install process as a collection of incremental updates is like using CVS to check out an early version of a file, then applying all the patches - instead of just getting the new copy. _install is your HEAD version, _updates are patches :-B

But if you want to run things that way, you can probably call your updates from the bottom of your install function.

.dan.
How to troubleshoot Drupal | http://www.coders.co.nz/