DDC-2161: Moving entity relationship doesn't move foreign key in mysql table #2719

Closed
opened 2026-01-22 14:01:38 +01:00 by admin · 5 comments
Owner

Originally created by @doctrinebot on GitHub (Nov 22, 2012).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user alex88:

Edit: moved the bug to the dbal project, please delete this or set as invalid, new bug:

http://www.doctrine-project.org/jira/browse/DBAL-392


These are the steps I've tried to reproduce the problem:

  • composer create-project symfony/framework-standard-edition path/ 2.1.3
  • edited parameters for mysql db
  • created attached 'Post' entity (note the parent/children fields)
  • updated schema with doctrine:schema:create

I see that the foreign key in phpmyadmin is correctly set to Post.id which is correct.

Now:

  • created another entity 'Argument'
  • moving the children field from 'Post' to 'Argument' removing setters getters into 'Post' and changing target entity field accordingly
  • Updated DB schema (doctrine:schema:update --force)

The situation is now the one you can find in Post2 and Argument attachments.

The problem is that now, the foreign key in Post field it's still on Post.id and not on Argument.id and schema:update says the DB is in sync with the metadata.

Manually deleting the foreign key and running schema:update makes the key being correctly created into Argument.id

Originally created by @doctrinebot on GitHub (Nov 22, 2012). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user alex88: Edit: moved the bug to the dbal project, please delete this or set as invalid, new bug: http://www.doctrine-project.org/jira/browse/[DBAL-392](http://www.doctrine-project.org/jira/browse/DBAL-392) --- These are the steps I've tried to reproduce the problem: - composer create-project symfony/framework-standard-edition path/ 2.1.3 - edited parameters for mysql db - created attached 'Post' entity (note the parent/children fields) - updated schema with doctrine:schema:create I see that the foreign key in phpmyadmin is correctly set to Post.id which is correct. Now: - created another entity 'Argument' - moving the children field from 'Post' to 'Argument' removing setters getters into 'Post' and changing target entity field accordingly - Updated DB schema (doctrine:schema:update --force) The situation is now the one you can find in Post2 and Argument attachments. The problem is that now, the foreign key in Post field it's still on Post.id and not on Argument.id and schema:update says the DB is in sync with the metadata. Manually deleting the foreign key and running schema:update makes the key being correctly created into Argument.id
admin added the Bug label 2026-01-22 14:01:38 +01:00
admin closed this issue 2026-01-22 14:01:38 +01:00
Author
Owner

@doctrinebot commented on GitHub (Nov 22, 2012):

@doctrinebot commented on GitHub (Nov 22, 2012): - relates to [DBAL-392: Moving entity relationship doesn't move foreign key in mysql table](http://www.doctrine-project.org/jira/browse/DBAL-392)
Author
Owner

@doctrinebot commented on GitHub (Nov 24, 2012):

Comment created by @beberlei:

A related Github Pull-Request [GH-234] was opened
https://github.com/doctrine/dbal/pull/234

@doctrinebot commented on GitHub (Nov 24, 2012): Comment created by @beberlei: A related Github Pull-Request [GH-234] was opened https://github.com/doctrine/dbal/pull/234
Author
Owner

@doctrinebot commented on GitHub (Nov 25, 2012):

Comment created by @beberlei:

On wrong project, see DBAL-392

@doctrinebot commented on GitHub (Nov 25, 2012): Comment created by @beberlei: On wrong project, see [DBAL-392](http://www.doctrine-project.org/jira/browse/DBAL-392)
Author
Owner

@doctrinebot commented on GitHub (Nov 25, 2012):

Issue was closed with resolution "Invalid"

@doctrinebot commented on GitHub (Nov 25, 2012): Issue was closed with resolution "Invalid"
Author
Owner

@doctrinebot commented on GitHub (Feb 3, 2014):

Comment created by @doctrinebot:

A related Github Pull-Request [GH-234] was closed:
https://github.com/doctrine/common/pull/234

@doctrinebot commented on GitHub (Feb 3, 2014): Comment created by @doctrinebot: A related Github Pull-Request [GH-234] was closed: https://github.com/doctrine/common/pull/234
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#2719