From 3634cb3d351dacd9cb82b5b512adfe6549b3e9b3 Mon Sep 17 00:00:00 2001 From: yashtodi94 Date: Tue, 17 Jan 2017 12:37:41 +0530 Subject: [PATCH] Documentation for adding named foreign keys Documentation for adding named foreign keys using the constraint parameter of the addForeignKey() method. --- docs/migrations.rst | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/docs/migrations.rst b/docs/migrations.rst index 367154e1e..1267564a7 100644 --- a/docs/migrations.rst +++ b/docs/migrations.rst @@ -1187,6 +1187,36 @@ This allows us to establish a foreign key relationship to a table which uses a c } } +We can add named foreign keys using the ``constraint`` parameter. This feature is supported as of Phinx version 0.6.5 + +.. code-block:: php + + table('your_table'); + $table->addForeignKey('foreign_id', 'reference_table', array('id'), + array('constraint'=>'your_foreign_key_name')); + ->save(); + } + + /** + * Migrate Down. + */ + public function down() + { + + } + } + We can also easily check if a foreign key exists: .. code-block:: php