Doctrine OneToOne incorrectly? generating a UNIQUE INDEX
If One organisation has Many Users and Many Users have One and only one organisation then it's not a One-to-One association.
One-to-One associations have to be unique.
Your association is ManyToOne
on the User side and OneToMany
on the organisation side.
User.php
/**
* @ManyToOne(targetEntity="Organisation")
*/
private $organisation;
Organisation.php
use Doctrine\Common\Collections\ArrayCollection;
/**
* @OneToMany(targetEntity="User", mappedBy="organisation")
*/
private $users;
function __construct() {
$this->users = new ArrayCollection();
}