You are here

public function IndexManager::DeployNew in Drupal driver for SQL Server and SQL Azure 8

Same name and namespace in other branches
  1. 8.2 src/Indexes/IndexManager.php \Drupal\sqlsrv\Indexes\IndexManager::DeployNew()

Deploy all missing indexes.

Return value

void

Throws

\Exception

File

src/Indexes/IndexManager.php, line 35

Class

IndexManager
Default indexes to be deployed for CORE functionality.

Namespace

Drupal\sqlsrv\Indexes

Code

public function DeployNew() {

  // Scan the Implementations folder
  $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Implementations';
  $files = file_scan_directory($dir, '/.*\\.sql$/');
  foreach ($files as $file) {
    $index = new Index($file->uri);
    $schema = $this->connection
      ->schema();
    if (!$schema
      ->_ExistsIndex($index
      ->GetTable(), $index
      ->GetName())) {
      try {

        // TODO: Consider the need to prefix the tables...
        $this->connection
          ->query($index
          ->GetCode());
      } catch (\Exception $e) {
        \Drupal::logger('MSSQL')
          ->notice("Could not deploy index {$index->GetName()} for table {$index->GetTable()}");
      }
    }
  }
}