php – FOSUserBundle username property inside custom class' annotation for fulltext index-ThrowExceptions

Exception or error:

I am trying to set two columns to be with fulltext index but my problem here is that username is coming from the FOS\UserBundle\Entity\User and if I try to use it in the annotation below I receive the error

[Doctrine\DBAL\Schema\SchemaException] There is no column with name
‘name, username’ on table my_table_name

because in my UserEntity I do not have a property username. It is defined in the BaseUser. Any ideas on how I can manage to do that? I manage to make it work directly altering the database table but would like to know how I can use the Doctrine approach here.

use FOS\UserBundle\Entity\User as BaseUser;

/**
 * @ORM\Table(name="my_table_name", indexes={@ORM\Index(name="escape", columns={"name, username"}, flags={"fulltext"})})
 */
class UserEntity extends BaseUser

Here is the working MySQL command:

ALTER TABLE table_clean_db.user ADD FULLTEXT INDEX escape (username, name);
How to solve:

I think tou have a typo here columns={"name, username"}.

It should be 2 strings separated by comma columns={"name", "username"}

Leave a Reply

Your email address will not be published. Required fields are marked *