src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php
private function applyPrimaryKey(PropertyField $field, IdProperty $prop)
    {
        unset($prop);

        $model  = $this->targetModel();
        $source = $model->source();

        $sql = strtr(
            'ALTER TABLE `%table` ADD PRIMARY KEY (`%key`)',
            [
                '%table' => $source->table(),
                '%key'   => $field->ident(),
            ]
        );
        $source->db()->query($sql);

        return $this;
    }
private function applyPrimaryKey(PropertyField $field, IdProperty $prop)
    {
        unset($prop);

        $model  = $this->targetModel();
        $source = $model->source();

        $sql = strtr(
            'ALTER TABLE `%table` ADD PRIMARY KEY (`%key`)',
            [
                '%table' => $source->table(),
                '%key'   => $field->ident(),
            ]
        );
        $source->db()->query($sql);

        return $this;
    }
private function applyPrimaryKey ( PropertyField $ field , IdProperty $ prop ) { unset ( $ prop ) ; $ model = $ this -> targetModel ( ) ; $ source = $ model -> source ( ) ; $ sql = strtr ( 'ALTER TABLE `%table` ADD PRIMARY KEY (`%key`)' , [ '%table' => $ source -> table ( ) , '%key' => $ field -> ident ( ) , ] ) ; $ source -> db ( ) -> query ( $ sql ) ; return $ this ; }
Set the given field as the primary key.

@param  PropertyField $field The new ID field.
@param  IdProperty    $prop  The new ID property.
@return self
Set the given field as the primary key .