Question

I have problem. I have to change type of fos_user.id to bigint. But I don't know how to do it. I have overriden the FOSUserBundle and I have tried code below, it's works but not for id.:

/**
 * @ORM\Entity
 * @ORM\Table(name="sf_guard_user")
 * @ORM\AttributeOverrides({
 *      @ORM\AttributeOverride(name="id", column=@ORM\Column(type="bigint", name="id")),
 *      @ORM\AttributeOverride(name="email", column=@ORM\Column(type="string", name="email_address", length=255)),
 * })
 */
class User extends BaseUser implements EncoderAwareInterface {
 //...
}
Was it helpful?

Solution

You don't need to override id. It should be defined in class that extends FOS\UserBundle\Model\User. Just define it inside your User class. Like this:

/**
 * @ORM\Entity
 * @ORM\Table(name="sf_guard_user")
 * @ORM\AttributeOverrides({
 *      @ORM\AttributeOverride(name="email", column=@ORM\Column(type="string", name="email_address", length=255)),
 * })
 */
class User extends BaseUser implements EncoderAwareInterface {
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="bigint")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

 //...
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top