You are here

public function SchemaDatabaseSchema_mysql::recreatePrimaryKey in Schema 8

Overrides DatabaseSchemaInspectionInterface::recreatePrimaryKey

File

src/SchemaDatabaseSchema_mysql.php, line 57
Schema module enhancements to DatabaseSchema_mysql

Class

SchemaDatabaseSchema_mysql

Namespace

Drupal\schema

Code

public function recreatePrimaryKey($table_name, $primary_key) {
  $sql = 'ALTER TABLE {' . $table_name . '} DROP PRIMARY KEY, ADD PRIMARY KEY (' . $this
    ->createKeySql($primary_key) . ')';
  $this->connection
    ->query($sql)
    ->execute();
}