You are here

protected function SchemaComparator::executeCompare in Schema 8

Generates comparison information and stores it in the $result field.

1 call to SchemaComparator::executeCompare()
SchemaComparator::execute in src/Comparison/SchemaComparator.php
Execute the schema comparison.

File

src/Comparison/SchemaComparator.php, line 75
Contains Drupal\schema\Comparison\SchemaComparator.

Class

SchemaComparator
Compares a declared schema array with the complete database schema.

Namespace

Drupal\schema\Comparison

Code

protected function executeCompare() {

  // Retrieve complete database schema.
  $inspect = $this->inspector
    ->inspect();
  foreach ($this->declared_schema as $t_name => $table) {

    // Check declared schema for inconsistencies.
    $this
      ->checkTable($t_name, $table);

    // Fix inconsistencies which we do not want to show up as differences.
    $this
      ->preprocessTableSchema($t_name, $table);

    // See if table exists in database and compare against schema if it does.
    if (!isset($inspect[$t_name])) {
      $this->result
        ->addMissingTable($t_name, $table);
    }
    else {
      $this
        ->compareTable($t_name, $table, $inspect[$t_name]);
      unset($inspect[$t_name]);
    }
  }

  // Mark remaining tables as extra tables, which are only in the database.
  foreach ($inspect as $name => $table) {
    $this->result
      ->addExtraTable($name, $table);
  }
}