src/Phinx/Db/Table.php
public function addForeignKeyWithName($name, $columns, $referencedTable, $referencedColumns = ['id'], $options = [])
    {
        $action = AddForeignKey::build(
            $this->table,
            $columns,
            $referencedTable,
            $referencedColumns,
            $options,
            $name
        );
        $this->actions->addAction($action);

        return $this;
    }
public function addForeignKeyWithName($name, $columns, $referencedTable, $referencedColumns = ['id'], $options = [])
    {
        $action = AddForeignKey::build(
            $this->table,
            $columns,
            $referencedTable,
            $referencedColumns,
            $options,
            $name
        );
        $this->actions->addAction($action);

        return $this;
    }
public function addForeignKeyWithName ( $ name , $ columns , $ referencedTable , $ referencedColumns = [ 'id' ] , $ options = [ ] ) { $ action = AddForeignKey :: build ( $ this -> table , $ columns , $ referencedTable , $ referencedColumns , $ options , $ name ) ; $ this -> actions -> addAction ( $ action ) ; return $ this ; }
Add a foreign key to a database table with a given name.

In $options you can specify on_delete|on_delete = cascade|no_action ..,
on_update, constraint = constraint name.

@param string $name The constraint name
@param string|array $columns Columns
@param string|\Phinx\Db\Table $referencedTable   Referenced Table
@param string|array $referencedColumns Referenced Columns
@param array $options Options
@return \Phinx\Db\Table
Add a foreign key to a database table with a given name .