summaryrefslogtreecommitdiffstatshomepage
path: root/core/modules/pgsql/pgsql.install
blob: dde8bef0c6c102370ac8de40a6e3efcb0485160e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php

/**
 * @file
 * Install, update and uninstall functions for the pgsql module.
 */

use Drupal\Core\Database\Database;
use Drupal\pgsql\Update10101;

/**
 * Implements hook_requirements().
 */
function pgsql_requirements() {
  $requirements = [];
  // Test with PostgreSQL databases for the status of the pg_trgm extension.
  if (Database::isActiveConnection()) {
    $connection = Database::getConnection();

    // Set the requirement just for postgres.
    if ($connection->driver() == 'pgsql') {
      $requirements['pgsql_extension_pg_trgm'] = [
        'severity' => REQUIREMENT_OK,
        'title' => t('PostgreSQL pg_trgm extension'),
        'value' => t('Available'),
        'description' => 'The pg_trgm PostgreSQL extension is present.',
      ];

      // If the extension is not available, set the requirement error.
      if (!$connection->schema()->extensionExists('pg_trgm')) {
        $requirements['pgsql_extension_pg_trgm']['severity'] = REQUIREMENT_ERROR;
        $requirements['pgsql_extension_pg_trgm']['value'] = t('Not created');
        $requirements['pgsql_extension_pg_trgm']['description'] = t('The <a href=":pg_trgm">pg_trgm</a> PostgreSQL extension is not present. The extension is required by Drupal 10 to improve performance when using PostgreSQL. See <a href=":requirements">Drupal database server requirements</a> for more information.', [
          ':pg_trgm' => 'https://www.postgresql.org/docs/current/pgtrgm.html',
          ':requirements' => 'https://www.drupal.org/docs/system-requirements/database-server-requirements',
        ]);
      }

    }
  }

  return $requirements;
}

/**
 * Update sequences' owner created from serial columns in PostgreSQL.
 */
function pgsql_update_10101(&$sandbox) {
  \Drupal::classResolver(Update10101::class)->update($sandbox);
}