Skip to content

Instantly share code, notes, and snippets.

@albe
Created April 8, 2015 09:46
Show Gist options
  • Save albe/05a5d93e9a11bf737949 to your computer and use it in GitHub Desktop.
Save albe/05a5d93e9a11bf737949 to your computer and use it in GitHub Desktop.
[!!!][BUGFIX] Make bidirectional OneToOne relations work correctly
This change fixes bidirectional OneToOne relations, which previously
resulted in foreign keys being created on both sides. Therefore the
related entities could no longer be deleted.
The problem was that the joinColum mapping was created in every case,
which doctrine interprets as a secondary hint for the owning side.
The joinColumn should only be created for the owning side, i.e. only
for unidirectional OneToOne and for the inversedBy side of a
bidirectional OneToOne.
This change is not breaking, but needs manual attention to fix the
schema of own projects as follows:
After upgrading to this change, you should run following commands
from command line to update your projects:
flow doctrine:migrationcreate
-> check the created migration file, it should contain a number of
"DROP FOREIGN KEY", "DROP INDEX" and "DROP {column}" statements
for each of your bidirectional OneToOne relations.
flow doctrine:migrate
-> applies the changes
Fixes: FLOW-87
Releases: master, 3.0, 2.3, 2.2
Change-Id: Iba0846328486c8816bcf25aa338cd78e3d0055d8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment