Symfony2 Doctrine schema update fails

前端 未结 5 1199
不知归路
不知归路 2021-02-07 11:53

I created database on my local machine. After moving my project to server I imported backup from local (because I had some important data there).

Now,when I\'m trying t

5条回答
  •  粉色の甜心
    2021-02-07 12:46

    For me it worked with the following setup (with two relations). The trick was to not mix up mappedBy and inversedBy.

    /**
     * @ORM\Entity
     * @ORM\Table(name="user")
     */
    class User extends BaseUser
    {
        /**
         * @var Merchant
         *
         * @ORM\OneToOne(targetEntity="Merchant", mappedBy="user")
         */
        protected $merchant;
    
        /**
         * @var Client
         *
         * @ORM\OneToOne(targetEntity="Client", mappedBy="user")
         */
        protected $client;
    }
    
    /**
     * @ORM\Table(name="merchant")
     * @ORM\Entity
     */
    class Merchant extends BaseEntity
    {
        /**
         * @ORM\OneToOne(targetEntity="User", inversedBy="merchant")
         */
        protected $user;
    }
    
    /**
     * @ORM\Table(name="client")
     * @ORM\Entity
     */
    class Client extends BaseEntity
    {
        /**
         * @ORM\OneToOne(targetEntity="User", inversedBy="client")
         */
        protected $user;
    }
    

提交回复
热议问题