function ModuleInstaller::uninstallSchema

Same name in other branches
  1. 10 core/lib/Drupal/Core/Extension/ModuleInstaller.php \Drupal\Core\Extension\ModuleInstaller::uninstallSchema()
  2. 11.x core/lib/Drupal/Core/Extension/ModuleInstaller.php \Drupal\Core\Extension\ModuleInstaller::uninstallSchema()

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

@internal

Parameters

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

1 call to ModuleInstaller::uninstallSchema()
ModuleInstaller::uninstall in core/lib/Drupal/Core/Extension/ModuleInstaller.php
Uninstalls a given list of modules.

File

core/lib/Drupal/Core/Extension/ModuleInstaller.php, line 660

Class

ModuleInstaller
Default implementation of the module installer.

Namespace

Drupal\Core\Extension

Code

protected function uninstallSchema(string $module) : void {
    $tables = $this->moduleHandler
        ->invoke($module, 'schema') ?? [];
    $schema = $this->connection
        ->schema();
    foreach (array_keys($tables) as $table) {
        if ($schema->tableExists($table)) {
            $schema->dropTable($table);
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.