function DatabaseQueue::ensureTableExists

Same name in other branches
  1. 9 core/lib/Drupal/Core/Queue/DatabaseQueue.php \Drupal\Core\Queue\DatabaseQueue::ensureTableExists()
  2. 10 core/lib/Drupal/Core/Queue/DatabaseQueue.php \Drupal\Core\Queue\DatabaseQueue::ensureTableExists()
  3. 11.x core/lib/Drupal/Core/Queue/DatabaseQueue.php \Drupal\Core\Queue\DatabaseQueue::ensureTableExists()

Check if the table exists and create it if not.

1 call to DatabaseQueue::ensureTableExists()
DatabaseQueue::createItem in core/lib/Drupal/Core/Queue/DatabaseQueue.php

File

core/lib/Drupal/Core/Queue/DatabaseQueue.php, line 239

Class

DatabaseQueue
Default queue implementation.

Namespace

Drupal\Core\Queue

Code

protected function ensureTableExists() {
    try {
        $database_schema = $this->connection
            ->schema();
        if (!$database_schema->tableExists(static::TABLE_NAME)) {
            $schema_definition = $this->schemaDefinition();
            $database_schema->createTable(static::TABLE_NAME, $schema_definition);
            return TRUE;
        }
    } catch (DatabaseException $e) {
        return TRUE;
    }
    return FALSE;
}

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