You are here

function db_drop_primary_key in Drupal 8

Same name and namespace in other branches
  1. 6 includes/database.mysql-common.inc \db_drop_primary_key()
  2. 6 includes/database.pgsql.inc \db_drop_primary_key()
  3. 7 includes/database/database.inc \db_drop_primary_key()

Drops the primary key of a database table.

Parameters

$table: Name of the table to be altered.

Return value

bool TRUE if the primary key was successfully dropped, FALSE if there was no primary key on this table to begin with.

Deprecated

in drupal:8.0.0 and is removed from drupal:9.0.0. Instead, get a database connection injected into your service from the container, get its schema driver, and call dropPrimaryKey() on it. For example, $injected_database->schema()->dropPrimaryKey($table);

See also

https://www.drupal.org/node/2993033

\Drupal\Core\Database\Schema::dropPrimaryKey()

Related topics

1 call to db_drop_primary_key()
DatabaseLegacyTest::testDbDropPrimaryKey in core/tests/Drupal/KernelTests/Core/Database/DatabaseLegacyTest.php
Tests deprecation of the db_drop_primary_key() function.

File

core/includes/database.inc, line 941
Core systems for the database layer.

Code

function db_drop_primary_key($table) {
  @trigger_error('db_drop_primary_key() is deprecated in drupal:8.0.0. It will be removed from drupal:9.0.0. Instead, get a database connection injected into your service from the container, get its schema driver, and call dropPrimaryKey() on it. For example, $injected_database->schema()->dropPrimaryKey($table). See https://www.drupal.org/node/2993033', E_USER_DEPRECATED);
  return Database::getConnection()
    ->schema()
    ->dropPrimaryKey($table);
}