| @@ 407-413 (lines=7) @@ | ||
| 404 | * @param array $options Options |
|
| 405 | * @return \Phinx\Db\Table |
|
| 406 | */ |
|
| 407 | public function addForeignKey($columns, $referencedTable, $referencedColumns = ['id'], $options = []) |
|
| 408 | { |
|
| 409 | $action = AddForeignKey::build($this->table, $columns, $referencedTable, $referencedColumns); |
|
| 410 | $this->actions->addAction($action); |
|
| 411 | ||
| 412 | return $this; |
|
| 413 | } |
|
| 414 | ||
| 415 | /** |
|
| 416 | * Add a foreign key to a database table with a given name. |
|
| @@ 428-441 (lines=14) @@ | ||
| 425 | * @param array $options Options |
|
| 426 | * @return \Phinx\Db\Table |
|
| 427 | */ |
|
| 428 | public function addForeignKeyWithName($name, $columns, $referencedTable, $referencedColumns = ['id'], $options = []) |
|
| 429 | { |
|
| 430 | $action = AddForeignKey::build( |
|
| 431 | $this->table, |
|
| 432 | $columns, |
|
| 433 | $referencedTable, |
|
| 434 | $referencedColumns, |
|
| 435 | $options, |
|
| 436 | $name |
|
| 437 | ); |
|
| 438 | $this->actions->addAction($action); |
|
| 439 | ||
| 440 | return $this; |
|
| 441 | } |
|
| 442 | ||
| 443 | /** |
|
| 444 | * Removes the given foreign key from the table. |
|
| @@ 450-456 (lines=7) @@ | ||
| 447 | * @param null|string $constraint Constraint names |
|
| 448 | * @return \Phinx\Db\Table |
|
| 449 | */ |
|
| 450 | public function dropForeignKey($columns, $constraint = null) |
|
| 451 | { |
|
| 452 | $action = DropForeignKey::build($this->table, $columns, $constraint); |
|
| 453 | $this->actions->addAction($action); |
|
| 454 | ||
| 455 | return $this; |
|
| 456 | } |
|
| 457 | ||
| 458 | /** |
|
| 459 | * Checks to see if a foreign key exists. |
|