function Schema::_createKeys

Same name and namespace in other branches
  1. 9 core/modules/pgsql/src/Driver/Database/pgsql/Schema.php \Drupal\pgsql\Driver\Database\pgsql\Schema::_createKeys()
  2. 8.9.x core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php \Drupal\Core\Database\Driver\pgsql\Schema::_createKeys()
  3. 10 core/modules/pgsql/src/Driver/Database/pgsql/Schema.php \Drupal\pgsql\Driver\Database\pgsql\Schema::_createKeys()
2 calls to Schema::_createKeys()
Schema::addField in core/modules/pgsql/src/Driver/Database/pgsql/Schema.php
Add a new field to a table.
Schema::changeField in core/modules/pgsql/src/Driver/Database/pgsql/Schema.php
Change a field definition.

File

core/modules/pgsql/src/Driver/Database/pgsql/Schema.php, line 1028

Class

Schema
PostgreSQL implementation of <a href="/api/drupal/core%21lib%21Drupal%21Core%21Database%21Schema.php/class/Schema/11.x" title="Provides a base implementation for Database Schema." class="local">\Drupal\Core\Database\Schema</a>.

Namespace

Drupal\pgsql\Driver\Database\pgsql

Code

protected function _createKeys($table, $new_keys) {
    if (isset($new_keys['primary key'])) {
        $this->addPrimaryKey($table, $new_keys['primary key']);
    }
    if (isset($new_keys['unique keys'])) {
        foreach ($new_keys['unique keys'] as $name => $fields) {
            $this->addUniqueKey($table, $name, $fields);
        }
    }
    if (isset($new_keys['indexes'])) {
        foreach ($new_keys['indexes'] as $name => $fields) {
            // Even though $new_keys is not a full schema it still has 'indexes' and
            // so is a partial schema. Technically addIndex() doesn't do anything
            // with it so passing an empty array would work as well.
            $this->addIndex($table, $name, $fields, $new_keys);
        }
    }
}

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