You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Deleting a parent of child, that do not have "depending=>true" relationship.
As such, the foreign_key was still the old id, we just removed.
Now there is an invalid foreign key set that doesnt exist as row anymore.
Expected Behavior
When generating migrations (bake task and otherwise):
'delete' => 'SET_NULL' for addForeignKey()
should be auto-set for such "NULLable" fields that have no such depending constraint.
This would make sure the foreign_key here is set to NULL again and when we query for all that have no relation to that parent we would also find the right entities.
Yes, this is only meant for nullable colums to keep data integrity.
If not nullable, the parent delete must delete also the children (via constraint or domain layer logic / relation setup).
I'm not sure I understand the scenario well. Is the situation that you have model relations defined, but no migration. Then when a migration is generated it should use model relations to infer the schema?
This is a (multiple allowed):
enhancement
CakePHP Version: latest
What you did
Deleting a parent of child, that do not have "depending=>true" relationship.
As such, the foreign_key was still the old id, we just removed.
Now there is an invalid foreign key set that doesnt exist as row anymore.
Expected Behavior
When generating migrations (bake task and otherwise):
'delete' => 'SET_NULL'
for addForeignKey()should be auto-set for such "NULLable" fields that have no such depending constraint.
This would make sure the foreign_key here is set to NULL again and when we query for all that have no relation to that parent we would also find the right entities.
Example code
For a DEFAULT NULL relation here.
The text was updated successfully, but these errors were encountered: