Hi,
I've previously successfully overridden the mapping of the orm user by redefining the whole mapping in my own user class and extending the user model (not entity) using userbundle 1.3.*.
I've recently started up a new project where I wanted to do this again and grabbed my classes from the previous project. In composer I've added userbundle 2.0.*@dev as my dependancy.
Now when clearing cache/validating schema I get the infamous 'Duplicate definition of column 'username' on entity' error for my own User class.
Here's a gist with my classes and configs,
https://gist.github.com/philrennie/7bea08dc45a8427f8140
I'm guessing this may be due to userbundle registering compiler and mapping passes, I saw this noted in the docs, looked at the code for it and then went to look at the commit where it changed
https://github.com/FriendsOfSymfony/FOSUserBundle/commit/6290fd7b6278706327f21aae55844e7d23be0008
and there's a note right at the end from @dbu that says this shouldn't happen, but I appear to be triggering it.
I've stared at this for a few hours now, so if someone could either point out where I've made a mistake or what I'm doing wrong I'd appreciate it.
strange, i don't know why this is happening. a few questions/ideas though:
@MappedSuperclass annotation? I am not 100% sure - i would have expected the BaseClass to not be seen by doctrine at all.Hi @philrennie,
I have the same issue when extending from use FOS\UserBundle\Model\User. You can use @ORM\AttributeOverrides to override the default settings.
@ORM\AttributeOverrides to User or BaseUser classExample:
/**
* ...
* @AttributeOverrides({
* @AttributeOverride(name="username",
* column=@Column(
* name = "username1234567",
* nullable = false,
* unique = true,
* length = 123
* )
* )
* })
Hi @estahn,
When I first raised this I was moving at speed and didn't manage to get the attributeoverrides working, I should revisit it in the near future.
What I did end up doing was setting FUB to use the 'custom' db_driver type (so no mapping was pulled in by the compiler pass) and implementing a super stripped down usermanager and userprovider to support them, which let me go wild with mapping a custom user entity (I was moving roles into the DB)
I created a gist of what I knocked up in case it's useful to anyone
https://gist.github.com/philrennie/45918e42147c3db7cca8
This is ancient and out of date so closing it off to be tidy
Most helpful comment
Hi @philrennie,
I have the same issue when extending from
use FOS\UserBundle\Model\User. You can use@ORM\AttributeOverridesto override the default settings.@ORM\AttributeOverridesto User or BaseUser classExample: