Fos用户包重复定义数据库 [英] Fos User bundle duplicate defination of database
本文介绍了Fos用户包重复定义数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我通过这个
php app / console doctrine更新数据库时:schema:update --force
它给出了以下给出的异常
MappingException:列email的重复定义'on entity'Dashboard\UserBundle\Entity\User'in a field or discriminator column mapping
我的user.php在下面给出
when i update the database through this php app/console doctrine:schema:update --force it gives the exception that is given below MappingException: Duplicate definition of column 'email' on entity 'Dashboard\UserBundle\Entity\User' in a field or discriminator column mapping my user.php is given below
<?php
// src/Dashboard/UserBundle/Entity/User.php
namespace Dashboard\UserBundle\Entity;
use FOS\UserBundle\Entity\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints AS Assert;
use Dashboard\UserBundle\Entity\User;
/**
* @ORM\Entity
* @ORM\Table(name="acme_user")
* @ORM\AttributeOverrides({
* @ORM\AttributeOverride(name="email", column=@ORM\Column(type="string", name="email", length=255, unique=false, nullable=true)),
* @ORM\AttributeOverride(name="emailCanonical", column=@ORM\Column(type="string", name="email_canonical", length=255, unique=false, nullable=true))
* })
*/
class User extends BaseUser
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotBlank()
* @Assert\Email()
*/
protected $email;
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotBlank()
*/
protected $Password;
public function getId()
{
return $this->id;
}
public function getEmail()
{
return $this->email;
}
public function setEmail($email)
{
$this->email = $email;
}
public function getPassword()
{
return $this->plainPassword;
}
public function setPassword($password)
{
$this->plainPassword = $password;
}
public function __construct()
{
parent::__construct();
// your own logic
}
}
如何删除这个异常?
推荐答案
删除$ email和他的getter和setter
Remove $email and his getter and setter
/**
* @ORM\Column(type="string", length=255)
* @Assert\NotBlank()
* @Assert\Email()
*/
protected $email;
它已经在BaseUser
It's already in BaseUser
这篇关于Fos用户包重复定义数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文