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\User
extends FOS\UserBundle\Entity\User
, which in turn extends FOS\UserBundle\Model\User
, which already has a $username
field. It also has an $email
field. So you simply need to remove the $username
and $email
fields from your class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With