drupal_uninstall_schema

Definition

drupal_uninstall_schema($module)
includes/common.inc, line 3138

Description

Remove all tables that a module defines in its hook_schema().

Note: This function does not pass the module's schema through hook_schema_alter(). The module's tables will be created exactly as the module defines them.

Parameters

$module The module for which the tables will be removed.

Return value

An array of arrays with the following key/value pairs:

  • success: a boolean indicating whether the query succeeded.
  • query: the SQL query(s) executed, passed through check_plain().

Related topics

Namesort iconDescription
Schema APIA Drupal schema definition is an array structure representing one or more tables and their related keys and indexes. A schema is defined by hook_schema(), which usually lives in a modulename.install file.

Code

<?php
function drupal_uninstall_schema($module) {
  $schema = drupal_get_schema_unprocessed($module);
  _drupal_initialize_schema($module, $schema);

  $ret = array();
  foreach ($schema as $table) {
    if (db_table_exists($table['name'])) {
      db_drop_table($ret, $table['name']);
    }
  }
  return $ret;
}
?>
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.