You can do different things depending on your use case.
- If you really need to test your install script again you need to uninstall your module rather than just disabling it. You can do that by running
drush dis mymodule && drush pm-uninstall mymodule
followed bydrush en mymodule
again. As @Clive mentions if you have the Devel module installed you can alsodrush dre mymodule
(Devel reinstall). Or disable the module at http://example.com/admin/modules and then uninstall the module at http://example.com/admin/modules/uninstall . You should probably have ahook_uninstall
function set up to clean up after your install. For example you may need to drop some tables or delete temporary files. See the link below for hook_uninstall. - If you have an update to already the installed module you should use
hook_update_n
instead ofhook_install
. Then you can visit http://example.com/update.php or rundrush updb
Link below. - Lastly, you can probably change the database table that records the installation. I don't recall exactly how to do that but I don't think its preferable.
Here are the docs on writing uninstall hooks. https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_uninstall/7
Here are the docs on writing update hooks. Basically the way I do it is make sure that hook_install
runs the update functions after it runs itself.
https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_update_N/7
eg:
/*
* Implements hook_install
*/
function mymodule_install() {
// do some things
// then run the updates
mymodule_update_7000();
mymodule_update_7001();
}
/*
* Implements hook_install
*/
function mymodule_update_7000() {
// do some other things
}
/*
* Implements hook_install
*/
function mymodule_update_7001() {
// do some more things
}