Skip to main content
added 113 characters in body; edited body
Source Link
Queenvictoria
  • 1.8k
  • 14
  • 16

You can do different things depending on your use case.

  1. 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 by drush en mymodule again. As @Clive mentions if you have the Devel module installed you can also drush 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 a hook_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.
  2. If you have an update to already the installed module you should use hook_update_n instead of hook_install. Then you can visit http://example.com/update.php or run drush updb Link below.
  3. 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
}

You can do different things depending on your use case.

  1. 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 by drush en mymodule again. 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 a hook_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.
  2. If you have an update to already the installed module you should use hook_update_n instead of hook_install. Then you can visit http://example.com/update.php or run drush updb Link below.
  3. 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
}

You can do different things depending on your use case.

  1. 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 by drush en mymodule again. As @Clive mentions if you have the Devel module installed you can also drush 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 a hook_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.
  2. If you have an update to already the installed module you should use hook_update_n instead of hook_install. Then you can visit http://example.com/update.php or run drush updb Link below.
  3. 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
}
Source Link
Queenvictoria
  • 1.8k
  • 14
  • 16

You can do different things depending on your use case.

  1. 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 by drush en mymodule again. 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 a hook_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.
  2. If you have an update to already the installed module you should use hook_update_n instead of hook_install. Then you can visit http://example.com/update.php or run drush updb Link below.
  3. 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
}