You are here

public function Tasks::initializeDatabase in Drupal driver for SQL Server and SQL Azure 8.2

Same name and namespace in other branches
  1. 8 drivers/lib/Drupal/Driver/Database/sqlsrv/Install/Tasks.php \Drupal\Driver\Database\sqlsrv\Install\Tasks::initializeDatabase()
  2. 3.0.x drivers/lib/Drupal/Driver/Database/sqlsrv/Install/Tasks.php \Drupal\Driver\Database\sqlsrv\Install\Tasks::initializeDatabase()

Make SQLServer Drupal friendly.

File

drivers/lib/Drupal/Driver/Database/sqlsrv/Install/Tasks.php, line 169
Definition of Drupal\Driver\Database\sqlsrv\Tasks

Class

Tasks
Specifies installation tasks for PostgreSQL databases.

Namespace

Drupal\Driver\Database\sqlsrv\Install

Code

public function initializeDatabase() {

  // We create some functions using global names instead of prefixing them
  // like we do with table names. This is so that we don't double up if more
  // than one instance of Drupal is running on a single database. We therefore
  // avoid trying to create them again in that case.
  try {

    /** @var \Drupal\Driver\Database\sqlsrv\Connection $database */
    $connection = Database::getConnection();
    Utils::DeployCustomFunctions($connection
      ->getConnection(), dirname(__FILE__) . '/../Programability');
    $this
      ->pass(t('SQLServer has initialized itself.'));

    // Ensure we clear the schema cache
    $connection
      ->getConnection()
      ->Cache('sqlsrv_meta')
      ->Clear(null);
    $connection
      ->getConnection()
      ->Cache('sqlsrv-table-exists')
      ->Clear(null);
    $connection
      ->getConnection()
      ->Cache('sqlsrv-tabledetails')
      ->Clear(null);
  } catch (\Exception $e) {
    $this
      ->fail(t('Drupal could not be correctly setup with the existing database. Revise any errors.'));
  }
}