public function Schema::compressPrimaryKeyIndex in Drupal driver for SQL Server and SQL Azure 4.1.x
Same name and namespace in other branches
- 4.2.x src/Driver/Database/sqlsrv/Schema.php \Drupal\sqlsrv\Driver\Database\sqlsrv\Schema::compressPrimaryKeyIndex()
- 3.1.x src/Driver/Database/sqlsrv/Schema.php \Drupal\sqlsrv\Driver\Database\sqlsrv\Schema::compressPrimaryKeyIndex()
- 4.0.x src/Driver/Database/sqlsrv/Schema.php \Drupal\sqlsrv\Driver\Database\sqlsrv\Schema::compressPrimaryKeyIndex()
Compress Primary key Index.
Sometimes the size of a table's primary key index needs to be reduced to allow for Primary XML Indexes.
Parameters
string $table: Table name.
int $limit: Limit size.
2 calls to Schema::compressPrimaryKeyIndex()
- Schema::addIndex in src/
Driver/ Database/ sqlsrv/ Schema.php - Add an index.
- Schema::dropIndex in src/
Driver/ Database/ sqlsrv/ Schema.php - Drop an index.
File
- src/
Driver/ Database/ sqlsrv/ Schema.php, line 1580
Class
Namespace
Drupal\sqlsrv\Driver\Database\sqlsrvCode
public function compressPrimaryKeyIndex($table, $limit = 900) {
// Introspect the schema and save the current primary key if the column
// we are modifying is part of it.
$primary_key_fields = $this
->introspectPrimaryKeyFields($table);
// SQL Server supports transactional DDL, so we can just start a transaction
// here and pray for the best.
$transaction = $this->connection
->startTransaction();
// Clear current Primary Key.
$this
->cleanUpPrimaryKey($table);
// Recreate the Primary Key with the given limit size.
$this
->createPrimaryKey($table, $primary_key_fields, $limit);
}