Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2161

Moving entity relationship doesn't move foreign key in mysql table

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Invalid
    • Affects Version/s: Git Master
    • Fix Version/s: None
    • Component/s: Mapping Drivers, ORM
    • Security Level: All
    • Labels:
    • Environment:
      Mac OSX, mysql 5.5.28, php 5.4.8, fresh symfony install with doctrine/orm 77d060ab74212919f1eaace72842ea43bf420f43

      Description

      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

      1. Argument.php
        2 kB
        Alessandro Tagliapietra
      2. Post.php
        2 kB
        Alessandro Tagliapietra
      3. Post2.php
        2 kB
        Alessandro Tagliapietra

        Issue Links

          Activity

          Alessandro Tagliapietra created issue -
          Alessandro Tagliapietra made changes -
          Field Original Value New Value
          Environment Mac OSX, fresh symfony install with doctrine/orm 77d060ab74212919f1eaace72842ea43bf420f43 Mac OSX, mysql 5.5.28, php 5.4.8, fresh symfony install with doctrine/orm 77d060ab74212919f1eaace72842ea43bf420f43
          Description 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
           - 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
          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
          Alessandro Tagliapietra made changes -
          Description 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
          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
          Hide
          Benjamin Eberlei added a comment -

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

          Show
          Benjamin Eberlei added a comment - A related Github Pull-Request [GH-234] was opened https://github.com/doctrine/dbal/pull/234
          Hide
          Benjamin Eberlei added a comment -

          On wrong project, see DBAL-392

          Show
          Benjamin Eberlei added a comment - On wrong project, see DBAL-392
          Benjamin Eberlei made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Invalid [ 6 ]
          Benjamin Eberlei made changes -
          Link This issue relates to DBAL-392 [ DBAL-392 ]
          Hide
          Doctrine Bot added a comment -

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

          Show
          Doctrine Bot added a comment - A related Github Pull-Request [GH-234] was closed: https://github.com/doctrine/common/pull/234

          This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

          • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DDC-2161, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

            People

            • Assignee:
              Benjamin Eberlei
              Reporter:
              Alessandro Tagliapietra
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: