I am trying to use the FOS_UserBundle for managing my users but everytime I try to update the db
php app/console doctrine:schema:update --force
I get following error:
Duplicate definition of column ‘username’ on entity in a field or discriminator column mapping. fos user bundle
It also happens with ’email’ when I comment out username.
My user class is actually very basic:
namespace My\MyBundle\Entity;
use FOS\UserBundle\Entity\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="fos_user")
*/
class User extends BaseUser
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string", length="100")
*/
protected $username;
/**
* @ORM\Column(type="string", length="100")
*/
protected $name;
/**
* @ORM\Column(type="string", length="100")
*/
protected $firstname;
/**
* @ORM\Column(type="string", length="150")
*/
protected $email;
}
Am I missing something?
Your
My\MyBundle\Entity\UserextendsFOS\UserBundle\Entity\User, which in turn extendsFOS\UserBundle\Model\User, which already has a$usernamefield. It also has an$emailfield. So you simply need to remove the$usernameand$emailfields from your class.