Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2551

schema-tool does not match join columns with identifier options

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Can't Fix
    • Affects Version/s: 2.3.4
    • Fix Version/s: None
    • Component/s: None
    • Security Level: All
    • Labels:
    • Environment:
      Zend Framework 2
      Doctrine ORM 2.3.4

      Description

      /**
       * Role
       *
       * @ORM\Entity
       * @ORM\Table(name="rbac_role", options={"collate"="utf8_general_ci"})
       * @package User\Entity
       */
      class Role
      {
          /**
           * @ORM\Id
           * @ORm\Column(name="role_id", type="integer", options={"unsigned"=true})
           * @ORM\GeneratedValue(strategy="AUTO")
           * @var int
           */
          protected $id;
      
          /**
           * @ORM\Column(name="role_name", name="string", length=32, nullable=true)
           * @var string
           */
          protected $name = null;
      
      
          /**
           * @ORM\ManyToOne(targetEntity="Role")
           * @ORM\JoinColumn(name="parent_role_id", referencedColumnName="id", nullable=true)
           * @var Role
           */
          protected $parentRole = null;
      
      $ php vendor/doctrine/orm/bin/doctrine.php orm:schema-tool:update --force
      
      Updating database schema...
      
      
      
        [Doctrine\DBAL\DBALException]
        An exception occurred while executing 'ALTER TABLE rbac_role ADD CONSTRAINT
         FK_C55D6FF2A44B56EA FOREIGN KEY (parent_role_id) REFERENCES rbac_role (id)
        ':
      
        SQLSTATE[HY000]: General error: 1005 Can't create table 'rbac.#sql-98_24b'
        (errno: 150)
      
      
      
      
      
      
        [PDOException]
        SQLSTATE[HY000]: General error: 1005 Can't create table 'rbac.#sql-98_24b'
        (errno: 150)
      
      

      Problem here: ====================================================

      ALTER TABLE rbac_role ADD CONSTRAINT
         FK_C55D6FF2A44B56EA FOREIGN KEY (parent_role_id) REFERENCES rbac_role (id)
      
       ==> `rbac_role (id)` should be `rbac_role (role_id)
      

        Activity

        Atans Chiu created issue -
        Atans Chiu made changes -
        Field Original Value New Value
        Description ```php
        /**
         * Role
         *
         * @ORM\Entity
         * @ORM\Table(name="rbac_role", options={"collate"="utf8_general_ci"})
         * @package User\Entity
         */
        class Role
        {
            /**
             * @ORM\Id
             * @ORm\Column(name="role_id", type="integer", options={"unsigned"=true})
             * @ORM\GeneratedValue(strategy="AUTO")
             * @var int
             */
            protected $id;

            /**
             * @ORM\Column(name="role_name", name="string", length=32, nullable=true)
             * @var string
             */
            protected $name = null;


            /**
             * @ORM\ManyToOne(targetEntity="Role")
             * @ORM\JoinColumn(name="parent_role_id", referencedColumnName="id", nullable=true)
             * @var Role
             */
            protected $parentRole = null;
        ```
        $ php vendor/doctrine/orm/bin/doctrine.php orm:schema-tool:update --force
        ```

        Updating database schema...



          [Doctrine\DBAL\DBALException]
          An exception occurred while executing 'ALTER TABLE rbac_role ADD CONSTRAINT
           FK_C55D6FF2A44B56EA FOREIGN KEY (parent_role_id) REFERENCES rbac_role (id)
          ':

          SQLSTATE[HY000]: General error: 1005 Can't create table 'rbac.#sql-98_24b'
          (errno: 150)






          [PDOException]
          SQLSTATE[HY000]: General error: 1005 Can't create table 'rbac.#sql-98_24b'
          (errno: 150)

        ```




        Doctrine 2.4.x-dev

        ALTER TABLE... (parent_role_id) REFERENCES `rbac_role (id)` should be `rbac_role (role_id)`
        ```php
        /**
         * Role
         *
         * @ORM\Entity
         * @ORM\Table(name="rbac_role", options={"collate"="utf8_general_ci"})
         * @package User\Entity
         */
        class Role
        {
            /**
             * @ORM\Id
             * @ORm\Column(name="role_id", type="integer", options={"unsigned"=true})
             * @ORM\GeneratedValue(strategy="AUTO")
             * @var int
             */
            protected $id;

            /**
             * @ORM\Column(name="role_name", name="string", length=32, nullable=true)
             * @var string
             */
            protected $name = null;


            /**
             * @ORM\ManyToOne(targetEntity="Role")
             * @ORM\JoinColumn(name="parent_role_id", referencedColumnName="id", nullable=true)
             * @var Role
             */
            protected $parentRole = null;
        ```
        $ php vendor/doctrine/orm/bin/doctrine.php orm:schema-tool:update --force
        ```

        Updating database schema...



          [Doctrine\DBAL\DBALException]
          An exception occurred while executing 'ALTER TABLE rbac_role ADD CONSTRAINT
           FK_C55D6FF2A44B56EA FOREIGN KEY (parent_role_id) REFERENCES rbac_role (id)
          ':

          SQLSTATE[HY000]: General error: 1005 Can't create table 'rbac.#sql-98_24b'
          (errno: 150)






          [PDOException]
          SQLSTATE[HY000]: General error: 1005 Can't create table 'rbac.#sql-98_24b'
          (errno: 150)

        ```




        Problem here: ====================================================
        ALTER TABLE rbac_role ADD CONSTRAINT
           FK_C55D6FF2A44B56EA FOREIGN KEY (parent_role_id) REFERENCES rbac_role (id)

         ==> `rbac_role (id)` should be `rbac_role (role_id)`
        Atans Chiu made changes -
        Environment Zend Framework 2
        Doctrine 2.4.x
        Zend Framework 2
        Doctrine 2.3.4
        Atans Chiu made changes -
        Environment Zend Framework 2
        Doctrine 2.3.4
        Zend Framework 2
        Doctrine ORM 2.3.4
        Marco Pivetta made changes -
        Description ```php
        /**
         * Role
         *
         * @ORM\Entity
         * @ORM\Table(name="rbac_role", options={"collate"="utf8_general_ci"})
         * @package User\Entity
         */
        class Role
        {
            /**
             * @ORM\Id
             * @ORm\Column(name="role_id", type="integer", options={"unsigned"=true})
             * @ORM\GeneratedValue(strategy="AUTO")
             * @var int
             */
            protected $id;

            /**
             * @ORM\Column(name="role_name", name="string", length=32, nullable=true)
             * @var string
             */
            protected $name = null;


            /**
             * @ORM\ManyToOne(targetEntity="Role")
             * @ORM\JoinColumn(name="parent_role_id", referencedColumnName="id", nullable=true)
             * @var Role
             */
            protected $parentRole = null;
        ```
        $ php vendor/doctrine/orm/bin/doctrine.php orm:schema-tool:update --force
        ```

        Updating database schema...



          [Doctrine\DBAL\DBALException]
          An exception occurred while executing 'ALTER TABLE rbac_role ADD CONSTRAINT
           FK_C55D6FF2A44B56EA FOREIGN KEY (parent_role_id) REFERENCES rbac_role (id)
          ':

          SQLSTATE[HY000]: General error: 1005 Can't create table 'rbac.#sql-98_24b'
          (errno: 150)






          [PDOException]
          SQLSTATE[HY000]: General error: 1005 Can't create table 'rbac.#sql-98_24b'
          (errno: 150)

        ```




        Problem here: ====================================================
        ALTER TABLE rbac_role ADD CONSTRAINT
           FK_C55D6FF2A44B56EA FOREIGN KEY (parent_role_id) REFERENCES rbac_role (id)

         ==> `rbac_role (id)` should be `rbac_role (role_id)`
        {code}
        /**
         * Role
         *
         * @ORM\Entity
         * @ORM\Table(name="rbac_role", options={"collate"="utf8_general_ci"})
         * @package User\Entity
         */
        class Role
        {
            /**
             * @ORM\Id
             * @ORm\Column(name="role_id", type="integer", options={"unsigned"=true})
             * @ORM\GeneratedValue(strategy="AUTO")
             * @var int
             */
            protected $id;

            /**
             * @ORM\Column(name="role_name", name="string", length=32, nullable=true)
             * @var string
             */
            protected $name = null;


            /**
             * @ORM\ManyToOne(targetEntity="Role")
             * @ORM\JoinColumn(name="parent_role_id", referencedColumnName="id", nullable=true)
             * @var Role
             */
            protected $parentRole = null;
        {code}

        {code}
        $ php vendor/doctrine/orm/bin/doctrine.php orm:schema-tool:update --force

        Updating database schema...



          [Doctrine\DBAL\DBALException]
          An exception occurred while executing 'ALTER TABLE rbac_role ADD CONSTRAINT
           FK_C55D6FF2A44B56EA FOREIGN KEY (parent_role_id) REFERENCES rbac_role (id)
          ':

          SQLSTATE[HY000]: General error: 1005 Can't create table 'rbac.#sql-98_24b'
          (errno: 150)






          [PDOException]
          SQLSTATE[HY000]: General error: 1005 Can't create table 'rbac.#sql-98_24b'
          (errno: 150)

        {code}




        Problem here: ====================================================
        {code}
        ALTER TABLE rbac_role ADD CONSTRAINT
           FK_C55D6FF2A44B56EA FOREIGN KEY (parent_role_id) REFERENCES rbac_role (id)

         ==> `rbac_role (id)` should be `rbac_role (role_id)
        {code}
        Marco Pivetta made changes -
        Summary doctrine schema-tool problem schema-tool does not match join columns with identifier options
        Marco Pivetta made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Benjamin Eberlei [ beberlei ] Marco Pivetta [ ocramius ]
        Fix Version/s 2.4 [ 10321 ]
        Resolution Can't Fix [ 7 ]
        Atans Chiu made changes -
        Fix Version/s 2.3.4 [ 10420 ]
        Marco Pivetta made changes -
        Affects Version/s 2.3.4 [ 10420 ]
        Marco Pivetta made changes -
        Fix Version/s 2.3.4 [ 10420 ]

          People

          • Assignee:
            Marco Pivetta
            Reporter:
            Atans Chiu
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: