Phinx: Support for named foreign key constraint in MySQL adapter

Created on 28 May 2013  路  8Comments  路  Source: cakephp/phinx

Hi,

Based on the little experience I have with Phinx, it seems impossible to specify the name of the foreign key I want when creating a new foreign key. Based on the code in robmorgan/phinx/src/Phinx/Db/Adapter/MysqlAdapter.php, either you have a foreign key with a constraint name OR a foreign key with an automatically generated name.

See https://gist.github.com/tomzx/5663921/revisions for a "potential" quick fix.

feature

All 8 comments

See #119

Hi, Is this issue still up for grabs ? I would love to do the necessary to see it merged.

+1

+1

+1

Hello, what's the plan with this feature?

It looks like you can set a foreign key name using the constraint option.

$table = $this->table('your_table');
$table->addForeignKey('foreign_id', 'reference_table', array('id'), array('constraint'=>'your_foreign_key_name'));
$table->save();

This is valid as of

$ vendor/bin/phinx --version
Phinx by Rob Morgan - https://phinx.org. version 0.6.5

Constraint names are supported through the constraint option.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

joshribakoff picture joshribakoff  路  15Comments

robmorgan picture robmorgan  路  20Comments

JamesTheHacker picture JamesTheHacker  路  15Comments

aimfeld picture aimfeld  路  23Comments

hmp5bs picture hmp5bs  路  17Comments