You are here

function drupal_uninstall_schema in Drupal 9

Same name and namespace in other branches
  1. 8 core/includes/schema.inc \drupal_uninstall_schema()
  2. 6 includes/common.inc \drupal_uninstall_schema()
  3. 7 includes/common.inc \drupal_uninstall_schema()

Removes all tables defined in a module's hook_schema().

Parameters

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

Deprecated

in drupal:9.2.0 and is removed from drupal:10.0.0. No direct replacement is provided.

See also

https://www.drupal.org/node/2970993

\Drupal\Core\Extension\ModuleInstaller::uninstallSchema()

Related topics

1 call to drupal_uninstall_schema()
SchemaDeprecationTest::testDeprecatedInstallSchema in core/tests/Drupal/KernelTests/Core/Extension/SchemaDeprecationTest.php
Tests deprecation of database schema API functions.

File

core/includes/schema.inc, line 134
Schema API handling functions.

Code

function drupal_uninstall_schema($module) {
  @trigger_error('drupal_uninstall_schema() is deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. No direct replacement is provided. See https://www.drupal.org/node/2970993', E_USER_DEPRECATED);
  $tables = drupal_get_module_schema($module);
  _drupal_schema_initialize($tables, $module, FALSE);
  $schema = \Drupal::database()
    ->schema();
  foreach ($tables as $table) {
    if ($schema
      ->tableExists($table['name'])) {
      $schema
        ->dropTable($table['name']);
    }
  }
}