Answer the question
In order to leave comments, you need to log in
How to solve problem with on delete cascade not working in Symfony 4 on many to many?
Throws an error when uninstalling the agent.
Connection:
/**
* Many Realties have Many Agents.
*
* @ManyToMany(targetEntity="App\Metrag\AppBundle\Entity\Realty", cascade={"persist", "remove"})
* @JoinTable(
* joinColumns={@JoinColumn(name="agent_id", referencedColumnName="id", onDelete="CASCADE")},
* inverseJoinColumns={@JoinColumn(name="realty_id", referencedColumnName="id", onDelete="CASCADE")}
* )
*/
private $realties;
SQLSTATE[23503]: Foreign key violation: 7 ERROR: update or delete on table "agents" violates foreign key co
nstraint "fk_89bf0de13414710b" on table "agent_realties"
DETAIL: Key (id)=(2) is still referenced from table "agent_realties".
In PDOConnection.php line 62:
SQLSTATE[23503]: Foreign key violation: 7 ERROR: update or delete on table "agents" violates foreign key co
nstraint "fk_89bf0de13414710b" on table "agent_realties"
DETAIL: Key (id)=(2) is still referenced from table "agent_realties".
In PDOConnection.php line 60:
SQLSTATE[23503]: Foreign key violation: 7 ERROR: update or delete on table "agents" violates foreign key co
nstraint "fk_89bf0de13414710b" on table "agent_realties"
DETAIL: Key (id)=(2) is still referenced from table "agent_realties".
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question