10

I have started with Magento 2 setup scripts and I found one small change with Magento's addForeignKey function parameters. In Magento 1, the arguments for the function is like,

public function addForeignKey($fkName, $column, $refTable, $refColumn, $onDelete = null, $onUpdate = null)

There is an option for defining what to do on update of referenced table row,
While in Magento 2, the arguments for the same function is like,

public function addForeignKey($fkName, $column, $refTable, $refColumn, $onDelete = null)

They have remove onUpdate argument.
Does anyone have any idea about why they did that??
Also can anyone guide me what to do if I want to add onUpdate action for foreign key?

1 Answer 1

2

According to this acknowledged Github issue, this is actually by design:

Hi, this is deliberate restriction, to achieve better compliance with other possible database engines. But you can implement actions like "ON UPDATE" on application level. In this case your code will be compatible with Magento SPI ( events, interceptors, e.t.c).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.