protected function DatabaseBackend::ensureBinExists

Check if the cache bin exists and create it if not.

1 call to DatabaseBackend::ensureBinExists()

File

drupal/core/lib/Drupal/Core/Cache/DatabaseBackend.php, line 423
Definition of Drupal\Core\Cache\DatabaseBackend.

Class

DatabaseBackend
Defines a default cache implementation.

Namespace

Drupal\Core\Cache

Code

protected function ensureBinExists() {
  try {
    $database_schema = $this->connection
      ->schema();
    if (!$database_schema
      ->tableExists($this->bin)) {
      $schema_definition = $this
        ->schemaDefinition();
      $database_schema
        ->createTable($this->bin, $schema_definition['bin']);

      // If the bin doesn't exist, the cache tags table may also not exist.
      if (!$database_schema
        ->tableExists('cache_tags')) {
        $database_schema
          ->createTable('cache_tags', $schema_definition['cache_tags']);
      }
      return TRUE;
    }
  } catch (SchemaObjectExistsException $e) {
    return TRUE;
  }
  return FALSE;
}