Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2: FOS_Userbundle Duplicate definition when updating db schema?

Tags:

symfony

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?

like image 841
Mike Avatar asked Nov 10 '11 14:11

Mike


1 Answers

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.

like image 150
igorw Avatar answered Jun 05 '23 10:06

igorw