How do I reinstall the Forum module in Drupal 7? I did something really stupid: I deleted the taxonomy_forum field (Forums) from the content type. Now I'm get all sorts of errors.


  PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'flo1121202154643.field_data_taxonomy_forums' doesn't exist:
  SELECT field_data_taxonomy_forums0.entity_type AS entity_type, field_data_taxonomy_forums0.entity_id AS entity_id, field_data_taxonomy_forums0.revision_id AS revision_id, field_data_taxonomy_forums0.bundle AS bundle FROM {field_data_taxonomy_forums} field_data_taxonomy_forums0 WHERE (field_data_taxonomy_forums0.deleted = :db_condition_placeholder_0) AND (field_data_taxonomy_forums0.bundle = ..........


How do I reinstall the Forum module in Drupal 7 from scratch (including recreating the database schema)?
To uninstall a module, you follow these steps:


Deselect the checkbox shown for the module in admin/modules, and click on the "Save configuration" button at the bottom of the page
Select the "Uninstall" tab (admin/modules/uninstall), and in that page select the checkbox shown close to the name of the module you want to uninstall ("Forum")
Click on the "Uninstall" button
In the next page, click again on "Uninstall"


When you execute the first two steps, you are only disabling the module, which is not yet uninstalled. It is when you execute the last two steps that you uninstall the module.

To re-install it, you need to:


Return to the page listing all the modules (admin/modules)
Select the checkbox shown for the module you want to install ("Forum")
Click on the "Save configuration" button at the bottom of the page


Uninstalling a module should already clear the cache, but to be sure you can manually clear the cache before to re-install the module.
Once the module is uninstalled, installing it back will let Drupal create the database tables used by the module again. The same tables are deleted from Drupal when the module is uninstalled.

I noticed a little issue that happens when you uninstall and re-install the Forum module: The default taxonomy term used by the module is created again all the times you re-install the module, and it seems it is not removed when the module is uninstalled. This is the result of uninstalling and re-installing the module more than once; each time the taxonomy term is created, even if it was already present.



Actually, it is not even required to uninstall, and re-install the module; it is enough you disable, and then re-enable the module, as the code that creates the missing field is not contained in forum_install(), but in forum_enable(), which the function executed when the module is enabled.

I was going to suggest a different way to resolve this issue, and which consisted in manually creating the missing field, but I noticed it doesn't work. The problem is that the module that allows to create a field through the user interface always add "field_" at the beginning of the field names for the fields you create, but the field created from the Forum module doesn't have that prefix; the result is that some database tables and a field present in a table don't have the name the module is expecting, and the module throws errors.