function Schema::createIndexSql

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

Build the SQL expression for indexes.

4 calls to Schema::createIndexSql()
Schema::addIndex in core/modules/sqlite/src/Driver/Database/sqlite/Schema.php
Add an index.
Schema::addUniqueKey in core/modules/sqlite/src/Driver/Database/sqlite/Schema.php
Add a unique key.
Schema::createTableSql in core/modules/sqlite/src/Driver/Database/sqlite/Schema.php
Generate SQL to create a new table from a Drupal schema definition.
Schema::renameTable in core/modules/sqlite/src/Driver/Database/sqlite/Schema.php
Rename a table.

File

core/modules/sqlite/src/Driver/Database/sqlite/Schema.php, line 62

Class

Schema
SQLite implementation of \Drupal\Core\Database\Schema.

Namespace

Drupal\sqlite\Driver\Database\sqlite

Code

protected function createIndexSql($tablename, $schema) {
    $sql = [];
    $info = $this->getPrefixInfo($tablename);
    if (!empty($schema['unique keys'])) {
        foreach ($schema['unique keys'] as $key => $fields) {
            $sql[] = 'CREATE UNIQUE INDEX [' . $info['schema'] . '].[' . $info['table'] . '_' . $key . '] ON [' . $info['table'] . '] (' . $this->createKeySql($fields) . ")\n";
        }
    }
    if (!empty($schema['indexes'])) {
        foreach ($schema['indexes'] as $key => $fields) {
            $sql[] = 'CREATE INDEX [' . $info['schema'] . '].[' . $info['table'] . '_' . $key . '] ON [' . $info['table'] . '] (' . $this->createKeySql($fields) . ")\n";
        }
    }
    return $sql;
}

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