function Schema::shortenIndex

Same name and namespace in other branches
  1. 9 core/modules/mysql/src/Driver/Database/mysql/Schema.php \Drupal\mysql\Driver\Database\mysql\Schema::shortenIndex()
  2. 8.9.x core/lib/Drupal/Core/Database/Driver/mysql/Schema.php \Drupal\Core\Database\Driver\mysql\Schema::shortenIndex()
  3. 10 core/modules/mysql/src/Driver/Database/mysql/Schema.php \Drupal\mysql\Driver\Database\mysql\Schema::shortenIndex()

Helper function for normalizeIndexes().

Shortens an index to 191 characters.

Parameters

array $index: The index array to be used in createKeySql.

See also

Drupal\mysql\Driver\Database\mysql\Schema::createKeySql()

Drupal\mysql\Driver\Database\mysql\Schema::normalizeIndexes()

1 call to Schema::shortenIndex()
Schema::getNormalizedIndexes in core/modules/mysql/src/Driver/Database/mysql/Schema.php
Gets normalized indexes from a table specification.

File

core/modules/mysql/src/Driver/Database/mysql/Schema.php, line 347

Class

Schema
MySQL 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\mysql\Driver\Database\mysql

Code

protected function shortenIndex(&$index) {
    if (is_array($index)) {
        if ($index[1] > 191) {
            $index[1] = 191;
        }
    }
    else {
        $index = [
            $index,
            191,
        ];
    }
}

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