I have a many-to-many relationship defined in my Symfony (using doctrine) project between Orders
and Upgrades
(an Order
can be associated with zero or more Upgrades
, and an Upgrade
can apply to zero or more Orders
).
# schema.yml
Order:
columns:
order_id: {...}
relations:
Upgrades:
class: Upgrade
local: order_id
foreign: upgrade_id
refClass: OrderUpgrade
Upgrade:
columns:
upgrade_id: {...}
relations:
Orders:
class: Order
local: upgrade_id
foreign: order_id
refClass: OrderUpgrade
OrderUpgrade:
columns:
order_id: {...}
upgrade_id: {...}
I want to set up delete cascade behavior so that if I delete an Order
or an Upgrade
, all of the related OrderUpgrades
are deleted. Where do I put onDelete: CASCADE
? Usually I would put it at the end of the relations section, but that would seem to imply in this case that deleting Orders
would cascade to delete Upgrades
. Is Symfony + Doctrine smart enough to know what I'm wanting if I put onDelete: CASCADE
in the above relations sections of schema.yml?