SchemaTool is generating unique index for associations that are OneToOne. I believe this is incorrect.
Section 6.6 of the Associations manual page at Doctrine shows an example of a OneToOne for a Product has one Shipping. This is shown to generate the Product table:
CREATE TABLE Product (
id INT AUTO_INCREMENT NOT NULL,
shipping_id INT DEFAULT NULL,
PRIMARY KEY(id)
) ENGINE = InnoDB;
However, with the same code for my entity User has one Organisation, my User table SQL is generated as
CREATE TABLE User (
id INT AUTO_INCREMENT NOT NULL,
organisation_id INT DEFAULT NULL,
UNIQ_3B978F9FA7F43455 (organisation_id),
PRIMARY KEY(id)
) ENGINE = InnoDB;
This prevents me adding 2 users with the same Organisation. Not correct.
I additinally tried to be verbose with the unique JoinColumn annotation param.
@JoinColumn(name="organisation_id", referencedColumnName="id", unique="false")
Any ideas? I can’t seem to find anything at all about this.
Thanks
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
ManyToOneon the User side andOneToManyon the organisation side.User.php
Organisation.php