You are here

public function ModuleCommands::cleanupSchemaVersion in Helper 8

Cleans up the schema versions for deleted modules.

@command module:schema-version:cleanup @aliases msvc @usage drush module:schema-version:cleanup Cleans up any missing module schemas.

File

src/Commands/ModuleCommands.php, line 288

Class

ModuleCommands
Drush commands for working with module schemas.

Namespace

Drupal\helper\Commands

Code

public function cleanupSchemaVersion() {
  $list = $this->moduleHandler
    ->getModuleList();

  /** @var array $schemas */
  $schemas = drupal_get_installed_schema_version(NULL, FALSE, TRUE);
  $missing = array_keys(array_diff_key($schemas, $list));
  if (empty($missing)) {
    return dt('No deleted module schemas to cleanup.');
  }
  $this
    ->io()
    ->note(dt('Found the following deleted modules with schemas to clean up:'));
  $this
    ->io()
    ->listing($missing);
  foreach ($missing as $module) {
    $this
      ->io()
      ->success($this
      ->deleteSchemaVersion($module));
  }
}