yii\db\Migration::dropPrimaryKey PHP Method

dropPrimaryKey() public method

Builds and executes a SQL statement for dropping a primary key.
public dropPrimaryKey ( string $name, string $table )
$name string the name of the primary key constraint to be removed.
$table string the table that the primary key constraint will be removed from.
    public function dropPrimaryKey($name, $table)
    {
        echo "    > drop primary key {$name} ...";
        $time = microtime(true);
        $this->db->createCommand()->dropPrimaryKey($name, $table)->execute();
        echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
    }

Usage Example

Beispiel #1
0
 /**
  * Builds and executes a SQL statement for dropping a primary key.
  * @param string $table the table that the primary key constraint will be removed from.
  * @param string $name the name of the primary key constraint to be removed.
  */
 public function dropPrimaryKey($table, $name = null)
 {
     $name = $name ?: $this->getNamePrimaryKey($table);
     parent::dropPrimaryKey($name, $table);
 }